]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - rescue/rescue/Makefile
MFC r362623:
[FreeBSD/stable/8.git] / rescue / rescue / Makefile
1 #$FreeBSD$
2 #       @(#)Makefile    8.1 (Berkeley) 6/2/93
3
4 NO_MAN=
5
6 .include <bsd.own.mk>
7 MK_SSP= no
8
9 PROG=   rescue
10 BINDIR?=/rescue
11
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
18
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
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
48 CRUNCH_BUILDOPTS+= -DRESCUE
49 # Define compile-time RESCUE symbol when compiling components
50 CRUNCH_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.
63 CRUNCH_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 #
71 CRUNCH_SRCDIRS+= bin
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
76
77 # Additional options for specific programs
78 CRUNCH_ALIAS_test= [
79 CRUNCH_ALIAS_sh= -sh
80 # The -sh alias shouldn't appear in /rescue as a hard link
81 CRUNCH_SUPPRESS_LINK_-sh= 1
82 CRUNCH_ALIAS_ln= link
83 CRUNCH_ALIAS_rm= unlink
84 CRUNCH_ALIAS_ed= red
85 CRUNCH_ALIAS_pkill= pgrep
86
87 .if ${MK_RCMDS} != "no"
88 CRUNCH_PROGS_bin+= rcp
89 .endif
90
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
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 #
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
119
120 .if ${MK_ATM} != "no"
121 CRUNCH_PROGS_sbin+= atmconfig
122 .endif
123
124 .if ${MK_INET6_SUPPORT} != "no"
125 CRUNCH_PROGS_sbin+= ping6
126 .endif
127
128 .if ${MK_IPFILTER} != "no"
129 CRUNCH_PROGS_sbin+= ipf
130 .endif
131 .if ${MK_ZFS} != "no"
132 CRUNCH_PROGS_sbin+= zfs
133 CRUNCH_PROGS_sbin+= zpool
134 .endif
135
136 # crunchgen does not like C++ programs; this should be fixed someday
137 # CRUNCH_PROGS+= devd
138
139 CRUNCH_LIBS+= -lalias -lcam -lcurses -ldevstat -lipsec
140 .if ${MK_IPX} != "no"
141 CRUNCH_LIBS+= -lipx
142 .endif
143 .if ${MK_ZFS} != "no"
144 CRUNCH_LIBS+= -lavl -ljail -lzfs_core -lzfs -lnvpair -lpthread -luutil -lumem
145 .endif
146 CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lreadline -lsbuf -lufs -lz
147
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
153 #CRUNCH_LIBS+= -lncp
154 #.endif
155 #CRUNCH_PROGS+= mount_smbfs
156 #CRUNCH_LIBS+= -lsmb
157 .endif
158
159 .if ${MACHINE} == "pc98"
160 CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98
161 .endif
162
163 .if ${MACHINE_ARCH} == "ia64"
164 CRUNCH_PROGS_sbin+= mca
165 .endif
166
167 .if ${MACHINE_ARCH} == "sparc64"
168 CRUNCH_PROGS_sbin+= bsdlabel sunlabel
169 .endif
170
171 .if ${MACHINE_ARCH} == "amd64"
172 CRUNCH_PROGS_sbin+= bsdlabel fdisk
173 CRUNCH_ALIAS_bsdlabel= disklabel
174 .endif
175
176 CRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm
177 CRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig
178 CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld
179 CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid
180 CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery
181 CRUNCH_SRCDIR_ipf= $(.CURDIR)/../../sbin/ipf/ipf
182 .if ${MK_ZFS} != "no"
183 CRUNCH_SRCDIR_zfs= ${.CURDIR}/../../cddl/sbin/zfs
184 CRUNCH_SRCDIR_zpool= ${.CURDIR}/../../cddl/sbin/zpool
185 .endif
186 CRUNCH_ALIAS_reboot= fastboot halt fasthalt
187 CRUNCH_ALIAS_restore= rrestore
188 CRUNCH_ALIAS_dump= rdump
189 CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
190 CRUNCH_ALIAS_geom= glabel gpart
191
192 # dhclient has historically been troublesome...
193 CRUNCH_PROGS_sbin+= dhclient
194 CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint
195
196 ##################################################################
197 # Programs from stock /usr/bin
198 #
199 CRUNCH_SRCDIRS+= usr.bin
200
201 CRUNCH_PROGS_usr.bin= head mt nc sed tail tee
202
203 CRUNCH_PROGS_usr.bin+= gzip
204 CRUNCH_ALIAS_gzip= gunzip gzcat zcat
205
206 CRUNCH_PROGS_usr.bin+= bzip2
207 CRUNCH_ALIAS_bzip2= bunzip2 bzcat
208 CRUNCH_LIBS+= -lbz2
209
210 CRUNCH_PROGS_usr.bin+= xz
211 CRUNCH_ALIAS_xz= unxz lzma unlzma xzcat lzcat
212 CRUNCH_LIBS+= -llzma
213
214 CRUNCH_PROGS_usr.bin+= tar
215 CRUNCH_LIBS+= -larchive -lmd
216 .if ${MK_OPENSSL} != "no"
217 CRUNCH_LIBS+= -lcrypto
218 .endif
219
220 CRUNCH_PROGS_usr.bin+= vi
221 CRUNCH_ALIAS_vi= ex
222
223 CRUNCH_PROGS_usr.bin+= id
224 CRUNCH_ALIAS_id= groups whoami
225
226 ##################################################################
227 # Programs from stock /usr/sbin
228 #
229 CRUNCH_SRCDIRS+= usr.sbin
230
231 CRUNCH_PROGS_usr.sbin= chroot
232
233 CRUNCH_PROGS_usr.sbin+= chown
234 CRUNCH_ALIAS_chown= chgrp
235 ##################################################################
236 CRUNCH_LIBS+= -lm
237
238 ##################################################################
239 #  The following is pretty nearly a generic crunchgen-handling makefile
240 #
241
242 CONF=   $(PROG).conf
243 OUTMK=  $(PROG).mk
244 OUTC=   $(PROG).c
245 OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache
246 CRUNCHOBJS= ${.OBJDIR}
247 .if defined(MAKEOBJDIRPREFIX)
248 CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR}
249 .else
250 CANONICALOBJDIR:= /usr/obj${.CURDIR}
251 .endif
252
253 CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
254
255 # Program names and their aliases contribute hardlinks to 'rescue' executable,
256 # except for those that get suppressed.
257 .for D in $(CRUNCH_SRCDIRS)
258 .for P in $(CRUNCH_PROGS_$(D))
259 .ifdef CRUNCH_SRCDIR_${P}
260 $(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
261 .else
262 $(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
263 .endif
264 .ifndef CRUNCH_SUPPRESS_LINK_${P}
265 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
266 .endif
267 .for A in $(CRUNCH_ALIAS_$(P))
268 .ifndef CRUNCH_SUPPRESS_LINK_${A}
269 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
270 .endif
271 .endfor
272 .endfor
273 .endfor
274
275 all: $(PROG)
276 exe: $(PROG)
277
278 $(CONF): Makefile
279         echo \# Auto-generated, do not edit >$(.TARGET)
280 .ifdef CRUNCH_BUILDOPTS
281         echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
282 .endif
283 .ifdef CRUNCH_LIBS
284         echo libs $(CRUNCH_LIBS) >>$(.TARGET)
285 .endif
286 .for D in $(CRUNCH_SRCDIRS)
287 .for P in $(CRUNCH_PROGS_$(D))
288         echo progs $(P) >>$(.TARGET)
289 .ifdef CRUNCH_SRCDIR_${P}
290         echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
291 .else
292         echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
293 .endif
294 .ifdef CRUNCH_BUILDOPTS_${P}
295         echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
296             $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
297 .else
298         echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
299 .endif
300 .for A in $(CRUNCH_ALIAS_$(P))
301         echo ln $(P) $(A) >>$(.TARGET)
302 .endfor
303 .endfor
304 .endfor
305
306 # XXX Make sure we don't pass -P to crunchgen(1).
307 .MAKEFLAGS:= ${.MAKEFLAGS:N-P}
308 .ORDER: $(OUTPUTS) objs
309 $(OUTPUTS): $(CONF)
310         MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \
311             -c $(OUTC) $(CONF)
312
313 $(PROG): $(OUTPUTS) objs
314         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
315
316 objs: $(OUTMK)
317         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
318
319 # <sigh> Someone should replace the bin/csh and bin/sh build-tools with
320 # shell scripts so we can remove this nonsense.
321 build-tools:
322 .for _tool in bin/csh bin/sh
323         cd $(.CURDIR)/../../${_tool}; \
324         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
325         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
326 .endfor
327
328 # Use a separate build tree to hold files compiled for this crunchgen binary
329 # Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
330 # get that to cooperate with bsd.prog.mk.  Besides, many of the standard
331 # targets should NOT be propagated into the components.
332 cleandepend cleandir obj objlink:
333 .for D in $(CRUNCH_SRCDIRS)
334 .for P in $(CRUNCH_PROGS_$(D))
335 .ifdef CRUNCH_SRCDIR_${P}
336         cd ${CRUNCH_SRCDIR_$(P)} && \
337             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
338             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
339 .else
340         cd $(.CURDIR)/../../${D}/${P} && \
341             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
342             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
343 .endif
344 .endfor
345 .endfor
346
347 clean:
348         rm -f ${CLEANFILES}
349         if [ -e ${.OBJDIR}/$(OUTMK) ]; then                             \
350                 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean;       \
351         fi
352 .for D in $(CRUNCH_SRCDIRS)
353 .for P in $(CRUNCH_PROGS_$(D))
354 .ifdef CRUNCH_SRCDIR_${P}
355         cd ${CRUNCH_SRCDIR_$(P)} && \
356             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
357             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
358 .else
359         cd $(.CURDIR)/../../${D}/${P} && \
360             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
361             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
362 .endif
363 .endfor
364 .endfor
365
366 .include <bsd.prog.mk>