xref: /freebsd/rescue/rescue/Makefile (revision fd6d4737)
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		\
952f161397SMarcel Moolenaar	fsirand gbde 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
1225673173eSEnji Cooper.if ${MK_ROUTED} != "no"
1235673173eSEnji CooperCRUNCH_PROGS_sbin+= routed rtquery
1245673173eSEnji Cooper.endif
1255673173eSEnji Cooper
12687820315SKip Macy.if ${MK_ZFS} != "no"
127830261e2SKyle EvansCRUNCH_PROGS_sbin+= bectl
12887820315SKip MacyCRUNCH_PROGS_sbin+= zfs
129ac4847e6SWarner LoshCRUNCH_PROGS_sbin+= zfsbootcfg
13087820315SKip MacyCRUNCH_PROGS_sbin+= zpool
1314c75e226SXin LICRUNCH_PROGS_usr.sbin+= zdb
13287820315SKip Macy.endif
1335433713cSDavid E. O'Brien
134884c25d1SGordon Tetlow# crunchgen does not like C++ programs; this should be fixed someday
135884c25d1SGordon Tetlow# CRUNCH_PROGS+= devd
136884c25d1SGordon Tetlow
13713916064SJohn BaldwinCRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma
13887820315SKip Macy.if ${MK_ZFS} != "no"
13982bebc79SBrooks DavisCRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt
1403aaed4cbSKonstantin BelousovCRUNCH_LIBS_zfs+=	${LIBBE} \
1413aaed4cbSKonstantin Belousov			${LIBZPOOL} \
1423aaed4cbSKonstantin Belousov			${LIBZFS} \
1435e4854cbSJohn Baldwin			${LIBZUTIL} \
1443aaed4cbSKonstantin Belousov			${LIBZFS_CORE} \
1453aaed4cbSKonstantin Belousov			${LIBZFSBOOTENV} \
1463aaed4cbSKonstantin Belousov			${LIBICP_RESCUE} \
1473aaed4cbSKonstantin Belousov			${LIBNVPAIR}
1483aaed4cbSKonstantin BelousovCRUNCH_LIBS_bectl+=	${CRUNCH_LIBS_zfs}
1493aaed4cbSKonstantin BelousovCRUNCH_LIBS_zpool+=	${CRUNCH_LIBS_zfs}
150a4e5e010SMartin MatuskaCRUNCH_LIBS_zdb+=	${CRUNCH_LIBS_zfs} ${LIBZDB}
151ac4847e6SWarner LoshCRUNCH_LIBS_zfsbootcfg+=${LIBZFSBOOTENV}
15253200025SRui Paulo.else
15353200025SRui Paulo# liblzma needs pthread
15482bebc79SBrooks DavisCRUNCH_LIBS+= -lpthread
15587820315SKip Macy.endif
15602b6306fSDimitry AndricCRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv
15702b6306fSDimitry Andric.if ${MK_OPENSSL} == "no"
15802b6306fSDimitry AndricCRUNCH_LIBS+= -lmd
15902b6306fSDimitry Andric.endif
16043518607SKenneth D. MerryCRUNCH_LIBS+= -lmt -lsbuf -lufs -lz
161884c25d1SGordon Tetlow
16225faff34SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
163fa4d25f5SEd MasteCRUNCH_PROGS_sbin+= bsdlabel fdisk
1649b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel
165237abf0cSDavide Italiano#CRUNCH_PROGS+= mount_smbfs
166237abf0cSDavide Italiano#CRUNCH_LIBS+= -lsmb
167884c25d1SGordon Tetlow.endif
168884c25d1SGordon Tetlow
16925faff34SWarner Losh.if ${MACHINE_CPUARCH} == "amd64"
1702f161397SMarcel MoolenaarCRUNCH_PROGS_sbin+= bsdlabel fdisk
1719b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel
172884c25d1SGordon Tetlow.endif
173884c25d1SGordon Tetlow
17423583802SWarner LoshCRUNCH_SRCDIR_rtquery= ${SRCTOP}/sbin/routed/rtquery
17523583802SWarner LoshCRUNCH_SRCDIR_ipf= ${SRCTOP}/sbin/ipf/ipf
17687820315SKip Macy.if ${MK_ZFS} != "no"
17723583802SWarner LoshCRUNCH_SRCDIR_zfs= ${SRCTOP}/cddl/sbin/zfs
17823583802SWarner LoshCRUNCH_SRCDIR_zpool= ${SRCTOP}/cddl/sbin/zpool
17923583802SWarner LoshCRUNCH_SRCDIR_zdb= ${SRCTOP}/cddl/usr.sbin/zdb
18087820315SKip Macy.endif
181fd6d4737SWarner LoshCRUNCH_ALIAS_reboot= fastboot halt fasthalt nextboot
182884c25d1SGordon TetlowCRUNCH_ALIAS_restore= rrestore
183884c25d1SGordon TetlowCRUNCH_ALIAS_dump= rdump
184884c25d1SGordon TetlowCRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
18508910321SRuslan ErmilovCRUNCH_ALIAS_geom= glabel gpart
1866a6050acSEnji CooperCRUNCH_ALIAS_shutdown= poweroff
187884c25d1SGordon Tetlow
188884c25d1SGordon Tetlow# dhclient has historically been troublesome...
189d4208689SBrooks DavisCRUNCH_PROGS_sbin+= dhclient
190884c25d1SGordon Tetlow
191884c25d1SGordon Tetlow##################################################################
192884c25d1SGordon Tetlow# Programs from stock /usr/bin
193884c25d1SGordon Tetlow#
194d60d0f81SGordon TetlowCRUNCH_SRCDIRS+= usr.bin
195884c25d1SGordon Tetlow
1964ab40004SEnji CooperCRUNCH_PROGS_usr.bin= head mt sed tail tee
197eb4e4048SYaroslav Tykhiy
1989a9ea25fSXin LICRUNCH_PROGS_usr.bin+= gzip
199884c25d1SGordon TetlowCRUNCH_ALIAS_gzip= gunzip gzcat zcat
200884c25d1SGordon Tetlow
201d60d0f81SGordon TetlowCRUNCH_PROGS_usr.bin+= bzip2
202884c25d1SGordon TetlowCRUNCH_ALIAS_bzip2= bunzip2 bzcat
203884c25d1SGordon TetlowCRUNCH_LIBS+= -lbz2
204884c25d1SGordon Tetlow
205e946bdbeSXin LICRUNCH_PROGS_usr.bin+= less
206e946bdbeSXin LICRUNCH_ALIAS_less= more
207e946bdbeSXin LI
2087fbeb03eSMartin MatuskaCRUNCH_PROGS_usr.bin+= xz
2097fbeb03eSMartin MatuskaCRUNCH_ALIAS_xz= unxz lzma unlzma xzcat lzcat
2107fbeb03eSMartin Matuska
211f831d936SBaptiste DaroussinCRUNCH_PROGS_usr.bin+= zstd
212f831d936SBaptiste DaroussinCRUNCH_ALIAS_zstd= unzstd zstdcat zstdmt
2135fead429SBryan DreweryCRUNCH_LIBS+=	${LDADD_zstd}
214f831d936SBaptiste Daroussin
2150f031350SJohn BaldwinCRUNCH_PROGS_usr.bin+=	fetch
2160f031350SJohn BaldwinCRUNCH_LIBS+=	-lfetch
2170f031350SJohn Baldwin
218cc7f9762SDavid E. O'BrienCRUNCH_PROGS_usr.bin+= tar
21902b6306fSDimitry AndricCRUNCH_LIBS+= -larchive
2203b495423STim Kientzle.if ${MK_OPENSSL} != "no"
2210f031350SJohn BaldwinCRUNCH_LIBS+= -lssl -lcrypto
2223b495423STim Kientzle.endif
22302b6306fSDimitry AndricCRUNCH_LIBS+= -lmd
224cc7f9762SDavid E. O'Brien
2254ab40004SEnji Cooper.if ${MK_NETCAT} != "no"
226f3e05661SEnji CooperCRUNCH_PROGS_usr.bin+=	nc
2274ab40004SEnji Cooper.endif
2284ab40004SEnji Cooper
229c50bf0f3SEnji Cooper.if ${MK_VI} != "no"
230d60d0f81SGordon TetlowCRUNCH_PROGS_usr.bin+= vi
231884c25d1SGordon TetlowCRUNCH_ALIAS_vi= ex
232c50bf0f3SEnji Cooper.endif
233884c25d1SGordon Tetlow
2347ad67863SDag-Erling SmørgravCRUNCH_PROGS_usr.bin+= id
2357ad67863SDag-Erling SmørgravCRUNCH_ALIAS_id= groups whoami
2367ad67863SDag-Erling Smørgrav
237884c25d1SGordon Tetlow##################################################################
238ad02aba6SDag-Erling Smørgrav# Programs from stock /usr/sbin
239ad02aba6SDag-Erling Smørgrav#
240ad02aba6SDag-Erling SmørgravCRUNCH_SRCDIRS+= usr.sbin
241ad02aba6SDag-Erling Smørgrav
24246839d12SEnji CooperCRUNCH_PROGS_usr.sbin+= chroot
243eb4e4048SYaroslav Tykhiy
244eb4e4048SYaroslav TykhiyCRUNCH_PROGS_usr.sbin+= chown
245eb4e4048SYaroslav TykhiyCRUNCH_ALIAS_chown= chgrp
24687820315SKip Macy##################################################################
247ad02aba6SDag-Erling Smørgrav
24894cba803SRyan MoellerCRUNCH_LIBS+=		${OBJTOP}/lib/libifconfig/libifconfig.a
24994cba803SRyan MoellerCRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
25094cba803SRyan Moeller
2513aaed4cbSKonstantin BelousovCRUNCH_LIBS_ifconfig+=	${LIBNV}
2523aaed4cbSKonstantin Belousov
2534d135bbdSJohn BaldwinCRUNCH_LIBS+= -lm
2544d135bbdSJohn Baldwin
25546839d12SEnji Cooper.if ${MK_ISCSI} != "no"
25646839d12SEnji CooperCRUNCH_PROGS_usr.bin+=	iscsictl
25746839d12SEnji CooperCRUNCH_PROGS_usr.sbin+=	iscsid
25863783933SJohn Baldwin
25963783933SJohn BaldwinCRUNCH_LIBS+=		${OBJTOP}/lib/libiscsiutil/libiscsiutil.a
26063783933SJohn BaldwinCRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libiscsiutil
26146839d12SEnji Cooper.endif
26246839d12SEnji Cooper
263169733f4SAdrian Chadd.include <bsd.crunchgen.mk>
264884c25d1SGordon Tetlow.include <bsd.prog.mk>
265