Makefile revision 117043
1#$FreeBSD: head/rescue/rescue/Makefile 117043 2003-06-29 20:44:12Z gordon $
2#	@(#)Makefile	8.1 (Berkeley) 6/2/93
3
4PROG=	rescue
5BINDIR?= /rescue
6
7# Uncomment to exclude tcsh
8#NO_TCSH=1
9
10# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh
11SCRIPTS= nextboot_FIXED
12SCRIPTSNAME_nextboot_FIXED= nextboot.sh
13nextboot_FIXED: ../../sbin/reboot/nextboot.sh
14	sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
15CLEANFILES+= nextboot_FIXED
16
17SCRIPTS+= dhclient_FIXED
18SCRIPTSNAME_dhclient_FIXED= dhclient-script
19dhclient_FIXED: ../../contrib/isc-dhcp/client/scripts/freebsd
20	sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
21CLEANFILES+= dhclient_FIXED
22
23#################################################################
24#
25# General notes:
26#
27# A number of Make variables are used to generate the crunchgen config file.
28#
29#  CRUNCH_SRCDIRS: lists directories to search for included programs
30#  CRUNCH_PROGS:  lists programs to be included
31#  CRUNCH_LIBS:  libraries to link with
32#  CRUNCH_BUILDOPTS: generic build options to be added to every program
33#
34# Special options can be specified for individual programs
35#  CRUNCH_SRCDIR_$(P): base source directory for program $(P)
36#  CRUNCH_BUILDOPTS_$(P): additional build options for $(P)
37#  CRUNCH_ALIAS_$(P): additional names to be used for $(P)
38#
39# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P}
40# will be used to generate a hard link to the resulting binary.
41# Specific links can be suppressed by setting
42# CRUNCH_SUPPRESS_LINK_$(NAME) to 1.
43#
44
45# Define Makefile variable RESCUE
46CRUNCH_BUILDOPTS+= -DRESCUE
47# Define compile-time RESCUE symbol when compiling components
48CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE
49
50#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS}
51
52# Hackery:  'librescue' exists merely as a tool for appropriately
53# recompiling specific library entries.  We _know_ they're needed, and
54# regular archive searching creates ugly library ordering problems.
55# Easiest fix: tell the linker to include them into the executable
56# first, so they are guaranteed to override the regular lib entries.
57# Note that if 'librescue' hasn't been compiled, we'll just get the
58# regular lib entries from libc and friends.
59CRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o
60
61###################################################################
62# Programs from stock /bin
63#
64# WARNING: Changing this list may require adjusting
65# /usr/include/paths.h as well!  You were warned!
66#
67CRUNCH_SRCDIRS+=$(.CURDIR)/../../bin $(.CURDIR)/../../usr.bin
68CRUNCH_PROGS=cat chflags chio chmod cp date dd df domainname echo ed	\
69	 expr getfacl hostname kenv kill ln ls mkdir mv pax ps pwd 	\
70	 realpath rm rmdir setfacl sh sleep stty sync test
71CRUNCH_LIBS+=-lcrypt -lcrypto -ledit -lkvm -ll -lm -ltermcap -lutil
72
73# Additional options for specific programs
74CRUNCH_ALIAS_test= [
75CRUNCH_ALIAS_sh= -sh
76# The -sh alias shouldn't appear in /rescue as a hard link
77CRUNCH_SUPPRESS_LINK_-sh=1
78CRUNCH_ALIAS_ln= link
79CRUNCH_ALIAS_rm= unlink
80CRUNCH_ALIAS_ed= red
81
82.if !defined(NO_RCMNDS)
83CRUNCH_PROGS+= rcp
84.endif
85
86.if !defined(NO_TCSH)
87CRUNCH_PROGS+= csh
88CRUNCH_ALIAS_csh= -csh tcsh -tcsh
89CRUNCH_SUPPRESS_LINK_-csh=1
90CRUNCH_SUPPRESS_LINK_-tcsh=1
91.endif
92
93#Is rmail of any use at all here?  I think not.
94#CRUNCH_PROGS+= rmail  
95
96###################################################################
97# Programs from standard /sbin
98#
99# WARNING: Changing this list may require adjusting
100# /usr/include/paths.h as well!  You were warned!
101#
102# Note that mdmfs and shutdown have their own private 'pathnames.h'
103# headers in addition to the standard 'paths.h' header.
104#
105CRUNCH_SRCDIRS+=$(.CURDIR)/../../sbin
106CRUNCH_PROGS+=atm adjkerntz atacontrol badsect camcontrol ccdconfig	\
107	clri comcontrol conscontrol devfs disklabel dmesg dump		\
108	dumpfs dumpon fdisk fore_dnld fsck fsck_ffs fsck_msdosfs fsdb	\
109	fsirand gbde growfs ifconfig ilmid init ip6fw ipf ipfs ipfstat	\
110	ipfw ipmon ipnat kldconfig kldload kldstat kldunload ldconfig 	\
111	md5 mdconfig mdmfs mknod mount mount_cd9660 mount_ext2fs	\
112	mount_msdosfs mount_nfs mount_ntfs mount_nullfs	mount_portalfs	\
113	mount_std mount_udf mount_umapfs mount_unionfs natd newfs	\
114	newfs_msdos nfsiod nos-tun ping ping6 quotacheck raidctl reboot	\
115	restore rcorder route routed rtquery rtsol savecore shutdown	\
116	slattach spppcontrol startslip swapon sysctl tunefs umount vinum
117
118# crunchgen does not like C++ programs; this should be fixed someday
119# CRUNCH_PROGS+= devd
120
121CRUNCH_LIBS+=-lalias -latm -lbsdxml -lcam -lcurses -ldevstat -lipsec -lipx \
122	-lgeom -lmd -lncp -lreadline -lsbuf -lsmb -lufs -lz 
123
124.if ${MACHINE_ARCH} == "i386"
125CRUNCH_PROGS+= cxconfig mount_nwfs mount_smbfs
126.endif
127
128.if ${MACHINE} == "pc98"
129CRUNCH_PROGS+= fdisk_pc98
130.endif
131
132.if ${MACHINE_ARCH} == "ia64"
133CRUNCH_PROGS+= mca gpt
134.endif
135
136.if ${MACHINE_ARCH} == "sparc64"
137.endif
138
139.if ${MACHINE_ARCH} == "alpha"
140.endif
141
142CRUNCH_SRCDIR_atm=$(.CURDIR)/../../sbin/atm/atm
143CRUNCH_SRCDIR_fore_dnld=$(.CURDIR)/../../sbin/atm/fore_dnld
144CRUNCH_SRCDIR_ilmid=$(.CURDIR)/../../sbin/atm/ilmid
145CRUNCH_SRCDIR_rtquery=$(.CURDIR)/../../sbin/routed/rtquery
146CRUNCH_ALIAS_reboot= fastboot halt fasthalt
147CRUNCH_ALIAS_restore=rrestore
148CRUNCH_ALIAS_dump= rdump
149CRUNCH_ALIAS_fsck_ffs=fsck_4.2bsd fsck_ufs
150CRUNCH_ALIAS_mount_std= mount_devfs mount_fdescfs mount_linprocfs mount_procfs
151
152# dhclient has historically been troublesome...
153CRUNCH_PROGS+=dhclient
154CRUNCH_BUILDOPTS_dhclient=-DRELEASE_CRUNCH -Dlint
155
156##################################################################
157# Programs from stock /usr/bin
158# 
159CRUNCH_SRCDIRS+=$(.CURDIR)/../../usr.bin
160CRUNCH_SRCDIRS+=$(.CURDIR)/../../gnu/usr.bin
161
162CRUNCH_PROGS+=wall
163
164CRUNCH_PROGS+=gzip
165CRUNCH_ALIAS_gzip=gunzip gzcat zcat
166
167CRUNCH_PROGS+=bzip2
168CRUNCH_ALIAS_bzip2=bunzip2 bzcat
169CRUNCH_LIBS+=-lbz2
170
171CRUNCH_PROGS+=tar
172CRUNCH_PROGS+=vi
173CRUNCH_ALIAS_vi=ex
174
175##################################################################
176#  The following is pretty nearly a generic crunchgen-handling makefile
177#
178
179CONF=	$(PROG).conf
180OUTMK=	$(PROG).mk
181OUTC=   $(PROG).c
182OUTPUTS= $(OUTMK) $(OUTC) $(PROG).cache
183CRUNCHOBJS= ${.OBJDIR}
184.if defined(MAKEOBJDIRPREFIX)
185CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
186.else
187CANONICALOBJDIR:=/usr/obj${.CURDIR}
188.endif
189
190NOMAN=	true
191CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
192
193# Program names and their aliases contribute hardlinks to 'rescue' executable,
194# except for those that get suppressed.
195.for P in $(CRUNCH_PROGS)
196.ifndef CRUNCH_SUPPRESS_LINK_${P}
197LINKS += $(BINDIR)/$(PROG) $(BINDIR)/$(P)
198.endif
199.for A in $(CRUNCH_ALIAS_$(P))
200.ifndef CRUNCH_SUPPRESS_LINK_${A}
201LINKS += $(BINDIR)/$(PROG) $(BINDIR)/$(A)
202.endif
203.endfor
204.endfor
205
206all: $(PROG)
207exe: $(PROG)
208
209$(CONF): Makefile
210	echo \# Auto-generated, do not edit >$(.TARGET)
211.for D in $(CRUNCH_SRCDIRS)
212	echo srcdirs $(D) >>$(.TARGET)
213.endfor
214.ifdef CRUNCH_BUILDOPTS
215	echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
216.endif
217.ifdef CRUNCH_LIBS
218	echo libs $(CRUNCH_LIBS) >>$(.TARGET)
219.endif
220.for P in $(CRUNCH_PROGS)
221	echo progs $(P) >>$(.TARGET)
222.ifdef CRUNCH_SRCDIR_${P}
223	echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
224.endif
225.ifdef CRUNCH_BUILDOPTS_${P}
226	echo special $(P) buildopts $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
227.endif
228.for A in $(CRUNCH_ALIAS_$(P))
229	echo ln $(P) $(A) >>$(.TARGET)
230.endfor
231.endfor
232
233
234$(OUTPUTS): $(CONF)
235	MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -q -m $(OUTMK) -c $(OUTC) $(CONF)
236
237# -m here forces make to treat the bsd.prog.mk and bsd.lib.mk in
238# this directory as overrides for the standard shared ones.
239$(PROG): $(OUTPUTS)
240	MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) 
241
242objs:
243	MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) objs
244
245# Use a separate build tree to hold files compiled for this crunchgen binary
246# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
247# get that to cooperate with bsd.prog.mk.  Besides, many of the standard
248# targets should NOT be propagated into the components.
249cleandepend cleandir obj objlink:
250.for D in $(CRUNCH_SRCDIRS)
251	cd ${D} && MAKEOBJDIRPREFIX=${CANONICALOBJDIR} make ${.TARGET}
252.endfor
253
254clean:
255	rm -f ${CLEANFILES}
256	if [ -e ${.OBJDIR}/$(OUTMK) ]; then		\
257		MAKEOBJDIRPREFIX=${CRUNCHOBJS} make -f $(OUTMK) clean;	\
258	fi
259.for D in $(CRUNCH_SRCDIRS) $(EXTRA_SRCDIRS)
260	cd ${D} && MAKEOBJDIRPREFIX=${CRUNCHOBJS} make clean
261.endfor
262
263.include <bsd.prog.mk>
264