]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - rescue/rescue/Makefile
This commit was generated by cvs2svn to compensate for changes in r179404,
[FreeBSD/FreeBSD.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
8 PROG=   rescue
9 BINDIR?=/rescue
10
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
17
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
23
24 #################################################################
25 #
26 # General notes:
27 #
28 # A number of Make variables are used to generate the crunchgen config file.
29 #
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
34 #
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)
39 #
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.
44 #
45
46 # Define Makefile variable RESCUE
47 CRUNCH_BUILDOPTS+= -DRESCUE
48 # Define compile-time RESCUE symbol when compiling components
49 CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE
50
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}
54
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
63
64 ###################################################################
65 # Programs from stock /bin
66 #
67 # WARNING: Changing this list may require adjusting
68 # /usr/include/paths.h as well!  You were warned!
69 #
70 CRUNCH_SRCDIRS+= bin
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
77 .endif
78
79 # Additional options for specific programs
80 CRUNCH_ALIAS_test= [
81 CRUNCH_ALIAS_sh= -sh
82 # The -sh alias shouldn't appear in /rescue as a hard link
83 CRUNCH_SUPPRESS_LINK_-sh= 1
84 CRUNCH_ALIAS_ln= link
85 CRUNCH_ALIAS_rm= unlink
86 CRUNCH_ALIAS_ed= red
87
88 CRUNCH_PROGS_bin+= pkill
89 CRUNCH_SRCDIR_pkill= ${.CURDIR}/../../usr.bin/pkill
90 CRUNCH_ALIAS_pkill= pgrep
91
92 .if ${MK_RCMDS} != "no"
93 CRUNCH_PROGS_bin+= rcp
94 .endif
95
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
101 .endif
102
103 ###################################################################
104 # Programs from standard /sbin
105 #
106 # WARNING: Changing this list may require adjusting
107 # /usr/include/paths.h as well!  You were warned!
108 #
109 # Note that mdmfs have their own private 'pathnames.h'
110 # headers in addition to the standard 'paths.h' header.
111 #
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 
124
125 .if ${MK_ATM} != "no"
126 CRUNCH_PROGS_sbin+= atmconfig
127 .endif
128
129 .if ${MK_INET6_SUPPORT} != "no"
130 CRUNCH_PROGS_sbin+= ping6
131 .endif
132
133 .if ${MK_IPFILTER} != "no"
134 CRUNCH_PROGS_sbin+= ipf
135 .endif
136
137 # crunchgen does not like C++ programs; this should be fixed someday
138 # CRUNCH_PROGS+= devd
139
140 CRUNCH_LIBS+= -lalias -lcam -lcurses -ldevstat -lipsec
141 .if ${MK_IPX} != "no"
142 CRUNCH_LIBS+= -lipx
143 .endif
144 CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv -lmd -lreadline -lsbuf -lufs -lz
145
146 .if ${MACHINE_ARCH} == "i386"
147 CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk
148 CRUNCH_ALIAS_bsdlabel= disklabel
149 #.if ${MK_NCP} != "no"
150 #CRUNCH_PROGS+= mount_nwfs
151 #CRUNCH_LIBS+= -lncp
152 #.endif
153 #CRUNCH_PROGS+= mount_smbfs
154 #CRUNCH_LIBS+= -lsmb
155 .endif
156
157 .if ${MACHINE} == "pc98"
158 CRUNCH_PROGS_sbin+= bsdlabel
159 CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98
160 .endif
161
162 .if ${MACHINE_ARCH} == "ia64"
163 CRUNCH_PROGS_sbin+= mca
164 .endif
165
166 .if ${MACHINE_ARCH} == "sparc64"
167 CRUNCH_PROGS_sbin+= bsdlabel sunlabel
168 .endif
169
170 .if ${MACHINE_ARCH} == "amd64"
171 CRUNCH_PROGS_sbin+= bsdlabel fdisk
172 CRUNCH_ALIAS_bsdlabel= disklabel
173 .endif
174
175 CRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm
176 CRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig
177 CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld
178 CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid
179 CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery
180 CRUNCH_SRCDIR_ipf= $(.CURDIR)/../../sbin/ipf/ipf
181 CRUNCH_ALIAS_reboot= fastboot halt fasthalt
182 CRUNCH_ALIAS_restore= rrestore
183 CRUNCH_ALIAS_dump= rdump
184 CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
185 CRUNCH_ALIAS_geom= glabel gpart
186
187 # dhclient has historically been troublesome...
188 CRUNCH_PROGS_sbin+= dhclient
189 CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint
190
191 ##################################################################
192 # Programs from stock /usr/bin
193
194 CRUNCH_SRCDIRS+= usr.bin
195
196 CRUNCH_PROGS_usr.bin= head mt sed tail tee
197
198 CRUNCH_PROGS_usr.bin+= gzip
199 CRUNCH_ALIAS_gzip= gunzip gzcat zcat
200
201 CRUNCH_PROGS_usr.bin+= bzip2
202 CRUNCH_ALIAS_bzip2= bunzip2 bzcat
203 CRUNCH_LIBS+= -lbz2
204
205 CRUNCH_PROGS_usr.bin+= tar
206 CRUNCH_LIBS+= -larchive
207
208 CRUNCH_PROGS_usr.bin+= vi
209 CRUNCH_ALIAS_vi= ex
210
211 CRUNCH_PROGS_usr.bin+= id
212 CRUNCH_ALIAS_id= groups whoami
213
214 ##################################################################
215 # Programs from stock /usr/sbin
216
217 CRUNCH_SRCDIRS+= usr.sbin
218
219 CRUNCH_PROGS_usr.sbin= chroot
220
221 CRUNCH_PROGS_usr.sbin+= chown
222 CRUNCH_ALIAS_chown= chgrp
223
224 ##################################################################
225 #  The following is pretty nearly a generic crunchgen-handling makefile
226 #
227
228 CONF=   $(PROG).conf
229 OUTMK=  $(PROG).mk
230 OUTC=   $(PROG).c
231 OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache
232 CRUNCHOBJS= ${.OBJDIR}
233 .if defined(MAKEOBJDIRPREFIX)
234 CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR}
235 .else
236 CANONICALOBJDIR:= /usr/obj${.CURDIR}
237 .endif
238
239 CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
240
241 # Program names and their aliases contribute hardlinks to 'rescue' executable,
242 # except for those that get suppressed.
243 .for D in $(CRUNCH_SRCDIRS)
244 .for P in $(CRUNCH_PROGS_$(D))
245 .ifdef CRUNCH_SRCDIR_${P}
246 $(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
247 .else
248 $(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
249 .endif
250 .ifndef CRUNCH_SUPPRESS_LINK_${P}
251 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
252 .endif
253 .for A in $(CRUNCH_ALIAS_$(P))
254 .ifndef CRUNCH_SUPPRESS_LINK_${A}
255 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
256 .endif
257 .endfor
258 .endfor
259 .endfor
260
261 all: $(PROG)
262 exe: $(PROG)
263
264 $(CONF): Makefile
265         echo \# Auto-generated, do not edit >$(.TARGET)
266 .ifdef CRUNCH_BUILDOPTS
267         echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
268 .endif
269 .ifdef CRUNCH_LIBS
270         echo libs $(CRUNCH_LIBS) >>$(.TARGET)
271 .endif
272 .for D in $(CRUNCH_SRCDIRS)
273 .for P in $(CRUNCH_PROGS_$(D))
274         echo progs $(P) >>$(.TARGET)
275 .ifdef CRUNCH_SRCDIR_${P}
276         echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
277 .else
278         echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
279 .endif
280 .ifdef CRUNCH_BUILDOPTS_${P}
281         echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
282             $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
283 .else
284         echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
285 .endif
286 .for A in $(CRUNCH_ALIAS_$(P))
287         echo ln $(P) $(A) >>$(.TARGET)
288 .endfor
289 .endfor
290 .endfor
291
292 # XXX Make sure we don't pass -P to crunchgen(1).
293 .MAKEFLAGS:= ${.MAKEFLAGS:N-P}
294 .ORDER: $(OUTPUTS) objs
295 $(OUTPUTS): $(CONF)
296         MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \
297             -c $(OUTC) $(CONF)
298
299 $(PROG): $(OUTPUTS) objs
300         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
301
302 objs: $(OUTMK)
303         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
304
305 # <sigh> Someone should replace the bin/csh and bin/sh build-tools with
306 # shell scripts so we can remove this nonsense.
307 build-tools:
308 .for _tool in bin/csh bin/sh 
309         cd $(.CURDIR)/../../${_tool}; \
310         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
311         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
312 .endfor
313
314 # Use a separate build tree to hold files compiled for this crunchgen binary
315 # Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
316 # get that to cooperate with bsd.prog.mk.  Besides, many of the standard
317 # targets should NOT be propagated into the components.
318 cleandepend cleandir obj objlink:
319 .for D in $(CRUNCH_SRCDIRS)
320 .for P in $(CRUNCH_PROGS_$(D))
321 .ifdef CRUNCH_SRCDIR_${P}
322         cd ${CRUNCH_SRCDIR_$(P)} && \
323             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
324             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
325 .else
326         cd $(.CURDIR)/../../${D}/${P} && \
327             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
328             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
329 .endif
330 .endfor
331 .endfor
332
333 clean:
334         rm -f ${CLEANFILES}
335         if [ -e ${.OBJDIR}/$(OUTMK) ]; then                             \
336                 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean;       \
337         fi
338 .for D in $(CRUNCH_SRCDIRS)
339 .for P in $(CRUNCH_PROGS_$(D))
340 .ifdef CRUNCH_SRCDIR_${P}
341         cd ${CRUNCH_SRCDIR_$(P)} && \
342             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
343             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
344 .else
345         cd $(.CURDIR)/../../${D}/${P} && \
346             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
347             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
348 .endif
349 .endfor
350 .endfor
351
352 .include <bsd.prog.mk>