xref: /freebsd/rescue/rescue/Makefile (revision 1edb7116)
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 gbde 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_ROUTED} != "no"
123CRUNCH_PROGS_sbin+= routed rtquery
124.endif
125
126.if ${MK_ZFS} != "no"
127CRUNCH_PROGS_sbin+= bectl
128CRUNCH_PROGS_sbin+= zfs
129CRUNCH_PROGS_sbin+= zfsbootcfg
130CRUNCH_PROGS_sbin+= zpool
131CRUNCH_PROGS_usr.sbin+= zdb
132.endif
133
134# crunchgen does not like C++ programs; this should be fixed someday
135# CRUNCH_PROGS+= devd
136
137CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma
138.if ${MK_ZFS} != "no"
139CRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt
140CRUNCH_LIBS_zfs+=	${LIBBE} \
141			${LIBZPOOL} \
142			${LIBZFS} \
143			${LIBZUTIL} \
144			${LIBZFS_CORE} \
145			${LIBZFSBOOTENV} \
146			${LIBICP_RESCUE} \
147			${LIBNVPAIR}
148CRUNCH_LIBS_bectl+=	${CRUNCH_LIBS_zfs}
149CRUNCH_LIBS_zpool+=	${CRUNCH_LIBS_zfs}
150CRUNCH_LIBS_zdb+=	${CRUNCH_LIBS_zfs} ${LIBZDB}
151CRUNCH_LIBS_zfsbootcfg+=${LIBZFSBOOTENV} \
152			${LIBZPOOL} \
153			${LIBZFS} \
154			${LIBZUTIL} \
155			${LIBZFS_CORE} \
156			${LIBICP_RESCUE} \
157			${LIBNVPAIR}
158.else
159# liblzma needs pthread
160CRUNCH_LIBS+= -lpthread
161.endif
162CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv
163.if ${MK_OPENSSL} == "no"
164CRUNCH_LIBS+= -lmd
165.endif
166CRUNCH_LIBS+= -lmt -lsbuf -lufs -lz
167
168.if ${MACHINE_CPUARCH} == "i386"
169CRUNCH_PROGS_sbin+= bsdlabel fdisk
170CRUNCH_ALIAS_bsdlabel= disklabel
171#CRUNCH_PROGS+= mount_smbfs
172#CRUNCH_LIBS+= -lsmb
173.endif
174
175.if ${MACHINE_CPUARCH} == "amd64"
176CRUNCH_PROGS_sbin+= bsdlabel fdisk
177CRUNCH_ALIAS_bsdlabel= disklabel
178.endif
179
180CRUNCH_SRCDIR_rtquery= ${SRCTOP}/sbin/routed/rtquery
181CRUNCH_SRCDIR_ipf= ${SRCTOP}/sbin/ipf/ipf
182.if ${MK_ZFS} != "no"
183CRUNCH_SRCDIR_zfs= ${SRCTOP}/cddl/sbin/zfs
184CRUNCH_SRCDIR_zpool= ${SRCTOP}/cddl/sbin/zpool
185CRUNCH_SRCDIR_zdb= ${SRCTOP}/cddl/usr.sbin/zdb
186.endif
187CRUNCH_ALIAS_reboot= fastboot halt fasthalt nextboot
188CRUNCH_ALIAS_restore= rrestore
189CRUNCH_ALIAS_dump= rdump
190CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
191CRUNCH_ALIAS_geom= glabel gpart
192CRUNCH_ALIAS_shutdown= poweroff
193
194# dhclient has historically been troublesome...
195CRUNCH_PROGS_sbin+= dhclient
196
197##################################################################
198# Programs from stock /usr/bin
199#
200CRUNCH_SRCDIRS+= usr.bin
201
202CRUNCH_PROGS_usr.bin= head mt sed tail tee
203
204CRUNCH_PROGS_usr.bin+= gzip
205CRUNCH_ALIAS_gzip= gunzip gzcat zcat
206
207CRUNCH_PROGS_usr.bin+= bzip2
208CRUNCH_ALIAS_bzip2= bunzip2 bzcat
209CRUNCH_LIBS+= -lbz2
210
211CRUNCH_PROGS_usr.bin+= less
212CRUNCH_ALIAS_less= more
213
214CRUNCH_PROGS_usr.bin+= xz
215CRUNCH_ALIAS_xz= unxz lzma unlzma xzcat lzcat
216
217CRUNCH_PROGS_usr.bin+= zstd
218CRUNCH_ALIAS_zstd= unzstd zstdcat zstdmt
219CRUNCH_LIBS+=	${LDADD_zstd}
220
221CRUNCH_PROGS_usr.bin+=	fetch
222CRUNCH_LIBS+=	-lfetch
223
224CRUNCH_PROGS_usr.bin+= tar
225CRUNCH_LIBS+= -larchive
226.if ${MK_OPENSSL} != "no"
227CRUNCH_LIBS+= -lssl -lcrypto
228.endif
229CRUNCH_LIBS+= -lmd
230
231.if ${MK_NETCAT} != "no"
232CRUNCH_PROGS_usr.bin+=	nc
233.endif
234
235.if ${MK_VI} != "no"
236CRUNCH_PROGS_usr.bin+= vi
237CRUNCH_ALIAS_vi= ex
238.endif
239
240CRUNCH_PROGS_usr.bin+= id
241CRUNCH_ALIAS_id= groups whoami
242
243##################################################################
244# Programs from stock /usr/sbin
245#
246CRUNCH_SRCDIRS+= usr.sbin
247
248CRUNCH_PROGS_usr.sbin+= chroot
249
250CRUNCH_PROGS_usr.sbin+= chown
251CRUNCH_ALIAS_chown= chgrp
252##################################################################
253
254CRUNCH_LIBS+=		${OBJTOP}/lib/libifconfig/libifconfig.a
255CRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
256
257CRUNCH_LIBS_ifconfig+=	${LIBNV}
258
259CRUNCH_LIBS+= -lm
260
261.if ${MK_ISCSI} != "no"
262CRUNCH_PROGS_usr.bin+=	iscsictl
263CRUNCH_PROGS_usr.sbin+=	iscsid
264
265CRUNCH_LIBS+=		${OBJTOP}/lib/libiscsiutil/libiscsiutil.a
266CRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libiscsiutil
267.endif
268
269.include <bsd.crunchgen.mk>
270.include <bsd.prog.mk>
271