3 .PATH: ${.CURDIR}/../../include
7 INCSGROUPS= INCS SYSINCS CASPERINC UFSINCS FFSINCS MSDOSFSINCS DISKINCS
10 SYSINCSDIR= ${INCLUDEDIR}/sys
11 CASPERINCDIR= ${INCLUDEDIR}/casper
12 # Also add ufs/ffs/msdosfs/disk headers to allow building makefs as a bootstrap tool
13 UFSINCSDIR= ${INCLUDEDIR}/ufs/ufs
14 FFSINCSDIR= ${INCLUDEDIR}/ufs/ffs
15 MSDOSFSINCSDIR= ${INCLUDEDIR}/fs/msdosfs
16 DISKINCSDIR= ${INCLUDEDIR}/sys/disk
20 _WITH_PWCACHEDB!= grep -c pwcache_groupdb /usr/include/grp.h || true
21 .if ${_WITH_PWCACHEDB} == 0
22 .PATH: ${.CURDIR}/../../contrib/libc-pwcache
23 CFLAGS+= -I${.CURDIR}/../../contrib/libc-pwcache \
24 -I${.CURDIR}/../../lib/libc/include
28 _WITH_STRSVIS!= grep -c strsvis /usr/include/vis.h || true
29 .if ${_WITH_STRSVIS} == 0
30 .PATH: ${.CURDIR}/../../contrib/libc-vis
32 CFLAGS+= -I${.CURDIR}/../../contrib/libc-vis \
33 -I${.CURDIR}/../../lib/libc/include
36 _WITH_REALLOCARRAY!= grep -c reallocarray /usr/include/stdlib.h || true
37 .if ${_WITH_REALLOCARRAY} == 0
38 .PATH: ${.CURDIR}/../../lib/libc/stdlib
41 CFLAGS+= -I${.CURDIR}/../../lib/libc/include
44 _WITH_UTIMENS!= grep -c utimensat /usr/include/sys/stat.h || true
45 .if ${_WITH_UTIMENS} == 0
47 SRCS+= futimens.c utimensat.c
50 _WITH_EXPLICIT_BZERO!= grep -c explicit_bzero /usr/include/strings.h || true
51 .if ${_WITH_EXPLICIT_BZERO} == 0
52 .PATH: ${SRCTOP}/sys/libkern
54 SRCS+= explicit_bzero.c
57 .if exists(/usr/include/capsicum_helpers.h)
58 _WITH_CAPH_ENTER!= grep -c caph_enter /usr/include/capsicum_helpers.h || true
59 _WITH_CAPH_RIGHTS_LIMIT!= grep -c caph_rights_limit /usr/include/capsicum_helpers.h || true
61 .if !defined(_WITH_CAPH_ENTER) || ${_WITH_CAPH_ENTER} == 0 || ${_WITH_CAPH_RIGHTS_LIMIT} == 0
62 .PATH: ${SRCTOP}/lib/libcapsicum
63 INCS+= capsicum_helpers.h
64 .PATH: ${SRCTOP}/lib/libcasper/libcasper
68 CASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_fileargs/cap_fileargs.h
74 .if defined(CROSS_BUILD_TESTING)
78 # To allow bootstrapping makefs on FreeBSD 11 or non-FreeBSD systems:
79 UFSINCS+= ${SRCTOP}/sys/ufs/ufs/dinode.h
80 UFSINCS+= ${SRCTOP}/sys/ufs/ufs/dir.h
81 FFSINCS+= ${SRCTOP}/sys/ufs/ffs/fs.h
83 MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/bootsect.h
84 MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/bpb.h
85 MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/denode.h
86 MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/direntry.h
87 MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/fat.h
88 MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/msdosfsmount.h
89 DISKINCS+= ${SRCTOP}/sys/sys/disk/bsd.h
91 # Needed to build config (since it uses libnv)
92 SYSINCS+= ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h \
93 ${SRCTOP}/sys/sys/dnv.h
95 # vtfontcvt is using sys/font.h
96 SYSINCS+= ${SRCTOP}/sys/sys/font.h
98 # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
99 # accidentally run tools that are incompatible but happen to be in $PATH.
100 # This is especially important when building on Linux/MacOS where many of the
101 # programs used during the build accept different flags or generate different
102 # output. On those platforms we only symlink the tools known to be compatible
103 # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
104 # from the FreeBSD sources during the bootstrap-tools stage.
106 # basic commands: It is fine to use the host version for all of these even on
107 # Linux/MacOS since we only use flags that are supported by all of them.
108 _host_tools_to_symlink= basename bzip2 bunzip2 chmod chown cmp comm cp date dd \
109 dirname echo env false find fmt gzip gunzip head hostname id ln ls \
110 mkdir mv nice patch rm realpath sh sleep stat tee touch tr true uname \
113 # We also need a symlink to the absolute path to the make binary used for
114 # the toplevel makefile. This is not necessarily the same as `which make`
115 # since e.g. on Linux and MacOS that will be GNU make.
116 _make_abs!= which "${MAKE}"
117 _host_abs_tools_to_symlink= ${_make_abs}:make ${_make_abs}:bmake
120 @echo "Linking host tools into ${DESTDIR}/bin"
121 .for _tool in ${_host_tools_to_symlink}
122 @if [ ! -e "${DESTDIR}/bin/${_tool}" ]; then \
123 source_path=`which ${_tool}`; \
124 if [ ! -e "$${source_path}" ] ; then \
125 echo "Cannot find host tool '${_tool}'"; false; \
127 ln -sfnv "$${source_path}" "${DESTDIR}/bin/${_tool}"; \
130 .for _tool in ${_host_abs_tools_to_symlink}
131 @source_path="${_tool:S/:/ /:[1]}"; \
132 target_path="${DESTDIR}/bin/${_tool:S/:/ /:[2]}"; \
133 if [ ! -e "$${target_path}" ] ; then \
134 if [ ! -e "$${source_path}" ] ; then \
135 echo "Host tool '${src_path}' is missing"; false; \
137 ln -sfnv "$${source_path}" "$${target_path}"; \
140 .if exists(/usr/libexec/flua)
141 ln -sf /usr/libexec/flua ${DESTDIR}/usr/libexec/flua
144 # Create all the directories that are needed during the legacy, bootstrap-tools
145 # and cross-tools stages. We do this here using mkdir since mtree may not exist
146 # yet (this happens if we are crossbuilding from Linux/Mac).
152 usr/include/private/ucl \
153 usr/include/private/zstd \
158 mkdir -p ${INSTALLDIR_LIST:S,^,${DESTDIR}/,}
160 # Link usr/bin, sbin, and usr/sbin to bin so that it doesn't matter whether a
161 # bootstrap tool was added to WORLTMP with a symlink or by building it in the
162 # bootstrap-tools phase. We could also overrride BINDIR when building bootstrap
163 # tools but adding the symlinks is easier and means all tools are also
164 # in the directory that they are installed to normally.
166 .for _dir in sbin usr/sbin usr/bin
167 # delete existing directories from before r340157
168 @if [ ! -L ${DESTDIR}/${_dir} ]; then \
169 echo "removing old non-symlink ${DESTDIR}/${_dir}"; \
170 rm -rf "${DESTDIR}/${_dir}"; \
173 ln -sfn bin ${DESTDIR}/sbin
174 ln -sfn ../bin ${DESTDIR}/usr/bin
175 ln -sfn ../bin ${DESTDIR}/usr/sbin
176 .for _group in ${INCSGROUPS:NINCS}
177 mkdir -p "${DESTDIR}/${${_group}DIR}"
180 .include <bsd.lib.mk>