Makefile revision 171453
1117035Sgordon#$FreeBSD: head/rescue/rescue/Makefile 171453 2007-07-14 21:49:24Z rwatson $ 2117035Sgordon# @(#)Makefile 8.1 (Berkeley) 6/2/93 3117035Sgordon 4156813SruNO_MAN= 5156813Sru 6156813Sru.include <bsd.own.mk> 7156813Sru 8117035SgordonPROG= rescue 9117692SobrienBINDIR?=/rescue 10117035Sgordon 11117035Sgordon# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh 12117035SgordonSCRIPTS= nextboot_FIXED 13153455SjhbSCRIPTSNAME_nextboot_FIXED= nextboot 14117035Sgordonnextboot_FIXED: ../../sbin/reboot/nextboot.sh 15117035Sgordon sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 16117035SgordonCLEANFILES+= nextboot_FIXED 17117035Sgordon 18147090SbrooksSCRIPTS+= dhclient_FIXED 19147090SbrooksSCRIPTSNAME_dhclient_FIXED= dhclient-script 20147090Sbrooksdhclient_FIXED: ../../sbin/dhclient/dhclient-script 21147090Sbrooks sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 22147090SbrooksCLEANFILES+= dhclient_FIXED 23117035Sgordon 24117035Sgordon################################################################# 25117035Sgordon# 26117035Sgordon# General notes: 27117035Sgordon# 28117035Sgordon# A number of Make variables are used to generate the crunchgen config file. 29117035Sgordon# 30117035Sgordon# CRUNCH_SRCDIRS: lists directories to search for included programs 31117035Sgordon# CRUNCH_PROGS: lists programs to be included 32117035Sgordon# CRUNCH_LIBS: libraries to link with 33117035Sgordon# CRUNCH_BUILDOPTS: generic build options to be added to every program 34117035Sgordon# 35117035Sgordon# Special options can be specified for individual programs 36117035Sgordon# CRUNCH_SRCDIR_$(P): base source directory for program $(P) 37117035Sgordon# CRUNCH_BUILDOPTS_$(P): additional build options for $(P) 38117035Sgordon# CRUNCH_ALIAS_$(P): additional names to be used for $(P) 39117035Sgordon# 40117035Sgordon# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P} 41117035Sgordon# will be used to generate a hard link to the resulting binary. 42117035Sgordon# Specific links can be suppressed by setting 43117035Sgordon# CRUNCH_SUPPRESS_LINK_$(NAME) to 1. 44117035Sgordon# 45117035Sgordon 46117035Sgordon# Define Makefile variable RESCUE 47117035SgordonCRUNCH_BUILDOPTS+= -DRESCUE 48117035Sgordon# Define compile-time RESCUE symbol when compiling components 49117035SgordonCRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE 50117035Sgordon 51117449Sgordon# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk 52117449Sgordon# rather than incorporating rescue-specific logic into standard files. 53117035Sgordon#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS} 54117035Sgordon 55117035Sgordon# Hackery: 'librescue' exists merely as a tool for appropriately 56117035Sgordon# recompiling specific library entries. We _know_ they're needed, and 57117035Sgordon# regular archive searching creates ugly library ordering problems. 58117035Sgordon# Easiest fix: tell the linker to include them into the executable 59117035Sgordon# first, so they are guaranteed to override the regular lib entries. 60117035Sgordon# Note that if 'librescue' hasn't been compiled, we'll just get the 61117035Sgordon# regular lib entries from libc and friends. 62117035SgordonCRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o 63117035Sgordon 64117035Sgordon################################################################### 65117035Sgordon# Programs from stock /bin 66117035Sgordon# 67117035Sgordon# WARNING: Changing this list may require adjusting 68117035Sgordon# /usr/include/paths.h as well! You were warned! 69117035Sgordon# 70117692SobrienCRUNCH_SRCDIRS+= bin 71117791SobrienCRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \ 72117601Sgordon ed expr getfacl hostname kenv kill ln ls mkdir mv pax ps pwd \ 73117791Sobrien realpath rm rmdir setfacl sh stty sync test 74117711SobrienCRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil 75156813Sru.if ${MK_OPENSSL} != "no" 76117711SobrienCRUNCH_LIBS+= -lcrypto 77117711Sobrien.endif 78117035Sgordon 79117035Sgordon# Additional options for specific programs 80117035SgordonCRUNCH_ALIAS_test= [ 81117035SgordonCRUNCH_ALIAS_sh= -sh 82117035Sgordon# The -sh alias shouldn't appear in /rescue as a hard link 83117692SobrienCRUNCH_SUPPRESS_LINK_-sh= 1 84117035SgordonCRUNCH_ALIAS_ln= link 85117035SgordonCRUNCH_ALIAS_rm= unlink 86117035SgordonCRUNCH_ALIAS_ed= red 87117035Sgordon 88156813Sru.if ${MK_RCMDS} != "no" 89117601SgordonCRUNCH_PROGS_bin+= rcp 90117035Sgordon.endif 91117035Sgordon 92156813Sru.if ${MK_TCSH} != "no" 93117601SgordonCRUNCH_PROGS_bin+= csh 94117035SgordonCRUNCH_ALIAS_csh= -csh tcsh -tcsh 95117692SobrienCRUNCH_SUPPRESS_LINK_-csh= 1 96117692SobrienCRUNCH_SUPPRESS_LINK_-tcsh= 1 97117035Sgordon.endif 98117035Sgordon 99117035Sgordon################################################################### 100117035Sgordon# Programs from standard /sbin 101117035Sgordon# 102117035Sgordon# WARNING: Changing this list may require adjusting 103117035Sgordon# /usr/include/paths.h as well! You were warned! 104117035Sgordon# 105117791Sobrien# Note that mdmfs have their own private 'pathnames.h' 106117035Sgordon# headers in addition to the standard 'paths.h' header. 107117035Sgordon# 108117692SobrienCRUNCH_SRCDIRS+= sbin 109119664SphkCRUNCH_PROGS_sbin= atacontrol badsect bsdlabel \ 110118826Sharti camcontrol ccdconfig clri devfs dmesg dump \ 111133799Smarius dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb \ 112119664Sphk fsirand gbde ifconfig init \ 113117791Sobrien kldconfig kldload kldstat kldunload ldconfig \ 114164526Srodrigc md5 mdconfig mdmfs mknod mount mount_cd9660 \ 115117086Sgordon mount_msdosfs mount_nfs mount_ntfs mount_nullfs \ 116171023Srafan mount_udf mount_unionfs newfs \ 117127075Sphk newfs_msdos nos-tun ping reboot \ 118117791Sobrien restore rcorder route routed rtquery rtsol savecore \ 119119664Sphk slattach spppcontrol startslip swapon sysctl tunefs umount 120117035Sgordon 121156813Sru.if ${MK_ATM} != "no" 122171453SrwatsonCRUNCH_PROGS_sbin+= atmconfig 123171453Srwatson# Disabled in 7.0 as netatm is not MPSAFE. 124171453Srwatson#CRUNCH_PROGS_sbin+= atm fore_dnld ilmid 125171453Srwatson#CRUNCH_LIBS+= -latm 126119664Sphk.endif 127119664Sphk 128156813Sru.if ${MK_INET6_SUPPORT} != "no" 129119664SphkCRUNCH_PROGS_sbin+= ping6 130119664Sphk.endif 131119664Sphk 132156813Sru.if ${MK_IPFILTER} != "no" 133145630SdarrenrCRUNCH_PROGS_sbin+= ipf 134117693Sobrien.endif 135117693Sobrien 136117035Sgordon# crunchgen does not like C++ programs; this should be fixed someday 137117035Sgordon# CRUNCH_PROGS+= devd 138117035Sgordon 139157177ScognetCRUNCH_LIBS+= -lalias -lcam -lcurses -ldevstat -lipsec 140156905Sru.if ${MK_IPX} != "no" 141156905SruCRUNCH_LIBS+= -lipx 142156905Sru.endif 143157177ScognetCRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv -lmd -lreadline -lsbuf -lufs -lz 144117035Sgordon 145117035Sgordon.if ${MACHINE_ARCH} == "i386" 146123131SimpCRUNCH_PROGS_sbin+= sconfig fdisk 147117057SgordonCRUNCH_ALIAS_bsdlabel= disklabel 148156905Sru#.if ${MK_NCP} != "no" 149156905Sru#CRUNCH_PROGS+= mount_nwfs 150156905Sru#CRUNCH_LIBS+= -lncp 151156905Sru#.endif 152156905Sru#CRUNCH_PROGS+= mount_smbfs 153156905Sru#CRUNCH_LIBS+= -lsmb 154117035Sgordon.endif 155117035Sgordon 156117035Sgordon.if ${MACHINE} == "pc98" 157117692SobrienCRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98 158117035Sgordon.endif 159117035Sgordon 160117035Sgordon.if ${MACHINE_ARCH} == "ia64" 161117601SgordonCRUNCH_PROGS_sbin+= mca gpt fdisk 162117035Sgordon.endif 163117035Sgordon 164117043Sgordon.if ${MACHINE_ARCH} == "sparc64" 165117601SgordonCRUNCH_PROGS_sbin+= sunlabel 166117035Sgordon.endif 167117035Sgordon 168117057Sgordon.if ${MACHINE_ARCH} == "amd64" 169117601SgordonCRUNCH_PROGS_sbin+= fdisk 170117057SgordonCRUNCH_ALIAS_bsdlabel= disklabel 171117057Sgordon.endif 172117057Sgordon 173117692SobrienCRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm 174118826ShartiCRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig 175117692SobrienCRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld 176117692SobrienCRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid 177117692SobrienCRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery 178145630SdarrenrCRUNCH_SRCDIR_ipf= $(.CURDIR)/../../sbin/ipf/ipf 179117035SgordonCRUNCH_ALIAS_reboot= fastboot halt fasthalt 180117692SobrienCRUNCH_ALIAS_restore= rrestore 181117035SgordonCRUNCH_ALIAS_dump= rdump 182117692SobrienCRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs 183117035Sgordon 184117035Sgordon# dhclient has historically been troublesome... 185147090SbrooksCRUNCH_PROGS_sbin+= dhclient 186147090SbrooksCRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint 187117035Sgordon 188117035Sgordon################################################################## 189117035Sgordon# Programs from stock /usr/bin 190117035Sgordon# 191117692SobrienCRUNCH_SRCDIRS+= usr.bin 192117035Sgordon 193166255SdelphijCRUNCH_PROGS_usr.bin+= gzip 194117692SobrienCRUNCH_ALIAS_gzip= gunzip gzcat zcat 195117035Sgordon 196117692SobrienCRUNCH_PROGS_usr.bin+= bzip2 197117692SobrienCRUNCH_ALIAS_bzip2= bunzip2 bzcat 198117692SobrienCRUNCH_LIBS+= -lbz2 199117035Sgordon 200138366SobrienCRUNCH_PROGS_usr.bin+= tar 201138366SobrienCRUNCH_LIBS+= -larchive 202138366Sobrien 203117692SobrienCRUNCH_PROGS_usr.bin+= vi 204117692SobrienCRUNCH_ALIAS_vi= ex 205117035Sgordon 206126874SdesCRUNCH_PROGS_usr.bin+= id 207126874SdesCRUNCH_ALIAS_id= groups whoami 208126874Sdes 209117035Sgordon################################################################## 210141478Sdes# Programs from stock /usr/sbin 211141478Sdes# 212141478SdesCRUNCH_SRCDIRS+= usr.sbin 213141478Sdes 214141478SdesCRUNCH_PROGS_usr.sbin+= chroot 215141478Sdes 216141478Sdes################################################################## 217117035Sgordon# The following is pretty nearly a generic crunchgen-handling makefile 218117035Sgordon# 219117035Sgordon 220117035SgordonCONF= $(PROG).conf 221117035SgordonOUTMK= $(PROG).mk 222117035SgordonOUTC= $(PROG).c 223117692SobrienOUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache 224117035SgordonCRUNCHOBJS= ${.OBJDIR} 225117035Sgordon.if defined(MAKEOBJDIRPREFIX) 226117692SobrienCANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR} 227117035Sgordon.else 228117692SobrienCANONICALOBJDIR:= /usr/obj${.CURDIR} 229117035Sgordon.endif 230117035Sgordon 231117035SgordonCLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h 232117035Sgordon 233117035Sgordon# Program names and their aliases contribute hardlinks to 'rescue' executable, 234117035Sgordon# except for those that get suppressed. 235117601Sgordon.for D in $(CRUNCH_SRCDIRS) 236117601Sgordon.for P in $(CRUNCH_PROGS_$(D)) 237139020Sru.ifdef CRUNCH_SRCDIR_${P} 238139020Sru$(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile 239139020Sru.else 240139020Sru$(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile 241139020Sru.endif 242117035Sgordon.ifndef CRUNCH_SUPPRESS_LINK_${P} 243117692SobrienLINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P) 244117035Sgordon.endif 245117035Sgordon.for A in $(CRUNCH_ALIAS_$(P)) 246117035Sgordon.ifndef CRUNCH_SUPPRESS_LINK_${A} 247117692SobrienLINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A) 248117035Sgordon.endif 249117035Sgordon.endfor 250117035Sgordon.endfor 251117601Sgordon.endfor 252117035Sgordon 253117035Sgordonall: $(PROG) 254117035Sgordonexe: $(PROG) 255117035Sgordon 256117035Sgordon$(CONF): Makefile 257117035Sgordon echo \# Auto-generated, do not edit >$(.TARGET) 258117035Sgordon.ifdef CRUNCH_BUILDOPTS 259117035Sgordon echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) 260117035Sgordon.endif 261117035Sgordon.ifdef CRUNCH_LIBS 262117035Sgordon echo libs $(CRUNCH_LIBS) >>$(.TARGET) 263117035Sgordon.endif 264117601Sgordon.for D in $(CRUNCH_SRCDIRS) 265117601Sgordon.for P in $(CRUNCH_PROGS_$(D)) 266117035Sgordon echo progs $(P) >>$(.TARGET) 267117035Sgordon.ifdef CRUNCH_SRCDIR_${P} 268117035Sgordon echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET) 269124695Skientzle.else 270124695Skientzle echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET) 271117035Sgordon.endif 272117035Sgordon.ifdef CRUNCH_BUILDOPTS_${P} 273139233Sru echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \ 274139233Sru $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET) 275139233Sru.else 276139233Sru echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET) 277117035Sgordon.endif 278117035Sgordon.for A in $(CRUNCH_ALIAS_$(P)) 279117035Sgordon echo ln $(P) $(A) >>$(.TARGET) 280117035Sgordon.endfor 281117035Sgordon.endfor 282117601Sgordon.endfor 283117035Sgordon 284140508Sru# XXX Make sure we don't pass -P to crunchgen(1). 285140508Sru.MAKEFLAGS:= ${.MAKEFLAGS:N-P} 286117956Sgordon.ORDER: $(OUTPUTS) objs 287117035Sgordon$(OUTPUTS): $(CONF) 288140508Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \ 289118299Sgordon -c $(OUTC) $(CONF) 290117035Sgordon 291117956Sgordon$(PROG): $(OUTPUTS) objs 292139234Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe 293117035Sgordon 294117956Sgordonobjs: $(OUTMK) 295123802Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs 296117035Sgordon 297117449Sgordon# <sigh> Someone should replace the bin/csh and bin/sh build-tools with 298117449Sgordon# shell scripts so we can remove this nonsense. 299117449Sgordonbuild-tools: 300117449Sgordon.for _tool in bin/csh bin/sh 301117601Sgordon cd $(.CURDIR)/../../${_tool}; \ 302143803Scperciva MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \ 303139233Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools 304117449Sgordon.endfor 305117449Sgordon 306117035Sgordon# Use a separate build tree to hold files compiled for this crunchgen binary 307117035Sgordon# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't 308117035Sgordon# get that to cooperate with bsd.prog.mk. Besides, many of the standard 309117035Sgordon# targets should NOT be propagated into the components. 310117035Sgordoncleandepend cleandir obj objlink: 311117035Sgordon.for D in $(CRUNCH_SRCDIRS) 312117601Sgordon.for P in $(CRUNCH_PROGS_$(D)) 313117601Sgordon.ifdef CRUNCH_SRCDIR_${P} 314117601Sgordon cd ${CRUNCH_SRCDIR_$(P)} && \ 315139233Sru MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 316157627Sru DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 317117601Sgordon.else 318117601Sgordon cd $(.CURDIR)/../../${D}/${P} && \ 319139233Sru MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 320157627Sru DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 321117601Sgordon.endif 322117035Sgordon.endfor 323117601Sgordon.endfor 324117035Sgordon 325117035Sgordonclean: 326117035Sgordon rm -f ${CLEANFILES} 327117692Sobrien if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ 328123802Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \ 329117035Sgordon fi 330117601Sgordon.for D in $(CRUNCH_SRCDIRS) 331117601Sgordon.for P in $(CRUNCH_PROGS_$(D)) 332117601Sgordon.ifdef CRUNCH_SRCDIR_${P} 333117601Sgordon cd ${CRUNCH_SRCDIR_$(P)} && \ 334139233Sru MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 335157627Sru DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 336117601Sgordon.else 337117601Sgordon cd $(.CURDIR)/../../${D}/${P} && \ 338139233Sru MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 339157627Sru DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 340117601Sgordon.endif 341117035Sgordon.endfor 342117601Sgordon.endfor 343117035Sgordon 344117035Sgordon.include <bsd.prog.mk> 345