Makefile revision 127075
197403Sobrien#$FreeBSD: head/rescue/rescue/Makefile 127075 2004-03-16 13:42:23Z phk $ 297403Sobrien# @(#)Makefile 8.1 (Berkeley) 6/2/93 3169691Skan 4117397SkanPROG= rescue 597403SobrienBINDIR?=/rescue 697403Sobrien 797403Sobrien# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh 897403SobrienSCRIPTS= nextboot_FIXED 997403SobrienSCRIPTSNAME_nextboot_FIXED= nextboot.sh 1097403Sobriennextboot_FIXED: ../../sbin/reboot/nextboot.sh 1197403Sobrien sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 1297403SobrienCLEANFILES+= nextboot_FIXED 1397403Sobrien 1497403SobrienSCRIPTS+= dhclient_FIXED 1597403SobrienSCRIPTSNAME_dhclient_FIXED= dhclient-script 1697403Sobriendhclient_FIXED: ../../contrib/isc-dhcp/client/scripts/freebsd 1797403Sobrien sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 1897403SobrienCLEANFILES+= dhclient_FIXED 19169691Skan 2097403Sobrien################################################################# 2197403Sobrien# 2297403Sobrien# General notes: 2397403Sobrien# 2497403Sobrien# A number of Make variables are used to generate the crunchgen config file. 2597403Sobrien# 2697403Sobrien# CRUNCH_SRCDIRS: lists directories to search for included programs 2797403Sobrien# CRUNCH_PROGS: lists programs to be included 2897403Sobrien# CRUNCH_LIBS: libraries to link with 2997403Sobrien# CRUNCH_BUILDOPTS: generic build options to be added to every program 3097403Sobrien# 3197403Sobrien# Special options can be specified for individual programs 3297403Sobrien# CRUNCH_SRCDIR_$(P): base source directory for program $(P) 3397403Sobrien# CRUNCH_BUILDOPTS_$(P): additional build options for $(P) 3497403Sobrien# CRUNCH_ALIAS_$(P): additional names to be used for $(P) 3597403Sobrien# 36169691Skan# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P} 37169691Skan# will be used to generate a hard link to the resulting binary. 38132720Skan# Specific links can be suppressed by setting 39132720Skan# CRUNCH_SUPPRESS_LINK_$(NAME) to 1. 4097403Sobrien# 4197403Sobrien 4297403Sobrien# Define Makefile variable RESCUE 43169691SkanCRUNCH_BUILDOPTS+= -DRESCUE 4497403Sobrien# Define compile-time RESCUE symbol when compiling components 45132720SkanCRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE 46132720Skan 47132720Skan# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk 48132720Skan# rather than incorporating rescue-specific logic into standard files. 49132720Skan#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS} 50132720Skan 51132720Skan# Hackery: 'librescue' exists merely as a tool for appropriately 52132720Skan# recompiling specific library entries. We _know_ they're needed, and 53132720Skan# regular archive searching creates ugly library ordering problems. 54132720Skan# Easiest fix: tell the linker to include them into the executable 55132720Skan# first, so they are guaranteed to override the regular lib entries. 56132720Skan# Note that if 'librescue' hasn't been compiled, we'll just get the 57132720Skan# regular lib entries from libc and friends. 58132720SkanCRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o 59132720Skan 60132720Skan################################################################### 61117397Skan# Programs from stock /bin 62132720Skan# 6397403Sobrien# WARNING: Changing this list may require adjusting 64117397Skan# /usr/include/paths.h as well! You were warned! 65132720Skan# 66132720SkanCRUNCH_SRCDIRS+= bin 67132720SkanCRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \ 68132720Skan ed expr getfacl hostname kenv kill ln ls mkdir mv pax ps pwd \ 69132720Skan realpath rm rmdir setfacl sh stty sync test 70132720SkanCRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil 71132720Skan.if !defined(NOCRYPT) && !defined(NO_OPENSSL) 72132720SkanCRUNCH_LIBS+= -lcrypto 73132720Skan.endif 74132720Skan 75132720Skan# Additional options for specific programs 76117397SkanCRUNCH_ALIAS_test= [ 77132720SkanCRUNCH_ALIAS_sh= -sh 78117397Skan# The -sh alias shouldn't appear in /rescue as a hard link 79132720SkanCRUNCH_SUPPRESS_LINK_-sh= 1 80117397SkanCRUNCH_ALIAS_ln= link 81132720SkanCRUNCH_ALIAS_rm= unlink 82117397SkanCRUNCH_ALIAS_ed= red 83132720Skan 84132720Skan.if !defined(NO_RCMNDS) 85132720SkanCRUNCH_PROGS_bin+= rcp 86117397Skan.endif 87132720Skan 88132720Skan.if !defined(NO_TCSH) 89132720SkanCRUNCH_PROGS_bin+= csh 90117397SkanCRUNCH_ALIAS_csh= -csh tcsh -tcsh 91132720SkanCRUNCH_SUPPRESS_LINK_-csh= 1 92117397SkanCRUNCH_SUPPRESS_LINK_-tcsh= 1 93132720Skan.endif 94132720Skan 95132720Skan################################################################### 96132720Skan# Programs from standard /sbin 97132720Skan# 98117397Skan# WARNING: Changing this list may require adjusting 99132720Skan# /usr/include/paths.h as well! You were warned! 10097403Sobrien# 101132720Skan# Note that mdmfs have their own private 'pathnames.h' 102117397Skan# headers in addition to the standard 'paths.h' header. 103117397Skan# 104117397SkanCRUNCH_SRCDIRS+= sbin 105117397SkanCRUNCH_PROGS_sbin= atacontrol badsect bsdlabel \ 106117397Skan camcontrol ccdconfig clri devfs dmesg dump \ 107117397Skan dumpfs dumpon fore_dnld fsck fsck_ffs fsck_msdosfs fsdb \ 108117397Skan fsirand gbde ifconfig init \ 109117397Skan kldconfig kldload kldstat kldunload ldconfig \ 110117397Skan md5 mdconfig mdmfs mknod mount mount_cd9660 mount_ext2fs \ 111117397Skan mount_msdosfs mount_nfs mount_ntfs mount_nullfs \ 112117397Skan mount_std mount_udf mount_umapfs mount_unionfs newfs \ 113117397Skan newfs_msdos nos-tun ping reboot \ 114117397Skan restore rcorder route routed rtquery rtsol savecore \ 115117397Skan slattach spppcontrol startslip swapon sysctl tunefs umount 116117397Skan 117117397Skan.if !defined(NOATM) 118117397SkanCRUNCH_PROGS_sbin+= atm atmconfig ilmid 119117397SkanCRUNCH_LIBS+= -latm 120117397Skan.endif 12197403Sobrien 122117397Skan.if !defined(NOINET6) 123132720SkanCRUNCH_PROGS_sbin+= ping6 12497403Sobrien.endif 12597403Sobrien 126117397Skan.if !defined(NO_VINUM) 127117397SkanCRUNCH_PROGS_sbin+= vinum 128132720Skan.endif 129117397Skan 130117397Skan.if !defined(NO_IPFILTER) 131169691SkanCRUNCH_PROGS_sbin+= ipf ipfs ipfstat ipmon ipnat 132132720Skan.endif 133117397Skan 134117397Skan# crunchgen does not like C++ programs; this should be fixed someday 13597403Sobrien# CRUNCH_PROGS+= devd 13697403Sobrien 137117397SkanCRUNCH_LIBS+= -lalias -lbsdxml -lcam -lcurses -ldevstat -lipsec -lipx \ 138117397Skan -lgeom -lkiconv -lmd -lreadline -lsbuf -lufs -lz 139132720Skan 14097403Sobrien.if ${MACHINE_ARCH} == "i386" 141117397SkanCRUNCH_PROGS_sbin+= sconfig fdisk 142132720SkanCRUNCH_ALIAS_bsdlabel= disklabel 143117397Skan#CRUNCH_PROGS+= mount_nwfs mount_smbfs 144132720Skan#CRUNCH_LIBS+= -lncp -lsmb 145132720Skan.endif 146117397Skan 147132720Skan.if ${MACHINE} == "pc98" 148132720SkanCRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98 149132720Skan.endif 150132720Skan 151132720Skan.if ${MACHINE_ARCH} == "ia64" 152132720SkanCRUNCH_PROGS_sbin+= mca gpt fdisk 153132720Skan.endif 154132720Skan 155132720Skan.if ${MACHINE_ARCH} == "sparc64" 15697403SobrienCRUNCH_PROGS_sbin+= sunlabel 157117397Skan.endif 158132720Skan 159132720Skan.if ${MACHINE_ARCH} == "alpha" 160117397SkanCRUNCH_ALIAS_bsdlabel= disklabel 16197403Sobrien.endif 162117397Skan 163132720Skan.if ${MACHINE_ARCH} == "amd64" 16497403SobrienCRUNCH_PROGS_sbin+= fdisk 165117397SkanCRUNCH_ALIAS_bsdlabel= disklabel 166117397Skan.endif 167117397Skan 168117397SkanCRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm 169132720SkanCRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig 17097403SobrienCRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld 17197403SobrienCRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid 172117397SkanCRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery 173117397SkanCRUNCH_ALIAS_reboot= fastboot halt fasthalt 174117397SkanCRUNCH_ALIAS_restore= rrestore 175117397SkanCRUNCH_ALIAS_dump= rdump 176117397SkanCRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs 177117397SkanCRUNCH_ALIAS_mount_std= mount_devfs mount_fdescfs mount_linprocfs mount_procfs 178117397Skan 179117397Skan# dhclient has historically been troublesome... 18097403SobrienCRUNCH_PROGS_sbin+= dhclient 181117397SkanCRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint 182117397Skan 183117397Skan################################################################## 184117397Skan# Programs from stock /usr/bin 185117397Skan# 186117397SkanCRUNCH_SRCDIRS+= usr.bin 187117397SkanCRUNCH_SRCDIRS+= gnu/usr.bin 18897403Sobrien 189117397SkanCRUNCH_PROGS_gnu/usr.bin+= gzip 190117397SkanCRUNCH_ALIAS_gzip= gunzip gzcat zcat 191117397Skan 192117397SkanCRUNCH_PROGS_usr.bin+= bzip2 193117397SkanCRUNCH_ALIAS_bzip2= bunzip2 bzcat 194117397SkanCRUNCH_LIBS+= -lbz2 195117397Skan 196117397SkanCRUNCH_PROGS_gnu/usr.bin+= tar 197117397SkanCRUNCH_PROGS_usr.bin+= vi 198117397SkanCRUNCH_ALIAS_vi= ex 19997403Sobrien 200132720SkanCRUNCH_PROGS_usr.bin+= id 201132720SkanCRUNCH_ALIAS_id= groups whoami 202169691Skan 20397403Sobrien################################################################## 204132720Skan# The following is pretty nearly a generic crunchgen-handling makefile 205# 206 207CONF= $(PROG).conf 208OUTMK= $(PROG).mk 209OUTC= $(PROG).c 210OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache 211CRUNCHOBJS= ${.OBJDIR} 212.if defined(MAKEOBJDIRPREFIX) 213CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR} 214.else 215CANONICALOBJDIR:= /usr/obj${.CURDIR} 216.endif 217 218NOMAN= true 219CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h 220 221# Program names and their aliases contribute hardlinks to 'rescue' executable, 222# except for those that get suppressed. 223.for D in $(CRUNCH_SRCDIRS) 224.for P in $(CRUNCH_PROGS_$(D)) 225.ifndef CRUNCH_SUPPRESS_LINK_${P} 226LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P) 227.endif 228.for A in $(CRUNCH_ALIAS_$(P)) 229.ifndef CRUNCH_SUPPRESS_LINK_${A} 230LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A) 231.endif 232.endfor 233.endfor 234.endfor 235 236all: $(PROG) 237exe: $(PROG) 238 239$(CONF): Makefile 240 echo \# Auto-generated, do not edit >$(.TARGET) 241.ifdef CRUNCH_BUILDOPTS 242 echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) 243.endif 244.ifdef CRUNCH_LIBS 245 echo libs $(CRUNCH_LIBS) >>$(.TARGET) 246.endif 247.for D in $(CRUNCH_SRCDIRS) 248.for P in $(CRUNCH_PROGS_$(D)) 249 echo progs $(P) >>$(.TARGET) 250.ifdef CRUNCH_SRCDIR_${P} 251 echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET) 252.else 253 echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET) 254.endif 255.ifdef CRUNCH_BUILDOPTS_${P} 256 echo special $(P) buildopts $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET) 257.endif 258.for A in $(CRUNCH_ALIAS_$(P)) 259 echo ln $(P) $(A) >>$(.TARGET) 260.endfor 261.endfor 262.endfor 263 264 265.ORDER: $(OUTPUTS) objs 266$(OUTPUTS): $(CONF) 267 MAKEFLAGS= MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -q -m $(OUTMK) \ 268 -c $(OUTC) $(CONF) 269 270$(PROG): $(OUTPUTS) objs 271 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) 272 273objs: $(OUTMK) 274 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs 275 276# <sigh> Someone should replace the bin/csh and bin/sh build-tools with 277# shell scripts so we can remove this nonsense. 278build-tools: 279.for _tool in bin/csh bin/sh 280 cd $(.CURDIR)/../../${_tool}; \ 281 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} DIRPRFX=rescue/${_tool} build-tools 282.endfor 283 284# Use a separate build tree to hold files compiled for this crunchgen binary 285# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't 286# get that to cooperate with bsd.prog.mk. Besides, many of the standard 287# targets should NOT be propagated into the components. 288cleandepend cleandir obj objlink: 289.for D in $(CRUNCH_SRCDIRS) 290.for P in $(CRUNCH_PROGS_$(D)) 291.ifdef CRUNCH_SRCDIR_${P} 292 cd ${CRUNCH_SRCDIR_$(P)} && \ 293 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} ${.TARGET} 294.else 295 cd $(.CURDIR)/../../${D}/${P} && \ 296 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} ${.TARGET} 297.endif 298.endfor 299.endfor 300 301clean: 302 rm -f ${CLEANFILES} 303 if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ 304 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \ 305 fi 306.for D in $(CRUNCH_SRCDIRS) 307.for P in $(CRUNCH_PROGS_$(D)) 308.ifdef CRUNCH_SRCDIR_${P} 309 cd ${CRUNCH_SRCDIR_$(P)} && \ 310 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} ${.TARGET} 311.else 312 cd $(.CURDIR)/../../${D}/${P} && \ 313 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} ${.TARGET} 314.endif 315.endfor 316.endfor 317 318.include <bsd.prog.mk> 319