1
2.include <src.opts.mk>
3.include <bsd.linker.mk>
4
5PACKAGE=rescue
6MAN=
7MK_SSP=	no
8# Static-PIE is not supported so we should not be linking against _pie.a libs.
9# This is also needed to avoid linking against sanitizer-instrumented libraries
10# since MK_ASAN/MK_UBSAN will instrument the .pieo object files.
11MK_PIE=	no
12NO_SHARED=	yes
13CRUNCH_BUILDOPTS+=	MK_PIE=no NO_SHARED=yes
14
15# lld >= 16 became more strict about multiply defined symbols. Since there are
16# many of those in crunchgen'd programs, turn off the check.
17.if ${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 160000
18LDFLAGS+=	-Wl,--allow-multiple-definition
19.endif
20
21PROG=	rescue
22BINDIR?=/rescue
23
24SCRIPTS+= dhclient_FIXED
25SCRIPTSNAME_dhclient_FIXED= dhclient-script
26dhclient_FIXED: ../../sbin/dhclient/dhclient-script
27	sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
28CLEANFILES+= dhclient_FIXED
29
30# The help which used to be here is now in mk/bsd.crunchgen.mk
31
32# Define Makefile variable RESCUE
33CRUNCH_BUILDOPTS+= -DRESCUE
34# Define compile-time RESCUE symbol when compiling components
35CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE
36
37# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk
38# rather than incorporating rescue-specific logic into standard files.
39#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS}
40
41# Hackery:  'librescue' exists merely as a tool for appropriately
42# recompiling specific library entries.  We _know_ they're needed, and
43# regular archive searching creates ugly library ordering problems.
44# Easiest fix: tell the linker to include them into the executable
45# first, so they are guaranteed to override the regular lib entries.
46# Note that if 'librescue' hasn't been compiled, we'll just get the
47# regular lib entries from libc and friends.
48CRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o
49
50###################################################################
51# Programs from stock /bin
52#
53# WARNING: Changing this list may require adjusting
54# /usr/include/paths.h as well!  You were warned!
55#
56CRUNCH_SRCDIRS+= bin
57CRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo 	\
58	 ed expr getfacl hostname kenv kill ln ls mkdir mv	\
59	 pkill ps pwd realpath rm rmdir setfacl sh sleep stty	\
60	 sync test
61CRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -lelf -ltermcapw -lutil -lxo
62CRUNCH_BUILDTOOLS+= bin/sh
63
64# Additional options for specific programs
65CRUNCH_ALIAS_test= [
66CRUNCH_ALIAS_sh= -sh
67# The -sh alias shouldn't appear in /rescue as a hard link
68CRUNCH_SUPPRESS_LINK_-sh= 1
69CRUNCH_ALIAS_ln= link
70CRUNCH_ALIAS_rm= unlink
71CRUNCH_ALIAS_ed= red
72CRUNCH_ALIAS_pkill= pgrep
73
74.if ${MK_TCSH} != "no"
75CRUNCH_PROGS_bin+= csh
76CRUNCH_ALIAS_csh= -csh tcsh -tcsh
77CRUNCH_BUILDTOOLS+= bin/csh
78CRUNCH_SUPPRESS_LINK_-csh= 1
79CRUNCH_SUPPRESS_LINK_-tcsh= 1
80.endif
81
82###################################################################
83# Programs from standard /sbin
84#
85# WARNING: Changing this list may require adjusting
86# /usr/include/paths.h as well!  You were warned!
87#
88# Note that mdmfs have their own private 'pathnames.h'
89# headers in addition to the standard 'paths.h' header.
90#
91CRUNCH_SRCDIRS+= sbin
92CRUNCH_PROGS_sbin= 						\
93	camcontrol clri devfs dmesg dump			\
94	dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb		\
95	fsirand geom ifconfig init 				\
96	kldconfig kldload kldstat kldunload ldconfig 		\
97	md5 mdconfig mdmfs mknod mount mount_cd9660		\
98	mount_msdosfs mount_nfs mount_nullfs			\
99	mount_udf mount_unionfs newfs				\
100	newfs_msdos nos-tun reboot				\
101	restore rcorder route savecore		 		\
102	shutdown swapon sysctl tunefs umount
103
104.if ${MK_CCD} != "no"
105CRUNCH_PROGS_sbin+= ccdconfig
106.endif
107
108.if ${MK_INET} != "no" || ${MK_INET6} != "no"
109CRUNCH_PROGS_sbin+= ping
110.endif
111
112.if ${MK_INET6_SUPPORT} != "no"
113CRUNCH_ALIAS_ping= ping6
114CRUNCH_PROGS_sbin+= rtsol
115.endif
116
117.if ${MK_IPFILTER} != "no"
118CRUNCH_PROGS_sbin+= ipf
119CRUNCH_LIBS_ipf+=	${LIBIPF}
120.endif
121
122.if ${MK_IPFW} != "no"
123CRUNCH_PROGS_sbin+= ipfw
124.endif
125
126.if ${MK_PF} != "no"
127CRUNCH_PROGS_sbin+= pfctl
128CRUNCH_LIBS_pfctl+= ${LIBPFCTL} ${LIBNV}
129.endif
130
131.if ${MK_ROUTED} != "no"
132CRUNCH_PROGS_sbin+= routed rtquery
133.endif
134
135.if ${MK_ZFS} != "no"
136CRUNCH_PROGS_sbin+= bectl
137CRUNCH_PROGS_sbin+= zfs
138CRUNCH_PROGS_sbin+= zfsbootcfg
139CRUNCH_PROGS_sbin+= zpool
140CRUNCH_PROGS_usr.sbin+= zdb
141.endif
142
143# crunchgen does not like C++ programs; this should be fixed someday
144# CRUNCH_PROGS+= devd
145
146CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma
147CRUNCH_LIBS_camcontrol+= ${LIBNVMF}
148.if ${MK_ZFS} != "no"
149CRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt
150CRUNCH_LIBS_zfs+=	${LIBBE} \
151			${LIBZPOOL} \
152			${LIBZFS} \
153			${LIBZUTIL} \
154			${LIBZFS_CORE} \
155			${LIBZFSBOOTENV} \
156			${LIBICP_RESCUE} \
157			${LIBNVPAIR}
158CRUNCH_LIBS_bectl+=	${CRUNCH_LIBS_zfs}
159CRUNCH_LIBS_zpool+=	${CRUNCH_LIBS_zfs}
160CRUNCH_LIBS_zdb+=	${CRUNCH_LIBS_zfs} ${LIBZDB}
161CRUNCH_LIBS_zfsbootcfg+=${LIBZFSBOOTENV} \
162			${LIBZPOOL} \
163			${LIBZFS} \
164			${LIBZUTIL} \
165			${LIBZFS_CORE} \
166			${LIBICP_RESCUE} \
167			${LIBNVPAIR}
168.else
169# liblzma needs pthread
170CRUNCH_LIBS+= -lpthread
171.endif
172CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv
173.if ${MK_OPENSSL} == "no"
174CRUNCH_LIBS+= -lmd
175.endif
176CRUNCH_LIBS+= -lmt -lsbuf -lufs -lz
177
178.if ${MACHINE_CPUARCH} == "i386"
179CRUNCH_PROGS_sbin+= bsdlabel fdisk
180CRUNCH_ALIAS_bsdlabel= disklabel
181#CRUNCH_PROGS+= mount_smbfs
182#CRUNCH_LIBS+= -lsmb
183.endif
184
185.if ${MACHINE_CPUARCH} == "amd64"
186CRUNCH_PROGS_sbin+= bsdlabel fdisk
187CRUNCH_ALIAS_bsdlabel= disklabel
188.endif
189
190CRUNCH_SRCDIR_rtquery= ${SRCTOP}/sbin/routed/rtquery
191CRUNCH_SRCDIR_ipf= ${SRCTOP}/sbin/ipf/ipf
192.if ${MK_ZFS} != "no"
193CRUNCH_SRCDIR_zfs= ${SRCTOP}/cddl/sbin/zfs
194CRUNCH_SRCDIR_zpool= ${SRCTOP}/cddl/sbin/zpool
195CRUNCH_SRCDIR_zdb= ${SRCTOP}/cddl/usr.sbin/zdb
196.endif
197CRUNCH_ALIAS_reboot= fastboot halt fasthalt nextboot
198CRUNCH_ALIAS_restore= rrestore
199CRUNCH_ALIAS_dump= rdump
200CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
201CRUNCH_ALIAS_geom= glabel gpart
202CRUNCH_ALIAS_shutdown= poweroff
203
204# dhclient has historically been troublesome...
205CRUNCH_PROGS_sbin+= dhclient
206
207##################################################################
208# Programs from stock /usr/bin
209#
210CRUNCH_SRCDIRS+= usr.bin
211
212CRUNCH_PROGS_usr.bin= head mt sed tail tee
213
214CRUNCH_PROGS_usr.bin+= gzip
215CRUNCH_ALIAS_gzip= gunzip gzcat zcat
216
217CRUNCH_PROGS_usr.bin+= bzip2
218CRUNCH_ALIAS_bzip2= bunzip2 bzcat
219CRUNCH_LIBS+= -lbz2
220
221CRUNCH_PROGS_usr.bin+= less
222CRUNCH_ALIAS_less= more
223
224CRUNCH_PROGS_usr.bin+= xz
225CRUNCH_ALIAS_xz= unxz lzma unlzma xzcat lzcat
226
227CRUNCH_PROGS_usr.bin+= zstd
228CRUNCH_ALIAS_zstd= unzstd zstdcat zstdmt
229CRUNCH_LIBS+=	-lprivatezstd
230
231CRUNCH_PROGS_usr.bin+=	fetch
232CRUNCH_LIBS+=	-lfetch
233
234CRUNCH_PROGS_usr.bin+= tar
235CRUNCH_LIBS+= -larchive
236.if ${MK_OPENSSL} != "no"
237CRUNCH_LIBS+= -lssl -lcrypto
238.endif
239CRUNCH_LIBS+= -lmd
240
241.if ${MK_NETCAT} != "no"
242CRUNCH_PROGS_usr.bin+=	nc
243.endif
244
245.if ${MK_VI} != "no"
246CRUNCH_PROGS_usr.bin+= vi
247CRUNCH_ALIAS_vi= ex
248.endif
249
250CRUNCH_PROGS_usr.bin+= id
251CRUNCH_ALIAS_id= groups whoami
252
253##################################################################
254# Programs from stock /usr/sbin
255#
256CRUNCH_SRCDIRS+= usr.sbin
257
258CRUNCH_PROGS_usr.sbin+= chroot
259
260CRUNCH_PROGS_usr.sbin+= chown
261CRUNCH_ALIAS_chown= chgrp
262##################################################################
263
264CRUNCH_LIBS+=		${OBJTOP}/lib/libifconfig/libifconfig.a
265CRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
266
267CRUNCH_LIBS_ifconfig+=	${LIBNV}
268
269CRUNCH_LIBS+= -lm
270
271.if ${MK_ISCSI} != "no"
272CRUNCH_PROGS_usr.bin+=	iscsictl
273CRUNCH_PROGS_usr.sbin+=	iscsid
274
275CRUNCH_LIBS+=		${OBJTOP}/lib/libiscsiutil/libiscsiutil.a
276CRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libiscsiutil
277.endif
278
279.include <bsd.crunchgen.mk>
280.include <bsd.prog.mk>
281