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