xref: /freebsd/rescue/rescue/Makefile (revision daf481f3)
1884c25d1SGordon Tetlow#$FreeBSD$
2884c25d1SGordon Tetlow#	@(#)Makefile	8.1 (Berkeley) 6/2/93
3884c25d1SGordon Tetlow
4c6063d0dSWarner Losh.include <src.opts.mk>
54af3fa14SWarner Losh
6ca832df4SGlen BarberPACKAGE=rescue
74af3fa14SWarner LoshMAN=
8d9ca85fcSRuslan ErmilovMK_SSP=	no
92eefc1d9SAlex Richardson# Static-PIE is not supported so we should not be linking against _pie.a libs.
102eefc1d9SAlex Richardson# This is also needed to avoid linking against sanitizer-instrumented libraries
112eefc1d9SAlex Richardson# since MK_ASAN/MK_UBSAN will instrument the .pieo object files.
122eefc1d9SAlex RichardsonMK_PIE=	no
1306cf1308SEd MasteNO_SHARED=	yes
142eefc1d9SAlex RichardsonCRUNCH_BUILDOPTS+=	MK_PIE=no NO_SHARED=yes
15e1fe3dbaSRuslan Ermilov
16884c25d1SGordon TetlowPROG=	rescue
17884c25d1SGordon TetlowBINDIR?=/rescue
18884c25d1SGordon Tetlow
19884c25d1SGordon Tetlow# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh
20884c25d1SGordon TetlowSCRIPTS= nextboot_FIXED
2104ddb211SJohn BaldwinSCRIPTSNAME_nextboot_FIXED= nextboot
22884c25d1SGordon Tetlownextboot_FIXED: ../../sbin/reboot/nextboot.sh
23884c25d1SGordon Tetlow	sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
24884c25d1SGordon TetlowCLEANFILES+= nextboot_FIXED
25884c25d1SGordon Tetlow
26d4208689SBrooks DavisSCRIPTS+= dhclient_FIXED
27d4208689SBrooks DavisSCRIPTSNAME_dhclient_FIXED= dhclient-script
28d4208689SBrooks Davisdhclient_FIXED: ../../sbin/dhclient/dhclient-script
29d4208689SBrooks Davis	sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET}
30d4208689SBrooks DavisCLEANFILES+= dhclient_FIXED
31884c25d1SGordon Tetlow
32169733f4SAdrian Chadd# The help which used to be here is now in mk/bsd.crunchgen.mk
33884c25d1SGordon Tetlow
34884c25d1SGordon Tetlow# Define Makefile variable RESCUE
35884c25d1SGordon TetlowCRUNCH_BUILDOPTS+= -DRESCUE
36884c25d1SGordon Tetlow# Define compile-time RESCUE symbol when compiling components
37884c25d1SGordon TetlowCRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE
38884c25d1SGordon Tetlow
394d938af0SGordon Tetlow# An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk
404d938af0SGordon Tetlow# rather than incorporating rescue-specific logic into standard files.
41884c25d1SGordon Tetlow#MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS}
42884c25d1SGordon Tetlow
43884c25d1SGordon Tetlow# Hackery:  'librescue' exists merely as a tool for appropriately
44884c25d1SGordon Tetlow# recompiling specific library entries.  We _know_ they're needed, and
45884c25d1SGordon Tetlow# regular archive searching creates ugly library ordering problems.
46884c25d1SGordon Tetlow# Easiest fix: tell the linker to include them into the executable
47884c25d1SGordon Tetlow# first, so they are guaranteed to override the regular lib entries.
48884c25d1SGordon Tetlow# Note that if 'librescue' hasn't been compiled, we'll just get the
49884c25d1SGordon Tetlow# regular lib entries from libc and friends.
50884c25d1SGordon TetlowCRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o
51884c25d1SGordon Tetlow
52884c25d1SGordon Tetlow###################################################################
53884c25d1SGordon Tetlow# Programs from stock /bin
54884c25d1SGordon Tetlow#
55884c25d1SGordon Tetlow# WARNING: Changing this list may require adjusting
56884c25d1SGordon Tetlow# /usr/include/paths.h as well!  You were warned!
57884c25d1SGordon Tetlow#
58d60d0f81SGordon TetlowCRUNCH_SRCDIRS+= bin
5939ae372dSDavid E. O'BrienCRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo 	\
6021be3b31SYaroslav Tykhiy	 ed expr getfacl hostname kenv kill ln ls mkdir mv	\
61e8b00d3dSXin LI	 pkill ps pwd realpath rm rmdir setfacl sh sleep stty	\
62e8b00d3dSXin LI	 sync test
63118eb647SEmmanuel VadotCRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -lelf -ltermcapw -lutil -lxo
64169733f4SAdrian ChaddCRUNCH_BUILDTOOLS+= bin/sh
65884c25d1SGordon Tetlow
66884c25d1SGordon Tetlow# Additional options for specific programs
67884c25d1SGordon TetlowCRUNCH_ALIAS_test= [
68884c25d1SGordon TetlowCRUNCH_ALIAS_sh= -sh
69884c25d1SGordon Tetlow# The -sh alias shouldn't appear in /rescue as a hard link
70884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-sh= 1
71884c25d1SGordon TetlowCRUNCH_ALIAS_ln= link
72884c25d1SGordon TetlowCRUNCH_ALIAS_rm= unlink
73884c25d1SGordon TetlowCRUNCH_ALIAS_ed= red
74eb4e4048SYaroslav TykhiyCRUNCH_ALIAS_pkill= pgrep
75eb4e4048SYaroslav Tykhiy
76e1fe3dbaSRuslan Ermilov.if ${MK_TCSH} != "no"
77d60d0f81SGordon TetlowCRUNCH_PROGS_bin+= csh
78884c25d1SGordon TetlowCRUNCH_ALIAS_csh= -csh tcsh -tcsh
79169733f4SAdrian ChaddCRUNCH_BUILDTOOLS+= bin/csh
80884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-csh= 1
81884c25d1SGordon TetlowCRUNCH_SUPPRESS_LINK_-tcsh= 1
82884c25d1SGordon Tetlow.endif
83884c25d1SGordon Tetlow
84884c25d1SGordon Tetlow###################################################################
85884c25d1SGordon Tetlow# Programs from standard /sbin
86884c25d1SGordon Tetlow#
87884c25d1SGordon Tetlow# WARNING: Changing this list may require adjusting
88884c25d1SGordon Tetlow# /usr/include/paths.h as well!  You were warned!
89884c25d1SGordon Tetlow#
9039ae372dSDavid E. O'Brien# Note that mdmfs have their own private 'pathnames.h'
91884c25d1SGordon Tetlow# headers in addition to the standard 'paths.h' header.
92884c25d1SGordon Tetlow#
93d60d0f81SGordon TetlowCRUNCH_SRCDIRS+= sbin
9493b09f58SKonstantin BelousovCRUNCH_PROGS_sbin= 						\
955673173eSEnji Cooper	camcontrol clri devfs dmesg dump			\
96cc795cb4SMarius Strobl	dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb		\
972f161397SMarcel Moolenaar	fsirand gbde geom ifconfig init 			\
9839ae372dSDavid E. O'Brien	kldconfig kldload kldstat kldunload ldconfig 		\
99c89454cbSCraig Rodrigues	md5 mdconfig mdmfs mknod mount mount_cd9660		\
100a42ac676SAttilio Rao	mount_msdosfs mount_nfs mount_nullfs			\
101534046e3SRong-En Fan	mount_udf mount_unionfs newfs				\
102daf481f3SEd Maste	newfs_msdos nos-tun reboot				\
1034ab40004SEnji Cooper	restore rcorder route savecore		 		\
1046aae3517SGleb Smirnoff	shutdown swapon sysctl tunefs umount
10540353969SPoul-Henning Kamp
1065673173eSEnji Cooper.if ${MK_CCD} != "no"
1075673173eSEnji CooperCRUNCH_PROGS_sbin+= ccdconfig
1085673173eSEnji Cooper.endif
1095673173eSEnji Cooper
110daf481f3SEd Maste.if ${MK_INET} != "no" || ${MK_INET6} != "no"
111daf481f3SEd MasteCRUNCH_PROGS_sbin+= ping
112daf481f3SEd Maste.endif
113daf481f3SEd Maste
114e1fe3dbaSRuslan Ermilov.if ${MK_INET6_SUPPORT} != "no"
115d2624517SAlan SomersCRUNCH_ALIAS_ping= ping6
1164ab40004SEnji CooperCRUNCH_PROGS_sbin+= rtsol
11740353969SPoul-Henning Kamp.endif
11840353969SPoul-Henning Kamp
119e1fe3dbaSRuslan Ermilov.if ${MK_IPFILTER} != "no"
120cf4ee2c9SDarren ReedCRUNCH_PROGS_sbin+= ipf
121ae9f7248SBryan DreweryCRUNCH_LIBS_ipf+=	${LIBIPF}
1225433713cSDavid E. O'Brien.endif
1235673173eSEnji Cooper
1245673173eSEnji Cooper.if ${MK_ROUTED} != "no"
1255673173eSEnji CooperCRUNCH_PROGS_sbin+= routed rtquery
1265673173eSEnji Cooper.endif
1275673173eSEnji Cooper
12887820315SKip Macy.if ${MK_ZFS} != "no"
129830261e2SKyle EvansCRUNCH_PROGS_sbin+= bectl
13087820315SKip MacyCRUNCH_PROGS_sbin+= zfs
13187820315SKip MacyCRUNCH_PROGS_sbin+= zpool
1324c75e226SXin LICRUNCH_PROGS_usr.sbin+= zdb
13387820315SKip Macy.endif
1345433713cSDavid E. O'Brien
135884c25d1SGordon Tetlow# crunchgen does not like C++ programs; this should be fixed someday
136884c25d1SGordon Tetlow# CRUNCH_PROGS+= devd
137884c25d1SGordon Tetlow
138b158d4d7SBaptiste DaroussinCRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw_real -ldevstat -lipsec -llzma
13987820315SKip Macy.if ${MK_ZFS} != "no"
1404c75e226SXin LICRUNCH_LIBS+= -lavl -lzpool -lzfs_core -lzfs -lnvpair -lpthread -luutil -lumem
141e307eb94SToomas SoomeCRUNCH_LIBS+= -lbe -lzfsbootenv -lzutil -ltpool -lspl -licp_rescue
14253200025SRui Paulo.else
14353200025SRui Paulo# liblzma needs pthread
14453200025SRui PauloCRUNCH_LIBS+= -lpthread
14587820315SKip Macy.endif
14602b6306fSDimitry AndricCRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv
14702b6306fSDimitry Andric.if ${MK_OPENSSL} == "no"
14802b6306fSDimitry AndricCRUNCH_LIBS+= -lmd
14902b6306fSDimitry Andric.endif
15043518607SKenneth D. MerryCRUNCH_LIBS+= -lmt -lsbuf -lufs -lz
151884c25d1SGordon Tetlow
15225faff34SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
1532f161397SMarcel MoolenaarCRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk
1549b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel
155237abf0cSDavide Italiano#CRUNCH_PROGS+= mount_smbfs
156237abf0cSDavide Italiano#CRUNCH_LIBS+= -lsmb
157884c25d1SGordon Tetlow.endif
158884c25d1SGordon Tetlow
15925faff34SWarner Losh.if ${MACHINE_CPUARCH} == "amd64"
1602f161397SMarcel MoolenaarCRUNCH_PROGS_sbin+= bsdlabel fdisk
1619b6e332fSGordon TetlowCRUNCH_ALIAS_bsdlabel= disklabel
162884c25d1SGordon Tetlow.endif
163884c25d1SGordon Tetlow
16423583802SWarner LoshCRUNCH_SRCDIR_rtquery= ${SRCTOP}/sbin/routed/rtquery
16523583802SWarner LoshCRUNCH_SRCDIR_ipf= ${SRCTOP}/sbin/ipf/ipf
16687820315SKip Macy.if ${MK_ZFS} != "no"
16723583802SWarner LoshCRUNCH_SRCDIR_zfs= ${SRCTOP}/cddl/sbin/zfs
16823583802SWarner LoshCRUNCH_SRCDIR_zpool= ${SRCTOP}/cddl/sbin/zpool
16923583802SWarner LoshCRUNCH_SRCDIR_zdb= ${SRCTOP}/cddl/usr.sbin/zdb
17087820315SKip Macy.endif
171884c25d1SGordon TetlowCRUNCH_ALIAS_reboot= fastboot halt fasthalt
172884c25d1SGordon TetlowCRUNCH_ALIAS_restore= rrestore
173884c25d1SGordon TetlowCRUNCH_ALIAS_dump= rdump
174884c25d1SGordon TetlowCRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs
17508910321SRuslan ErmilovCRUNCH_ALIAS_geom= glabel gpart
1766a6050acSEnji CooperCRUNCH_ALIAS_shutdown= poweroff
177884c25d1SGordon Tetlow
178884c25d1SGordon Tetlow# dhclient has historically been troublesome...
179d4208689SBrooks DavisCRUNCH_PROGS_sbin+= dhclient
180884c25d1SGordon Tetlow
181884c25d1SGordon Tetlow##################################################################
182884c25d1SGordon Tetlow# Programs from stock /usr/bin
183884c25d1SGordon Tetlow#
184d60d0f81SGordon TetlowCRUNCH_SRCDIRS+= usr.bin
185884c25d1SGordon Tetlow
1864ab40004SEnji CooperCRUNCH_PROGS_usr.bin= head mt sed tail tee
187eb4e4048SYaroslav Tykhiy
1889a9ea25fSXin LICRUNCH_PROGS_usr.bin+= gzip
189884c25d1SGordon TetlowCRUNCH_ALIAS_gzip= gunzip gzcat zcat
190884c25d1SGordon Tetlow
191d60d0f81SGordon TetlowCRUNCH_PROGS_usr.bin+= bzip2
192884c25d1SGordon TetlowCRUNCH_ALIAS_bzip2= bunzip2 bzcat
193884c25d1SGordon TetlowCRUNCH_LIBS+= -lbz2
194884c25d1SGordon Tetlow
195e946bdbeSXin LICRUNCH_PROGS_usr.bin+= less
196e946bdbeSXin LICRUNCH_ALIAS_less= more
197e946bdbeSXin LI
1987fbeb03eSMartin MatuskaCRUNCH_PROGS_usr.bin+= xz
1997fbeb03eSMartin MatuskaCRUNCH_ALIAS_xz= unxz lzma unlzma xzcat lzcat
2007fbeb03eSMartin Matuska
201f831d936SBaptiste DaroussinCRUNCH_PROGS_usr.bin+= zstd
202f831d936SBaptiste DaroussinCRUNCH_ALIAS_zstd= unzstd zstdcat zstdmt
2035fead429SBryan DreweryCRUNCH_LIBS+=	${LDADD_zstd}
204f831d936SBaptiste Daroussin
205cc7f9762SDavid E. O'BrienCRUNCH_PROGS_usr.bin+= tar
20602b6306fSDimitry AndricCRUNCH_LIBS+= -larchive
2073b495423STim Kientzle.if ${MK_OPENSSL} != "no"
2083b495423STim KientzleCRUNCH_LIBS+= -lcrypto
2093b495423STim Kientzle.endif
21002b6306fSDimitry AndricCRUNCH_LIBS+= -lmd
211cc7f9762SDavid E. O'Brien
2124ab40004SEnji Cooper.if ${MK_NETCAT} != "no"
213f3e05661SEnji CooperCRUNCH_PROGS_usr.bin+=	nc
2144ab40004SEnji Cooper.endif
2154ab40004SEnji Cooper
216c50bf0f3SEnji Cooper.if ${MK_VI} != "no"
217d60d0f81SGordon TetlowCRUNCH_PROGS_usr.bin+= vi
218884c25d1SGordon TetlowCRUNCH_ALIAS_vi= ex
219c50bf0f3SEnji Cooper.endif
220884c25d1SGordon Tetlow
2217ad67863SDag-Erling SmørgravCRUNCH_PROGS_usr.bin+= id
2227ad67863SDag-Erling SmørgravCRUNCH_ALIAS_id= groups whoami
2237ad67863SDag-Erling Smørgrav
224884c25d1SGordon Tetlow##################################################################
225ad02aba6SDag-Erling Smørgrav# Programs from stock /usr/sbin
226ad02aba6SDag-Erling Smørgrav#
227ad02aba6SDag-Erling SmørgravCRUNCH_SRCDIRS+= usr.sbin
228ad02aba6SDag-Erling Smørgrav
22946839d12SEnji CooperCRUNCH_PROGS_usr.sbin+= chroot
230eb4e4048SYaroslav Tykhiy
231eb4e4048SYaroslav TykhiyCRUNCH_PROGS_usr.sbin+= chown
232eb4e4048SYaroslav TykhiyCRUNCH_ALIAS_chown= chgrp
23387820315SKip Macy##################################################################
234ad02aba6SDag-Erling Smørgrav
23594cba803SRyan MoellerCRUNCH_LIBS+=		${OBJTOP}/lib/libifconfig/libifconfig.a
23694cba803SRyan MoellerCRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
23794cba803SRyan Moeller
2384d135bbdSJohn BaldwinCRUNCH_LIBS+= -lm
2394d135bbdSJohn Baldwin
24046839d12SEnji Cooper.if ${MK_ISCSI} != "no"
24146839d12SEnji CooperCRUNCH_PROGS_usr.bin+=	iscsictl
24246839d12SEnji CooperCRUNCH_PROGS_usr.sbin+=	iscsid
24363783933SJohn Baldwin
24463783933SJohn BaldwinCRUNCH_LIBS+=		${OBJTOP}/lib/libiscsiutil/libiscsiutil.a
24563783933SJohn BaldwinCRUNCH_BUILDOPTS+=	CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libiscsiutil
24646839d12SEnji Cooper.endif
24746839d12SEnji Cooper
248169733f4SAdrian Chadd.include <bsd.crunchgen.mk>
249884c25d1SGordon Tetlow.include <bsd.prog.mk>
250