130aaff11SWarner Losh# $FreeBSD$ 230aaff11SWarner Losh 330aaff11SWarner Losh.PATH: ${.CURDIR}/../../include 430aaff11SWarner Losh 51c62f923SWarner LoshLIB= egacy 6c2774610SDavid E. O'BrienSRC= 7d5f4dd1bSMariusz ZaborskiINCSGROUPS= INCS SYSINCS CASPERINC 830aaff11SWarner LoshINCS= 930aaff11SWarner Losh 10d80f1dd1SJilles TjoelkerSYSINCSDIR= ${INCLUDEDIR}/sys 11d5f4dd1bSMariusz ZaborskiCASPERINCDIR= ${INCLUDEDIR}/casper 12d80f1dd1SJilles Tjoelker 1330aaff11SWarner LoshBOOTSTRAPPING?= 0 1430aaff11SWarner Losh 15804baa38SBryan Drewery_WITH_PWCACHEDB!= grep -c pwcache_groupdb /usr/include/grp.h || true 1679626055SBrooks Davis.if ${_WITH_PWCACHEDB} == 0 1779626055SBrooks Davis.PATH: ${.CURDIR}/../../contrib/libc-pwcache 1879626055SBrooks DavisCFLAGS+= -I${.CURDIR}/../../contrib/libc-pwcache \ 1979626055SBrooks Davis -I${.CURDIR}/../../lib/libc/include 2079626055SBrooks DavisSRCS+= pwcache.c 2179626055SBrooks Davis.endif 2279626055SBrooks Davis 23804baa38SBryan Drewery_WITH_STRSVIS!= grep -c strsvis /usr/include/vis.h || true 2479626055SBrooks Davis.if ${_WITH_STRSVIS} == 0 2579626055SBrooks Davis.PATH: ${.CURDIR}/../../contrib/libc-vis 2679626055SBrooks DavisSRCS+= vis.c 2779626055SBrooks DavisCFLAGS+= -I${.CURDIR}/../../contrib/libc-vis \ 2879626055SBrooks Davis -I${.CURDIR}/../../lib/libc/include 2979626055SBrooks Davis.endif 3079626055SBrooks Davis 31804baa38SBryan Drewery_WITH_REALLOCARRAY!= grep -c reallocarray /usr/include/stdlib.h || true 328e7e3163SDimitry Andric.if ${_WITH_REALLOCARRAY} == 0 338e7e3163SDimitry Andric.PATH: ${.CURDIR}/../../lib/libc/stdlib 348e7e3163SDimitry AndricINCS+= stdlib.h 358e7e3163SDimitry AndricSRCS+= reallocarray.c 368e7e3163SDimitry AndricCFLAGS+= -I${.CURDIR}/../../lib/libc/include 378e7e3163SDimitry Andric.endif 388e7e3163SDimitry Andric 39d80f1dd1SJilles Tjoelker_WITH_UTIMENS!= grep -c utimensat /usr/include/sys/stat.h || true 40d80f1dd1SJilles Tjoelker.if ${_WITH_UTIMENS} == 0 41d80f1dd1SJilles TjoelkerSYSINCS+= stat.h 42d80f1dd1SJilles TjoelkerSRCS+= futimens.c utimensat.c 43d80f1dd1SJilles Tjoelker.endif 44d80f1dd1SJilles Tjoelker 458d14ced6SAlex Richardson_WITH_EXPLICIT_BZERO!= grep -c explicit_bzero /usr/include/strings.h || true 468d14ced6SAlex Richardson.if ${_WITH_EXPLICIT_BZERO} == 0 478d14ced6SAlex Richardson.PATH: ${SRCTOP}/sys/libkern 488d14ced6SAlex RichardsonINCS+= strings.h 498d14ced6SAlex RichardsonSRCS+= explicit_bzero.c 508d14ced6SAlex Richardson.endif 518d14ced6SAlex Richardson 523b7e9bfeSAlex Richardson.if exists(/usr/include/capsicum_helpers.h) 533b7e9bfeSAlex Richardson_WITH_CAPH_ENTER!= grep -c caph_enter /usr/include/capsicum_helpers.h || true 54fbe12f20SMark Johnston_WITH_CAPH_RIGHTS_LIMIT!= grep -c caph_rights_limit /usr/include/capsicum_helpers.h || true 553b7e9bfeSAlex Richardson.endif 56fbe12f20SMark Johnston.if !defined(_WITH_CAPH_ENTER) || ${_WITH_CAPH_ENTER} == 0 || ${_WITH_CAPH_RIGHTS_LIMIT} == 0 573b7e9bfeSAlex Richardson.PATH: ${SRCTOP}/lib/libcapsicum 583b7e9bfeSAlex RichardsonINCS+= capsicum_helpers.h 593b7e9bfeSAlex Richardson.PATH: ${SRCTOP}/lib/libcasper/libcasper 603b7e9bfeSAlex RichardsonINCS+= libcasper.h 613b7e9bfeSAlex Richardson.endif 623b7e9bfeSAlex Richardson 63d5f4dd1bSMariusz ZaborskiCASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_fileargs/cap_fileargs.h 64d5f4dd1bSMariusz Zaborski 6530aaff11SWarner Losh.if empty(SRCS) 6630aaff11SWarner LoshSRCS= dummy.c 6730aaff11SWarner Losh.endif 6830aaff11SWarner Losh 69f09a3cc4SRuslan Ermilov.if defined(CROSS_BUILD_TESTING) 70f09a3cc4SRuslan ErmilovSUBDIR= cross-build 71f09a3cc4SRuslan Ermilov.endif 72f09a3cc4SRuslan Ermilov 7363889bbdSAlex Richardson# Needed to build config (since it uses libnv) 74c36f4276SMarius StroblSYSINCS+= ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h \ 75c36f4276SMarius Strobl ${SRCTOP}/sys/sys/dnv.h 7663889bbdSAlex Richardson 778f62bca4SAlex Richardson# We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't 788f62bca4SAlex Richardson# accidentally run tools that are incompatible but happen to be in $PATH. 798f62bca4SAlex Richardson# This is especially important when building on Linux/MacOS where many of the 808f62bca4SAlex Richardson# programs used during the build accept different flags or generate different 818f62bca4SAlex Richardson# output. On those platforms we only symlink the tools known to be compatible 828f62bca4SAlex Richardson# (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others 838f62bca4SAlex Richardson# from the FreeBSD sources during the bootstrap-tools stage. 848f62bca4SAlex Richardson 858f62bca4SAlex Richardson# basic commands: It is fine to use the host version for all of these even on 868f62bca4SAlex Richardson# Linux/MacOS since we only use flags that are supported by all of them. 878f62bca4SAlex Richardson_host_tools_to_symlink= basename bzip2 bunzip2 chmod chown cmp comm cp date \ 888f62bca4SAlex Richardson dirname echo env false find fmt gzip gunzip head hostname id ln ls \ 898f62bca4SAlex Richardson mkdir mv nice patch rm realpath sh sleep stat tee touch tr true uname \ 908f62bca4SAlex Richardson uniq wc which 918f62bca4SAlex Richardson 928f62bca4SAlex Richardson# We also need a symlink to the absolute path to the make binary used for 938f62bca4SAlex Richardson# the toplevel makefile. This is not necessarily the same as `which make` 948f62bca4SAlex Richardson# since e.g. on Linux and MacOS that will be GNU make. 958f62bca4SAlex Richardson_make_abs!= which "${MAKE}" 968f62bca4SAlex Richardson_host_abs_tools_to_symlink= ${_make_abs}:make ${_make_abs}:bmake 978f62bca4SAlex Richardson 988f62bca4SAlex Richardsonhost-symlinks: 998f62bca4SAlex Richardson @echo "Linking host tools into ${DESTDIR}/bin" 1008f62bca4SAlex Richardson.for _tool in ${_host_tools_to_symlink} 1018f62bca4SAlex Richardson @if [ ! -e "${DESTDIR}/bin/${_tool}" ]; then \ 1028f62bca4SAlex Richardson source_path=`which ${_tool}`; \ 1038f62bca4SAlex Richardson if [ ! -e "$${source_path}" ] ; then \ 1048f62bca4SAlex Richardson echo "Cannot find host tool '${_tool}'"; false; \ 1058f62bca4SAlex Richardson fi; \ 1068f62bca4SAlex Richardson ln -sfnv "$${source_path}" "${DESTDIR}/bin/${_tool}"; \ 1078f62bca4SAlex Richardson fi 1088f62bca4SAlex Richardson.endfor 1098f62bca4SAlex Richardson.for _tool in ${_host_abs_tools_to_symlink} 1108f62bca4SAlex Richardson @source_path="${_tool:S/:/ /:[1]}"; \ 1118f62bca4SAlex Richardson target_path="${DESTDIR}/bin/${_tool:S/:/ /:[2]}"; \ 1128f62bca4SAlex Richardson if [ ! -e "$${target_path}" ] ; then \ 1138f62bca4SAlex Richardson if [ ! -e "$${source_path}" ] ; then \ 1148f62bca4SAlex Richardson echo "Host tool '${src_path}' is missing"; false; \ 1158f62bca4SAlex Richardson fi; \ 1168f62bca4SAlex Richardson ln -sfnv "$${source_path}" "$${target_path}"; \ 1178f62bca4SAlex Richardson fi 1188f62bca4SAlex Richardson.endfor 119*4f47920eSKyle Evans.if exists(/usr/libexec/flua) 120*4f47920eSKyle Evans ln -sf /usr/libexec/flua ${DESTDIR}/usr/libexec/flua 121*4f47920eSKyle Evans.endif 1224acc8a67SAlex Richardson 1234acc8a67SAlex Richardson# Create all the directories that are needed during the legacy, bootstrap-tools 1244acc8a67SAlex Richardson# and cross-tools stages. We do this here using mkdir since mtree may not exist 1254acc8a67SAlex Richardson# yet (this happens if we are crossbuilding from Linux/Mac). 12617adf17bSSimon J. GerratyINSTALLDIR_LIST= \ 12717adf17bSSimon J. Gerraty bin \ 12817adf17bSSimon J. Gerraty lib/casper \ 12917adf17bSSimon J. Gerraty lib/geom \ 13017adf17bSSimon J. Gerraty usr/include/casper \ 13117adf17bSSimon J. Gerraty usr/include/private/zstd \ 13217adf17bSSimon J. Gerraty usr/lib \ 133f22a5921SKyle Evans usr/libexec 13417adf17bSSimon J. Gerraty 1354acc8a67SAlex Richardsoninstalldirs: 13617adf17bSSimon J. Gerraty mkdir -p ${INSTALLDIR_LIST:S,^,${DESTDIR}/,} 13717adf17bSSimon J. Gerraty 1388f62bca4SAlex Richardson# Link usr/bin, sbin, and usr/sbin to bin so that it doesn't matter whether a 1398f62bca4SAlex Richardson# bootstrap tool was added to WORLTMP with a symlink or by building it in the 1408f62bca4SAlex Richardson# bootstrap-tools phase. We could also overrride BINDIR when building bootstrap 1418f62bca4SAlex Richardson# tools but adding the symlinks is easier and means all tools are also 1428f62bca4SAlex Richardson# in the directory that they are installed to normally. 143b25c7179SAlex Richardson 144b25c7179SAlex Richardson.for _dir in sbin usr/sbin usr/bin 145b25c7179SAlex Richardson# delete existing directories from before r340157 146b25c7179SAlex Richardson @if [ ! -L ${DESTDIR}/${_dir} ]; then \ 147b25c7179SAlex Richardson echo "removing old non-symlink ${DESTDIR}/${_dir}"; \ 148b25c7179SAlex Richardson rm -rf "${DESTDIR}/${_dir}"; \ 149b25c7179SAlex Richardson fi 150b25c7179SAlex Richardson.endfor 151b25c7179SAlex Richardson ln -sfn bin ${DESTDIR}/sbin 152b25c7179SAlex Richardson ln -sfn ../bin ${DESTDIR}/usr/bin 153b25c7179SAlex Richardson ln -sfn ../bin ${DESTDIR}/usr/sbin 1544acc8a67SAlex Richardson.for _group in ${INCSGROUPS:NINCS} 1554acc8a67SAlex Richardson mkdir -p "${DESTDIR}/${${_group}DIR}" 1564acc8a67SAlex Richardson.endfor 1574acc8a67SAlex Richardson 15830aaff11SWarner Losh.include <bsd.lib.mk> 159