Makefile revision 188895
1117035Sgordon#$FreeBSD: head/rescue/rescue/Makefile 188895 2009-02-21 15:04:31Z ru $ 2117035Sgordon# @(#)Makefile 8.1 (Berkeley) 6/2/93 3117035Sgordon 4156813SruNO_MAN= 5156813Sru 6156813Sru.include <bsd.own.mk> 7188895SruMK_SSP= no 8156813Sru 9117035SgordonPROG= rescue 10117692SobrienBINDIR?=/rescue 11117035Sgordon 12117035Sgordon# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh 13117035SgordonSCRIPTS= nextboot_FIXED 14153455SjhbSCRIPTSNAME_nextboot_FIXED= nextboot 15117035Sgordonnextboot_FIXED: ../../sbin/reboot/nextboot.sh 16117035Sgordon sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 17117035SgordonCLEANFILES+= nextboot_FIXED 18117035Sgordon 19147090SbrooksSCRIPTS+= dhclient_FIXED 20147090SbrooksSCRIPTSNAME_dhclient_FIXED= dhclient-script 21147090Sbrooksdhclient_FIXED: ../../sbin/dhclient/dhclient-script 22147090Sbrooks sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 23147090SbrooksCLEANFILES+= dhclient_FIXED 24117035Sgordon 25117035Sgordon################################################################# 26117035Sgordon# 27117035Sgordon# General notes: 28117035Sgordon# 29117035Sgordon# A number of Make variables are used to generate the crunchgen config file. 30117035Sgordon# 31117035Sgordon# CRUNCH_SRCDIRS: lists directories to search for included programs 32117035Sgordon# CRUNCH_PROGS: lists programs to be included 33117035Sgordon# CRUNCH_LIBS: libraries to link with 34117035Sgordon# CRUNCH_BUILDOPTS: generic build options to be added to every program 35117035Sgordon# 36117035Sgordon# Special options can be specified for individual programs 37117035Sgordon# CRUNCH_SRCDIR_$(P): base source directory for program $(P) 38117035Sgordon# CRUNCH_BUILDOPTS_$(P): additional build options for $(P) 39117035Sgordon# CRUNCH_ALIAS_$(P): additional names to be used for $(P) 40117035Sgordon# 41117035Sgordon# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P} 42117035Sgordon# will be used to generate a hard link to the resulting binary. 43117035Sgordon# Specific links can be suppressed by setting 44117035Sgordon# CRUNCH_SUPPRESS_LINK_$(NAME) to 1. 45117035Sgordon# 46117035Sgordon 47117035Sgordon# Define Makefile variable RESCUE 48117035SgordonCRUNCH_BUILDOPTS+= -DRESCUE 49117035Sgordon# Define compile-time RESCUE symbol when compiling components 50117035SgordonCRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE 51117035Sgordon 52117449Sgordon# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk 53117449Sgordon# rather than incorporating rescue-specific logic into standard files. 54117035Sgordon#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS} 55117035Sgordon 56117035Sgordon# Hackery: 'librescue' exists merely as a tool for appropriately 57117035Sgordon# recompiling specific library entries. We _know_ they're needed, and 58117035Sgordon# regular archive searching creates ugly library ordering problems. 59117035Sgordon# Easiest fix: tell the linker to include them into the executable 60117035Sgordon# first, so they are guaranteed to override the regular lib entries. 61117035Sgordon# Note that if 'librescue' hasn't been compiled, we'll just get the 62117035Sgordon# regular lib entries from libc and friends. 63117035SgordonCRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o 64117035Sgordon 65117035Sgordon################################################################### 66117035Sgordon# Programs from stock /bin 67117035Sgordon# 68117035Sgordon# WARNING: Changing this list may require adjusting 69117035Sgordon# /usr/include/paths.h as well! You were warned! 70117035Sgordon# 71117692SobrienCRUNCH_SRCDIRS+= bin 72117791SobrienCRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \ 73182543Syar ed expr getfacl hostname kenv kill ln ls mkdir mv \ 74183007Simp pkill ps pwd realpath rm rmdir setfacl sh stty sync test 75117711SobrienCRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil 76156813Sru.if ${MK_OPENSSL} != "no" 77117711SobrienCRUNCH_LIBS+= -lcrypto 78117711Sobrien.endif 79117035Sgordon 80117035Sgordon# Additional options for specific programs 81117035SgordonCRUNCH_ALIAS_test= [ 82117035SgordonCRUNCH_ALIAS_sh= -sh 83117035Sgordon# The -sh alias shouldn't appear in /rescue as a hard link 84117692SobrienCRUNCH_SUPPRESS_LINK_-sh= 1 85117035SgordonCRUNCH_ALIAS_ln= link 86117035SgordonCRUNCH_ALIAS_rm= unlink 87117035SgordonCRUNCH_ALIAS_ed= red 88173073SyarCRUNCH_ALIAS_pkill= pgrep 89173073Syar 90156813Sru.if ${MK_RCMDS} != "no" 91117601SgordonCRUNCH_PROGS_bin+= rcp 92117035Sgordon.endif 93117035Sgordon 94156813Sru.if ${MK_TCSH} != "no" 95117601SgordonCRUNCH_PROGS_bin+= csh 96117035SgordonCRUNCH_ALIAS_csh= -csh tcsh -tcsh 97117692SobrienCRUNCH_SUPPRESS_LINK_-csh= 1 98117692SobrienCRUNCH_SUPPRESS_LINK_-tcsh= 1 99117035Sgordon.endif 100117035Sgordon 101117035Sgordon################################################################### 102117035Sgordon# Programs from standard /sbin 103117035Sgordon# 104117035Sgordon# WARNING: Changing this list may require adjusting 105117035Sgordon# /usr/include/paths.h as well! You were warned! 106117035Sgordon# 107117791Sobrien# Note that mdmfs have their own private 'pathnames.h' 108117035Sgordon# headers in addition to the standard 'paths.h' header. 109117035Sgordon# 110117692SobrienCRUNCH_SRCDIRS+= sbin 111183007SimpCRUNCH_PROGS_sbin= atacontrol badsect \ 112183007Simp camcontrol ccdconfig clri devfs dmesg dump \ 113133799Smarius dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb \ 114173314Smarcel fsirand gbde geom ifconfig init \ 115183007Simp kldconfig kldload kldstat kldunload ldconfig \ 116183007Simp md5 mdconfig mdmfs mknod mount mount_cd9660 \ 117183007Simp mount_msdosfs mount_nfs mount_ntfs mount_nullfs \ 118183007Simp mount_udf mount_unionfs newfs \ 119183007Simp newfs_msdos nos-tun ping reboot \ 120183007Simp restore rcorder route routed rtquery rtsol savecore \ 121119664Sphk slattach spppcontrol startslip swapon sysctl tunefs umount 122117035Sgordon 123156813Sru.if ${MK_ATM} != "no" 124171453SrwatsonCRUNCH_PROGS_sbin+= atmconfig 125119664Sphk.endif 126119664Sphk 127156813Sru.if ${MK_INET6_SUPPORT} != "no" 128119664SphkCRUNCH_PROGS_sbin+= ping6 129119664Sphk.endif 130119664Sphk 131156813Sru.if ${MK_IPFILTER} != "no" 132145630SdarrenrCRUNCH_PROGS_sbin+= ipf 133117693Sobrien.endif 134117693Sobrien 135117035Sgordon# crunchgen does not like C++ programs; this should be fixed someday 136117035Sgordon# CRUNCH_PROGS+= devd 137117035Sgordon 138157177ScognetCRUNCH_LIBS+= -lalias -lcam -lcurses -ldevstat -lipsec 139156905Sru.if ${MK_IPX} != "no" 140156905SruCRUNCH_LIBS+= -lipx 141156905Sru.endif 142157177ScognetCRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv -lmd -lreadline -lsbuf -lufs -lz 143117035Sgordon 144117035Sgordon.if ${MACHINE_ARCH} == "i386" 145173314SmarcelCRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk 146117057SgordonCRUNCH_ALIAS_bsdlabel= disklabel 147156905Sru#.if ${MK_NCP} != "no" 148156905Sru#CRUNCH_PROGS+= mount_nwfs 149156905Sru#CRUNCH_LIBS+= -lncp 150156905Sru#.endif 151156905Sru#CRUNCH_PROGS+= mount_smbfs 152156905Sru#CRUNCH_LIBS+= -lsmb 153117035Sgordon.endif 154117035Sgordon 155117035Sgordon.if ${MACHINE} == "pc98" 156173314SmarcelCRUNCH_PROGS_sbin+= bsdlabel 157117692SobrienCRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98 158117035Sgordon.endif 159117035Sgordon 160117035Sgordon.if ${MACHINE_ARCH} == "ia64" 161173314SmarcelCRUNCH_PROGS_sbin+= mca 162117035Sgordon.endif 163117035Sgordon 164117043Sgordon.if ${MACHINE_ARCH} == "sparc64" 165173314SmarcelCRUNCH_PROGS_sbin+= bsdlabel sunlabel 166117035Sgordon.endif 167117035Sgordon 168117057Sgordon.if ${MACHINE_ARCH} == "amd64" 169173314SmarcelCRUNCH_PROGS_sbin+= bsdlabel 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 183177707SruCRUNCH_ALIAS_geom= glabel gpart 184117035Sgordon 185117035Sgordon# dhclient has historically been troublesome... 186147090SbrooksCRUNCH_PROGS_sbin+= dhclient 187147090SbrooksCRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint 188117035Sgordon 189117035Sgordon################################################################## 190117035Sgordon# Programs from stock /usr/bin 191117035Sgordon# 192117692SobrienCRUNCH_SRCDIRS+= usr.bin 193117035Sgordon 194173073SyarCRUNCH_PROGS_usr.bin= head mt sed tail tee 195173073Syar 196166255SdelphijCRUNCH_PROGS_usr.bin+= gzip 197117692SobrienCRUNCH_ALIAS_gzip= gunzip gzcat zcat 198117035Sgordon 199117692SobrienCRUNCH_PROGS_usr.bin+= bzip2 200117692SobrienCRUNCH_ALIAS_bzip2= bunzip2 bzcat 201117692SobrienCRUNCH_LIBS+= -lbz2 202117035Sgordon 203138366SobrienCRUNCH_PROGS_usr.bin+= tar 204138366SobrienCRUNCH_LIBS+= -larchive 205138366Sobrien 206117692SobrienCRUNCH_PROGS_usr.bin+= vi 207117692SobrienCRUNCH_ALIAS_vi= ex 208117035Sgordon 209126874SdesCRUNCH_PROGS_usr.bin+= id 210126874SdesCRUNCH_ALIAS_id= groups whoami 211126874Sdes 212117035Sgordon################################################################## 213141478Sdes# Programs from stock /usr/sbin 214141478Sdes# 215141478SdesCRUNCH_SRCDIRS+= usr.sbin 216141478Sdes 217173073SyarCRUNCH_PROGS_usr.sbin= chroot 218141478Sdes 219173073SyarCRUNCH_PROGS_usr.sbin+= chown 220173073SyarCRUNCH_ALIAS_chown= chgrp 221173073Syar 222141478Sdes################################################################## 223117035Sgordon# The following is pretty nearly a generic crunchgen-handling makefile 224117035Sgordon# 225117035Sgordon 226117035SgordonCONF= $(PROG).conf 227117035SgordonOUTMK= $(PROG).mk 228117035SgordonOUTC= $(PROG).c 229117692SobrienOUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache 230117035SgordonCRUNCHOBJS= ${.OBJDIR} 231117035Sgordon.if defined(MAKEOBJDIRPREFIX) 232117692SobrienCANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR} 233117035Sgordon.else 234117692SobrienCANONICALOBJDIR:= /usr/obj${.CURDIR} 235117035Sgordon.endif 236117035Sgordon 237117035SgordonCLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h 238117035Sgordon 239117035Sgordon# Program names and their aliases contribute hardlinks to 'rescue' executable, 240117035Sgordon# except for those that get suppressed. 241117601Sgordon.for D in $(CRUNCH_SRCDIRS) 242117601Sgordon.for P in $(CRUNCH_PROGS_$(D)) 243139020Sru.ifdef CRUNCH_SRCDIR_${P} 244139020Sru$(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile 245139020Sru.else 246139020Sru$(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile 247139020Sru.endif 248117035Sgordon.ifndef CRUNCH_SUPPRESS_LINK_${P} 249117692SobrienLINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P) 250117035Sgordon.endif 251117035Sgordon.for A in $(CRUNCH_ALIAS_$(P)) 252117035Sgordon.ifndef CRUNCH_SUPPRESS_LINK_${A} 253117692SobrienLINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A) 254117035Sgordon.endif 255117035Sgordon.endfor 256117035Sgordon.endfor 257117601Sgordon.endfor 258117035Sgordon 259117035Sgordonall: $(PROG) 260117035Sgordonexe: $(PROG) 261117035Sgordon 262117035Sgordon$(CONF): Makefile 263117035Sgordon echo \# Auto-generated, do not edit >$(.TARGET) 264117035Sgordon.ifdef CRUNCH_BUILDOPTS 265117035Sgordon echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) 266117035Sgordon.endif 267117035Sgordon.ifdef CRUNCH_LIBS 268117035Sgordon echo libs $(CRUNCH_LIBS) >>$(.TARGET) 269117035Sgordon.endif 270117601Sgordon.for D in $(CRUNCH_SRCDIRS) 271117601Sgordon.for P in $(CRUNCH_PROGS_$(D)) 272117035Sgordon echo progs $(P) >>$(.TARGET) 273117035Sgordon.ifdef CRUNCH_SRCDIR_${P} 274117035Sgordon echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET) 275124695Skientzle.else 276124695Skientzle echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET) 277117035Sgordon.endif 278117035Sgordon.ifdef CRUNCH_BUILDOPTS_${P} 279139233Sru echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \ 280139233Sru $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET) 281139233Sru.else 282139233Sru echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET) 283117035Sgordon.endif 284117035Sgordon.for A in $(CRUNCH_ALIAS_$(P)) 285117035Sgordon echo ln $(P) $(A) >>$(.TARGET) 286117035Sgordon.endfor 287117035Sgordon.endfor 288117601Sgordon.endfor 289117035Sgordon 290140508Sru# XXX Make sure we don't pass -P to crunchgen(1). 291140508Sru.MAKEFLAGS:= ${.MAKEFLAGS:N-P} 292117956Sgordon.ORDER: $(OUTPUTS) objs 293117035Sgordon$(OUTPUTS): $(CONF) 294140508Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \ 295118299Sgordon -c $(OUTC) $(CONF) 296117035Sgordon 297117956Sgordon$(PROG): $(OUTPUTS) objs 298139234Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe 299117035Sgordon 300117956Sgordonobjs: $(OUTMK) 301123802Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs 302117035Sgordon 303117449Sgordon# <sigh> Someone should replace the bin/csh and bin/sh build-tools with 304117449Sgordon# shell scripts so we can remove this nonsense. 305117449Sgordonbuild-tools: 306117449Sgordon.for _tool in bin/csh bin/sh 307117601Sgordon cd $(.CURDIR)/../../${_tool}; \ 308143803Scperciva MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \ 309139233Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools 310117449Sgordon.endfor 311117449Sgordon 312117035Sgordon# Use a separate build tree to hold files compiled for this crunchgen binary 313117035Sgordon# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't 314117035Sgordon# get that to cooperate with bsd.prog.mk. Besides, many of the standard 315117035Sgordon# targets should NOT be propagated into the components. 316117035Sgordoncleandepend cleandir obj objlink: 317117035Sgordon.for D in $(CRUNCH_SRCDIRS) 318117601Sgordon.for P in $(CRUNCH_PROGS_$(D)) 319117601Sgordon.ifdef CRUNCH_SRCDIR_${P} 320117601Sgordon cd ${CRUNCH_SRCDIR_$(P)} && \ 321139233Sru MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 322157627Sru DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 323117601Sgordon.else 324117601Sgordon cd $(.CURDIR)/../../${D}/${P} && \ 325139233Sru MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 326157627Sru DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 327117601Sgordon.endif 328117035Sgordon.endfor 329117601Sgordon.endfor 330117035Sgordon 331117035Sgordonclean: 332117035Sgordon rm -f ${CLEANFILES} 333117692Sobrien if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ 334123802Sru MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \ 335117035Sgordon fi 336117601Sgordon.for D in $(CRUNCH_SRCDIRS) 337117601Sgordon.for P in $(CRUNCH_PROGS_$(D)) 338117601Sgordon.ifdef CRUNCH_SRCDIR_${P} 339117601Sgordon cd ${CRUNCH_SRCDIR_$(P)} && \ 340139233Sru MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 341157627Sru DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 342117601Sgordon.else 343117601Sgordon cd $(.CURDIR)/../../${D}/${P} && \ 344139233Sru MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ 345157627Sru DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} 346117601Sgordon.endif 347117035Sgordon.endfor 348117601Sgordon.endfor 349117035Sgordon 350117035Sgordon.include <bsd.prog.mk> 351