Makefile revision 141478
1#$FreeBSD: head/rescue/rescue/Makefile 141478 2005-02-07 21:19:18Z des $ 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 echo \ 68 ed expr getfacl hostname kenv kill ln ls mkdir mv pax ps pwd \ 69 realpath rm rmdir setfacl sh stty sync test 70CRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil 71.if !defined(NO_CRYPT) && !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 have their own private 'pathnames.h' 102# headers in addition to the standard 'paths.h' header. 103# 104CRUNCH_SRCDIRS+= sbin 105CRUNCH_PROGS_sbin= atacontrol badsect bsdlabel \ 106 camcontrol ccdconfig clri devfs dmesg dump \ 107 dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb \ 108 fsirand gbde ifconfig init \ 109 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 newfs \ 113 newfs_msdos nos-tun ping reboot \ 114 restore rcorder route routed rtquery rtsol savecore \ 115 slattach spppcontrol startslip swapon sysctl tunefs umount 116 117.if !defined(NO_ATM) 118CRUNCH_PROGS_sbin+= atm atmconfig fore_dnld ilmid 119CRUNCH_LIBS+= -latm 120.endif 121 122.if !defined(NO_INET6) 123CRUNCH_PROGS_sbin+= ping6 124.endif 125 126.if !defined(NO_IPFILTER) 127CRUNCH_PROGS_sbin+= ipf ipfs ipfstat ipmon ipnat 128.endif 129 130# crunchgen does not like C++ programs; this should be fixed someday 131# CRUNCH_PROGS+= devd 132 133CRUNCH_LIBS+= -lalias -lbsdxml -lcam -lcurses -ldevstat -lipsec -lipx \ 134 -lgeom -lkiconv -lmd -lreadline -lsbuf -lufs -lz 135 136.if ${MACHINE_ARCH} == "i386" 137CRUNCH_PROGS_sbin+= sconfig fdisk 138CRUNCH_ALIAS_bsdlabel= disklabel 139#CRUNCH_PROGS+= mount_nwfs mount_smbfs 140#CRUNCH_LIBS+= -lncp -lsmb 141.endif 142 143.if ${MACHINE} == "pc98" 144CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98 145.endif 146 147.if ${MACHINE_ARCH} == "ia64" 148CRUNCH_PROGS_sbin+= mca gpt fdisk 149.endif 150 151.if ${MACHINE_ARCH} == "sparc64" 152CRUNCH_PROGS_sbin+= sunlabel 153.endif 154 155.if ${MACHINE_ARCH} == "alpha" 156CRUNCH_ALIAS_bsdlabel= disklabel 157.endif 158 159.if ${MACHINE_ARCH} == "amd64" 160CRUNCH_PROGS_sbin+= fdisk 161CRUNCH_ALIAS_bsdlabel= disklabel 162.endif 163 164CRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm 165CRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig 166CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld 167CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid 168CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery 169CRUNCH_ALIAS_reboot= fastboot halt fasthalt 170CRUNCH_ALIAS_restore= rrestore 171CRUNCH_ALIAS_dump= rdump 172CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs 173CRUNCH_ALIAS_mount_std= mount_devfs mount_fdescfs mount_linprocfs mount_procfs 174 175# dhclient has historically been troublesome... 176CRUNCH_PROGS_sbin+= dhclient 177CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint 178 179################################################################## 180# Programs from stock /usr/bin 181# 182CRUNCH_SRCDIRS+= usr.bin 183CRUNCH_SRCDIRS+= gnu/usr.bin 184 185CRUNCH_PROGS_gnu/usr.bin+= gzip 186CRUNCH_ALIAS_gzip= gunzip gzcat zcat 187 188CRUNCH_PROGS_usr.bin+= bzip2 189CRUNCH_ALIAS_bzip2= bunzip2 bzcat 190CRUNCH_LIBS+= -lbz2 191 192CRUNCH_PROGS_usr.bin+= tar 193CRUNCH_LIBS+= -larchive 194 195CRUNCH_PROGS_usr.bin+= vi 196CRUNCH_ALIAS_vi= ex 197 198CRUNCH_PROGS_usr.bin+= id 199CRUNCH_ALIAS_id= groups whoami 200 201################################################################## 202# Programs from stock /usr/sbin 203# 204CRUNCH_SRCDIRS+= usr.sbin 205 206CRUNCH_PROGS_usr.sbin+= chroot 207 208################################################################## 209# The following is pretty nearly a generic crunchgen-handling makefile 210# 211 212CONF= $(PROG).conf 213OUTMK= $(PROG).mk 214OUTC= $(PROG).c 215OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache 216CRUNCHOBJS= ${.OBJDIR} 217.if defined(MAKEOBJDIRPREFIX) 218CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR} 219.else 220CANONICALOBJDIR:= /usr/obj${.CURDIR} 221.endif 222 223NO_MAN= 224CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h 225 226# Program names and their aliases contribute hardlinks to 'rescue' executable, 227# except for those that get suppressed. 228.for D in $(CRUNCH_SRCDIRS) 229.for P in $(CRUNCH_PROGS_$(D)) 230.ifdef CRUNCH_SRCDIR_${P} 231$(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile 232.else 233$(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile 234.endif 235.ifndef CRUNCH_SUPPRESS_LINK_${P} 236LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P) 237.endif 238.for A in $(CRUNCH_ALIAS_$(P)) 239.ifndef CRUNCH_SUPPRESS_LINK_${A} 240LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A) 241.endif 242.endfor 243.endfor 244.endfor 245 246all: $(PROG) 247exe: $(PROG) 248 249$(CONF): Makefile 250 echo \# Auto-generated, do not edit >$(.TARGET) 251.ifdef CRUNCH_BUILDOPTS 252 echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) 253.endif 254.ifdef CRUNCH_LIBS 255 echo libs $(CRUNCH_LIBS) >>$(.TARGET) 256.endif 257.for D in $(CRUNCH_SRCDIRS) 258.for P in $(CRUNCH_PROGS_$(D)) 259 echo progs $(P) >>$(.TARGET) 260.ifdef CRUNCH_SRCDIR_${P} 261 echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET) 262.else 263 echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET) 264.endif 265.ifdef CRUNCH_BUILDOPTS_${P} 266 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \ 267 $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET) 268.else 269 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET) 270.endif 271.for A in $(CRUNCH_ALIAS_$(P)) 272 echo ln $(P) $(A) >>$(.TARGET) 273.endfor 274.endfor 275.endfor 276 277# XXX Make sure we don't pass -P to crunchgen(1). 278.MAKEFLAGS:= ${.MAKEFLAGS:N-P} 279.ORDER: $(OUTPUTS) objs 280$(OUTPUTS): $(CONF) 281 MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \ 282 -c $(OUTC) $(CONF) 283 284$(PROG): $(OUTPUTS) objs 285 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe 286 287objs: $(OUTMK) 288 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs 289 290# <sigh> Someone should replace the bin/csh and bin/sh build-tools with 291# shell scripts so we can remove this nonsense. 292build-tools: 293.for _tool in bin/csh bin/sh 294 cd $(.CURDIR)/../../${_tool}; \ 295 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools 296.endfor 297 298# Use a separate build tree to hold files compiled for this crunchgen binary 299# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't 300# get that to cooperate with bsd.prog.mk. Besides, many of the standard 301# targets should NOT be propagated into the components. 302cleandepend cleandir obj objlink: 303.for D in $(CRUNCH_SRCDIRS) 304.for P in $(CRUNCH_PROGS_$(D)) 305.ifdef CRUNCH_SRCDIR_${P} 306 cd ${CRUNCH_SRCDIR_$(P)} && \ 307 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 308 DIRPRFX=${DIRPRFX}${P}/ ${.TARGET} 309.else 310 cd $(.CURDIR)/../../${D}/${P} && \ 311 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 312 DIRPRFX=${DIRPRFX}${P}/ ${.TARGET} 313.endif 314.endfor 315.endfor 316 317clean: 318 rm -f ${CLEANFILES} 319 if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ 320 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \ 321 fi 322.for D in $(CRUNCH_SRCDIRS) 323.for P in $(CRUNCH_PROGS_$(D)) 324.ifdef CRUNCH_SRCDIR_${P} 325 cd ${CRUNCH_SRCDIR_$(P)} && \ 326 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 327 DIRPRFX=${DIRPRFX}${P}/ ${.TARGET} 328.else 329 cd $(.CURDIR)/../../${D}/${P} && \ 330 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 331 DIRPRFX=${DIRPRFX}${P}/ ${.TARGET} 332.endif 333.endfor 334.endfor 335 336.include <bsd.prog.mk> 337