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