aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2023-04-22 19:01:49 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2023-04-22 19:01:49 +0000
commit8561d0b2ec50eb127b58dee30bf49ef519947457 (patch)
treeebe94922f8f2a1694ba6d13d165aa1d18e05610c /share
parentdbce131b8f40dbd5997db130e59ed7736a79f680 (diff)
Diffstat (limited to 'share')
-rw-r--r--share/mk/local.dirdeps.mk11
-rw-r--r--share/mk/local.init.mk5
-rw-r--r--share/mk/local.sys.mk8
-rw-r--r--share/mk/src.init.linux.mk15
-rw-r--r--share/mk/src.init.mk31
5 files changed, 68 insertions, 2 deletions
diff --git a/share/mk/local.dirdeps.mk b/share/mk/local.dirdeps.mk
index 246c9cdef114..d0ae1c0171cb 100644
--- a/share/mk/local.dirdeps.mk
+++ b/share/mk/local.dirdeps.mk
@@ -60,7 +60,15 @@ cleanup_worldtmp: .PHONY .NOMETA
rm -rf ${OBJTOP}/tmp
beforedirdeps: cleanup_worldtmp
.endif
-.endif
+
+# pseudo option for building host tools on old or non-FreeBSD host
+# allows us to leverage Makefile.depend.options with
+# DIRDEPS_OPTIONS = host_egacy
+# dirdeps-options.mk will qualify with ${DEP_MACHINE} (and others)
+# before looking at the bare option.
+MK_host_egacy.host= ${MK_host_egacy}
+
+.endif # !target(_DIRDEP_USE)
# reset this each time
DIRDEPS_FILTER.xtras=
@@ -69,6 +77,7 @@ DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
.endif
.if ${DEP_MACHINE} != "host"
+MK_host_egacy.${DEP_MACHINE}= no
# this is how we can handle optional dependencies
.if ${DEP_RELDIR} == "lib/libc"
diff --git a/share/mk/local.init.mk b/share/mk/local.init.mk
index c8072004697f..1d165c339ff0 100644
--- a/share/mk/local.init.mk
+++ b/share/mk/local.init.mk
@@ -19,7 +19,10 @@ CFLAGS_LAST+= --sysroot=${SYSROOT}
CXXFLAGS_LAST+= --sysroot=${SYSROOT}
LDADD+= --sysroot=${SYSROOT}
.elif ${MK_STAGING} == "yes"
-CFLAGS+= -isystem ${STAGE_INCLUDEDIR}
+ISYSTEM?= ${STAGE_INCLUDEDIR}
+# no space after -isystem makes it easier to
+# grep the flag out of command lines (in meta files) to see its value.
+CFLAGS+= -isystem${ISYSTEM}
# XXX: May be needed for GCC to build with libc++ rather than libstdc++. See Makefile.inc1
#CXXFLAGS+= -std=gnu++11
#LDADD+= -L${STAGE_LIBDIR}/libc++
diff --git a/share/mk/local.sys.mk b/share/mk/local.sys.mk
index 1817f6393949..1aac5014b737 100644
--- a/share/mk/local.sys.mk
+++ b/share/mk/local.sys.mk
@@ -79,6 +79,14 @@ JOB_MAX:= ${jm:R}
.endif
.endif
+.if ${MK_DIRDEPS_BUILD} == "yes"
+.if ${.MAKE.OS} != "FreeBSD" || ${_HOST_OSREL:R} < ${OS_REVISION:R}
+# a pseudo option to indicate we need libegacy for host
+MK_host_egacy= yes
+.endif
+.endif
+MK_host_egacy?= no
+
.if ${.MAKE.MODE:Mmeta*} != ""
# we can afford to use cookies to prevent some targets
# re-running needlessly but only when using filemon.
diff --git a/share/mk/src.init.linux.mk b/share/mk/src.init.linux.mk
new file mode 100644
index 000000000000..1e351e1b41f6
--- /dev/null
+++ b/share/mk/src.init.linux.mk
@@ -0,0 +1,15 @@
+# We want to build some host tools (eg makefs, mkimg) for Linux
+# This only gets included during DIRDEPS_BUILD when MACHINE is "host"
+
+CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux
+
+WARNS= 0
+
+.ifdef PROG
+LOCAL_LIBRARIES+= bsd egacy
+LIBADD+= egacy m
+.endif
+
+# Bring in the full GNU namespace
+CFLAGS+= -D_GNU_SOURCE
+
diff --git a/share/mk/src.init.mk b/share/mk/src.init.mk
index 2067dcdbbabc..148dc7a3e960 100644
--- a/share/mk/src.init.mk
+++ b/share/mk/src.init.mk
@@ -8,4 +8,35 @@ buildenv: .PHONY
${_+_}@env BUILDENV_DIR=${.CURDIR} ${MAKE} -C ${SRCTOP} buildenv
.endif
+.if ${MACHINE:Nhost*} == ""
+.if ${.MAKE.OS} != "FreeBSD"
+# these won't work anyway - see tools/build/mk/Makefile.boot.pre
+MK_DEBUG_FILES= no
+MK_MAN= no
+MK_PIE= no
+MK_RETPOLINE= no
+NO_SHARED= no
+MK_TESTS= no
+
+.-include <src.init.${.MAKE.OS:tl}.mk>
+
+CFLAGS+= \
+ -DHAVE_NBTOOL_CONFIG_H=1 \
+ -I${SRCTOP}/tools/build/cross-build/include/common \
+
+.endif
+
+.if ${MK_host_egacy} == "yes"
+.ifdef PROG
+LOCAL_LIBRARIES+= egacy
+LIBADD+= egacy
+.endif
+.endif
+
+.if ${MK_STAGING} == "yes"
+ISYSTEM= /usr/include
+CFLAGS+= -I${STAGE_INCLUDEDIR}
+.endif
+.endif
+
.endif # !target(__<src.init.mk>__)