130aaff11SWarner Losh.PATH: ${.CURDIR}/../../include 230aaff11SWarner Losh 37e35117eSCy Schubert# XXX We need to include this to avoid installing MIT KRB5 includes on 47e35117eSCy Schubert# XXX Heimdal systems. Remove the following line when Heimdal is finally 57e35117eSCy Schubert# XXX removed. 67e35117eSCy Schubert.include <src.opts.mk> 77e35117eSCy Schubert 81c62f923SWarner LoshLIB= egacy 9c2774610SDavid E. O'BrienSRC= 10162ae9c8SAlex RichardsonINCSGROUPS= INCS SYSINCS CASPERINC UFSINCS FFSINCS MSDOSFSINCS DISKINCS 117ec1ec4fSAlex RichardsonINCSGROUPS+= MACHINESYSINCS RPCINCS 127e35117eSCy Schubert.if ${MK_MITKRB5} != "no" 137e35117eSCy SchubertINCSGROUPS+= EDITINC K5GSSRPCINC GSSAPIINC 147e35117eSCy SchubertINCSGROUPS+= K5GSSAPIINC K52GSSAPIINC KRB5INC 157e35117eSCy Schubert.endif 1630aaff11SWarner LoshINCS= 1730aaff11SWarner Losh 18d80f1dd1SJilles TjoelkerSYSINCSDIR= ${INCLUDEDIR}/sys 19d5f4dd1bSMariusz ZaborskiCASPERINCDIR= ${INCLUDEDIR}/casper 20162ae9c8SAlex Richardson# Also add ufs/ffs/msdosfs/disk headers to allow building makefs as a bootstrap tool 21162ae9c8SAlex RichardsonUFSINCSDIR= ${INCLUDEDIR}/ufs/ufs 22162ae9c8SAlex RichardsonFFSINCSDIR= ${INCLUDEDIR}/ufs/ffs 23162ae9c8SAlex RichardsonMSDOSFSINCSDIR= ${INCLUDEDIR}/fs/msdosfs 24162ae9c8SAlex RichardsonDISKINCSDIR= ${INCLUDEDIR}/sys/disk 257ec1ec4fSAlex RichardsonMACHINESYSINCSDIR= ${INCLUDEDIR}/machine 267ec1ec4fSAlex RichardsonRPCINCSDIR= ${INCLUDEDIR}/rpc 277e35117eSCy Schubert.if ${MK_MITKRB5} != "no" 287e35117eSCy SchubertEDITINCDIR= ${INCLUDEDIR}/edit/readline 297e35117eSCy SchubertK5GSSRPCINCDIR= ${INCLUDEDIR}/gssrpc 307e35117eSCy SchubertGSSAPIINCDIR= ${INCLUDEDIR}/gssapi 317e35117eSCy SchubertK5GSSAPIINCDIR= ${INCLUDEDIR}/gssapi_krb5 327e35117eSCy SchubertK52GSSAPIINCDIR=${INCLUDEDIR}/gssapi_krb5/gssapi 337e35117eSCy SchubertKRB5INCDIR= ${INCLUDEDIR}/krb5 347e35117eSCy SchubertKDB5INCDIR= ${INCLUDEDIR}/kdb5 357e35117eSCy SchubertKADM5INCDIR= ${INCLUDEDIR}/kadm5 367e35117eSCy Schubert.endif 37d80f1dd1SJilles Tjoelker 3830aaff11SWarner LoshBOOTSTRAPPING?= 0 3930aaff11SWarner Losh 407ec1ec4fSAlex Richardson 417ec1ec4fSAlex Richardson.if ${.MAKE.OS} == "Darwin" 427ec1ec4fSAlex Richardson_XCODE_ROOT!=xcode-select -p 437ec1ec4fSAlex Richardson# since macOS 10.14 C headers are no longer installed in /usr but only 447ec1ec4fSAlex Richardson# provided via the SDK 457ec1ec4fSAlex Richardson.if ${_XCODE_ROOT} == "/Library/Developer/CommandLineTools" 467ec1ec4fSAlex Richardson# Only command line tools installed -> host headers are in the SDKs directory 477ec1ec4fSAlex Richardson_MACOS_SDK_DIR=${_XCODE_ROOT}/SDKs/MacOSX.sdk/ 487ec1ec4fSAlex Richardson.else 497ec1ec4fSAlex Richardson# Full XCode installed -> host headers are below Platforms/MacOSX.platform 507ec1ec4fSAlex Richardson_MACOS_SDK_DIR=${_XCODE_ROOT}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk 517ec1ec4fSAlex Richardson.endif 527ec1ec4fSAlex RichardsonHOST_INCLUDE_ROOT=${_MACOS_SDK_DIR}/usr/include 537ec1ec4fSAlex Richardson.if !exists(${HOST_INCLUDE_ROOT}/stdio.h) 546f6fbfa3SEd Maste.error You must install the macOS SDK (try xcode-select --install) 557ec1ec4fSAlex Richardson.endif 567ec1ec4fSAlex Richardson.else 577ec1ec4fSAlex RichardsonHOST_INCLUDE_ROOT=/usr/include 587ec1ec4fSAlex Richardson.endif 597ec1ec4fSAlex Richardson 607ec1ec4fSAlex Richardson# Allow building libc-internal files (also on non-FreeBSD hosts) 617ec1ec4fSAlex RichardsonCFLAGS+= -I${.CURDIR}/libc-bootstrap 627ec1ec4fSAlex Richardson# Symbol versioning is not required for -legacy (and macOS bootstrap) 637ec1ec4fSAlex RichardsonMK_SYMVER= no 647ec1ec4fSAlex Richardson 657ec1ec4fSAlex Richardson_WITH_PWCACHEDB!= grep -c pwcache_groupdb ${HOST_INCLUDE_ROOT}/grp.h || true 6679626055SBrooks Davis.if ${_WITH_PWCACHEDB} == 0 6779626055SBrooks Davis.PATH: ${.CURDIR}/../../contrib/libc-pwcache 687ec1ec4fSAlex RichardsonCFLAGS.pwcache.c+= -I${.CURDIR}/../../contrib/libc-pwcache 6979626055SBrooks DavisSRCS+= pwcache.c 7079626055SBrooks Davis.endif 7179626055SBrooks Davis 727ec1ec4fSAlex Richardson_WITH_STRSVIS!= grep -c strsvis ${HOST_INCLUDE_ROOT}/vis.h 2>/dev/null || true 7379626055SBrooks Davis.if ${_WITH_STRSVIS} == 0 7479626055SBrooks Davis.PATH: ${.CURDIR}/../../contrib/libc-vis 757ec1ec4fSAlex RichardsonINCS+= vis.h 767ec1ec4fSAlex RichardsonSRCS+= vis.c unvis.c 77a5252831SAlex RichardsonCFLAGS.vis.c+= -I${.CURDIR}/../../contrib/libc-vis -DHAVE_VIS=0 -DHAVE_SVIS=0 78a5252831SAlex RichardsonCFLAGS.unvis.c+= -I${.CURDIR}/../../contrib/libc-vis -DHAVE_VIS=0 -DHAVE_SVIS=0 7979626055SBrooks Davis.endif 8079626055SBrooks Davis 817ec1ec4fSAlex Richardson_WITH_REALLOCARRAY!= grep -c reallocarray ${HOST_INCLUDE_ROOT}/stdlib.h || true 828e7e3163SDimitry Andric.if ${_WITH_REALLOCARRAY} == 0 838e7e3163SDimitry Andric.PATH: ${.CURDIR}/../../lib/libc/stdlib 848e7e3163SDimitry AndricINCS+= stdlib.h 858e7e3163SDimitry AndricSRCS+= reallocarray.c 868e7e3163SDimitry Andric.endif 878e7e3163SDimitry Andric 88c5e54e56SEd Maste.if exists(${HOST_INCLUDE_ROOT}/sys/stat.h) 897ec1ec4fSAlex Richardson_WITH_UTIMENS!= grep -c utimensat ${HOST_INCLUDE_ROOT}/sys/stat.h || true 90c5e54e56SEd Maste.else 91c5e54e56SEd Maste_WITH_UTIMENS= 0 92c5e54e56SEd Maste.endif 93d80f1dd1SJilles Tjoelker.if ${_WITH_UTIMENS} == 0 94d80f1dd1SJilles TjoelkerSYSINCS+= stat.h 95d80f1dd1SJilles TjoelkerSRCS+= futimens.c utimensat.c 96d80f1dd1SJilles Tjoelker.endif 97d80f1dd1SJilles Tjoelker 98ac6b2b43SJohn Baldwin_WITH_EXPLICIT_BZERO!= cat ${HOST_INCLUDE_ROOT}/strings.h ${HOST_INCLUDE_ROOT}/string.h | grep -c explicit_bzero || true 998d14ced6SAlex Richardson.if ${_WITH_EXPLICIT_BZERO} == 0 1007ec1ec4fSAlex Richardson# .PATH: ${SRCTOP}/sys/libkern 1017ec1ec4fSAlex Richardson# Adding sys/libkern to .PATH breaks building the cross-build compat library 1027ec1ec4fSAlex Richardson# since that attempts to build strlcpy.c from libc and adding libkern here will 1037ec1ec4fSAlex Richardson# cause it to pick the file from libkern instead (which won't compile). 1047ec1ec4fSAlex Richardson# Avoid modifying .PATH by creating a copy in the build directory instead. 1057ec1ec4fSAlex Richardsonexplicit_bzero.c: ${SRCTOP}/sys/libkern/explicit_bzero.c 1067ec1ec4fSAlex Richardson cp ${.ALLSRC} ${.TARGET} 1077ec1ec4fSAlex RichardsonCLEANFILES+= explicit_bzero.c 1088d14ced6SAlex RichardsonINCS+= strings.h 1098d14ced6SAlex RichardsonSRCS+= explicit_bzero.c 1108d14ced6SAlex Richardson.endif 1118d14ced6SAlex Richardson 1125425ba83SKa Ho Ng_WITH_FSPACECTL!= grep -c fspacectl ${HOST_INCLUDE_ROOT}/fcntl.h || true 1135425ba83SKa Ho Ng.if ${_WITH_FSPACECTL} == 0 1145425ba83SKa Ho NgINCS+= fcntl.h 1155425ba83SKa Ho NgSRCS+= fspacectl.c 1165425ba83SKa Ho Ng.endif 1177ec1ec4fSAlex Richardson 1187ec1ec4fSAlex Richardson.if exists(${HOST_INCLUDE_ROOT}/capsicum_helpers.h) 1197ec1ec4fSAlex Richardson_WITH_CAPH_ENTER!= grep -c caph_enter ${HOST_INCLUDE_ROOT}/capsicum_helpers.h || true 1207ec1ec4fSAlex Richardson_WITH_CAPH_RIGHTS_LIMIT!= grep -c caph_rights_limit ${HOST_INCLUDE_ROOT}/capsicum_helpers.h || true 1213b7e9bfeSAlex Richardson.endif 122fbe12f20SMark Johnston.if !defined(_WITH_CAPH_ENTER) || ${_WITH_CAPH_ENTER} == 0 || ${_WITH_CAPH_RIGHTS_LIMIT} == 0 1233b7e9bfeSAlex Richardson.PATH: ${SRCTOP}/lib/libcapsicum 1243b7e9bfeSAlex RichardsonINCS+= capsicum_helpers.h 1253b7e9bfeSAlex Richardson.PATH: ${SRCTOP}/lib/libcasper/libcasper 1263b7e9bfeSAlex RichardsonINCS+= libcasper.h 1273b7e9bfeSAlex Richardson.endif 1283b7e9bfeSAlex Richardson 1297ec1ec4fSAlex Richardson# rpcgen should build against the source tree rpc/types.h and not the host. 1307ec1ec4fSAlex Richardson# This is especially important on non-FreeBSD systems where the types may 1317ec1ec4fSAlex Richardson# not match. 1327ec1ec4fSAlex RichardsonRPCINCS+= ${SRCTOP}/sys/rpc/types.h 1337ec1ec4fSAlex Richardson 1347ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/mpool.h 1357ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/ndbm.h 1367ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/err.h 1377ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/stringlist.h 1387ec1ec4fSAlex Richardson 1397ec1ec4fSAlex Richardson# Needed to build arc4random.c 1407ec1ec4fSAlex RichardsonINCSGROUPS+= CHACHA20INCS 1417ec1ec4fSAlex RichardsonCHACHA20INCSDIR= ${INCLUDEDIR}/crypto/chacha20 1427ec1ec4fSAlex RichardsonCHACHA20INCS+= ${SRCTOP}/sys/crypto/chacha20/_chacha.h \ 1437ec1ec4fSAlex Richardson ${SRCTOP}/sys/crypto/chacha20/chacha.h 1447ec1ec4fSAlex Richardson 145db98bc2cSSimon J. Gerraty.if ${MACHINE} == "host" 146db98bc2cSSimon J. Gerraty_host_arch= ${_HOST_ARCH} 147f9df6097SSimon J. Gerraty.elif ${MACHINE} == "host32" 148f9df6097SSimon J. Gerraty_host_arch= ${_HOST_ARCH32} 149db98bc2cSSimon J. Gerraty.else 1507ec1ec4fSAlex Richardson_host_arch=${MACHINE} 151db98bc2cSSimon J. Gerraty.endif 1527ec1ec4fSAlex Richardson.if ${_host_arch} == "x86_64" 1537ec1ec4fSAlex Richardson# bmake on Linux/mac often prints that instead of amd64 1547ec1ec4fSAlex Richardson_host_arch=amd64 1558c22b9f3SKyle Evans.elif ${_host_arch} == "aarch64" 1568c22b9f3SKyle Evans# Linux calls arm64, aarch64, across the board 1578c22b9f3SKyle Evans_host_arch=arm64 1587b81e6c7SJustin Hibbits.elif ${_host_arch:Mppc*} 1597b81e6c7SJustin Hibbits_host_arch=powerpc 1607ec1ec4fSAlex Richardson.endif 1617ec1ec4fSAlex Richardson.if ${_host_arch} == "unknown" 1627ec1ec4fSAlex Richardson# HACK: If MACHINE is unknown, assume we are building on x86 1637ec1ec4fSAlex Richardson_host_arch=amd64 1647ec1ec4fSAlex Richardson.endif 1657ec1ec4fSAlex RichardsonMACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/elf.h 1667ec1ec4fSAlex Richardson.if ${_host_arch} == "amd64" || ${_host_arch} == "i386" 1677ec1ec4fSAlex RichardsonINCSGROUPS+= X86INCS 1687ec1ec4fSAlex RichardsonX86INCSDIR= ${INCLUDEDIR}/x86 1697ec1ec4fSAlex RichardsonX86INCS+= ${SRCTOP}/sys/x86/include/elf.h 1707ec1ec4fSAlex Richardson.endif 1717ec1ec4fSAlex Richardson 1727ec1ec4fSAlex Richardson# needed for btxld: 1737ec1ec4fSAlex RichardsonMACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/exec.h 1747ec1ec4fSAlex RichardsonMACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/reloc.h 1757ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/a.out.h 1767ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/nlist.h 1777ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/imgact_aout.h 1787ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/nlist_aout.h 1797ec1ec4fSAlex Richardson 1803b073d2eSBrooks Davis# macOS's bitstring lacks FreeBSD-specific additions used by makefs's ZFS code 1813b073d2eSBrooks Davis# and Linux doesn't have it at all. Older FreeBSD versions lack recent 1823b073d2eSBrooks Davis# additions. 1833b073d2eSBrooks DavisINCS+= ${SRCTOP}/include/bitstring.h 1843b073d2eSBrooks DavisSYSINCS+= ${SRCTOP}/sys/sys/bitstring.h 185ed845580SAlex Richardson 186ed845580SAlex Richardson.if ${.MAKE.OS} != "FreeBSD" 187ed845580SAlex Richardson.PATH: ${.CURDIR}/cross-build 188e9ba1fd5SJessica Clarke 189e9ba1fd5SJessica Clarke# Needed by our sys/types.h wrapper 190e9ba1fd5SJessica ClarkeSYSINCS+= ${SRCTOP}/sys/sys/bitcount.h 191e9ba1fd5SJessica Clarke 1927ec1ec4fSAlex Richardson# dbopen() behaves differently on Linux and FreeBSD so we ensure that we 1937ec1ec4fSAlex Richardson# bootstrap the FreeBSD db code. The cross-build headers #define dbopen() to 1947ec1ec4fSAlex Richardson# __freebsd_dbopen() so that we don't ever use the host version 1957ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/db.h 1967ec1ec4fSAlex RichardsonLIBC_SRCTOP= ${SRCTOP}/lib/libc/ 1977ec1ec4fSAlex Richardson.include "${LIBC_SRCTOP}/db/Makefile.inc" 1987ec1ec4fSAlex Richardson# Do the same as we did for dbopen() for getopt() on since it's not compatible 1997ec1ec4fSAlex Richardson# on Linux (and to avoid surprises also compile the FreeBSD code on macOS) 2007ec1ec4fSAlex Richardson.PATH: ${LIBC_SRCTOP}/stdlib 2017ec1ec4fSAlex RichardsonSRCS+= getopt.c getopt_long.c 2027ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/getopt.h 2037ec1ec4fSAlex Richardson 2047ec1ec4fSAlex Richardson# getcap.c is needed for cap_mkdb: 2057ec1ec4fSAlex Richardson.PATH: ${LIBC_SRCTOP}/gen 2067ec1ec4fSAlex RichardsonSRCS+= getcap.c 207962a3814SAlex Richardson# Glibc does not provide all err*/warn* functions, and for macOS we need the 208962a3814SAlex Richardson# alias with the extra underscore. 209962a3814SAlex RichardsonSRCS+= err.c 2107ec1ec4fSAlex Richardson# Add various libbc functions that are not available in glibc: 2117ec1ec4fSAlex RichardsonSRCS+= stringlist.c setmode.c 2127ec1ec4fSAlex RichardsonSRCS+= strtonum.c merge.c heapsort.c reallocf.c 2137ec1ec4fSAlex Richardson.PATH: ${LIBC_SRCTOP}/locale 2147ec1ec4fSAlex RichardsonSRCS+= rpmatch.c 2157ec1ec4fSAlex Richardson 2167ec1ec4fSAlex Richardson.if ${.MAKE.OS} == "Linux" 217ceefd491SAndrew Turner# On Linux, glibc does not provide strmode. It only provides strlcpy 218ceefd491SAndrew Turner# and strlcat from glibc 2.38. 2197ec1ec4fSAlex Richardson.PATH: ${LIBC_SRCTOP}/string 220ceefd491SAndrew TurnerSRCS+= strmode.c 221ceefd491SAndrew Turner# Assume if strlcpy exists so does strlcat 222ceefd491SAndrew Turner_WITH_EXPLICIT_STRLCPY!= cat ${HOST_INCLUDE_ROOT}/strings.h ${HOST_INCLUDE_ROOT}/string.h | grep -c strlcpy || true 223ceefd491SAndrew Turner.if ${_WITH_EXPLICIT_STRLCPY} == 0 224ceefd491SAndrew TurnerSRCS+= strlcpy.c strlcat.c 225ceefd491SAndrew Turner.endif 226548f8a65SJessica Clarke# On Linux, glibc provides ffs* but not fls* 227548f8a65SJessica ClarkeSRCS+= fls.c flsl.c flsll.c 2287ec1ec4fSAlex Richardson# Compile the fgetln/fgetwln/closefrom fallback code from libbsd: 2297ec1ec4fSAlex RichardsonSRCS+= fgetln_fallback.c fgetwln_fallback.c closefrom.c 2307ec1ec4fSAlex RichardsonCFLAGS.closefrom.c+= -DSTDC_HEADERS -DHAVE_SYS_DIR_H -DHAVE_DIRENT_H \ 2317ec1ec4fSAlex Richardson -DHAVE_DIRFD -DHAVE_SYSCONF 232962a3814SAlex Richardson# Provide getprogname/setprograme 233962a3814SAlex RichardsonSRCS+= progname.c 23452c8e24cSJessica Clarke# Provide fflagstostr/strtofflags for mtree and makefs 23552c8e24cSJessica Clarke# On macOS we use the host's so conflate host and target flags, which ideally 23652c8e24cSJessica Clarke# we'd avoid, but in practice these align for many flags, including 23752c8e24cSJessica Clarke# SF_IMMUTABLE, the only flag we currently set during install. 23852c8e24cSJessica ClarkeSRCS+= strtofflags.c 239976ba7f0SSimon J. Gerraty 240881ec813SJessica Clarke# macOS has a standalone cross-build implementation, but Linux can use the same 241881ec813SJessica Clarke# ELF one as FreeBSD 242881ec813SJessica ClarkeSYSINCS+= ${SRCTOP}/sys/sys/linker_set.h 243881ec813SJessica Clarke 2440ec03c0bSMark Johnston.endif # ${MAKE.OS} == "Linux" 2450ec03c0bSMark Johnston 2460ec03c0bSMark Johnston.if ${.MAKE.OS} == "Darwin" 2470ec03c0bSMark Johnston# Standalone implementation of secure_getenv(), not available on MacOS. 2480ec03c0bSMark JohnstonSRCS+= secure_getenv.c 2490ec03c0bSMark Johnston.endif # ${MAKE.OS} == "Darwin" 2500ec03c0bSMark Johnston 2517ec1ec4fSAlex Richardson# Provide the same arc4random implementation on Linux/macOS 2527ec1ec4fSAlex RichardsonCFLAGS.arc4random.c+= -I${SRCTOP}/sys/crypto/chacha20 -D__isthreaded=1 2537ec1ec4fSAlex RichardsonSRCS+= arc4random.c arc4random_uniform.c 2547ec1ec4fSAlex Richardson 2557ec1ec4fSAlex Richardson# expand_number() is not provided by either Linux or MacOS libutil 2567ec1ec4fSAlex Richardson.PATH: ${SRCTOP}/lib/libutil 2577ec1ec4fSAlex RichardsonSRCS+= expand_number.c 2587ec1ec4fSAlex Richardson# Linux libutil also doesn't have fparseln 2597ec1ec4fSAlex RichardsonSRCS+= fparseln.c 2607ec1ec4fSAlex Richardson# A dummy sysctl for tzsetup: 2617ec1ec4fSAlex RichardsonSRCS+= fake_sysctl.c 2627ec1ec4fSAlex Richardson 2637ec1ec4fSAlex Richardson# capsicum support 2647ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/capsicum.h 2657ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/caprights.h 2667ec1ec4fSAlex RichardsonSRCS+= capsicum_stubs.c 2677ec1ec4fSAlex Richardson# XXX: we can't add ${SRCTOP}/sys/kern to .PATH since that will causes 2687ec1ec4fSAlex Richardson# conflicts with other files. Instead copy subr_capability to the build dir. 2697ec1ec4fSAlex Richardsonsubr_capability.c: ${SRCTOP}/sys/kern/subr_capability.c 2707ec1ec4fSAlex Richardson cp ${.ALLSRC} ${.TARGET} 2717ec1ec4fSAlex RichardsonSRCS+= subr_capability.c 2727ec1ec4fSAlex RichardsonCLEANFILES+= subr_capability.c 273*3923bf59SJessica Clarke 274*3923bf59SJessica Clarke# Headers needed for msdosfs use in makefs 275*3923bf59SJessica ClarkeSYSINCS+= ${SRCTOP}/sys/sys/_callout.h 276*3923bf59SJessica ClarkeSYSINCS+= ${SRCTOP}/sys/sys/_lock.h 277*3923bf59SJessica ClarkeSYSINCS+= ${SRCTOP}/sys/sys/_lockmgr.h 278*3923bf59SJessica ClarkeSYSINCS+= ${SRCTOP}/sys/sys/_task.h 2790ec03c0bSMark Johnston.endif # ${MAKE.OS} != "FreeBSD" 2807ec1ec4fSAlex Richardson 281d5f4dd1bSMariusz ZaborskiCASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_fileargs/cap_fileargs.h 282aefe30c5SMariusz ZaborskiCASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_net/cap_net.h 283d5f4dd1bSMariusz Zaborski 2847e35117eSCy Schubert.if ${MK_MITKRB5} != "no" 2857e35117eSCy SchubertEDITINC+= ${SRCTOP}/contrib/libedit/readline/readline.h 2867e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/auth.h 2877e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/auth_gss.h 2887e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/auth_gssapi.h 2897e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/auth_unix.h 2907e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/clnt.h 2917e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/netdb.h 2927e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/pmap_clnt.h 2937e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/pmap_prot.h 2947e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/pmap_rmt.h 2957e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/rpc_msg.h 2967e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/rpc.h 2977e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/svc_auth.h 2987e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/svc.h 2997e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/krb5/include/gssrpc/types.h 3007e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/xdr.h 3017e35117eSCy SchubertK5GSSRPCINC+= ${SRCTOP}/crypto/krb5/src/include/gssrpc/xdr.h 3027e35117eSCy SchubertGSSAPIINC+= ${SRCTOP}/crypto/krb5/src/lib/gssapi/krb5/gssapi_krb5.h 3037e35117eSCy SchubertGSSAPIINC+= ${SRCTOP}/crypto/krb5/src/lib/gssapi/generic/gssapi_alloc.h 3047e35117eSCy SchubertGSSAPIINC+= ${SRCTOP}/crypto/krb5/src/lib/gssapi/generic/gssapi_generic.h 3057e35117eSCy SchubertGSSAPIINC+= ${SRCTOP}/crypto/krb5/src/lib/gssapi/generic/gssapi_ext.h 3067e35117eSCy SchubertK5GSSAPIINC+= ${SRCTOP}/crypto/krb5/src/include/gssapi.h 3077e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/ccselect_plugin.h 3087e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/certauth_plugin.h 3097e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/clpreauth_plugin.h 3107e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/hostrealm_plugin.h 3117e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/kadm5_auth_plugin.h 3127e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/kadm5_hook_plugin.h 3137e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/kdcpolicy_plugin.h 3147e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/kdcpreauth_plugin.h 3157e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/localauth_plugin.h 3167e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/locate_plugin.h 3177e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/plugin.h 3187e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/preauth_plugin.h 3197e35117eSCy SchubertKRB5INC+= ${SRCTOP}/crypto/krb5/src/include/krb5/pwqual_plugin.h 3207e35117eSCy SchubertINCS+= ${SRCTOP}/crypto/krb5/src/include/gssapi.h 3217e35117eSCy SchubertINCS+= ${SRCTOP}/crypto/krb5/src/include/kdb.h 3227e35117eSCy SchubertINCS+= ${SRCTOP}/crypto/krb5/src/include/krb5.h 3237e35117eSCy SchubertINCS+= ${SRCTOP}/crypto/krb5/src/include/krad.h 3247e35117eSCy SchubertINCS+= ${SRCTOP}/crypto/krb5/src/util/et/com_err.h 3257e35117eSCy SchubertINCS+= ${SRCTOP}/crypto/krb5/src/util/verto/verto-module.h 3267e35117eSCy SchubertINCS+= ${SRCTOP}/crypto/krb5/src/util/verto/verto.h 3277e35117eSCy Schubert.endif 3287e35117eSCy Schubert 32930aaff11SWarner Losh.if empty(SRCS) 33030aaff11SWarner LoshSRCS= dummy.c 33130aaff11SWarner Losh.endif 33230aaff11SWarner Losh 333f09a3cc4SRuslan Ermilov.if defined(CROSS_BUILD_TESTING) 334f09a3cc4SRuslan ErmilovSUBDIR= cross-build 335f09a3cc4SRuslan Ermilov.endif 336f09a3cc4SRuslan Ermilov 337162ae9c8SAlex Richardson# To allow bootstrapping makefs on FreeBSD 11 or non-FreeBSD systems: 338162ae9c8SAlex RichardsonUFSINCS+= ${SRCTOP}/sys/ufs/ufs/dinode.h 339162ae9c8SAlex RichardsonUFSINCS+= ${SRCTOP}/sys/ufs/ufs/dir.h 340162ae9c8SAlex RichardsonFFSINCS+= ${SRCTOP}/sys/ufs/ffs/fs.h 341162ae9c8SAlex Richardson 342162ae9c8SAlex RichardsonMSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/bootsect.h 343162ae9c8SAlex RichardsonMSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/bpb.h 344162ae9c8SAlex RichardsonMSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/denode.h 345162ae9c8SAlex RichardsonMSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/direntry.h 346162ae9c8SAlex RichardsonMSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/fat.h 347162ae9c8SAlex RichardsonMSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/msdosfsmount.h 348162ae9c8SAlex RichardsonDISKINCS+= ${SRCTOP}/sys/sys/disk/bsd.h 349162ae9c8SAlex Richardson 35063889bbdSAlex Richardson# Needed to build config (since it uses libnv) 3518a50aa09SJohn BaldwinSYSINCS+= ${SRCTOP}/sys/sys/_nv.h 352c36f4276SMarius StroblSYSINCS+= ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h \ 353000321baSReid Linnemann ${SRCTOP}/sys/sys/dnv.h ${SRCTOP}/sys/sys/nv_namespace.h 35463889bbdSAlex Richardson 355313232ddSAlex Richardson# Needed when bootstrapping ldd (since it uses DF_1_PIE) 356313232ddSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/elf32.h 357313232ddSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/elf64.h 358313232ddSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/elf_common.h 359313232ddSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/elf_generic.h 3607ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/queue.h 3617ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/md5.h 3627ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/sbuf.h 3637ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/tree.h 364313232ddSAlex Richardson 365e7fd9688SToomas Soome# vtfontcvt is using sys/font.h 366e7fd9688SToomas SoomeSYSINCS+= ${SRCTOP}/sys/sys/font.h 3677ec1ec4fSAlex Richardson# For mkscrfil.c: 3687ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/consio.h 3697ec1ec4fSAlex Richardson# for gencat: 3707ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/nl_types.h 3717ec1ec4fSAlex Richardson# for vtfontcvt: 3727ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/fnv_hash.h 3737ec1ec4fSAlex Richardson# opensolaris compatibility 3747ec1ec4fSAlex RichardsonINCS+= ${SRCTOP}/include/elf.h 3757ec1ec4fSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/elf.h 3762d5d2a98SMark JohnstonSYSINCS+= ${SRCTOP}/sys/sys/ctf.h 377968a3db7SJessica Clarke# for kbdcontrol: 378968a3db7SJessica ClarkeSYSINCS+= ${SRCTOP}/sys/sys/kbio.h 379ff7c12c1SJessica Clarke# for kldxref: 380ff7c12c1SJessica ClarkeSYSINCS+= ${SRCTOP}/sys/sys/module.h 38183069000SKyle Evans.if ${.MAKE.OS} != "FreeBSD" 38283069000SKyle Evans# for libmd: 38383069000SKyle EvansSYSINCS+= ${SRCTOP}/sys/sys/md4.h 38483069000SKyle Evans.endif 385e7fd9688SToomas Soome 3868f62bca4SAlex Richardson# We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't 3878f62bca4SAlex Richardson# accidentally run tools that are incompatible but happen to be in $PATH. 3888f62bca4SAlex Richardson# This is especially important when building on Linux/MacOS where many of the 3898f62bca4SAlex Richardson# programs used during the build accept different flags or generate different 3908f62bca4SAlex Richardson# output. On those platforms we only symlink the tools known to be compatible 3918f62bca4SAlex Richardson# (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others 3928f62bca4SAlex Richardson# from the FreeBSD sources during the bootstrap-tools stage. 3938f62bca4SAlex Richardson 3948f62bca4SAlex Richardson# basic commands: It is fine to use the host version for all of these even on 3958f62bca4SAlex Richardson# Linux/MacOS since we only use flags that are supported by all of them. 396ea6c594cSAlex Richardson_host_tools_to_symlink= basename bzip2 bunzip2 chmod chown cmp comm cp date dd \ 3978f62bca4SAlex Richardson dirname echo env false find fmt gzip gunzip head hostname id ln ls \ 3985c9cb96aSAlex Richardson mkdir mv nice patch rm sh sleep stat tee time touch tr true uname uniq \ 3995c9cb96aSAlex Richardson unxz wc which xz 4008f62bca4SAlex Richardson 4018f62bca4SAlex Richardson# We also need a symlink to the absolute path to the make binary used for 4028f62bca4SAlex Richardson# the toplevel makefile. This is not necessarily the same as `which make` 4038f62bca4SAlex Richardson# since e.g. on Linux and MacOS that will be GNU make. 4048f62bca4SAlex Richardson_make_abs!= which "${MAKE}" 4058f62bca4SAlex Richardson_host_abs_tools_to_symlink= ${_make_abs}:make ${_make_abs}:bmake 4068f62bca4SAlex Richardson 40765f28f63SJessica Clarke_LINK_HOST_TOOL= ln -sfn 40865f28f63SJessica Clarke 409a8b20f4fSAlexander Richardson.if ${.MAKE.OS} == "FreeBSD" 410a8b20f4fSAlexander Richardson# When building on FreeBSD we always copy the host tools instead of linking 411a8b20f4fSAlexander Richardson# into WORLDTMP to avoid issues with incompatible libraries (see r364030). 412a8b20f4fSAlexander Richardson# Note: we could create links if we don't intend to update the current machine. 413a8b20f4fSAlexander Richardson_COPY_HOST_TOOL= cp -pf 414a8b20f4fSAlexander Richardson.else 415a8b20f4fSAlexander Richardson# However, this is not necessary on Linux/macOS. Additionally, copying the host 416a8b20f4fSAlexander Richardson# tools to another directory with cp -p results in freezes on macOS Big Sur for 417a8b20f4fSAlexander Richardson# some unknown reason. It can also break building inside docker containers if 418a8b20f4fSAlexander Richardson# there are ACLs on shared volumes. 41965f28f63SJessica Clarke_COPY_HOST_TOOL= ${_LINK_HOST_TOOL} 420dd3ad7c2SJessica Clarke 4217ec1ec4fSAlex Richardson.if ${.MAKE.OS} == "Darwin" 4227ec1ec4fSAlex Richardson# /usr/bin/cpp may invoke xcrun: 4237ec1ec4fSAlex Richardson_host_tools_to_symlink+= xcrun 4247ec1ec4fSAlex Richardson.endif # ${.MAKE.OS} == "Darwin" 425dd3ad7c2SJessica Clarke 426dd3ad7c2SJessica Clarke# On Ubuntu /bin/sh is dash which is totally useless, and the same for modern 427dd3ad7c2SJessica Clarke# macOS. Let's just link bash as the build sh since that will work fine. 4287ec1ec4fSAlex Richardson_host_abs_tools_to_symlink+= /bin/bash:sh 4297ec1ec4fSAlex Richardson_host_tools_to_symlink:= ${_host_tools_to_symlink:Nsh} 4307ec1ec4fSAlex Richardson.endif 4317ec1ec4fSAlex Richardson 43265f28f63SJessica Clarke# We also need to symlink any non-absolute toolchain commands. Clang finds its 43301718a2eSJessica Clarke# resource directory relative to itself, so CC/CXX/CPP cannot be copied, and 43401718a2eSJessica Clarke# there should be no concerns about installing over the current system since we 43501718a2eSJessica Clarke# don't use the toolchain during install, so that's not an issue. However, 43601718a2eSJessica Clarke# before Clang 13 there was no symlink detection for FreeBSD so that was broken 43701718a2eSJessica Clarke# in the same way as copying (https://reviews.llvm.org/D103346), thus create a 43801718a2eSJessica Clarke# wrapper script for each to work around this and behave like a symlink. 43901718a2eSJessica Clarke# Remove this hack and just use a symlink once Clang 13 can be assumed. 44001718a2eSJessica Clarke# For consistency, we use the same strategy for LD. 44101718a2eSJessica Clarke.include <bsd.compiler.mk> 44201718a2eSJessica Clarke.if ${.MAKE.OS} == "FreeBSD" && ${COMPILER_TYPE} == "clang" && \ 44301718a2eSJessica Clarke ${COMPILER_VERSION} < 130000 44401718a2eSJessica Clarke_WRAP_HOST_TOOL= sh -c "printf '\#!/bin/sh\nexec \"\%s\" \"\$$@\"\n' \"\$$0\" > \"\$$1\" && chmod +x \"\$$1\"" 44501718a2eSJessica Clarke.else 44601718a2eSJessica Clarke_WRAP_HOST_TOOL= ${_LINK_HOST_TOOL} 44701718a2eSJessica Clarke.endif 44865f28f63SJessica Clarke.for var in CC CXX CPP LD 44965f28f63SJessica Clarke.for X in $${_empty_var_} X 4505d1ecf0bSKyle Evans.if !empty(${X}${var}) && !${${X}${var}:[1]:M/*} && \ 4515d1ecf0bSKyle Evans !${_toolchain_tools_to_symlink:U:M${${X}${var}:[1]}} 4525d1ecf0bSKyle Evans_toolchain_tools_to_symlink+= ${${X}${var}:[1]} 45365f28f63SJessica Clarke.endif 45465f28f63SJessica Clarke.endfor 45565f28f63SJessica Clarke.endfor 45665f28f63SJessica Clarke 4578f62bca4SAlex Richardsonhost-symlinks: 4588f62bca4SAlex Richardson @echo "Linking host tools into ${DESTDIR}/bin" 4598f62bca4SAlex Richardson.for _tool in ${_host_tools_to_symlink} 4608c9e4550SJessica Clarke @export PATH=$${PATH}:/usr/local/bin; \ 4618c9e4550SJessica Clarke source_path=`which ${_tool} || echo /dev/null/no/such`; \ 4628f62bca4SAlex Richardson if [ ! -e "$${source_path}" ] ; then \ 4635bb9250eSAlex Richardson echo "Cannot find host tool '${_tool}' in PATH ($$PATH)." >&2; false; \ 4648f62bca4SAlex Richardson fi; \ 46533176cdcSWarner Losh rm -f "${DESTDIR}/bin/${_tool}"; \ 466a8b20f4fSAlexander Richardson ${_COPY_HOST_TOOL} "$${source_path}" "${DESTDIR}/bin/${_tool}" 4678f62bca4SAlex Richardson.endfor 4688f62bca4SAlex Richardson.for _tool in ${_host_abs_tools_to_symlink} 4698f62bca4SAlex Richardson @source_path="${_tool:S/:/ /:[1]}"; \ 4708f62bca4SAlex Richardson target_path="${DESTDIR}/bin/${_tool:S/:/ /:[2]}"; \ 4718f62bca4SAlex Richardson if [ ! -e "$${source_path}" ] ; then \ 472ddf312e8SMark Johnston echo "Host tool '$${source_path}' is missing"; false; \ 4738f62bca4SAlex Richardson fi; \ 47433176cdcSWarner Losh rm -f "$${target_path}"; \ 475a8b20f4fSAlexander Richardson ${_COPY_HOST_TOOL} "$${source_path}" "$${target_path}" 4768f62bca4SAlex Richardson.endfor 4774f47920eSKyle Evans.if exists(/usr/libexec/flua) 47833176cdcSWarner Losh rm -f ${DESTDIR}/usr/libexec/flua 479a8b20f4fSAlexander Richardson ${_COPY_HOST_TOOL} /usr/libexec/flua ${DESTDIR}/usr/libexec/flua 4804f47920eSKyle Evans.endif 48165f28f63SJessica Clarke.for _tool in ${_toolchain_tools_to_symlink} 48265f28f63SJessica Clarke @export PATH=$${PATH}:/usr/local/bin; \ 48365f28f63SJessica Clarke source_path=`which ${_tool} || echo /dev/null/no/such`; \ 48465f28f63SJessica Clarke if [ ! -e "$${source_path}" ] ; then \ 48565f28f63SJessica Clarke echo "Cannot find host tool '${_tool}' in PATH ($$PATH)." >&2; false; \ 48665f28f63SJessica Clarke fi; \ 48765f28f63SJessica Clarke rm -f "${DESTDIR}/bin/${_tool}"; \ 48801718a2eSJessica Clarke ${_WRAP_HOST_TOOL} "$${source_path}" "${DESTDIR}/bin/${_tool}" 48965f28f63SJessica Clarke.endfor 4904acc8a67SAlex Richardson 4914acc8a67SAlex Richardson# Create all the directories that are needed during the legacy, bootstrap-tools 4924acc8a67SAlex Richardson# and cross-tools stages. We do this here using mkdir since mtree may not exist 4934acc8a67SAlex Richardson# yet (this happens if we are crossbuilding from Linux/Mac). 49417adf17bSSimon J. GerratyINSTALLDIR_LIST= \ 49517adf17bSSimon J. Gerraty bin \ 49617adf17bSSimon J. Gerraty lib/geom \ 49717adf17bSSimon J. Gerraty usr/include/casper \ 49894a82666SRyan Moeller usr/include/private/ucl \ 49917adf17bSSimon J. Gerraty usr/include/private/zstd \ 50017adf17bSSimon J. Gerraty usr/lib \ 5017ba31d58SJessica Clarke usr/libdata/pkgconfig \ 502f22a5921SKyle Evans usr/libexec 50317adf17bSSimon J. Gerraty 5044acc8a67SAlex Richardsoninstalldirs: 50517adf17bSSimon J. Gerraty mkdir -p ${INSTALLDIR_LIST:S,^,${DESTDIR}/,} 50617adf17bSSimon J. Gerraty 5078f62bca4SAlex Richardson# Link usr/bin, sbin, and usr/sbin to bin so that it doesn't matter whether a 5088f62bca4SAlex Richardson# bootstrap tool was added to WORLTMP with a symlink or by building it in the 5098f62bca4SAlex Richardson# bootstrap-tools phase. We could also overrride BINDIR when building bootstrap 5108f62bca4SAlex Richardson# tools but adding the symlinks is easier and means all tools are also 5118f62bca4SAlex Richardson# in the directory that they are installed to normally. 512b25c7179SAlex Richardson 513b25c7179SAlex Richardson.for _dir in sbin usr/sbin usr/bin 514b25c7179SAlex Richardson# delete existing directories from before r340157 5155bb9250eSAlex Richardson @if [ -e ${DESTDIR}/${_dir} ] && [ ! -L ${DESTDIR}/${_dir} ]; then \ 516b25c7179SAlex Richardson echo "removing old non-symlink ${DESTDIR}/${_dir}"; \ 517b25c7179SAlex Richardson rm -rf "${DESTDIR}/${_dir}"; \ 518b25c7179SAlex Richardson fi 519b25c7179SAlex Richardson.endfor 520b25c7179SAlex Richardson ln -sfn bin ${DESTDIR}/sbin 521b25c7179SAlex Richardson ln -sfn ../bin ${DESTDIR}/usr/bin 522b25c7179SAlex Richardson ln -sfn ../bin ${DESTDIR}/usr/sbin 5234acc8a67SAlex Richardson.for _group in ${INCSGROUPS:NINCS} 5244acc8a67SAlex Richardson mkdir -p "${DESTDIR}/${${_group}DIR}" 5254acc8a67SAlex Richardson.endfor 5264acc8a67SAlex Richardson 52730aaff11SWarner Losh.include <bsd.lib.mk> 528