]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - rescue/rescue/Makefile
This commit was generated by cvs2svn to compensate for changes in r172771,
[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 .if ${MK_RCMDS} != "no"
89 CRUNCH_PROGS_bin+= rcp
90 .endif
91
92 .if ${MK_TCSH} != "no"
93 CRUNCH_PROGS_bin+= csh
94 CRUNCH_ALIAS_csh= -csh tcsh -tcsh
95 CRUNCH_SUPPRESS_LINK_-csh= 1
96 CRUNCH_SUPPRESS_LINK_-tcsh= 1
97 .endif
98
99 ###################################################################
100 # Programs from standard /sbin
101 #
102 # WARNING: Changing this list may require adjusting
103 # /usr/include/paths.h as well!  You were warned!
104 #
105 # Note that mdmfs have their own private 'pathnames.h'
106 # headers in addition to the standard 'paths.h' header.
107 #
108 CRUNCH_SRCDIRS+= sbin
109 CRUNCH_PROGS_sbin= atacontrol badsect bsdlabel          \
110         camcontrol ccdconfig clri devfs dmesg dump                      \
111         dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb           \
112         fsirand gbde ifconfig init                              \
113         kldconfig kldload kldstat kldunload ldconfig                    \
114         md5 mdconfig mdmfs mknod mount mount_cd9660     \
115         mount_msdosfs mount_nfs mount_ntfs mount_nullfs                 \
116         mount_udf mount_unionfs newfs           \
117         newfs_msdos nos-tun ping reboot                 \
118         restore rcorder route routed rtquery rtsol savecore             \
119         slattach spppcontrol startslip swapon sysctl tunefs umount 
120
121 .if ${MK_ATM} != "no"
122 CRUNCH_PROGS_sbin+= atmconfig
123 # Disabled in 7.0 as netatm is not MPSAFE.
124 #CRUNCH_PROGS_sbin+= atm fore_dnld ilmid
125 #CRUNCH_LIBS+= -latm
126 .endif
127
128 .if ${MK_INET6_SUPPORT} != "no"
129 CRUNCH_PROGS_sbin+= ping6
130 .endif
131
132 .if ${MK_IPFILTER} != "no"
133 CRUNCH_PROGS_sbin+= ipf
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 CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv -lmd -lreadline -lsbuf -lufs -lz
144
145 .if ${MACHINE_ARCH} == "i386"
146 CRUNCH_PROGS_sbin+= sconfig fdisk
147 CRUNCH_ALIAS_bsdlabel= disklabel
148 #.if ${MK_NCP} != "no"
149 #CRUNCH_PROGS+= mount_nwfs
150 #CRUNCH_LIBS+= -lncp
151 #.endif
152 #CRUNCH_PROGS+= mount_smbfs
153 #CRUNCH_LIBS+= -lsmb
154 .endif
155
156 .if ${MACHINE} == "pc98"
157 CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98
158 .endif
159
160 .if ${MACHINE_ARCH} == "ia64"
161 CRUNCH_PROGS_sbin+= mca gpt fdisk
162 .endif
163
164 .if ${MACHINE_ARCH} == "sparc64"
165 CRUNCH_PROGS_sbin+= sunlabel
166 .endif
167
168 .if ${MACHINE_ARCH} == "amd64"
169 CRUNCH_PROGS_sbin+= fdisk
170 CRUNCH_ALIAS_bsdlabel= disklabel
171 .endif
172
173 CRUNCH_SRCDIR_atm= $(.CURDIR)/../../sbin/atm/atm
174 CRUNCH_SRCDIR_atmconfig= $(.CURDIR)/../../sbin/atm/atmconfig
175 CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../../sbin/atm/fore_dnld
176 CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid
177 CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery
178 CRUNCH_SRCDIR_ipf= $(.CURDIR)/../../sbin/ipf/ipf
179 CRUNCH_ALIAS_reboot= fastboot halt fasthalt
180 CRUNCH_ALIAS_restore= rrestore
181 CRUNCH_ALIAS_dump= rdump
182 CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
183
184 # dhclient has historically been troublesome...
185 CRUNCH_PROGS_sbin+= dhclient
186 CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRUNCH -Dlint
187
188 ##################################################################
189 # Programs from stock /usr/bin
190
191 CRUNCH_SRCDIRS+= usr.bin
192
193 CRUNCH_PROGS_usr.bin+= gzip
194 CRUNCH_ALIAS_gzip= gunzip gzcat zcat
195
196 CRUNCH_PROGS_usr.bin+= bzip2
197 CRUNCH_ALIAS_bzip2= bunzip2 bzcat
198 CRUNCH_LIBS+= -lbz2
199
200 CRUNCH_PROGS_usr.bin+= tar
201 CRUNCH_LIBS+= -larchive
202
203 CRUNCH_PROGS_usr.bin+= vi
204 CRUNCH_ALIAS_vi= ex
205
206 CRUNCH_PROGS_usr.bin+= id
207 CRUNCH_ALIAS_id= groups whoami
208
209 ##################################################################
210 # Programs from stock /usr/sbin
211
212 CRUNCH_SRCDIRS+= usr.sbin
213
214 CRUNCH_PROGS_usr.sbin+= chroot
215
216 ##################################################################
217 #  The following is pretty nearly a generic crunchgen-handling makefile
218 #
219
220 CONF=   $(PROG).conf
221 OUTMK=  $(PROG).mk
222 OUTC=   $(PROG).c
223 OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache
224 CRUNCHOBJS= ${.OBJDIR}
225 .if defined(MAKEOBJDIRPREFIX)
226 CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR}
227 .else
228 CANONICALOBJDIR:= /usr/obj${.CURDIR}
229 .endif
230
231 CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
232
233 # Program names and their aliases contribute hardlinks to 'rescue' executable,
234 # except for those that get suppressed.
235 .for D in $(CRUNCH_SRCDIRS)
236 .for P in $(CRUNCH_PROGS_$(D))
237 .ifdef CRUNCH_SRCDIR_${P}
238 $(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
239 .else
240 $(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
241 .endif
242 .ifndef CRUNCH_SUPPRESS_LINK_${P}
243 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
244 .endif
245 .for A in $(CRUNCH_ALIAS_$(P))
246 .ifndef CRUNCH_SUPPRESS_LINK_${A}
247 LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
248 .endif
249 .endfor
250 .endfor
251 .endfor
252
253 all: $(PROG)
254 exe: $(PROG)
255
256 $(CONF): Makefile
257         echo \# Auto-generated, do not edit >$(.TARGET)
258 .ifdef CRUNCH_BUILDOPTS
259         echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
260 .endif
261 .ifdef CRUNCH_LIBS
262         echo libs $(CRUNCH_LIBS) >>$(.TARGET)
263 .endif
264 .for D in $(CRUNCH_SRCDIRS)
265 .for P in $(CRUNCH_PROGS_$(D))
266         echo progs $(P) >>$(.TARGET)
267 .ifdef CRUNCH_SRCDIR_${P}
268         echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
269 .else
270         echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
271 .endif
272 .ifdef CRUNCH_BUILDOPTS_${P}
273         echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
274             $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
275 .else
276         echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
277 .endif
278 .for A in $(CRUNCH_ALIAS_$(P))
279         echo ln $(P) $(A) >>$(.TARGET)
280 .endfor
281 .endfor
282 .endfor
283
284 # XXX Make sure we don't pass -P to crunchgen(1).
285 .MAKEFLAGS:= ${.MAKEFLAGS:N-P}
286 .ORDER: $(OUTPUTS) objs
287 $(OUTPUTS): $(CONF)
288         MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \
289             -c $(OUTC) $(CONF)
290
291 $(PROG): $(OUTPUTS) objs
292         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
293
294 objs: $(OUTMK)
295         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
296
297 # <sigh> Someone should replace the bin/csh and bin/sh build-tools with
298 # shell scripts so we can remove this nonsense.
299 build-tools:
300 .for _tool in bin/csh bin/sh 
301         cd $(.CURDIR)/../../${_tool}; \
302         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
303         MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
304 .endfor
305
306 # Use a separate build tree to hold files compiled for this crunchgen binary
307 # Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
308 # get that to cooperate with bsd.prog.mk.  Besides, many of the standard
309 # targets should NOT be propagated into the components.
310 cleandepend cleandir obj objlink:
311 .for D in $(CRUNCH_SRCDIRS)
312 .for P in $(CRUNCH_PROGS_$(D))
313 .ifdef CRUNCH_SRCDIR_${P}
314         cd ${CRUNCH_SRCDIR_$(P)} && \
315             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
316             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
317 .else
318         cd $(.CURDIR)/../../${D}/${P} && \
319             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
320             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
321 .endif
322 .endfor
323 .endfor
324
325 clean:
326         rm -f ${CLEANFILES}
327         if [ -e ${.OBJDIR}/$(OUTMK) ]; then                             \
328                 MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean;       \
329         fi
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}
336 .else
337         cd $(.CURDIR)/../../${D}/${P} && \
338             MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
339             DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
340 .endif
341 .endfor
342 .endfor
343
344 .include <bsd.prog.mk>