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 543b7e9bfeSAlex Richardson.endif 553b7e9bfeSAlex Richardson.if !defined(_WITH_CAPH_ENTER) || ${_WITH_CAPH_ENTER} == 0 563b7e9bfeSAlex Richardson.PATH: ${SRCTOP}/lib/libcapsicum 573b7e9bfeSAlex RichardsonINCS+= capsicum_helpers.h 583b7e9bfeSAlex Richardson.PATH: ${SRCTOP}/lib/libcasper/libcasper 593b7e9bfeSAlex RichardsonINCS+= libcasper.h 603b7e9bfeSAlex Richardson.endif 613b7e9bfeSAlex Richardson 62d5f4dd1bSMariusz ZaborskiCASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_fileargs/cap_fileargs.h 63d5f4dd1bSMariusz Zaborski 6430aaff11SWarner Losh.if empty(SRCS) 6530aaff11SWarner LoshSRCS= dummy.c 6630aaff11SWarner Losh.endif 6730aaff11SWarner Losh 68f09a3cc4SRuslan Ermilov.if defined(CROSS_BUILD_TESTING) 69f09a3cc4SRuslan ErmilovSUBDIR= cross-build 70f09a3cc4SRuslan Ermilov.endif 71f09a3cc4SRuslan Ermilov 7263889bbdSAlex Richardson# Needed to build config (since it uses libnv) 73*c36f4276SMarius StroblSYSINCS+= ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h \ 74*c36f4276SMarius Strobl ${SRCTOP}/sys/sys/dnv.h 7563889bbdSAlex Richardson 768f62bca4SAlex Richardson# We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't 778f62bca4SAlex Richardson# accidentally run tools that are incompatible but happen to be in $PATH. 788f62bca4SAlex Richardson# This is especially important when building on Linux/MacOS where many of the 798f62bca4SAlex Richardson# programs used during the build accept different flags or generate different 808f62bca4SAlex Richardson# output. On those platforms we only symlink the tools known to be compatible 818f62bca4SAlex Richardson# (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others 828f62bca4SAlex Richardson# from the FreeBSD sources during the bootstrap-tools stage. 838f62bca4SAlex Richardson 848f62bca4SAlex Richardson# basic commands: It is fine to use the host version for all of these even on 858f62bca4SAlex Richardson# Linux/MacOS since we only use flags that are supported by all of them. 868f62bca4SAlex Richardson_host_tools_to_symlink= basename bzip2 bunzip2 chmod chown cmp comm cp date \ 878f62bca4SAlex Richardson dirname echo env false find fmt gzip gunzip head hostname id ln ls \ 888f62bca4SAlex Richardson mkdir mv nice patch rm realpath sh sleep stat tee touch tr true uname \ 898f62bca4SAlex Richardson uniq wc which 908f62bca4SAlex Richardson 918f62bca4SAlex Richardson# We also need a symlink to the absolute path to the make binary used for 928f62bca4SAlex Richardson# the toplevel makefile. This is not necessarily the same as `which make` 938f62bca4SAlex Richardson# since e.g. on Linux and MacOS that will be GNU make. 948f62bca4SAlex Richardson_make_abs!= which "${MAKE}" 958f62bca4SAlex Richardson_host_abs_tools_to_symlink= ${_make_abs}:make ${_make_abs}:bmake 968f62bca4SAlex Richardson 978f62bca4SAlex Richardsonhost-symlinks: 988f62bca4SAlex Richardson @echo "Linking host tools into ${DESTDIR}/bin" 998f62bca4SAlex Richardson.for _tool in ${_host_tools_to_symlink} 1008f62bca4SAlex Richardson @if [ ! -e "${DESTDIR}/bin/${_tool}" ]; then \ 1018f62bca4SAlex Richardson source_path=`which ${_tool}`; \ 1028f62bca4SAlex Richardson if [ ! -e "$${source_path}" ] ; then \ 1038f62bca4SAlex Richardson echo "Cannot find host tool '${_tool}'"; false; \ 1048f62bca4SAlex Richardson fi; \ 1058f62bca4SAlex Richardson ln -sfnv "$${source_path}" "${DESTDIR}/bin/${_tool}"; \ 1068f62bca4SAlex Richardson fi 1078f62bca4SAlex Richardson.endfor 1088f62bca4SAlex Richardson.for _tool in ${_host_abs_tools_to_symlink} 1098f62bca4SAlex Richardson @source_path="${_tool:S/:/ /:[1]}"; \ 1108f62bca4SAlex Richardson target_path="${DESTDIR}/bin/${_tool:S/:/ /:[2]}"; \ 1118f62bca4SAlex Richardson if [ ! -e "$${target_path}" ] ; then \ 1128f62bca4SAlex Richardson if [ ! -e "$${source_path}" ] ; then \ 1138f62bca4SAlex Richardson echo "Host tool '${src_path}' is missing"; false; \ 1148f62bca4SAlex Richardson fi; \ 1158f62bca4SAlex Richardson ln -sfnv "$${source_path}" "$${target_path}"; \ 1168f62bca4SAlex Richardson fi 1178f62bca4SAlex Richardson.endfor 1184acc8a67SAlex Richardson 1194acc8a67SAlex Richardson# Create all the directories that are needed during the legacy, bootstrap-tools 1204acc8a67SAlex Richardson# and cross-tools stages. We do this here using mkdir since mtree may not exist 1214acc8a67SAlex Richardson# yet (this happens if we are crossbuilding from Linux/Mac). 1224acc8a67SAlex Richardsoninstalldirs: 123d5f4dd1bSMariusz Zaborski.for _dir in bin usr/lib usr/include usr/include/casper lib/geom lib/casper 1244acc8a67SAlex Richardson mkdir -p "${DESTDIR}/${_dir}" 1254acc8a67SAlex Richardson.endfor 1268f62bca4SAlex Richardson# Link usr/bin, sbin, and usr/sbin to bin so that it doesn't matter whether a 1278f62bca4SAlex Richardson# bootstrap tool was added to WORLTMP with a symlink or by building it in the 1288f62bca4SAlex Richardson# bootstrap-tools phase. We could also overrride BINDIR when building bootstrap 1298f62bca4SAlex Richardson# tools but adding the symlinks is easier and means all tools are also 1308f62bca4SAlex Richardson# in the directory that they are installed to normally. 131b25c7179SAlex Richardson 132b25c7179SAlex Richardson.for _dir in sbin usr/sbin usr/bin 133b25c7179SAlex Richardson# delete existing directories from before r340157 134b25c7179SAlex Richardson @if [ ! -L ${DESTDIR}/${_dir} ]; then \ 135b25c7179SAlex Richardson echo "removing old non-symlink ${DESTDIR}/${_dir}"; \ 136b25c7179SAlex Richardson rm -rf "${DESTDIR}/${_dir}"; \ 137b25c7179SAlex Richardson fi 138b25c7179SAlex Richardson.endfor 139b25c7179SAlex Richardson ln -sfn bin ${DESTDIR}/sbin 140b25c7179SAlex Richardson ln -sfn ../bin ${DESTDIR}/usr/bin 141b25c7179SAlex Richardson ln -sfn ../bin ${DESTDIR}/usr/sbin 1424acc8a67SAlex Richardson.for _group in ${INCSGROUPS:NINCS} 1434acc8a67SAlex Richardson mkdir -p "${DESTDIR}/${${_group}DIR}" 1444acc8a67SAlex Richardson.endfor 1454acc8a67SAlex Richardson 14630aaff11SWarner Losh.include <bsd.lib.mk> 147