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