130aaff11SWarner Losh# $FreeBSD$ 230aaff11SWarner Losh 330aaff11SWarner Losh.PATH: ${.CURDIR}/../../include 430aaff11SWarner Losh 51c62f923SWarner LoshLIB= egacy 6c2774610SDavid E. O'BrienSRC= 7d80f1dd1SJilles TjoelkerINCSGROUPS= INCS SYSINCS 830aaff11SWarner LoshINCS= 930aaff11SWarner Losh 10d80f1dd1SJilles TjoelkerSYSINCSDIR= ${INCLUDEDIR}/sys 11d80f1dd1SJilles Tjoelker 1230aaff11SWarner LoshBOOTSTRAPPING?= 0 1330aaff11SWarner Losh 14804baa38SBryan Drewery_WITH_PWCACHEDB!= grep -c pwcache_groupdb /usr/include/grp.h || true 1579626055SBrooks Davis.if ${_WITH_PWCACHEDB} == 0 1679626055SBrooks Davis.PATH: ${.CURDIR}/../../contrib/libc-pwcache 1779626055SBrooks DavisCFLAGS+= -I${.CURDIR}/../../contrib/libc-pwcache \ 1879626055SBrooks Davis -I${.CURDIR}/../../lib/libc/include 1979626055SBrooks DavisSRCS+= pwcache.c 2079626055SBrooks Davis.endif 2179626055SBrooks Davis 22804baa38SBryan Drewery_WITH_STRSVIS!= grep -c strsvis /usr/include/vis.h || true 2379626055SBrooks Davis.if ${_WITH_STRSVIS} == 0 2479626055SBrooks Davis.PATH: ${.CURDIR}/../../contrib/libc-vis 2579626055SBrooks DavisSRCS+= vis.c 2679626055SBrooks DavisCFLAGS+= -I${.CURDIR}/../../contrib/libc-vis \ 2779626055SBrooks Davis -I${.CURDIR}/../../lib/libc/include 2879626055SBrooks Davis.endif 2979626055SBrooks Davis 30804baa38SBryan Drewery_WITH_REALLOCARRAY!= grep -c reallocarray /usr/include/stdlib.h || true 318e7e3163SDimitry Andric.if ${_WITH_REALLOCARRAY} == 0 328e7e3163SDimitry Andric.PATH: ${.CURDIR}/../../lib/libc/stdlib 338e7e3163SDimitry AndricINCS+= stdlib.h 348e7e3163SDimitry AndricSRCS+= reallocarray.c 358e7e3163SDimitry AndricCFLAGS+= -I${.CURDIR}/../../lib/libc/include 368e7e3163SDimitry Andric.endif 378e7e3163SDimitry Andric 38d80f1dd1SJilles Tjoelker_WITH_UTIMENS!= grep -c utimensat /usr/include/sys/stat.h || true 39d80f1dd1SJilles Tjoelker.if ${_WITH_UTIMENS} == 0 40d80f1dd1SJilles TjoelkerSYSINCS+= stat.h 41d80f1dd1SJilles TjoelkerSRCS+= futimens.c utimensat.c 42d80f1dd1SJilles Tjoelker.endif 43d80f1dd1SJilles Tjoelker 448d14ced6SAlex Richardson_WITH_EXPLICIT_BZERO!= grep -c explicit_bzero /usr/include/strings.h || true 458d14ced6SAlex Richardson.if ${_WITH_EXPLICIT_BZERO} == 0 468d14ced6SAlex Richardson.PATH: ${SRCTOP}/sys/libkern 478d14ced6SAlex RichardsonINCS+= strings.h 488d14ced6SAlex RichardsonSRCS+= explicit_bzero.c 498d14ced6SAlex Richardson.endif 508d14ced6SAlex Richardson 5130aaff11SWarner Losh.if empty(SRCS) 5230aaff11SWarner LoshSRCS= dummy.c 5330aaff11SWarner Losh.endif 5430aaff11SWarner Losh 55f09a3cc4SRuslan Ermilov.if defined(CROSS_BUILD_TESTING) 56f09a3cc4SRuslan ErmilovSUBDIR= cross-build 57f09a3cc4SRuslan Ermilov.endif 58f09a3cc4SRuslan Ermilov 5963889bbdSAlex Richardson# Needed to build config (since it uses libnv) 6063889bbdSAlex RichardsonSYSINCS+= ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h 6163889bbdSAlex Richardson 62*8f62bca4SAlex Richardson# We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't 63*8f62bca4SAlex Richardson# accidentally run tools that are incompatible but happen to be in $PATH. 64*8f62bca4SAlex Richardson# This is especially important when building on Linux/MacOS where many of the 65*8f62bca4SAlex Richardson# programs used during the build accept different flags or generate different 66*8f62bca4SAlex Richardson# output. On those platforms we only symlink the tools known to be compatible 67*8f62bca4SAlex Richardson# (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others 68*8f62bca4SAlex Richardson# from the FreeBSD sources during the bootstrap-tools stage. 69*8f62bca4SAlex Richardson 70*8f62bca4SAlex Richardson# basic commands: It is fine to use the host version for all of these even on 71*8f62bca4SAlex Richardson# Linux/MacOS since we only use flags that are supported by all of them. 72*8f62bca4SAlex Richardson_host_tools_to_symlink= basename bzip2 bunzip2 chmod chown cmp comm cp date \ 73*8f62bca4SAlex Richardson dirname echo env false find fmt gzip gunzip head hostname id ln ls \ 74*8f62bca4SAlex Richardson mkdir mv nice patch rm realpath sh sleep stat tee touch tr true uname \ 75*8f62bca4SAlex Richardson uniq wc which 76*8f62bca4SAlex Richardson 77*8f62bca4SAlex Richardson# We also need a symlink to the absolute path to the make binary used for 78*8f62bca4SAlex Richardson# the toplevel makefile. This is not necessarily the same as `which make` 79*8f62bca4SAlex Richardson# since e.g. on Linux and MacOS that will be GNU make. 80*8f62bca4SAlex Richardson_make_abs!= which "${MAKE}" 81*8f62bca4SAlex Richardson_host_abs_tools_to_symlink= ${_make_abs}:make ${_make_abs}:bmake 82*8f62bca4SAlex Richardson 83*8f62bca4SAlex Richardsonhost-symlinks: 84*8f62bca4SAlex Richardson @echo "Linking host tools into ${DESTDIR}/bin" 85*8f62bca4SAlex Richardson.for _tool in ${_host_tools_to_symlink} 86*8f62bca4SAlex Richardson @if [ ! -e "${DESTDIR}/bin/${_tool}" ]; then \ 87*8f62bca4SAlex Richardson source_path=`which ${_tool}`; \ 88*8f62bca4SAlex Richardson if [ ! -e "$${source_path}" ] ; then \ 89*8f62bca4SAlex Richardson echo "Cannot find host tool '${_tool}'"; false; \ 90*8f62bca4SAlex Richardson fi; \ 91*8f62bca4SAlex Richardson ln -sfnv "$${source_path}" "${DESTDIR}/bin/${_tool}"; \ 92*8f62bca4SAlex Richardson fi 93*8f62bca4SAlex Richardson.endfor 94*8f62bca4SAlex Richardson.for _tool in ${_host_abs_tools_to_symlink} 95*8f62bca4SAlex Richardson @source_path="${_tool:S/:/ /:[1]}"; \ 96*8f62bca4SAlex Richardson target_path="${DESTDIR}/bin/${_tool:S/:/ /:[2]}"; \ 97*8f62bca4SAlex Richardson if [ ! -e "$${target_path}" ] ; then \ 98*8f62bca4SAlex Richardson if [ ! -e "$${source_path}" ] ; then \ 99*8f62bca4SAlex Richardson echo "Host tool '${src_path}' is missing"; false; \ 100*8f62bca4SAlex Richardson fi; \ 101*8f62bca4SAlex Richardson ln -sfnv "$${source_path}" "$${target_path}"; \ 102*8f62bca4SAlex Richardson fi 103*8f62bca4SAlex Richardson.endfor 1044acc8a67SAlex Richardson 1054acc8a67SAlex Richardson# Create all the directories that are needed during the legacy, bootstrap-tools 1064acc8a67SAlex Richardson# and cross-tools stages. We do this here using mkdir since mtree may not exist 1074acc8a67SAlex Richardson# yet (this happens if we are crossbuilding from Linux/Mac). 1084acc8a67SAlex Richardsoninstalldirs: 109*8f62bca4SAlex Richardson.for _dir in bin usr/lib usr/include lib/geom lib/casper 1104acc8a67SAlex Richardson mkdir -p "${DESTDIR}/${_dir}" 1114acc8a67SAlex Richardson.endfor 112*8f62bca4SAlex Richardson# Link usr/bin, sbin, and usr/sbin to bin so that it doesn't matter whether a 113*8f62bca4SAlex Richardson# bootstrap tool was added to WORLTMP with a symlink or by building it in the 114*8f62bca4SAlex Richardson# bootstrap-tools phase. We could also overrride BINDIR when building bootstrap 115*8f62bca4SAlex Richardson# tools but adding the symlinks is easier and means all tools are also 116*8f62bca4SAlex Richardson# in the directory that they are installed to normally. 117*8f62bca4SAlex Richardson ln -sf bin ${DESTDIR}/sbin 118*8f62bca4SAlex Richardson ln -sf ../bin ${DESTDIR}/usr/bin 119*8f62bca4SAlex Richardson ln -sf ../bin ${DESTDIR}/usr/sbin 1204acc8a67SAlex Richardson.for _group in ${INCSGROUPS:NINCS} 1214acc8a67SAlex Richardson mkdir -p "${DESTDIR}/${${_group}DIR}" 1224acc8a67SAlex Richardson.endfor 1234acc8a67SAlex Richardson 12430aaff11SWarner Losh.include <bsd.lib.mk> 125