Makefile revision 183006
1#$FreeBSD: head/rescue/rescue/Makefile 183006 2008-09-13 19:54:15Z imp $ 2# @(#)Makefile 8.1 (Berkeley) 6/2/93 3 4NO_MAN= 5WITHOUT_SSP= 6 7.include <bsd.own.mk> 8 9PROG= rescue 10BINDIR?=/rescue 11 12# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh 13SCRIPTS= nextboot_FIXED 14SCRIPTSNAME_nextboot_FIXED= nextboot 15nextboot_FIXED: ../../sbin/reboot/nextboot.sh 16 sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 17CLEANFILES+= nextboot_FIXED 18 19SCRIPTS+= dhclient_FIXED 20SCRIPTSNAME_dhclient_FIXED= dhclient-script 21dhclient_FIXED: ../../sbin/dhclient/dhclient-script 22 sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 23CLEANFILES+= dhclient_FIXED 24 25################################################################# 26# 27# General notes: 28# 29# A number of Make variables are used to generate the crunchgen config file. 30# 31# CRUNCH_SRCDIRS: lists directories to search for included programs 32# CRUNCH_PROGS: lists programs to be included 33# CRUNCH_LIBS: libraries to link with 34# CRUNCH_BUILDOPTS: generic build options to be added to every program 35# 36# Special options can be specified for individual programs 37# CRUNCH_SRCDIR_$(P): base source directory for program $(P) 38# CRUNCH_BUILDOPTS_$(P): additional build options for $(P) 39# CRUNCH_ALIAS_$(P): additional names to be used for $(P) 40# 41# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P} 42# will be used to generate a hard link to the resulting binary. 43# Specific links can be suppressed by setting 44# CRUNCH_SUPPRESS_LINK_$(NAME) to 1. 45# 46 47# Define Makefile variable RESCUE 48CRUNCH_BUILDOPTS+= -DRESCUE 49# Define compile-time RESCUE symbol when compiling components 50CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE 51 52# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk 53# rather than incorporating rescue-specific logic into standard files. 54#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS} 55 56# Hackery: 'librescue' exists merely as a tool for appropriately 57# recompiling specific library entries. We _know_ they're needed, and 58# regular archive searching creates ugly library ordering problems. 59# Easiest fix: tell the linker to include them into the executable 60# first, so they are guaranteed to override the regular lib entries. 61# Note that if 'librescue' hasn't been compiled, we'll just get the 62# regular lib entries from libc and friends. 63CRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o 64 65################################################################### 66# Programs from stock /bin 67# 68# WARNING: Changing this list may require adjusting 69# /usr/include/paths.h as well! You were warned! 70# 71CRUNCH_SRCDIRS+= bin 72CRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \ 73 ed expr getfacl hostname kenv kill ln ls mkdir mv \ 74 pkill ps pwd \ 75 realpath rm rmdir setfacl sh stty sync test 76CRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil 77.if ${MK_OPENSSL} != "no" 78CRUNCH_LIBS+= -lcrypto 79.endif 80 81# Additional options for specific programs 82CRUNCH_ALIAS_test= [ 83CRUNCH_ALIAS_sh= -sh 84# The -sh alias shouldn't appear in /rescue as a hard link 85CRUNCH_SUPPRESS_LINK_-sh= 1 86CRUNCH_ALIAS_ln= link 87CRUNCH_ALIAS_rm= unlink 88CRUNCH_ALIAS_ed= red 89CRUNCH_ALIAS_pkill= pgrep 90 91.if ${MK_RCMDS} != "no" 92CRUNCH_PROGS_bin+= rcp 93.endif 94 95.if ${MK_TCSH} != "no" 96CRUNCH_PROGS_bin+= csh 97CRUNCH_ALIAS_csh= -csh tcsh -tcsh 98CRUNCH_SUPPRESS_LINK_-csh= 1 99CRUNCH_SUPPRESS_LINK_-tcsh= 1 100.endif 101 102################################################################### 103# Programs from standard /sbin 104# 105# WARNING: Changing this list may require adjusting 106# /usr/include/paths.h as well! You were warned! 107# 108# Note that mdmfs have their own private 'pathnames.h' 109# headers in addition to the standard 'paths.h' header. 110# 111CRUNCH_SRCDIRS+= sbin 112CRUNCH_PROGS_sbin= atacontrol badsect \ 113 camcontrol ccdconfig clri devfs dmesg dump \ 114 dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb \ 115 fsirand gbde geom ifconfig init \ 116 kldconfig kldload kldstat kldunload ldconfig \ 117 md5 mdconfig mdmfs mknod mount mount_cd9660 \ 118 mount_msdosfs mount_nfs mount_ntfs mount_nullfs \ 119 mount_udf mount_unionfs newfs \ 120 newfs_msdos nos-tun ping reboot \ 121 restore rcorder route routed rtquery rtsol savecore \ 122 slattach spppcontrol startslip swapon sysctl tunefs umount 123 124.if ${MK_ATM} != "no" 125CRUNCH_PROGS_sbin+= atmconfig 126.endif 127 128.if ${MK_INET6_SUPPORT} != "no" 129CRUNCH_PROGS_sbin+= ping6 130.endif 131 132.if ${MK_IPFILTER} != "no" 133CRUNCH_PROGS_sbin+= ipf 134.endif 135 136# crunchgen does not like C++ programs; this should be fixed someday 137# CRUNCH_PROGS+= devd 138 139CRUNCH_LIBS+= -lalias -lcam -lcurses -ldevstat -lipsec 140.if ${MK_IPX} != "no" 141CRUNCH_LIBS+= -lipx 142.endif 143CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv -lmd -lreadline -lsbuf -lufs -lz 144 145.if ${MACHINE_ARCH} == "i386" 146CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk 147CRUNCH_ALIAS_bsdlabel= disklabel 148#.if ${MK_NCP} != "no" 149#CRUNCH_PROGS+= mount_nwfs 150#CRUNCH_LIBS+= -lncp 151#.endif 152#CRUNCH_PROGS+= mount_smbfs 153#CRUNCH_LIBS+= -lsmb 154.endif 155 156.if ${MACHINE} == "pc98" 157CRUNCH_PROGS_sbin+= bsdlabel 158CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98 159.endif 160 161.if ${MACHINE_ARCH} == "ia64" 162CRUNCH_PROGS_sbin+= mca 163.endif 164 165.if ${MACHINE_ARCH} == "sparc64" 166CRUNCH_PROGS_sbin+= bsdlabel sunlabel 167.endif 168 169.if ${MACHINE_ARCH} == "amd64" 170CRUNCH_PROGS_sbin+= bsdlabel fdisk 171CRUNCH_ALIAS_bsdlabel= disklabel 172.endif 173 174CRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm 175CRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig 176CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld 177CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid 178CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery 179CRUNCH_SRCDIR_ipf= $(.CURDIR)/../../sbin/ipf/ipf 180CRUNCH_ALIAS_reboot= fastboot halt fasthalt 181CRUNCH_ALIAS_restore= rrestore 182CRUNCH_ALIAS_dump= rdump 183CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs 184CRUNCH_ALIAS_geom= glabel gpart 185 186# dhclient has historically been troublesome... 187CRUNCH_PROGS_sbin+= dhclient 188CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint 189 190################################################################## 191# Programs from stock /usr/bin 192# 193CRUNCH_SRCDIRS+= usr.bin 194 195CRUNCH_PROGS_usr.bin= head mt sed tail tee 196 197CRUNCH_PROGS_usr.bin+= gzip 198CRUNCH_ALIAS_gzip= gunzip gzcat zcat 199 200CRUNCH_PROGS_usr.bin+= bzip2 201CRUNCH_ALIAS_bzip2= bunzip2 bzcat 202CRUNCH_LIBS+= -lbz2 203 204CRUNCH_PROGS_usr.bin+= tar 205CRUNCH_LIBS+= -larchive 206 207CRUNCH_PROGS_usr.bin+= vi 208CRUNCH_ALIAS_vi= ex 209 210CRUNCH_PROGS_usr.bin+= id 211CRUNCH_ALIAS_id= groups whoami 212 213################################################################## 214# Programs from stock /usr/sbin 215# 216CRUNCH_SRCDIRS+= usr.sbin 217 218CRUNCH_PROGS_usr.sbin= chroot 219 220CRUNCH_PROGS_usr.sbin+= chown 221CRUNCH_ALIAS_chown= chgrp 222 223################################################################## 224# The following is pretty nearly a generic crunchgen-handling makefile 225# 226 227CONF= $(PROG).conf 228OUTMK= $(PROG).mk 229OUTC= $(PROG).c 230OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache 231CRUNCHOBJS= ${.OBJDIR} 232.if defined(MAKEOBJDIRPREFIX) 233CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR} 234.else 235CANONICALOBJDIR:= /usr/obj${.CURDIR} 236.endif 237 238CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h 239 240# Program names and their aliases contribute hardlinks to 'rescue' executable, 241# except for those that get suppressed. 242.for D in $(CRUNCH_SRCDIRS) 243.for P in $(CRUNCH_PROGS_$(D)) 244.ifdef CRUNCH_SRCDIR_${P} 245$(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile 246.else 247$(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile 248.endif 249.ifndef CRUNCH_SUPPRESS_LINK_${P} 250LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P) 251.endif 252.for A in $(CRUNCH_ALIAS_$(P)) 253.ifndef CRUNCH_SUPPRESS_LINK_${A} 254LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A) 255.endif 256.endfor 257.endfor 258.endfor 259 260all: $(PROG) 261exe: $(PROG) 262 263$(CONF): Makefile 264 echo \# Auto-generated, do not edit >$(.TARGET) 265.ifdef CRUNCH_BUILDOPTS 266 echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) 267.endif 268.ifdef CRUNCH_LIBS 269 echo libs $(CRUNCH_LIBS) >>$(.TARGET) 270.endif 271.for D in $(CRUNCH_SRCDIRS) 272.for P in $(CRUNCH_PROGS_$(D)) 273 echo progs $(P) >>$(.TARGET) 274.ifdef CRUNCH_SRCDIR_${P} 275 echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET) 276.else 277 echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET) 278.endif 279.ifdef CRUNCH_BUILDOPTS_${P} 280 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \ 281 $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET) 282.else 283 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET) 284.endif 285.for A in $(CRUNCH_ALIAS_$(P)) 286 echo ln $(P) $(A) >>$(.TARGET) 287.endfor 288.endfor 289.endfor 290 291# XXX Make sure we don't pass -P to crunchgen(1). 292.MAKEFLAGS:= ${.MAKEFLAGS:N-P} 293.ORDER: $(OUTPUTS) objs 294$(OUTPUTS): $(CONF) 295 MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \ 296 -c $(OUTC) $(CONF) 297 298$(PROG): $(OUTPUTS) objs 299 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe 300 301objs: $(OUTMK) 302 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs 303 304# <sigh> Someone should replace the bin/csh and bin/sh build-tools with 305# shell scripts so we can remove this nonsense. 306build-tools: 307.for _tool in bin/csh bin/sh 308 cd $(.CURDIR)/../../${_tool}; \ 309 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \ 310 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools 311.endfor 312 313# Use a separate build tree to hold files compiled for this crunchgen binary 314# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't 315# get that to cooperate with bsd.prog.mk. Besides, many of the standard 316# targets should NOT be propagated into the components. 317cleandepend cleandir obj objlink: 318.for D in $(CRUNCH_SRCDIRS) 319.for P in $(CRUNCH_PROGS_$(D)) 320.ifdef CRUNCH_SRCDIR_${P} 321 cd ${CRUNCH_SRCDIR_$(P)} && \ 322 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 323 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 324.else 325 cd $(.CURDIR)/../../${D}/${P} && \ 326 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 327 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 328.endif 329.endfor 330.endfor 331 332clean: 333 rm -f ${CLEANFILES} 334 if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ 335 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \ 336 fi 337.for D in $(CRUNCH_SRCDIRS) 338.for P in $(CRUNCH_PROGS_$(D)) 339.ifdef CRUNCH_SRCDIR_${P} 340 cd ${CRUNCH_SRCDIR_$(P)} && \ 341 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 342 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 343.else 344 cd $(.CURDIR)/../../${D}/${P} && \ 345 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 346 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 347.endif 348.endfor 349.endfor 350 351.include <bsd.prog.mk> 352