xref: /freebsd/rescue/rescue/Makefile (revision 315ee00f)
1#	@(#)Makefile	8.1 (Berkeley) 6/2/93
2
3.include <src.opts.mk>
4.include <bsd.linker.mk>
5
6PACKAGE=rescue
7MAN=
8MK_SSP=	no
9# Static-PIE is not supported so we should not be linking against _pie.a libs.
10# This is also needed to avoid linking against sanitizer-instrumented libraries
11# since MK_ASAN/MK_UBSAN will instrument the .pieo object files.
12MK_PIE=	no
13NO_SHARED=	yes
14CRUNCH_BUILDOPTS+=	MK_PIE=no NO_SHARED=yes
15
16# lld >= 16 became more strict about multiply defined symbols. Since there are
17# many of those in crunchgen'd programs, turn off the check.
18.if ${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 160000
19LDFLAGS+=	-Wl,--allow-multiple-definition
20.endif
21
22PROG=	rescue
23BINDIR?=/rescue
24
25# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh
26SCRIPTS= nextboot_FIXED
27SCRIPTSNAME_nextboot_FIXED= nextboot
28nextboot_FIXED: ../../sbin/reboot/nextboot.sh
29	sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
30CLEANFILES+= nextboot_FIXED
31
32SCRIPTS+= dhclient_FIXED
33SCRIPTSNAME_dhclient_FIXED= dhclient-script
34dhclient_FIXED: ../../sbin/dhclient/dhclient-script
35	sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
36CLEANFILES+= dhclient_FIXED
37
38# The help which used to be here is now in mk/bsd.crunchgen.mk
39
40# Define Makefile variable RESCUE
41CRUNCH_BUILDOPTS+= -DRESCUE
42# Define compile-time RESCUE symbol when compiling components
43CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE
44
45# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk
46# rather than incorporating rescue-specific logic into standard files.
47#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS}
48
49# Hackery:  'librescue' exists merely as a tool for appropriately
50# recompiling specific library entries.  We _know_ they're needed, and
51# regular archive searching creates ugly library ordering problems.
52# Easiest fix: tell the linker to include them into the executable
53# first, so they are guaranteed to override the regular lib entries.
54# Note that if 'librescue' hasn't been compiled, we'll just get the
55# regular lib entries from libc and friends.
56CRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o
57
58###################################################################
59# Programs from stock /bin
60#
61# WARNING: Changing this list may require adjusting
62# /usr/include/paths.h as well!  You were warned!
63#
64CRUNCH_SRCDIRS+= bin
65CRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo 	\
66	 ed expr getfacl hostname kenv kill ln ls mkdir mv	\
67	 pkill ps pwd realpath rm rmdir setfacl sh sleep stty	\
68	 sync test
69CRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -lelf -ltermcapw -lutil -lxo
70CRUNCH_BUILDTOOLS+= bin/sh
71
72# Additional options for specific programs
73CRUNCH_ALIAS_test= [
74CRUNCH_ALIAS_sh= -sh
75# The -sh alias shouldn't appear in /rescue as a hard link
76CRUNCH_SUPPRESS_LINK_-sh= 1
77CRUNCH_ALIAS_ln= link
78CRUNCH_ALIAS_rm= unlink
79CRUNCH_ALIAS_ed= red
80CRUNCH_ALIAS_pkill= pgrep
81
82.if ${MK_TCSH} != "no"
83CRUNCH_PROGS_bin+= csh
84CRUNCH_ALIAS_csh= -csh tcsh -tcsh
85CRUNCH_BUILDTOOLS+= bin/csh
86CRUNCH_SUPPRESS_LINK_-csh= 1
87CRUNCH_SUPPRESS_LINK_-tcsh= 1
88.endif
89
90###################################################################
91# Programs from standard /sbin
92#
93# WARNING: Changing this list may require adjusting
94# /usr/include/paths.h as well!  You were warned!
95#
96# Note that mdmfs have their own private 'pathnames.h'
97# headers in addition to the standard 'paths.h' header.
98#
99CRUNCH_SRCDIRS+= sbin
100CRUNCH_PROGS_sbin= 						\
101	camcontrol clri devfs dmesg dump			\
102	dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb		\
103	fsirand gbde geom ifconfig init 			\
104	kldconfig kldload kldstat kldunload ldconfig 		\
105	md5 mdconfig mdmfs mknod mount mount_cd9660		\
106	mount_msdosfs mount_nfs mount_nullfs			\
107	mount_udf mount_unionfs newfs				\
108	newfs_msdos nos-tun reboot				\
109	restore rcorder route savecore		 		\
110	shutdown swapon sysctl tunefs umount
111
112.if ${MK_CCD} != "no"
113CRUNCH_PROGS_sbin+= ccdconfig
114.endif
115
116.if ${MK_INET} != "no" || ${MK_INET6} != "no"
117CRUNCH_PROGS_sbin+= ping
118.endif
119
120.if ${MK_INET6_SUPPORT} != "no"
121CRUNCH_ALIAS_ping= ping6
122CRUNCH_PROGS_sbin+= rtsol
123.endif
124
125.if ${MK_IPFILTER} != "no"
126CRUNCH_PROGS_sbin+= ipf
127CRUNCH_LIBS_ipf+=	${LIBIPF}
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+= zpool
138CRUNCH_PROGS_usr.sbin+= zdb
139.endif
140
141# crunchgen does not like C++ programs; this should be fixed someday
142# CRUNCH_PROGS+= devd
143
144CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma
145.if ${MK_ZFS} != "no"
146CRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt
147CRUNCH_LIBS_zfs+=	${LIBBE} \
148			${LIBZPOOL} \
149			${LIBZFS} \
150			${LIBZUTIL} \
151			${LIBZFS_CORE} \
152			${LIBZFSBOOTENV} \
153			${LIBICP_RESCUE} \
154			${LIBNVPAIR}
155CRUNCH_LIBS_bectl+=	${CRUNCH_LIBS_zfs}
156CRUNCH_LIBS_zpool+=	${CRUNCH_LIBS_zfs}
157CRUNCH_LIBS_zdb+=	${CRUNCH_LIBS_zfs}
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
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