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