Makefile revision 122341
1178479Sjb#$FreeBSD: head/rescue/rescue/Makefile 122341 2003-11-09 01:22:27Z obrien $ 2178479Sjb# @(#)Makefile 8.1 (Berkeley) 6/2/93 3178479Sjb 4178479SjbPROG= rescue 5178479SjbBINDIR?=/rescue 6178479Sjb 7178479Sjb# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh 8178479SjbSCRIPTS= nextboot_FIXED 9178479SjbSCRIPTSNAME_nextboot_FIXED= nextboot.sh 10178479Sjbnextboot_FIXED: ../../sbin/reboot/nextboot.sh 11178479Sjb sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 12178479SjbCLEANFILES+= nextboot_FIXED 13178479Sjb 14178479SjbSCRIPTS+= dhclient_FIXED 15178479SjbSCRIPTSNAME_dhclient_FIXED= dhclient-script 16178479Sjbdhclient_FIXED: ../../contrib/isc-dhcp/client/scripts/freebsd 17178479Sjb sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 18178479SjbCLEANFILES+= dhclient_FIXED 19178479Sjb 20178479Sjb################################################################# 21178563Sjb# 22178479Sjb# General notes: 23178479Sjb# 24178479Sjb# A number of Make variables are used to generate the crunchgen config file. 25178479Sjb# 26178479Sjb# CRUNCH_SRCDIRS: lists directories to search for included programs 27178479Sjb# CRUNCH_PROGS: lists programs to be included 28178479Sjb# CRUNCH_LIBS: libraries to link with 29178479Sjb# CRUNCH_BUILDOPTS: generic build options to be added to every program 30178479Sjb# 31178479Sjb# Special options can be specified for individual programs 32178479Sjb# CRUNCH_SRCDIR_$(P): base source directory for program $(P) 33178479Sjb# CRUNCH_BUILDOPTS_$(P): additional build options for $(P) 34178563Sjb# CRUNCH_ALIAS_$(P): additional names to be used for $(P) 35178563Sjb# 36178563Sjb# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P} 37178563Sjb# will be used to generate a hard link to the resulting binary. 38178563Sjb# Specific links can be suppressed by setting 39178563Sjb# CRUNCH_SUPPRESS_LINK_$(NAME) to 1. 40178563Sjb# 41178479Sjb 42178479Sjb# Define Makefile variable RESCUE 43178479SjbCRUNCH_BUILDOPTS+= -DRESCUE 44178479Sjb# Define compile-time RESCUE symbol when compiling components 45178479SjbCRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE 46178479Sjb 47178479Sjb# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk 48178479Sjb# rather than incorporating rescue-specific logic into standard files. 49178479Sjb#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS} 50178479Sjb 51178479Sjb# Hackery: 'librescue' exists merely as a tool for appropriately 52178479Sjb# recompiling specific library entries. We _know_ they're needed, and 53178479Sjb# regular archive searching creates ugly library ordering problems. 54178479Sjb# Easiest fix: tell the linker to include them into the executable 55178479Sjb# first, so they are guaranteed to override the regular lib entries. 56178479Sjb# Note that if 'librescue' hasn't been compiled, we'll just get the 57178479Sjb# regular lib entries from libc and friends. 58178479SjbCRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o 59178479Sjb 60178479Sjb################################################################### 61178479Sjb# Programs from stock /bin 62178479Sjb# 63178479Sjb# WARNING: Changing this list may require adjusting 64178479Sjb# /usr/include/paths.h as well! You were warned! 65178479Sjb# 66178479SjbCRUNCH_SRCDIRS+= bin 67178479SjbCRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \ 68178479Sjb ed expr getfacl hostname kenv kill ln ls mkdir mv pax ps pwd \ 69178479Sjb realpath rm rmdir setfacl sh stty sync test 70178479SjbCRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil 71178479Sjb.if !defined(NOCRYPT) && !defined(NO_OPENSSL) 72178479SjbCRUNCH_LIBS+= -lcrypto 73178479Sjb.endif 74178479Sjb 75178479Sjb# Additional options for specific programs 76178479SjbCRUNCH_ALIAS_test= [ 77178479SjbCRUNCH_ALIAS_sh= -sh 78178479Sjb# The -sh alias shouldn't appear in /rescue as a hard link 79178479SjbCRUNCH_SUPPRESS_LINK_-sh= 1 80178479SjbCRUNCH_ALIAS_ln= link 81178479SjbCRUNCH_ALIAS_rm= unlink 82178479SjbCRUNCH_ALIAS_ed= red 83178479Sjb 84178479Sjb.if !defined(NO_RCMNDS) 85178479SjbCRUNCH_PROGS_bin+= rcp 86178479Sjb.endif 87178479Sjb 88178479Sjb.if !defined(NO_TCSH) 89178479SjbCRUNCH_PROGS_bin+= csh 90178479SjbCRUNCH_ALIAS_csh= -csh tcsh -tcsh 91178479SjbCRUNCH_SUPPRESS_LINK_-csh= 1 92178479SjbCRUNCH_SUPPRESS_LINK_-tcsh= 1 93178479Sjb.endif 94178479Sjb 95178479Sjb################################################################### 96178479Sjb# Programs from standard /sbin 97178479Sjb# 98178479Sjb# WARNING: Changing this list may require adjusting 99178479Sjb# /usr/include/paths.h as well! You were warned! 100178479Sjb# 101178479Sjb# Note that mdmfs have their own private 'pathnames.h' 102178479Sjb# headers in addition to the standard 'paths.h' header. 103178479Sjb# 104178479SjbCRUNCH_SRCDIRS+= sbin 105178479SjbCRUNCH_PROGS_sbin= atacontrol badsect bsdlabel \ 106178479Sjb camcontrol ccdconfig clri devfs dmesg dump \ 107178479Sjb dumpfs dumpon fore_dnld fsck fsck_ffs fsck_msdosfs fsdb \ 108178479Sjb fsirand gbde ifconfig init \ 109178479Sjb kldconfig kldload kldstat kldunload ldconfig \ 110178479Sjb md5 mdconfig mdmfs mknod mount mount_cd9660 mount_ext2fs \ 111178479Sjb mount_msdosfs mount_nfs mount_ntfs mount_nullfs \ 112178479Sjb mount_std mount_udf mount_umapfs mount_unionfs newfs \ 113178479Sjb newfs_msdos nos-tun ping raidctl reboot \ 114178479Sjb restore rcorder route routed rtquery rtsol savecore \ 115178479Sjb slattach spppcontrol startslip swapon sysctl tunefs umount 116178479Sjb 117178479Sjb.if !defined(NOATM) 118178479SjbCRUNCH_PROGS_sbin+= atm atmconfig ilmid 119178479SjbCRUNCH_LIBS+= -latm 120178479Sjb.endif 121178479Sjb 122178479Sjb.if !defined(NOINET6) 123178479SjbCRUNCH_PROGS_sbin+= ping6 124178479Sjb.endif 125178479Sjb 126178479Sjb.if !defined(NO_VINUM) 127178479SjbCRUNCH_PROGS_sbin+= vinum 128178479Sjb.endif 129178479Sjb 130178479Sjb.if !defined(NO_IPFILTER) 131178479SjbCRUNCH_PROGS_sbin+= ipf ipfs ipmon # ipnat 132178479Sjb.endif 133178479Sjb 134178479Sjb# crunchgen does not like C++ programs; this should be fixed someday 135178479Sjb# CRUNCH_PROGS+= devd 136178479Sjb 137178479SjbCRUNCH_LIBS+= -lalias -lbsdxml -lcam -lcurses -ldevstat -lipsec -lipx \ 138178563Sjb -lgeom -lkiconv -lmd -lreadline -lsbuf -lufs -lz 139178563Sjb 140210425Savg.if ${MACHINE_ARCH} == "i386" 141178563SjbCRUNCH_PROGS_sbin+= cxconfig fdisk 142178479SjbCRUNCH_ALIAS_bsdlabel= disklabel 143178479Sjb#CRUNCH_PROGS+= mount_nwfs mount_smbfs 144178479Sjb#CRUNCH_LIBS+= -lncp -lsmb 145178479Sjb.endif 146178479Sjb 147178479Sjb.if ${MACHINE} == "pc98" 148178479SjbCRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98 149178479Sjb.endif 150178479Sjb 151178479Sjb.if ${MACHINE_ARCH} == "ia64" 152178479SjbCRUNCH_PROGS_sbin+= mca gpt fdisk 153178479Sjb.endif 154178479Sjb 155178479Sjb.if ${MACHINE_ARCH} == "sparc64" 156178479SjbCRUNCH_PROGS_sbin+= sunlabel 157178479Sjb.endif 158178479Sjb 159178479Sjb.if ${MACHINE_ARCH} == "alpha" 160178479SjbCRUNCH_ALIAS_bsdlabel= disklabel 161178479Sjb.endif 162178479Sjb 163178479Sjb.if ${MACHINE_ARCH} == "amd64" 164178479SjbCRUNCH_PROGS_sbin+= fdisk 165178479SjbCRUNCH_ALIAS_bsdlabel= disklabel 166178479Sjb.endif 167178479Sjb 168178479SjbCRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm 169178479SjbCRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig 170178479SjbCRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld 171178479SjbCRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid 172178479SjbCRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery 173178479SjbCRUNCH_ALIAS_reboot= fastboot halt fasthalt 174178479SjbCRUNCH_ALIAS_restore= rrestore 175178479SjbCRUNCH_ALIAS_dump= rdump 176178479SjbCRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs 177178479SjbCRUNCH_ALIAS_mount_std= mount_devfs mount_fdescfs mount_linprocfs mount_procfs 178178479Sjb 179178479Sjb# dhclient has historically been troublesome... 180178479SjbCRUNCH_PROGS_sbin+= dhclient 181178479SjbCRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint 182178479Sjb 183178479Sjb################################################################## 184178479Sjb# Programs from stock /usr/bin 185178479Sjb# 186178479SjbCRUNCH_SRCDIRS+= usr.bin 187178479SjbCRUNCH_SRCDIRS+= gnu/usr.bin 188178479Sjb 189178479SjbCRUNCH_PROGS_gnu/usr.bin+= gzip 190178479SjbCRUNCH_ALIAS_gzip= gunzip gzcat zcat 191178479Sjb 192178479SjbCRUNCH_PROGS_usr.bin+= bzip2 193178479SjbCRUNCH_ALIAS_bzip2= bunzip2 bzcat 194178479SjbCRUNCH_LIBS+= -lbz2 195178479Sjb 196178479SjbCRUNCH_PROGS_gnu/usr.bin+= tar 197178479SjbCRUNCH_PROGS_usr.bin+= vi 198178563SjbCRUNCH_ALIAS_vi= ex 199178479Sjb 200178479Sjb################################################################## 201178479Sjb# The following is pretty nearly a generic crunchgen-handling makefile 202178479Sjb# 203178479Sjb 204178479SjbCONF= $(PROG).conf 205178479SjbOUTMK= $(PROG).mk 206178479SjbOUTC= $(PROG).c 207178479SjbOUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache 208178479SjbCRUNCHOBJS= ${.OBJDIR} 209178479Sjb.if defined(MAKEOBJDIRPREFIX) 210178479SjbCANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR} 211178479Sjb.else 212178479SjbCANONICALOBJDIR:= /usr/obj${.CURDIR} 213178479Sjb.endif 214178479Sjb 215178479SjbNOMAN= true 216178479SjbCLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h 217178479Sjb 218178479Sjb# Program names and their aliases contribute hardlinks to 'rescue' executable, 219178479Sjb# except for those that get suppressed. 220178479Sjb.for D in $(CRUNCH_SRCDIRS) 221178479Sjb.for P in $(CRUNCH_PROGS_$(D)) 222178479Sjb.ifndef CRUNCH_SUPPRESS_LINK_${P} 223178479SjbLINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P) 224178479Sjb.endif 225178479Sjb.for A in $(CRUNCH_ALIAS_$(P)) 226178479Sjb.ifndef CRUNCH_SUPPRESS_LINK_${A} 227178479SjbLINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A) 228178479Sjb.endif 229178479Sjb.endfor 230178479Sjb.endfor 231178479Sjb.endfor 232178479Sjb 233178479Sjball: $(PROG) 234178479Sjbexe: $(PROG) 235178479Sjb 236178479Sjb$(CONF): Makefile 237178479Sjb echo \# Auto-generated, do not edit >$(.TARGET) 238178479Sjb.for D in $(CRUNCH_SRCDIRS) 239178479Sjb echo srcdirs $(.CURDIR)/../../$(D) >>$(.TARGET) 240178479Sjb.endfor 241178479Sjb.ifdef CRUNCH_BUILDOPTS 242178479Sjb echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) 243178479Sjb.endif 244178479Sjb.ifdef CRUNCH_LIBS 245178479Sjb echo libs $(CRUNCH_LIBS) >>$(.TARGET) 246178479Sjb.endif 247178479Sjb.for D in $(CRUNCH_SRCDIRS) 248178479Sjb.for P in $(CRUNCH_PROGS_$(D)) 249178479Sjb echo progs $(P) >>$(.TARGET) 250178479Sjb.ifdef CRUNCH_SRCDIR_${P} 251178479Sjb echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET) 252178479Sjb.endif 253178479Sjb.ifdef CRUNCH_BUILDOPTS_${P} 254178479Sjb echo special $(P) buildopts $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET) 255178479Sjb.endif 256178479Sjb.for A in $(CRUNCH_ALIAS_$(P)) 257178479Sjb echo ln $(P) $(A) >>$(.TARGET) 258178479Sjb.endfor 259178479Sjb.endfor 260178479Sjb.endfor 261178479Sjb 262178479Sjb 263178479Sjb.ORDER: $(OUTPUTS) objs 264178479Sjb$(OUTPUTS): $(CONF) 265178479Sjb MAKEFLAGS= MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -q -m $(OUTMK) \ 266178479Sjb -c $(OUTC) $(CONF) 267178479Sjb 268178479Sjb$(PROG): $(OUTPUTS) objs 269178479Sjb MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) 270178479Sjb 271178479Sjbobjs: $(OUTMK) 272178479Sjb MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) objs 273178479Sjb 274178479Sjb# <sigh> Someone should replace the bin/csh and bin/sh build-tools with 275178479Sjb# shell scripts so we can remove this nonsense. 276178479Sjbbuild-tools: 277178479Sjb.for _tool in bin/csh bin/sh 278178479Sjb cd $(.CURDIR)/../../${_tool}; \ 279178479Sjb MAKEOBJDIRPREFIX=${CRUNCHOBJS} make DIRPRFX=rescue/${_tool} build-tools 280178479Sjb.endfor 281178563Sjb 282178563Sjb# Use a separate build tree to hold files compiled for this crunchgen binary 283178563Sjb# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't 284178563Sjb# get that to cooperate with bsd.prog.mk. Besides, many of the standard 285178479Sjb# targets should NOT be propagated into the components. 286178479Sjbcleandepend cleandir obj objlink: 287178479Sjb.for D in $(CRUNCH_SRCDIRS) 288178479Sjb.for P in $(CRUNCH_PROGS_$(D)) 289178479Sjb.ifdef CRUNCH_SRCDIR_${P} 290178563Sjb cd ${CRUNCH_SRCDIR_$(P)} && \ 291178479Sjb MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 292178563Sjb.else 293178563Sjb cd $(.CURDIR)/../../${D}/${P} && \ 294178563Sjb MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 295178479Sjb.endif 296178479Sjb.endfor 297178479Sjb.endfor 298178479Sjb 299178479Sjbclean: 300178479Sjb rm -f ${CLEANFILES} 301178479Sjb if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ 302178479Sjb MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) clean; \ 303178479Sjb fi 304178479Sjb.for D in $(CRUNCH_SRCDIRS) 305178479Sjb.for P in $(CRUNCH_PROGS_$(D)) 306178479Sjb.ifdef CRUNCH_SRCDIR_${P} 307178479Sjb cd ${CRUNCH_SRCDIR_$(P)} && \ 308178479Sjb MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 309178479Sjb.else 310178479Sjb cd $(.CURDIR)/../../${D}/${P} && \ 311178479Sjb MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 312178479Sjb.endif 313178479Sjb.endfor 314178479Sjb.endfor 315178479Sjb 316178479Sjb.include <bsd.prog.mk> 317178479Sjb