xref: /freebsd/rescue/rescue/Makefile (revision d50f4136)
1884c25d1SGordon Tetlow
2c6063d0dSWarner Losh.include <src.opts.mk>
3653e8c11SDimitry Andric.include <bsd.linker.mk>
44af3fa14SWarner Losh
5ca832df4SGlen BarberPACKAGE=rescue
64af3fa14SWarner LoshMAN=
7d9ca85fcSRuslan ErmilovMK_SSP=	no
82eefc1d9SAlex Richardson# Static-PIE is not supported so we should not be linking against _pie.a libs.
92eefc1d9SAlex Richardson# This is also needed to avoid linking against sanitizer-instrumented libraries
102eefc1d9SAlex Richardson# since MK_ASAN/MK_UBSAN will instrument the .pieo object files.
112eefc1d9SAlex RichardsonMK_PIE=	no
1206cf1308SEd MasteNO_SHARED=	yes
132eefc1d9SAlex RichardsonCRUNCH_BUILDOPTS+=	MK_PIE=no NO_SHARED=yes
14e1fe3dbaSRuslan Ermilov
15458f4722SDimitry Andric# lld >= 16 became more strict about multiply defined symbols. Since there are
16458f4722SDimitry Andric# many of those in crunchgen'd programs, turn off the check.
17458f4722SDimitry Andric.if ${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 160000
18458f4722SDimitry AndricLDFLAGS+=	-Wl,--allow-multiple-definition
19458f4722SDimitry Andric.endif
20458f4722SDimitry Andric
21884c25d1SGordon TetlowPROG=	rescue
22884c25d1SGordon TetlowBINDIR?=/rescue
23884c25d1SGordon Tetlow
24d4208689SBrooks DavisSCRIPTS+= dhclient_FIXED
25d4208689SBrooks DavisSCRIPTSNAME_dhclient_FIXED= dhclient-script
26d4208689SBrooks Davisdhclient_FIXED: ../../sbin/dhclient/dhclient-script
27d4208689SBrooks Davis	sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
28d4208689SBrooks DavisCLEANFILES+= dhclient_FIXED
29884c25d1SGordon Tetlow
30169733f4SAdrian Chadd# The help which used to be here is now in mk/bsd.crunchgen.mk
31884c25d1SGordon Tetlow
32884c25d1SGordon Tetlow# Define Makefile variable RESCUE
33884c25d1SGordon TetlowCRUNCH_BUILDOPTS+= -DRESCUE
34884c25d1SGordon Tetlow# Define compile-time RESCUE symbol when compiling components
35884c25d1SGordon TetlowCRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE
36884c25d1SGordon Tetlow
374d938af0SGordon Tetlow# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk
384d938af0SGordon Tetlow# rather than incorporating rescue-specific logic into standard files.
39884c25d1SGordon Tetlow#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS}
40884c25d1SGordon Tetlow
41884c25d1SGordon Tetlow# Hackery:  'librescue' exists merely as a tool for appropriately
42884c25d1SGordon Tetlow# recompiling specific library entries.  We _know_ they're needed, and
43884c25d1SGordon Tetlow# regular archive searching creates ugly library ordering problems.
44884c25d1SGordon Tetlow# Easiest fix: tell the linker to include them into the executable
45884c25d1SGordon Tetlow# first, so they are guaranteed to override the regular lib entries.
46884c25d1SGordon Tetlow# Note that if 'librescue' hasn't been compiled, we'll just get the
47884c25d1SGordon Tetlow# regular lib entries from libc and friends.
48884c25d1SGordon TetlowCRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o
49884c25d1SGordon Tetlow
50884c25d1SGordon Tetlow###################################################################
51884c25d1SGordon Tetlow# Programs from stock /bin
52884c25d1SGordon Tetlow#
53884c25d1SGordon Tetlow# WARNING: Changing this list may require adjusting
54884c25d1SGordon Tetlow# /usr/include/paths.h as well!  You were warned!
55884c25d1SGordon Tetlow#
56d60d0f81SGordon TetlowCRUNCH_SRCDIRS+= bin
5739ae372dSDavid E. O'BrienCRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo 	\
5821be3b31SYaroslav Tykhiy	 ed expr getfacl hostname kenv kill ln ls mkdir mv	\
59e8b00d3dSXin LI	 pkill ps pwd realpath rm rmdir setfacl sh sleep stty	\
60e8b00d3dSXin LI	 sync test
61118eb647SEmmanuel VadotCRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -lelf -ltermcapw -lutil -lxo
62169733f4SAdrian ChaddCRUNCH_BUILDTOOLS+= bin/sh
63884c25d1SGordon Tetlow
64884c25d1SGordon Tetlow# Additional options for specific programs
65884c25d1SGordon TetlowCRUNCH_ALIAS_test= [
66884c25d1SGordon TetlowCRUNCH_ALIAS_sh= -sh
67884c25d1SGordon Tetlow# The -sh alias shouldn't appear in /rescue as a hard link
68884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-sh= 1
69884c25d1SGordon TetlowCRUNCH_ALIAS_ln= link
70884c25d1SGordon TetlowCRUNCH_ALIAS_rm= unlink
71884c25d1SGordon TetlowCRUNCH_ALIAS_ed= red
72eb4e4048SYaroslav TykhiyCRUNCH_ALIAS_pkill= pgrep
73eb4e4048SYaroslav Tykhiy
74e1fe3dbaSRuslan Ermilov.if ${MK_TCSH} != "no"
75d60d0f81SGordon TetlowCRUNCH_PROGS_bin+= csh
76884c25d1SGordon TetlowCRUNCH_ALIAS_csh= -csh tcsh -tcsh
77169733f4SAdrian ChaddCRUNCH_BUILDTOOLS+= bin/csh
78884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-csh= 1
79884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-tcsh= 1
80884c25d1SGordon Tetlow.endif
81884c25d1SGordon Tetlow
82884c25d1SGordon Tetlow###################################################################
83884c25d1SGordon Tetlow# Programs from standard /sbin
84884c25d1SGordon Tetlow#
85884c25d1SGordon Tetlow# WARNING: Changing this list may require adjusting
86884c25d1SGordon Tetlow# /usr/include/paths.h as well!  You were warned!
87884c25d1SGordon Tetlow#
8839ae372dSDavid E. O'Brien# Note that mdmfs have their own private 'pathnames.h'
89884c25d1SGordon Tetlow# headers in addition to the standard 'paths.h' header.
90884c25d1SGordon Tetlow#
91d60d0f81SGordon TetlowCRUNCH_SRCDIRS+= sbin
9293b09f58SKonstantin BelousovCRUNCH_PROGS_sbin= 						\
935673173eSEnji Cooper	camcontrol clri devfs dmesg dump			\
94cc795cb4SMarius Strobl	dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb		\
95*d50f4136SPoul-Henning Kamp	fsirand geom ifconfig init 				\
9639ae372dSDavid E. O'Brien	kldconfig kldload kldstat kldunload ldconfig 		\
97c89454cbSCraig Rodrigues	md5 mdconfig mdmfs mknod mount mount_cd9660		\
98a42ac676SAttilio Rao	mount_msdosfs mount_nfs mount_nullfs			\
99534046e3SRong-En Fan	mount_udf mount_unionfs newfs				\
100daf481f3SEd Maste	newfs_msdos nos-tun reboot				\
1014ab40004SEnji Cooper	restore rcorder route savecore		 		\
1026aae3517SGleb Smirnoff	shutdown swapon sysctl tunefs umount
10340353969SPoul-Henning Kamp
1045673173eSEnji Cooper.if ${MK_CCD} != "no"
1055673173eSEnji CooperCRUNCH_PROGS_sbin+= ccdconfig
1065673173eSEnji Cooper.endif
1075673173eSEnji Cooper
108daf481f3SEd Maste.if ${MK_INET} != "no" || ${MK_INET6} != "no"
109daf481f3SEd MasteCRUNCH_PROGS_sbin+= ping
110daf481f3SEd Maste.endif
111daf481f3SEd Maste
112e1fe3dbaSRuslan Ermilov.if ${MK_INET6_SUPPORT} != "no"
113d2624517SAlan SomersCRUNCH_ALIAS_ping= ping6
1144ab40004SEnji CooperCRUNCH_PROGS_sbin+= rtsol
11540353969SPoul-Henning Kamp.endif
11640353969SPoul-Henning Kamp
117e1fe3dbaSRuslan Ermilov.if ${MK_IPFILTER} != "no"
118cf4ee2c9SDarren ReedCRUNCH_PROGS_sbin+= ipf
119ae9f7248SBryan DreweryCRUNCH_LIBS_ipf+=	${LIBIPF}
1205433713cSDavid E. O'Brien.endif
1215673173eSEnji Cooper
12242acb16bSLexi Winter.if ${MK_IPFW} != "no"
12342acb16bSLexi WinterCRUNCH_PROGS_sbin+= ipfw
12442acb16bSLexi Winter.endif
12542acb16bSLexi Winter
12642acb16bSLexi Winter.if ${MK_PF} != "no"
12742acb16bSLexi WinterCRUNCH_PROGS_sbin+= pfctl
12842acb16bSLexi WinterCRUNCH_LIBS_pfctl+= ${LIBPFCTL} ${LIBNV}
12942acb16bSLexi Winter.endif
13042acb16bSLexi Winter
1315673173eSEnji Cooper.if ${MK_ROUTED} != "no"
1325673173eSEnji CooperCRUNCH_PROGS_sbin+= routed rtquery
1335673173eSEnji Cooper.endif
1345673173eSEnji Cooper
13587820315SKip Macy.if ${MK_ZFS} != "no"
136830261e2SKyle EvansCRUNCH_PROGS_sbin+= bectl
13787820315SKip MacyCRUNCH_PROGS_sbin+= zfs
138ac4847e6SWarner LoshCRUNCH_PROGS_sbin+= zfsbootcfg
13987820315SKip MacyCRUNCH_PROGS_sbin+= zpool
1404c75e226SXin LICRUNCH_PROGS_usr.sbin+= zdb
14187820315SKip Macy.endif
1425433713cSDavid E. O'Brien
143884c25d1SGordon Tetlow# crunchgen does not like C++ programs; this should be fixed someday
144884c25d1SGordon Tetlow# CRUNCH_PROGS+= devd
145884c25d1SGordon Tetlow
14613916064SJohn BaldwinCRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma
14707c6a62bSJohn BaldwinCRUNCH_LIBS_camcontrol+= ${LIBNVMF}
14887820315SKip Macy.if ${MK_ZFS} != "no"
14982bebc79SBrooks DavisCRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt
1503aaed4cbSKonstantin BelousovCRUNCH_LIBS_zfs+=	${LIBBE} \
1513aaed4cbSKonstantin Belousov			${LIBZPOOL} \
1523aaed4cbSKonstantin Belousov			${LIBZFS} \
1535e4854cbSJohn Baldwin			${LIBZUTIL} \
1543aaed4cbSKonstantin Belousov			${LIBZFS_CORE} \
1553aaed4cbSKonstantin Belousov			${LIBZFSBOOTENV} \
1563aaed4cbSKonstantin Belousov			${LIBICP_RESCUE} \
1573aaed4cbSKonstantin Belousov			${LIBNVPAIR}
1583aaed4cbSKonstantin BelousovCRUNCH_LIBS_bectl+=	${CRUNCH_LIBS_zfs}
1593aaed4cbSKonstantin BelousovCRUNCH_LIBS_zpool+=	${CRUNCH_LIBS_zfs}
160a4e5e010SMartin MatuskaCRUNCH_LIBS_zdb+=	${CRUNCH_LIBS_zfs} ${LIBZDB}
161bd45bbe4SWarner LoshCRUNCH_LIBS_zfsbootcfg+=${LIBZFSBOOTENV} \
162bd45bbe4SWarner Losh			${LIBZPOOL} \
163bd45bbe4SWarner Losh			${LIBZFS} \
164bd45bbe4SWarner Losh			${LIBZUTIL} \
165bd45bbe4SWarner Losh			${LIBZFS_CORE} \
166bd45bbe4SWarner Losh			${LIBICP_RESCUE} \
167bd45bbe4SWarner Losh			${LIBNVPAIR}
16853200025SRui Paulo.else
16953200025SRui Paulo# liblzma needs pthread
17082bebc79SBrooks DavisCRUNCH_LIBS+= -lpthread
17187820315SKip Macy.endif
17202b6306fSDimitry AndricCRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv
17302b6306fSDimitry Andric.if ${MK_OPENSSL} == "no"
17402b6306fSDimitry AndricCRUNCH_LIBS+= -lmd
17502b6306fSDimitry Andric.endif
17643518607SKenneth D. MerryCRUNCH_LIBS+= -lmt -lsbuf -lufs -lz
177884c25d1SGordon Tetlow
17825faff34SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
179fa4d25f5SEd MasteCRUNCH_PROGS_sbin+= bsdlabel fdisk
1809b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel
181237abf0cSDavide Italiano#CRUNCH_PROGS+= mount_smbfs
182237abf0cSDavide Italiano#CRUNCH_LIBS+= -lsmb
183884c25d1SGordon Tetlow.endif
184884c25d1SGordon Tetlow
18525faff34SWarner Losh.if ${MACHINE_CPUARCH} == "amd64"
1862f161397SMarcel MoolenaarCRUNCH_PROGS_sbin+= bsdlabel fdisk
1879b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel
188884c25d1SGordon Tetlow.endif
189884c25d1SGordon Tetlow
19023583802SWarner LoshCRUNCH_SRCDIR_rtquery= ${SRCTOP}/sbin/routed/rtquery
19123583802SWarner LoshCRUNCH_SRCDIR_ipf= ${SRCTOP}/sbin/ipf/ipf
19287820315SKip Macy.if ${MK_ZFS} != "no"
19323583802SWarner LoshCRUNCH_SRCDIR_zfs= ${SRCTOP}/cddl/sbin/zfs
19423583802SWarner LoshCRUNCH_SRCDIR_zpool= ${SRCTOP}/cddl/sbin/zpool
19523583802SWarner LoshCRUNCH_SRCDIR_zdb= ${SRCTOP}/cddl/usr.sbin/zdb
19687820315SKip Macy.endif
197fd6d4737SWarner LoshCRUNCH_ALIAS_reboot= fastboot halt fasthalt nextboot
198884c25d1SGordon TetlowCRUNCH_ALIAS_restore= rrestore
199884c25d1SGordon TetlowCRUNCH_ALIAS_dump= rdump
200884c25d1SGordon TetlowCRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
20108910321SRuslan ErmilovCRUNCH_ALIAS_geom= glabel gpart
2026a6050acSEnji CooperCRUNCH_ALIAS_shutdown= poweroff
203884c25d1SGordon Tetlow
204884c25d1SGordon Tetlow# dhclient has historically been troublesome...
205d4208689SBrooks DavisCRUNCH_PROGS_sbin+= dhclient
206884c25d1SGordon Tetlow
207884c25d1SGordon Tetlow##################################################################
208884c25d1SGordon Tetlow# Programs from stock /usr/bin
209884c25d1SGordon Tetlow#
210d60d0f81SGordon TetlowCRUNCH_SRCDIRS+= usr.bin
211884c25d1SGordon Tetlow
2124ab40004SEnji CooperCRUNCH_PROGS_usr.bin= head mt sed tail tee
213eb4e4048SYaroslav Tykhiy
2149a9ea25fSXin LICRUNCH_PROGS_usr.bin+= gzip
215884c25d1SGordon TetlowCRUNCH_ALIAS_gzip= gunzip gzcat zcat
216884c25d1SGordon Tetlow
217d60d0f81SGordon TetlowCRUNCH_PROGS_usr.bin+= bzip2
218884c25d1SGordon TetlowCRUNCH_ALIAS_bzip2= bunzip2 bzcat
219884c25d1SGordon TetlowCRUNCH_LIBS+= -lbz2
220884c25d1SGordon Tetlow
221e946bdbeSXin LICRUNCH_PROGS_usr.bin+= less
222e946bdbeSXin LICRUNCH_ALIAS_less= more
223e946bdbeSXin LI
2247fbeb03eSMartin MatuskaCRUNCH_PROGS_usr.bin+= xz
2257fbeb03eSMartin MatuskaCRUNCH_ALIAS_xz= unxz lzma unlzma xzcat lzcat
2267fbeb03eSMartin Matuska
227f831d936SBaptiste DaroussinCRUNCH_PROGS_usr.bin+= zstd
228f831d936SBaptiste DaroussinCRUNCH_ALIAS_zstd= unzstd zstdcat zstdmt
229ff6b71c2SJessica ClarkeCRUNCH_LIBS+=	-lprivatezstd
230f831d936SBaptiste Daroussin
2310f031350SJohn BaldwinCRUNCH_PROGS_usr.bin+=	fetch
2320f031350SJohn BaldwinCRUNCH_LIBS+=	-lfetch
2330f031350SJohn Baldwin
234cc7f9762SDavid E. O'BrienCRUNCH_PROGS_usr.bin+= tar
23502b6306fSDimitry AndricCRUNCH_LIBS+= -larchive
2363b495423STim Kientzle.if ${MK_OPENSSL} != "no"
2370f031350SJohn BaldwinCRUNCH_LIBS+= -lssl -lcrypto
2383b495423STim Kientzle.endif
23902b6306fSDimitry AndricCRUNCH_LIBS+= -lmd
240cc7f9762SDavid E. O'Brien
2414ab40004SEnji Cooper.if ${MK_NETCAT} != "no"
242f3e05661SEnji CooperCRUNCH_PROGS_usr.bin+=	nc
2434ab40004SEnji Cooper.endif
2444ab40004SEnji Cooper
245c50bf0f3SEnji Cooper.if ${MK_VI} != "no"
246d60d0f81SGordon TetlowCRUNCH_PROGS_usr.bin+= vi
247884c25d1SGordon TetlowCRUNCH_ALIAS_vi= ex
248c50bf0f3SEnji Cooper.endif
249884c25d1SGordon Tetlow
2507ad67863SDag-Erling SmørgravCRUNCH_PROGS_usr.bin+= id
2517ad67863SDag-Erling SmørgravCRUNCH_ALIAS_id= groups whoami
2527ad67863SDag-Erling Smørgrav
253884c25d1SGordon Tetlow##################################################################
254ad02aba6SDag-Erling Smørgrav# Programs from stock /usr/sbin
255ad02aba6SDag-Erling Smørgrav#
256ad02aba6SDag-Erling SmørgravCRUNCH_SRCDIRS+= usr.sbin
257ad02aba6SDag-Erling Smørgrav
25846839d12SEnji CooperCRUNCH_PROGS_usr.sbin+= chroot
259eb4e4048SYaroslav Tykhiy
260eb4e4048SYaroslav TykhiyCRUNCH_PROGS_usr.sbin+= chown
261eb4e4048SYaroslav TykhiyCRUNCH_ALIAS_chown= chgrp
26287820315SKip Macy##################################################################
263ad02aba6SDag-Erling Smørgrav
26494cba803SRyan MoellerCRUNCH_LIBS+=		${OBJTOP}/lib/libifconfig/libifconfig.a
26594cba803SRyan MoellerCRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
26694cba803SRyan Moeller
2673aaed4cbSKonstantin BelousovCRUNCH_LIBS_ifconfig+=	${LIBNV}
2683aaed4cbSKonstantin Belousov
2694d135bbdSJohn BaldwinCRUNCH_LIBS+= -lm
2704d135bbdSJohn Baldwin
27146839d12SEnji Cooper.if ${MK_ISCSI} != "no"
27246839d12SEnji CooperCRUNCH_PROGS_usr.bin+=	iscsictl
27346839d12SEnji CooperCRUNCH_PROGS_usr.sbin+=	iscsid
27463783933SJohn Baldwin
27563783933SJohn BaldwinCRUNCH_LIBS+=		${OBJTOP}/lib/libiscsiutil/libiscsiutil.a
27663783933SJohn BaldwinCRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libiscsiutil
27746839d12SEnji Cooper.endif
27846839d12SEnji Cooper
279169733f4SAdrian Chadd.include <bsd.crunchgen.mk>
280884c25d1SGordon Tetlow.include <bsd.prog.mk>
281