2 # @(#)Makefile 8.1 (Berkeley) 6/2/93
12 # Shell scripts need #! line to be edited from /bin/sh to /rescue/sh
13 SCRIPTS= nextboot_FIXED
14 SCRIPTSNAME_nextboot_FIXED= nextboot
15 nextboot_FIXED: ../../sbin/reboot/nextboot.sh
16 sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
17 CLEANFILES+= nextboot_FIXED
19 SCRIPTS+= dhclient_FIXED
20 SCRIPTSNAME_dhclient_FIXED= dhclient-script
21 dhclient_FIXED: ../../sbin/dhclient/dhclient-script
22 sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
23 CLEANFILES+= dhclient_FIXED
25 #################################################################
29 # A number of Make variables are used to generate the crunchgen config file.
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
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)
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.
47 # Define Makefile variable RESCUE
48 CRUNCH_BUILDOPTS+= -DRESCUE
49 # Define compile-time RESCUE symbol when compiling components
50 CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE
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}
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.
63 CRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o
65 ###################################################################
66 # Programs from stock /bin
68 # WARNING: Changing this list may require adjusting
69 # /usr/include/paths.h as well! You were warned!
72 CRUNCH_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
75 CRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -ltermcap -lutil
77 # Additional options for specific programs
80 # The -sh alias shouldn't appear in /rescue as a hard link
81 CRUNCH_SUPPRESS_LINK_-sh= 1
83 CRUNCH_ALIAS_rm= unlink
85 CRUNCH_ALIAS_pkill= pgrep
87 .if ${MK_RCMDS} != "no"
88 CRUNCH_PROGS_bin+= rcp
91 .if ${MK_TCSH} != "no"
92 CRUNCH_PROGS_bin+= csh
93 CRUNCH_ALIAS_csh= -csh tcsh -tcsh
94 CRUNCH_SUPPRESS_LINK_-csh= 1
95 CRUNCH_SUPPRESS_LINK_-tcsh= 1
98 ###################################################################
99 # Programs from standard /sbin
101 # WARNING: Changing this list may require adjusting
102 # /usr/include/paths.h as well! You were warned!
104 # Note that mdmfs have their own private 'pathnames.h'
105 # headers in addition to the standard 'paths.h' header.
107 CRUNCH_SRCDIRS+= sbin
108 CRUNCH_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
120 .if ${MK_ATM} != "no"
121 CRUNCH_PROGS_sbin+= atmconfig
124 .if ${MK_INET6_SUPPORT} != "no"
125 CRUNCH_PROGS_sbin+= ping6
128 .if ${MK_IPFILTER} != "no"
129 CRUNCH_PROGS_sbin+= ipf
131 .if ${MK_ZFS} != "no"
132 CRUNCH_PROGS_sbin+= zfs
133 CRUNCH_PROGS_sbin+= zpool
136 # crunchgen does not like C++ programs; this should be fixed someday
137 # CRUNCH_PROGS+= devd
139 CRUNCH_LIBS+= -lalias -lcam -lcurses -ldevstat -lipsec
140 .if ${MK_IPX} != "no"
143 .if ${MK_ZFS} != "no"
144 CRUNCH_LIBS+= -lzfs -lnvpair -luutil -lavl
146 CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lreadline -lsbuf -lufs -lz
148 .if ${MACHINE_ARCH} == "i386"
149 CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk
150 CRUNCH_ALIAS_bsdlabel= disklabel
151 #.if ${MK_NCP} != "no"
152 #CRUNCH_PROGS+= mount_nwfs
155 #CRUNCH_PROGS+= mount_smbfs
159 .if ${MACHINE} == "pc98"
160 CRUNCH_PROGS_sbin+= bsdlabel
161 CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98
164 .if ${MACHINE_ARCH} == "ia64"
165 CRUNCH_PROGS_sbin+= mca
168 .if ${MACHINE_ARCH} == "sparc64"
169 CRUNCH_PROGS_sbin+= bsdlabel sunlabel
172 .if ${MACHINE_ARCH} == "amd64"
173 CRUNCH_PROGS_sbin+= bsdlabel fdisk
174 CRUNCH_ALIAS_bsdlabel= disklabel
177 CRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm
178 CRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig
179 CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld
180 CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid
181 CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery
182 CRUNCH_SRCDIR_ipf= $(.CURDIR)/../../sbin/ipf/ipf
183 .if ${MK_ZFS} != "no"
184 CRUNCH_SRCDIR_zfs= ${.CURDIR}/../../cddl/sbin/zfs
185 CRUNCH_SRCDIR_zpool= ${.CURDIR}/../../cddl/sbin/zpool
187 CRUNCH_ALIAS_reboot= fastboot halt fasthalt
188 CRUNCH_ALIAS_restore= rrestore
189 CRUNCH_ALIAS_dump= rdump
190 CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
191 CRUNCH_ALIAS_geom= glabel gpart
193 # dhclient has historically been troublesome...
194 CRUNCH_PROGS_sbin+= dhclient
195 CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint
197 ##################################################################
198 # Programs from stock /usr/bin
200 CRUNCH_SRCDIRS+= usr.bin
202 CRUNCH_PROGS_usr.bin= head mt sed tail tee
204 CRUNCH_PROGS_usr.bin+= gzip
205 CRUNCH_ALIAS_gzip= gunzip gzcat zcat
207 CRUNCH_PROGS_usr.bin+= bzip2
208 CRUNCH_ALIAS_bzip2= bunzip2 bzcat
211 CRUNCH_PROGS_usr.bin+= tar
212 CRUNCH_LIBS+= -larchive -lmd
213 .if ${MK_OPENSSL} != "no"
214 CRUNCH_LIBS+= -lcrypto
217 CRUNCH_PROGS_usr.bin+= vi
220 CRUNCH_PROGS_usr.bin+= id
221 CRUNCH_ALIAS_id= groups whoami
223 ##################################################################
224 # Programs from stock /usr/sbin
226 CRUNCH_SRCDIRS+= usr.sbin
228 CRUNCH_PROGS_usr.sbin= chroot
230 CRUNCH_PROGS_usr.sbin+= chown
231 CRUNCH_ALIAS_chown= chgrp
232 ##################################################################
235 ##################################################################
236 # The following is pretty nearly a generic crunchgen-handling makefile
242 OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache
243 CRUNCHOBJS= ${.OBJDIR}
244 .if defined(MAKEOBJDIRPREFIX)
245 CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR}
247 CANONICALOBJDIR:= /usr/obj${.CURDIR}
250 CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
252 # Program names and their aliases contribute hardlinks to 'rescue' executable,
253 # except for those that get suppressed.
254 .for D in $(CRUNCH_SRCDIRS)
255 .for P in $(CRUNCH_PROGS_$(D))
256 .ifdef CRUNCH_SRCDIR_${P}
257 $(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
259 $(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
261 .ifndef CRUNCH_SUPPRESS_LINK_${P}
262 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
264 .for A in $(CRUNCH_ALIAS_$(P))
265 .ifndef CRUNCH_SUPPRESS_LINK_${A}
266 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
276 echo \# Auto-generated, do not edit >$(.TARGET)
277 .ifdef CRUNCH_BUILDOPTS
278 echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
281 echo libs $(CRUNCH_LIBS) >>$(.TARGET)
283 .for D in $(CRUNCH_SRCDIRS)
284 .for P in $(CRUNCH_PROGS_$(D))
285 echo progs $(P) >>$(.TARGET)
286 .ifdef CRUNCH_SRCDIR_${P}
287 echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
289 echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
291 .ifdef CRUNCH_BUILDOPTS_${P}
292 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
293 $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
295 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
297 .for A in $(CRUNCH_ALIAS_$(P))
298 echo ln $(P) $(A) >>$(.TARGET)
303 # XXX Make sure we don't pass -P to crunchgen(1).
304 .MAKEFLAGS:= ${.MAKEFLAGS:N-P}
305 .ORDER: $(OUTPUTS) objs
307 MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \
310 $(PROG): $(OUTPUTS) objs
311 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
314 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
316 # <sigh> Someone should replace the bin/csh and bin/sh build-tools with
317 # shell scripts so we can remove this nonsense.
319 .for _tool in bin/csh bin/sh
320 cd $(.CURDIR)/../../${_tool}; \
321 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
322 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
325 # Use a separate build tree to hold files compiled for this crunchgen binary
326 # Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
327 # get that to cooperate with bsd.prog.mk. Besides, many of the standard
328 # targets should NOT be propagated into the components.
329 cleandepend cleandir obj objlink:
330 .for D in $(CRUNCH_SRCDIRS)
331 .for P in $(CRUNCH_PROGS_$(D))
332 .ifdef CRUNCH_SRCDIR_${P}
333 cd ${CRUNCH_SRCDIR_$(P)} && \
334 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
335 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
337 cd $(.CURDIR)/../../${D}/${P} && \
338 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
339 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
346 if [ -e ${.OBJDIR}/$(OUTMK) ]; then \
347 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \
349 .for D in $(CRUNCH_SRCDIRS)
350 .for P in $(CRUNCH_PROGS_$(D))
351 .ifdef CRUNCH_SRCDIR_${P}
352 cd ${CRUNCH_SRCDIR_$(P)} && \
353 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
354 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
356 cd $(.CURDIR)/../../${D}/${P} && \
357 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
358 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
363 .include <bsd.prog.mk>