2 # @(#)Makefile 8.1 (Berkeley) 6/2/93
11 # Shell scripts need #! line to be edited from /bin/sh to /rescue/sh
12 SCRIPTS= nextboot_FIXED
13 SCRIPTSNAME_nextboot_FIXED= nextboot
14 nextboot_FIXED: ../../sbin/reboot/nextboot.sh
15 sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
16 CLEANFILES+= nextboot_FIXED
18 SCRIPTS+= dhclient_FIXED
19 SCRIPTSNAME_dhclient_FIXED= dhclient-script
20 dhclient_FIXED: ../../sbin/dhclient/dhclient-script
21 sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
22 CLEANFILES+= dhclient_FIXED
24 #################################################################
28 # A number of Make variables are used to generate the crunchgen config file.
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
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)
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.
46 # Define Makefile variable RESCUE
47 CRUNCH_BUILDOPTS+= -DRESCUE
48 # Define compile-time RESCUE symbol when compiling components
49 CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE
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}
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.
62 CRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o
64 ###################################################################
65 # Programs from stock /bin
67 # WARNING: Changing this list may require adjusting
68 # /usr/include/paths.h as well! You were warned!
71 CRUNCH_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
74 CRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil
75 .if ${MK_OPENSSL} != "no"
76 CRUNCH_LIBS+= -lcrypto
79 # Additional options for specific programs
82 # The -sh alias shouldn't appear in /rescue as a hard link
83 CRUNCH_SUPPRESS_LINK_-sh= 1
85 CRUNCH_ALIAS_rm= unlink
88 CRUNCH_PROGS_bin+= pkill
89 CRUNCH_SRCDIR_pkill= ${.CURDIR}/../../usr.bin/pkill
90 CRUNCH_ALIAS_pkill= pgrep
92 .if ${MK_RCMDS} != "no"
93 CRUNCH_PROGS_bin+= rcp
96 .if ${MK_TCSH} != "no"
97 CRUNCH_PROGS_bin+= csh
98 CRUNCH_ALIAS_csh= -csh tcsh -tcsh
99 CRUNCH_SUPPRESS_LINK_-csh= 1
100 CRUNCH_SUPPRESS_LINK_-tcsh= 1
103 ###################################################################
104 # Programs from standard /sbin
106 # WARNING: Changing this list may require adjusting
107 # /usr/include/paths.h as well! You were warned!
109 # Note that mdmfs have their own private 'pathnames.h'
110 # headers in addition to the standard 'paths.h' header.
112 CRUNCH_SRCDIRS+= sbin
113 CRUNCH_PROGS_sbin= atacontrol badsect \
114 camcontrol ccdconfig clri devfs dmesg dump \
115 dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb \
116 fsirand gbde geom ifconfig init \
117 kldconfig kldload kldstat kldunload ldconfig \
118 md5 mdconfig mdmfs mknod mount mount_cd9660 \
119 mount_msdosfs mount_nfs mount_ntfs mount_nullfs \
120 mount_udf mount_unionfs newfs \
121 newfs_msdos nos-tun ping reboot \
122 restore rcorder route routed rtquery rtsol savecore \
123 slattach spppcontrol startslip swapon sysctl tunefs umount
125 .if ${MK_ATM} != "no"
126 CRUNCH_PROGS_sbin+= atmconfig
127 # Disabled in 7.0 as netatm is not MPSAFE.
128 #CRUNCH_PROGS_sbin+= atm fore_dnld ilmid
132 .if ${MK_INET6_SUPPORT} != "no"
133 CRUNCH_PROGS_sbin+= ping6
136 .if ${MK_IPFILTER} != "no"
137 CRUNCH_PROGS_sbin+= ipf
140 # crunchgen does not like C++ programs; this should be fixed someday
141 # CRUNCH_PROGS+= devd
143 CRUNCH_LIBS+= -lalias -lcam -lcurses -ldevstat -lipsec
144 .if ${MK_IPX} != "no"
147 CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv -lmd -lreadline -lsbuf -lufs -lz
149 .if ${MACHINE_ARCH} == "i386"
150 CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk
151 CRUNCH_ALIAS_bsdlabel= disklabel
152 #.if ${MK_NCP} != "no"
153 #CRUNCH_PROGS+= mount_nwfs
156 #CRUNCH_PROGS+= mount_smbfs
160 .if ${MACHINE} == "pc98"
161 CRUNCH_PROGS_sbin+= bsdlabel
162 CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98
165 .if ${MACHINE_ARCH} == "ia64"
166 CRUNCH_PROGS_sbin+= mca
169 .if ${MACHINE_ARCH} == "sparc64"
170 CRUNCH_PROGS_sbin+= bsdlabel sunlabel
173 .if ${MACHINE_ARCH} == "amd64"
174 CRUNCH_PROGS_sbin+= bsdlabel fdisk
175 CRUNCH_ALIAS_bsdlabel= disklabel
178 CRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm
179 CRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig
180 CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld
181 CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid
182 CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery
183 CRUNCH_SRCDIR_ipf= $(.CURDIR)/../../sbin/ipf/ipf
184 CRUNCH_ALIAS_reboot= fastboot halt fasthalt
185 CRUNCH_ALIAS_restore= rrestore
186 CRUNCH_ALIAS_dump= rdump
187 CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
188 CRUNCH_ALIAS_geom= gpart
190 # dhclient has historically been troublesome...
191 CRUNCH_PROGS_sbin+= dhclient
192 CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint
194 ##################################################################
195 # Programs from stock /usr/bin
197 CRUNCH_SRCDIRS+= usr.bin
199 CRUNCH_PROGS_usr.bin= head mt sed tail tee
201 CRUNCH_PROGS_usr.bin+= gzip
202 CRUNCH_ALIAS_gzip= gunzip gzcat zcat
204 CRUNCH_PROGS_usr.bin+= bzip2
205 CRUNCH_ALIAS_bzip2= bunzip2 bzcat
208 CRUNCH_PROGS_usr.bin+= tar
209 CRUNCH_LIBS+= -larchive
211 CRUNCH_PROGS_usr.bin+= vi
214 CRUNCH_PROGS_usr.bin+= id
215 CRUNCH_ALIAS_id= groups whoami
217 ##################################################################
218 # Programs from stock /usr/sbin
220 CRUNCH_SRCDIRS+= usr.sbin
222 CRUNCH_PROGS_usr.sbin= chroot
224 CRUNCH_PROGS_usr.sbin+= chown
225 CRUNCH_ALIAS_chown= chgrp
227 ##################################################################
228 # The following is pretty nearly a generic crunchgen-handling makefile
234 OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache
235 CRUNCHOBJS= ${.OBJDIR}
236 .if defined(MAKEOBJDIRPREFIX)
237 CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR}
239 CANONICALOBJDIR:= /usr/obj${.CURDIR}
242 CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
244 # Program names and their aliases contribute hardlinks to 'rescue' executable,
245 # except for those that get suppressed.
246 .for D in $(CRUNCH_SRCDIRS)
247 .for P in $(CRUNCH_PROGS_$(D))
248 .ifdef CRUNCH_SRCDIR_${P}
249 $(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
251 $(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
253 .ifndef CRUNCH_SUPPRESS_LINK_${P}
254 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
256 .for A in $(CRUNCH_ALIAS_$(P))
257 .ifndef CRUNCH_SUPPRESS_LINK_${A}
258 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
268 echo \# Auto-generated, do not edit >$(.TARGET)
269 .ifdef CRUNCH_BUILDOPTS
270 echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
273 echo libs $(CRUNCH_LIBS) >>$(.TARGET)
275 .for D in $(CRUNCH_SRCDIRS)
276 .for P in $(CRUNCH_PROGS_$(D))
277 echo progs $(P) >>$(.TARGET)
278 .ifdef CRUNCH_SRCDIR_${P}
279 echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
281 echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
283 .ifdef CRUNCH_BUILDOPTS_${P}
284 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
285 $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
287 echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
289 .for A in $(CRUNCH_ALIAS_$(P))
290 echo ln $(P) $(A) >>$(.TARGET)
295 # XXX Make sure we don't pass -P to crunchgen(1).
296 .MAKEFLAGS:= ${.MAKEFLAGS:N-P}
297 .ORDER: $(OUTPUTS) objs
299 MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \
302 $(PROG): $(OUTPUTS) objs
303 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
306 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
308 # <sigh> Someone should replace the bin/csh and bin/sh build-tools with
309 # shell scripts so we can remove this nonsense.
311 .for _tool in bin/csh bin/sh
312 cd $(.CURDIR)/../../${_tool}; \
313 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
314 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
317 # Use a separate build tree to hold files compiled for this crunchgen binary
318 # Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
319 # get that to cooperate with bsd.prog.mk. Besides, many of the standard
320 # targets should NOT be propagated into the components.
321 cleandepend cleandir obj objlink:
322 .for D in $(CRUNCH_SRCDIRS)
323 .for P in $(CRUNCH_PROGS_$(D))
324 .ifdef CRUNCH_SRCDIR_${P}
325 cd ${CRUNCH_SRCDIR_$(P)} && \
326 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
327 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
329 cd $(.CURDIR)/../../${D}/${P} && \
330 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
331 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
338 if [ -e ${.OBJDIR}/$(OUTMK) ]; then \
339 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \
341 .for D in $(CRUNCH_SRCDIRS)
342 .for P in $(CRUNCH_PROGS_$(D))
343 .ifdef CRUNCH_SRCDIR_${P}
344 cd ${CRUNCH_SRCDIR_$(P)} && \
345 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
346 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
348 cd $(.CURDIR)/../../${D}/${P} && \
349 MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
350 DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
355 .include <bsd.prog.mk>