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