1 2.include <src.opts.mk> 3.include <bsd.linker.mk> 4 5PACKAGE=rescue 6MAN= 7MK_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. 11MK_PIE= no 12NO_SHARED= yes 13CRUNCH_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 18LDFLAGS+= -Wl,--allow-multiple-definition 19.endif 20 21PROG= rescue 22BINDIR?=/rescue 23 24# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh 25SCRIPTS= nextboot_FIXED 26SCRIPTSNAME_nextboot_FIXED= nextboot 27nextboot_FIXED: ../../sbin/reboot/nextboot.sh 28 sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 29CLEANFILES+= nextboot_FIXED 30 31SCRIPTS+= dhclient_FIXED 32SCRIPTSNAME_dhclient_FIXED= dhclient-script 33dhclient_FIXED: ../../sbin/dhclient/dhclient-script 34 sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} 35CLEANFILES+= dhclient_FIXED 36 37# The help which used to be here is now in mk/bsd.crunchgen.mk 38 39# Define Makefile variable RESCUE 40CRUNCH_BUILDOPTS+= -DRESCUE 41# Define compile-time RESCUE symbol when compiling components 42CRUNCH_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. 55CRUNCH_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# 63CRUNCH_SRCDIRS+= bin 64CRUNCH_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 68CRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -lelf -ltermcapw -lutil -lxo 69CRUNCH_BUILDTOOLS+= bin/sh 70 71# Additional options for specific programs 72CRUNCH_ALIAS_test= [ 73CRUNCH_ALIAS_sh= -sh 74# The -sh alias shouldn't appear in /rescue as a hard link 75CRUNCH_SUPPRESS_LINK_-sh= 1 76CRUNCH_ALIAS_ln= link 77CRUNCH_ALIAS_rm= unlink 78CRUNCH_ALIAS_ed= red 79CRUNCH_ALIAS_pkill= pgrep 80 81.if ${MK_TCSH} != "no" 82CRUNCH_PROGS_bin+= csh 83CRUNCH_ALIAS_csh= -csh tcsh -tcsh 84CRUNCH_BUILDTOOLS+= bin/csh 85CRUNCH_SUPPRESS_LINK_-csh= 1 86CRUNCH_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# 98CRUNCH_SRCDIRS+= sbin 99CRUNCH_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" 112CRUNCH_PROGS_sbin+= ccdconfig 113.endif 114 115.if ${MK_INET} != "no" || ${MK_INET6} != "no" 116CRUNCH_PROGS_sbin+= ping 117.endif 118 119.if ${MK_INET6_SUPPORT} != "no" 120CRUNCH_ALIAS_ping= ping6 121CRUNCH_PROGS_sbin+= rtsol 122.endif 123 124.if ${MK_IPFILTER} != "no" 125CRUNCH_PROGS_sbin+= ipf 126CRUNCH_LIBS_ipf+= ${LIBIPF} 127.endif 128 129.if ${MK_ROUTED} != "no" 130CRUNCH_PROGS_sbin+= routed rtquery 131.endif 132 133.if ${MK_ZFS} != "no" 134CRUNCH_PROGS_sbin+= bectl 135CRUNCH_PROGS_sbin+= zfs 136CRUNCH_PROGS_sbin+= zpool 137CRUNCH_PROGS_usr.sbin+= zdb 138.endif 139 140# crunchgen does not like C++ programs; this should be fixed someday 141# CRUNCH_PROGS+= devd 142 143CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma 144.if ${MK_ZFS} != "no" 145CRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt 146CRUNCH_LIBS_zfs+= ${LIBBE} \ 147 ${LIBZPOOL} \ 148 ${LIBZFS} \ 149 ${LIBZUTIL} \ 150 ${LIBZFS_CORE} \ 151 ${LIBZFSBOOTENV} \ 152 ${LIBICP_RESCUE} \ 153 ${LIBNVPAIR} 154CRUNCH_LIBS_bectl+= ${CRUNCH_LIBS_zfs} 155CRUNCH_LIBS_zpool+= ${CRUNCH_LIBS_zfs} 156CRUNCH_LIBS_zdb+= ${CRUNCH_LIBS_zfs} 157.else 158# liblzma needs pthread 159CRUNCH_LIBS+= -lpthread 160.endif 161CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv 162.if ${MK_OPENSSL} == "no" 163CRUNCH_LIBS+= -lmd 164.endif 165CRUNCH_LIBS+= -lmt -lsbuf -lufs -lz 166 167.if ${MACHINE_CPUARCH} == "i386" 168CRUNCH_PROGS_sbin+= bsdlabel fdisk 169CRUNCH_ALIAS_bsdlabel= disklabel 170#CRUNCH_PROGS+= mount_smbfs 171#CRUNCH_LIBS+= -lsmb 172.endif 173 174.if ${MACHINE_CPUARCH} == "amd64" 175CRUNCH_PROGS_sbin+= bsdlabel fdisk 176CRUNCH_ALIAS_bsdlabel= disklabel 177.endif 178 179CRUNCH_SRCDIR_rtquery= ${SRCTOP}/sbin/routed/rtquery 180CRUNCH_SRCDIR_ipf= ${SRCTOP}/sbin/ipf/ipf 181.if ${MK_ZFS} != "no" 182CRUNCH_SRCDIR_zfs= ${SRCTOP}/cddl/sbin/zfs 183CRUNCH_SRCDIR_zpool= ${SRCTOP}/cddl/sbin/zpool 184CRUNCH_SRCDIR_zdb= ${SRCTOP}/cddl/usr.sbin/zdb 185.endif 186CRUNCH_ALIAS_reboot= fastboot halt fasthalt 187CRUNCH_ALIAS_restore= rrestore 188CRUNCH_ALIAS_dump= rdump 189CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs 190CRUNCH_ALIAS_geom= glabel gpart 191CRUNCH_ALIAS_shutdown= poweroff 192 193# dhclient has historically been troublesome... 194CRUNCH_PROGS_sbin+= dhclient 195 196################################################################## 197# Programs from stock /usr/bin 198# 199CRUNCH_SRCDIRS+= usr.bin 200 201CRUNCH_PROGS_usr.bin= head mt sed tail tee 202 203CRUNCH_PROGS_usr.bin+= gzip 204CRUNCH_ALIAS_gzip= gunzip gzcat zcat 205 206CRUNCH_PROGS_usr.bin+= bzip2 207CRUNCH_ALIAS_bzip2= bunzip2 bzcat 208CRUNCH_LIBS+= -lbz2 209 210CRUNCH_PROGS_usr.bin+= less 211CRUNCH_ALIAS_less= more 212 213CRUNCH_PROGS_usr.bin+= xz 214CRUNCH_ALIAS_xz= unxz lzma unlzma xzcat lzcat 215 216CRUNCH_PROGS_usr.bin+= zstd 217CRUNCH_ALIAS_zstd= unzstd zstdcat zstdmt 218CRUNCH_LIBS+= ${LDADD_zstd} 219 220CRUNCH_PROGS_usr.bin+= fetch 221CRUNCH_LIBS+= -lfetch 222 223CRUNCH_PROGS_usr.bin+= tar 224CRUNCH_LIBS+= -larchive 225.if ${MK_OPENSSL} != "no" 226CRUNCH_LIBS+= -lssl -lcrypto 227.endif 228CRUNCH_LIBS+= -lmd 229 230.if ${MK_NETCAT} != "no" 231CRUNCH_PROGS_usr.bin+= nc 232.endif 233 234.if ${MK_VI} != "no" 235CRUNCH_PROGS_usr.bin+= vi 236CRUNCH_ALIAS_vi= ex 237.endif 238 239CRUNCH_PROGS_usr.bin+= id 240CRUNCH_ALIAS_id= groups whoami 241 242################################################################## 243# Programs from stock /usr/sbin 244# 245CRUNCH_SRCDIRS+= usr.sbin 246 247CRUNCH_PROGS_usr.sbin+= chroot 248 249CRUNCH_PROGS_usr.sbin+= chown 250CRUNCH_ALIAS_chown= chgrp 251################################################################## 252 253CRUNCH_LIBS+= ${OBJTOP}/lib/libifconfig/libifconfig.a 254CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig 255 256CRUNCH_LIBS_ifconfig+= ${LIBNV} 257 258CRUNCH_LIBS+= -lm 259 260.if ${MK_ISCSI} != "no" 261CRUNCH_PROGS_usr.bin+= iscsictl 262CRUNCH_PROGS_usr.sbin+= iscsid 263 264CRUNCH_LIBS+= ${OBJTOP}/lib/libiscsiutil/libiscsiutil.a 265CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libiscsiutil 266.endif 267 268.include <bsd.crunchgen.mk> 269.include <bsd.prog.mk> 270