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