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