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