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