1884c25d1SGordon Tetlow#$FreeBSD$ 2884c25d1SGordon Tetlow# @(#)Makefile 8.1 (Berkeley) 6/2/93 3884c25d1SGordon Tetlow 4884c25d1SGordon TetlowPROG= rescue 5884c25d1SGordon TetlowBINDIR?= /rescue 6884c25d1SGordon Tetlow 7884c25d1SGordon Tetlow# Uncomment to exclude tcsh 8884c25d1SGordon Tetlow#NO_TCSH=1 9884c25d1SGordon Tetlow 10884c25d1SGordon Tetlow# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh 11884c25d1SGordon TetlowSCRIPTS= nextboot_FIXED 12884c25d1SGordon TetlowSCRIPTSNAME_nextboot_FIXED= nextboot.sh 13884c25d1SGordon Tetlownextboot_FIXED: ../../sbin/reboot/nextboot.sh 14884c25d1SGordon Tetlow sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 15884c25d1SGordon TetlowCLEANFILES+= nextboot_FIXED 16884c25d1SGordon Tetlow 17884c25d1SGordon TetlowSCRIPTS+= dhclient_FIXED 18884c25d1SGordon TetlowSCRIPTSNAME_dhclient_FIXED= dhclient-script 19884c25d1SGordon Tetlowdhclient_FIXED: ../../contrib/isc-dhcp/client/scripts/freebsd 20884c25d1SGordon Tetlow sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 21884c25d1SGordon TetlowCLEANFILES+= dhclient_FIXED 22884c25d1SGordon Tetlow 23884c25d1SGordon Tetlow################################################################# 24884c25d1SGordon Tetlow# 25884c25d1SGordon Tetlow# General notes: 26884c25d1SGordon Tetlow# 27884c25d1SGordon Tetlow# A number of Make variables are used to generate the crunchgen config file. 28884c25d1SGordon Tetlow# 29884c25d1SGordon Tetlow# CRUNCH_SRCDIRS: lists directories to search for included programs 30884c25d1SGordon Tetlow# CRUNCH_PROGS: lists programs to be included 31884c25d1SGordon Tetlow# CRUNCH_LIBS: libraries to link with 32884c25d1SGordon Tetlow# CRUNCH_BUILDOPTS: generic build options to be added to every program 33884c25d1SGordon Tetlow# 34884c25d1SGordon Tetlow# Special options can be specified for individual programs 35884c25d1SGordon Tetlow# CRUNCH_SRCDIR_$(P): base source directory for program $(P) 36884c25d1SGordon Tetlow# CRUNCH_BUILDOPTS_$(P): additional build options for $(P) 37884c25d1SGordon Tetlow# CRUNCH_ALIAS_$(P): additional names to be used for $(P) 38884c25d1SGordon Tetlow# 39884c25d1SGordon Tetlow# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P} 40884c25d1SGordon Tetlow# will be used to generate a hard link to the resulting binary. 41884c25d1SGordon Tetlow# Specific links can be suppressed by setting 42884c25d1SGordon Tetlow# CRUNCH_SUPPRESS_LINK_$(NAME) to 1. 43884c25d1SGordon Tetlow# 44884c25d1SGordon Tetlow 45884c25d1SGordon Tetlow# Define Makefile variable RESCUE 46884c25d1SGordon TetlowCRUNCH_BUILDOPTS+= -DRESCUE 47884c25d1SGordon Tetlow# Define compile-time RESCUE symbol when compiling components 48884c25d1SGordon TetlowCRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE 49884c25d1SGordon Tetlow 504d938af0SGordon Tetlow# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk 514d938af0SGordon Tetlow# rather than incorporating rescue-specific logic into standard files. 52884c25d1SGordon Tetlow#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS} 53884c25d1SGordon Tetlow 54884c25d1SGordon Tetlow# Hackery: 'librescue' exists merely as a tool for appropriately 55884c25d1SGordon Tetlow# recompiling specific library entries. We _know_ they're needed, and 56884c25d1SGordon Tetlow# regular archive searching creates ugly library ordering problems. 57884c25d1SGordon Tetlow# Easiest fix: tell the linker to include them into the executable 58884c25d1SGordon Tetlow# first, so they are guaranteed to override the regular lib entries. 59884c25d1SGordon Tetlow# Note that if 'librescue' hasn't been compiled, we'll just get the 60884c25d1SGordon Tetlow# regular lib entries from libc and friends. 61884c25d1SGordon TetlowCRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o 62884c25d1SGordon Tetlow 63884c25d1SGordon Tetlow################################################################### 64884c25d1SGordon Tetlow# Programs from stock /bin 65884c25d1SGordon Tetlow# 66884c25d1SGordon Tetlow# WARNING: Changing this list may require adjusting 67884c25d1SGordon Tetlow# /usr/include/paths.h as well! You were warned! 68884c25d1SGordon Tetlow# 69884c25d1SGordon TetlowCRUNCH_SRCDIRS+=$(.CURDIR)/../../bin $(.CURDIR)/../../usr.bin 70884c25d1SGordon TetlowCRUNCH_PROGS=cat chflags chio chmod cp date dd df domainname echo ed \ 71884c25d1SGordon Tetlow expr getfacl hostname kenv kill ln ls mkdir mv pax ps pwd \ 72884c25d1SGordon Tetlow realpath rm rmdir setfacl sh sleep stty sync test 73884c25d1SGordon TetlowCRUNCH_LIBS+=-lcrypt -lcrypto -ledit -lkvm -ll -lm -ltermcap -lutil 74884c25d1SGordon Tetlow 75884c25d1SGordon Tetlow# Additional options for specific programs 76884c25d1SGordon TetlowCRUNCH_ALIAS_test= [ 77884c25d1SGordon TetlowCRUNCH_ALIAS_sh= -sh 78884c25d1SGordon Tetlow# The -sh alias shouldn't appear in /rescue as a hard link 79884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-sh=1 80884c25d1SGordon TetlowCRUNCH_ALIAS_ln= link 81884c25d1SGordon TetlowCRUNCH_ALIAS_rm= unlink 82884c25d1SGordon TetlowCRUNCH_ALIAS_ed= red 83884c25d1SGordon Tetlow 84884c25d1SGordon Tetlow.if !defined(NO_RCMNDS) 85884c25d1SGordon TetlowCRUNCH_PROGS+= rcp 86884c25d1SGordon Tetlow.endif 87884c25d1SGordon Tetlow 88884c25d1SGordon Tetlow.if !defined(NO_TCSH) 89884c25d1SGordon TetlowCRUNCH_PROGS+= csh 90884c25d1SGordon TetlowCRUNCH_ALIAS_csh= -csh tcsh -tcsh 91884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-csh=1 92884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-tcsh=1 93884c25d1SGordon Tetlow.endif 94884c25d1SGordon Tetlow 95884c25d1SGordon Tetlow#Is rmail of any use at all here? I think not. 96884c25d1SGordon Tetlow#CRUNCH_PROGS+= rmail 97884c25d1SGordon Tetlow 98884c25d1SGordon Tetlow################################################################### 99884c25d1SGordon Tetlow# Programs from standard /sbin 100884c25d1SGordon Tetlow# 101884c25d1SGordon Tetlow# WARNING: Changing this list may require adjusting 102884c25d1SGordon Tetlow# /usr/include/paths.h as well! You were warned! 103884c25d1SGordon Tetlow# 104884c25d1SGordon Tetlow# Note that mdmfs and shutdown have their own private 'pathnames.h' 105884c25d1SGordon Tetlow# headers in addition to the standard 'paths.h' header. 106884c25d1SGordon Tetlow# 107884c25d1SGordon TetlowCRUNCH_SRCDIRS+=$(.CURDIR)/../../sbin 1089b6e332fSGordon TetlowCRUNCH_PROGS+=atm adjkerntz atacontrol badsect bsdlabel camcontrol \ 1099b6e332fSGordon Tetlow ccdconfig clri comcontrol conscontrol devfs dmesg dump \ 1109b6e332fSGordon Tetlow dumpfs dumpon fore_dnld fsck fsck_ffs fsck_msdosfs fsdb \ 111884c25d1SGordon Tetlow fsirand gbde growfs ifconfig ilmid init ip6fw ipf ipfs ipfstat \ 112884c25d1SGordon Tetlow ipfw ipmon ipnat kldconfig kldload kldstat kldunload ldconfig \ 113884c25d1SGordon Tetlow md5 mdconfig mdmfs mknod mount mount_cd9660 mount_ext2fs \ 114a3367e4fSGordon Tetlow mount_msdosfs mount_nfs mount_ntfs mount_nullfs \ 115884c25d1SGordon Tetlow mount_std mount_udf mount_umapfs mount_unionfs natd newfs \ 116884c25d1SGordon Tetlow newfs_msdos nfsiod nos-tun ping ping6 quotacheck raidctl reboot \ 117884c25d1SGordon Tetlow restore rcorder route routed rtquery rtsol savecore shutdown \ 118884c25d1SGordon Tetlow slattach spppcontrol startslip swapon sysctl tunefs umount vinum 119884c25d1SGordon Tetlow 120884c25d1SGordon Tetlow# crunchgen does not like C++ programs; this should be fixed someday 121884c25d1SGordon Tetlow# CRUNCH_PROGS+= devd 122884c25d1SGordon Tetlow 123884c25d1SGordon TetlowCRUNCH_LIBS+=-lalias -latm -lbsdxml -lcam -lcurses -ldevstat -lipsec -lipx \ 124107e6cdaSGordon Tetlow -lgeom -lmd -lreadline -lsbuf -lufs -lz 125884c25d1SGordon Tetlow 126884c25d1SGordon Tetlow.if ${MACHINE_ARCH} == "i386" 127107e6cdaSGordon TetlowCRUNCH_PROGS+= cxconfig fdisk 1289b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel 129107e6cdaSGordon Tetlow#CRUNCH_PROGS+= mount_nwfs mount_smbfs 130107e6cdaSGordon Tetlow#CRUNCH_LIBS+= -lncp -lsmb 131884c25d1SGordon Tetlow.endif 132884c25d1SGordon Tetlow 133884c25d1SGordon Tetlow.if ${MACHINE} == "pc98" 134107e6cdaSGordon TetlowCRUNCH_SRCDIR_fdisk=$(.CURDIR)/../../sbin/fdisk_pc98 135884c25d1SGordon Tetlow.endif 136884c25d1SGordon Tetlow 137884c25d1SGordon Tetlow.if ${MACHINE_ARCH} == "ia64" 1389b6e332fSGordon TetlowCRUNCH_PROGS+= mca gpt fdisk 139884c25d1SGordon Tetlow.endif 140884c25d1SGordon Tetlow 14158824dccSGordon Tetlow.if ${MACHINE_ARCH} == "sparc64" 142107e6cdaSGordon TetlowCRUNCH_PROGS+= sunlabel 143884c25d1SGordon Tetlow.endif 144884c25d1SGordon Tetlow 145884c25d1SGordon Tetlow.if ${MACHINE_ARCH} == "alpha" 1469b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel 1479b6e332fSGordon Tetlow.endif 1489b6e332fSGordon Tetlow 1499b6e332fSGordon Tetlow.if ${MACHINE_ARCH} == "amd64" 1509b6e332fSGordon TetlowCRUNCH_PROGS+= fdisk 1519b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel 152884c25d1SGordon Tetlow.endif 153884c25d1SGordon Tetlow 154884c25d1SGordon TetlowCRUNCH_SRCDIR_atm=$(.CURDIR)/../../sbin/atm/atm 155884c25d1SGordon TetlowCRUNCH_SRCDIR_fore_dnld=$(.CURDIR)/../../sbin/atm/fore_dnld 156884c25d1SGordon TetlowCRUNCH_SRCDIR_ilmid=$(.CURDIR)/../../sbin/atm/ilmid 157884c25d1SGordon TetlowCRUNCH_SRCDIR_rtquery=$(.CURDIR)/../../sbin/routed/rtquery 158884c25d1SGordon TetlowCRUNCH_ALIAS_reboot= fastboot halt fasthalt 159884c25d1SGordon TetlowCRUNCH_ALIAS_restore=rrestore 160884c25d1SGordon TetlowCRUNCH_ALIAS_dump= rdump 161884c25d1SGordon TetlowCRUNCH_ALIAS_fsck_ffs=fsck_4.2bsd fsck_ufs 162884c25d1SGordon TetlowCRUNCH_ALIAS_mount_std= mount_devfs mount_fdescfs mount_linprocfs mount_procfs 163884c25d1SGordon Tetlow 164884c25d1SGordon Tetlow# dhclient has historically been troublesome... 165884c25d1SGordon TetlowCRUNCH_PROGS+=dhclient 166884c25d1SGordon TetlowCRUNCH_BUILDOPTS_dhclient=-DRELEASE_CRUNCH -Dlint 167884c25d1SGordon Tetlow 168884c25d1SGordon Tetlow################################################################## 169884c25d1SGordon Tetlow# Programs from stock /usr/bin 170884c25d1SGordon Tetlow# 171884c25d1SGordon TetlowCRUNCH_SRCDIRS+=$(.CURDIR)/../../usr.bin 172884c25d1SGordon TetlowCRUNCH_SRCDIRS+=$(.CURDIR)/../../gnu/usr.bin 173884c25d1SGordon Tetlow 174884c25d1SGordon TetlowCRUNCH_PROGS+=wall 175884c25d1SGordon Tetlow 176884c25d1SGordon TetlowCRUNCH_PROGS+=gzip 177884c25d1SGordon TetlowCRUNCH_ALIAS_gzip=gunzip gzcat zcat 178884c25d1SGordon Tetlow 179884c25d1SGordon TetlowCRUNCH_PROGS+=bzip2 180884c25d1SGordon TetlowCRUNCH_ALIAS_bzip2=bunzip2 bzcat 181884c25d1SGordon TetlowCRUNCH_LIBS+=-lbz2 182884c25d1SGordon Tetlow 183884c25d1SGordon TetlowCRUNCH_PROGS+=tar 184884c25d1SGordon TetlowCRUNCH_PROGS+=vi 185884c25d1SGordon TetlowCRUNCH_ALIAS_vi=ex 186884c25d1SGordon Tetlow 187884c25d1SGordon Tetlow################################################################## 188884c25d1SGordon Tetlow# The following is pretty nearly a generic crunchgen-handling makefile 189884c25d1SGordon Tetlow# 190884c25d1SGordon Tetlow 191884c25d1SGordon TetlowCONF= $(PROG).conf 192884c25d1SGordon TetlowOUTMK= $(PROG).mk 193884c25d1SGordon TetlowOUTC= $(PROG).c 194884c25d1SGordon TetlowOUTPUTS= $(OUTMK) $(OUTC) $(PROG).cache 195884c25d1SGordon TetlowCRUNCHOBJS= ${.OBJDIR} 196884c25d1SGordon Tetlow.if defined(MAKEOBJDIRPREFIX) 197884c25d1SGordon TetlowCANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 198884c25d1SGordon Tetlow.else 199884c25d1SGordon TetlowCANONICALOBJDIR:=/usr/obj${.CURDIR} 200884c25d1SGordon Tetlow.endif 201884c25d1SGordon Tetlow 202884c25d1SGordon TetlowNOMAN= true 203884c25d1SGordon TetlowCLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h 204884c25d1SGordon Tetlow 205884c25d1SGordon Tetlow# Program names and their aliases contribute hardlinks to 'rescue' executable, 206884c25d1SGordon Tetlow# except for those that get suppressed. 207884c25d1SGordon Tetlow.for P in $(CRUNCH_PROGS) 208884c25d1SGordon Tetlow.ifndef CRUNCH_SUPPRESS_LINK_${P} 209884c25d1SGordon TetlowLINKS += $(BINDIR)/$(PROG) $(BINDIR)/$(P) 210884c25d1SGordon Tetlow.endif 211884c25d1SGordon Tetlow.for A in $(CRUNCH_ALIAS_$(P)) 212884c25d1SGordon Tetlow.ifndef CRUNCH_SUPPRESS_LINK_${A} 213884c25d1SGordon TetlowLINKS += $(BINDIR)/$(PROG) $(BINDIR)/$(A) 214884c25d1SGordon Tetlow.endif 215884c25d1SGordon Tetlow.endfor 216884c25d1SGordon Tetlow.endfor 217884c25d1SGordon Tetlow 218884c25d1SGordon Tetlowall: $(PROG) 219884c25d1SGordon Tetlowexe: $(PROG) 220884c25d1SGordon Tetlow 221884c25d1SGordon Tetlow$(CONF): Makefile 222884c25d1SGordon Tetlow echo \# Auto-generated, do not edit >$(.TARGET) 223884c25d1SGordon Tetlow.for D in $(CRUNCH_SRCDIRS) 224884c25d1SGordon Tetlow echo srcdirs $(D) >>$(.TARGET) 225884c25d1SGordon Tetlow.endfor 226884c25d1SGordon Tetlow.ifdef CRUNCH_BUILDOPTS 227884c25d1SGordon Tetlow echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) 228884c25d1SGordon Tetlow.endif 229884c25d1SGordon Tetlow.ifdef CRUNCH_LIBS 230884c25d1SGordon Tetlow echo libs $(CRUNCH_LIBS) >>$(.TARGET) 231884c25d1SGordon Tetlow.endif 232884c25d1SGordon Tetlow.for P in $(CRUNCH_PROGS) 233884c25d1SGordon Tetlow echo progs $(P) >>$(.TARGET) 234884c25d1SGordon Tetlow.ifdef CRUNCH_SRCDIR_${P} 235884c25d1SGordon Tetlow echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET) 236884c25d1SGordon Tetlow.endif 237884c25d1SGordon Tetlow.ifdef CRUNCH_BUILDOPTS_${P} 238884c25d1SGordon Tetlow echo special $(P) buildopts $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET) 239884c25d1SGordon Tetlow.endif 240884c25d1SGordon Tetlow.for A in $(CRUNCH_ALIAS_$(P)) 241884c25d1SGordon Tetlow echo ln $(P) $(A) >>$(.TARGET) 242884c25d1SGordon Tetlow.endfor 243884c25d1SGordon Tetlow.endfor 244884c25d1SGordon Tetlow 245884c25d1SGordon Tetlow 246884c25d1SGordon Tetlow$(OUTPUTS): $(CONF) 247884c25d1SGordon Tetlow MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -q -m $(OUTMK) -c $(OUTC) $(CONF) 248884c25d1SGordon Tetlow 249884c25d1SGordon Tetlow$(PROG): $(OUTPUTS) 250884c25d1SGordon Tetlow MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) 251884c25d1SGordon Tetlow 252884c25d1SGordon Tetlowobjs: 253884c25d1SGordon Tetlow MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) objs 254884c25d1SGordon Tetlow 2554d938af0SGordon Tetlow# <sigh> Someone should replace the bin/csh and bin/sh build-tools with 2564d938af0SGordon Tetlow# shell scripts so we can remove this nonsense. 2574d938af0SGordon Tetlowbuild-tools: 2584d938af0SGordon Tetlow.for _tool in bin/csh bin/sh 2594d938af0SGordon Tetlow cd ${.CURDIR}/../../${_tool}; \ 2604d938af0SGordon Tetlow MAKEOBJDIRPREFIX=${CRUNCHOBJS} make DIRPRFX=rescue/${_tool} build-tools 2614d938af0SGordon Tetlow.endfor 2624d938af0SGordon Tetlow 263884c25d1SGordon Tetlow# Use a separate build tree to hold files compiled for this crunchgen binary 264884c25d1SGordon Tetlow# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't 265884c25d1SGordon Tetlow# get that to cooperate with bsd.prog.mk. Besides, many of the standard 266884c25d1SGordon Tetlow# targets should NOT be propagated into the components. 267884c25d1SGordon Tetlowcleandepend cleandir obj objlink: 268884c25d1SGordon Tetlow.for D in $(CRUNCH_SRCDIRS) 269884c25d1SGordon Tetlow cd ${D} && MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 270884c25d1SGordon Tetlow.endfor 271884c25d1SGordon Tetlow 272884c25d1SGordon Tetlowclean: 273884c25d1SGordon Tetlow rm -f ${CLEANFILES} 274884c25d1SGordon Tetlow if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ 275884c25d1SGordon Tetlow MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) clean; \ 276884c25d1SGordon Tetlow fi 277884c25d1SGordon Tetlow.for D in $(CRUNCH_SRCDIRS) $(EXTRA_SRCDIRS) 278884c25d1SGordon Tetlow cd ${D} && MAKEOBJDIRPREFIX=${CRUNCHOBJS} make clean 279884c25d1SGordon Tetlow.endfor 280884c25d1SGordon Tetlow 281884c25d1SGordon Tetlow.include <bsd.prog.mk> 282