Makefile revision 117692
1#$FreeBSD: head/rescue/rescue/Makefile 117692 2003-07-17 16:33:18Z obrien $ 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+= bin 70CRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df domainname echo \ 71 ed 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_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 ipf ipfs ipfstat \ 109 ipfw ipmon ipnat 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# crunchgen does not like C++ programs; this should be fixed someday 118# CRUNCH_PROGS+= devd 119 120CRUNCH_LIBS+= -lalias -latm -lbsdxml -lcam -lcurses -ldevstat -lipsec -lipx \ 121 -lgeom -lmd -lreadline -lsbuf -lufs -lz 122 123.if ${MACHINE_ARCH} == "i386" 124CRUNCH_PROGS_sbin+= cxconfig fdisk 125CRUNCH_ALIAS_bsdlabel= disklabel 126#CRUNCH_PROGS+= mount_nwfs mount_smbfs 127#CRUNCH_LIBS+= -lncp -lsmb 128.endif 129 130.if ${MACHINE} == "pc98" 131CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98 132.endif 133 134.if ${MACHINE_ARCH} == "ia64" 135CRUNCH_PROGS_sbin+= mca gpt fdisk 136.endif 137 138.if ${MACHINE_ARCH} == "sparc64" 139CRUNCH_PROGS_sbin+= sunlabel 140.endif 141 142.if ${MACHINE_ARCH} == "alpha" 143CRUNCH_ALIAS_bsdlabel= disklabel 144.endif 145 146.if ${MACHINE_ARCH} == "amd64" 147CRUNCH_PROGS_sbin+= fdisk 148CRUNCH_ALIAS_bsdlabel= disklabel 149.endif 150 151CRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm 152CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld 153CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid 154CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery 155CRUNCH_ALIAS_reboot= fastboot halt fasthalt 156CRUNCH_ALIAS_restore= rrestore 157CRUNCH_ALIAS_dump= rdump 158CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs 159CRUNCH_ALIAS_mount_std= mount_devfs mount_fdescfs mount_linprocfs mount_procfs 160 161# dhclient has historically been troublesome... 162CRUNCH_PROGS_sbin+= dhclient 163CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint 164 165################################################################## 166# Programs from stock /usr/bin 167# 168CRUNCH_SRCDIRS+= usr.bin 169CRUNCH_SRCDIRS+= gnu/usr.bin 170 171CRUNCH_PROGS_usr.bin+= wall 172 173CRUNCH_PROGS_gnu/usr.bin+= gzip 174CRUNCH_ALIAS_gzip= gunzip gzcat zcat 175 176CRUNCH_PROGS_usr.bin+= bzip2 177CRUNCH_ALIAS_bzip2= bunzip2 bzcat 178CRUNCH_LIBS+= -lbz2 179 180CRUNCH_PROGS_gnu/usr.bin+= tar 181CRUNCH_PROGS_usr.bin+= vi 182CRUNCH_ALIAS_vi= ex 183 184################################################################## 185# The following is pretty nearly a generic crunchgen-handling makefile 186# 187 188CONF= $(PROG).conf 189OUTMK= $(PROG).mk 190OUTC= $(PROG).c 191OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache 192CRUNCHOBJS= ${.OBJDIR} 193.if defined(MAKEOBJDIRPREFIX) 194CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR} 195.else 196CANONICALOBJDIR:= /usr/obj${.CURDIR} 197.endif 198 199NOMAN= true 200CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h 201 202# Program names and their aliases contribute hardlinks to 'rescue' executable, 203# except for those that get suppressed. 204.for D in $(CRUNCH_SRCDIRS) 205.for P in $(CRUNCH_PROGS_$(D)) 206.ifndef CRUNCH_SUPPRESS_LINK_${P} 207LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P) 208.endif 209.for A in $(CRUNCH_ALIAS_$(P)) 210.ifndef CRUNCH_SUPPRESS_LINK_${A} 211LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A) 212.endif 213.endfor 214.endfor 215.endfor 216 217all: $(PROG) 218exe: $(PROG) 219 220$(CONF): Makefile 221 echo \# Auto-generated, do not edit >$(.TARGET) 222.for D in $(CRUNCH_SRCDIRS) 223 echo srcdirs $(.CURDIR)/../../$(D) >>$(.TARGET) 224.endfor 225.ifdef CRUNCH_BUILDOPTS 226 echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) 227.endif 228.ifdef CRUNCH_LIBS 229 echo libs $(CRUNCH_LIBS) >>$(.TARGET) 230.endif 231.for D in $(CRUNCH_SRCDIRS) 232.for P in $(CRUNCH_PROGS_$(D)) 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.endfor 245 246 247$(OUTPUTS): $(CONF) 248 MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -q -m $(OUTMK) -c $(OUTC) \ 249 $(CONF) 250 251$(PROG): $(OUTPUTS) 252 MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) 253 254objs: 255 MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) objs 256 257# <sigh> Someone should replace the bin/csh and bin/sh build-tools with 258# shell scripts so we can remove this nonsense. 259build-tools: 260.for _tool in bin/csh bin/sh 261 cd $(.CURDIR)/../../${_tool}; \ 262 MAKEOBJDIRPREFIX=${CRUNCHOBJS} make DIRPRFX=rescue/${_tool} build-tools 263.endfor 264 265# Use a separate build tree to hold files compiled for this crunchgen binary 266# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't 267# get that to cooperate with bsd.prog.mk. Besides, many of the standard 268# targets should NOT be propagated into the components. 269cleandepend cleandir obj objlink: 270.for D in $(CRUNCH_SRCDIRS) 271.for P in $(CRUNCH_PROGS_$(D)) 272.ifdef CRUNCH_SRCDIR_${P} 273 cd ${CRUNCH_SRCDIR_$(P)} && \ 274 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 275.else 276 cd $(.CURDIR)/../../${D}/${P} && \ 277 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 278.endif 279.endfor 280.endfor 281 282clean: 283 rm -f ${CLEANFILES} 284 if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ 285 MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) clean; \ 286 fi 287.for D in $(CRUNCH_SRCDIRS) 288.for P in $(CRUNCH_PROGS_$(D)) 289.ifdef CRUNCH_SRCDIR_${P} 290 cd ${CRUNCH_SRCDIR_$(P)} && \ 291 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 292.else 293 cd $(.CURDIR)/../../${D}/${P} && \ 294 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET} 295.endif 296.endfor 297.endfor 298 299.include <bsd.prog.mk> 300