Hello NetBSD toolchain devs, While experimenting with rumprun and building rump kernels, I had some patches I wanted to test to verify they did not cause any regressions in NetBSD proper. Unfortunately but unsurprisingly the build.sh crashed like nobody's business when trying to build NetBSD from a GNU Guix System Distribution host. Guix (and it's sister OS, Nix) are unique in that they do not use the traditional filesystem layout with /usr/include, /lib, etc., preferring to manage dependencies in new ways. I spent plenty of time over the last week patching build.sh and the Makefiles to ensure adequate support for HOST_CPPFLAGS and HOST_CXXFLAGS throughout the toolchain build process. Care was taken not to cross HOST_CPPFLAGS with standard CPPFLAGS where they don't belong. Combined with LIBRARY_PATH environment support, this makes the build system compatible with GNU Guix hosts. I have not tested NixOS, but I am sure it should support it as well. Regarding LIBRARY_PATH, I tried HOST_LDFLAGS="-L..." instead and unsetting LIBRARY_PATH from the make env, but this breaks in one special case for linking with crti.o, where it tries to resolve _lib_crti.o which does not exist. I think this is a gcc bug in the different treatment between LIBRARY_PATH=<path> and -L<path>, but I settled to use LIBRARY_PATH here which does not do any improper linking in the build output when it is present. Please take a look at the attached patch and try it out to make sure it does not break any of your work flows! Thank you -- Sincerely, Ryan Sundberg
From 17f1ca045b401cc955c3258bcb5af134f38dcb77 Mon Sep 17 00:00:00 2001
From: Ryan Sundberg <ryan%arctype.co@localhost>
Date: Tue, 14 Sep 2021 21:32:37 -0700
Subject: [PATCH] build.sh: Support building from GuixSD/NixOS hosts
Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, and LIBRARY_PATH. These variables are
necessary to support building NetBSD from a GNU Guix or NixOS host,
where /usr/include, /lib, and all but /bin/sh do not exist.
In many cases, support for HOST_CPPFLAGS was incomplete.
The build was tested using Guix System Distribution:
guix environment --ad-hoc gcc-toolchain zlib cdrtools
HOST_CXXFLAGS="-isystem =/include/c++" \
HOST_CPPFLAGS="-isysroot ${GUIX_ENVIRONMENT} -isystem =/include" \
HOST_CC=gcc \
./build.sh -U -O obj -T tools-obj -j12 -m amd64 -a x86_64 -c gcc release
anita test $(pwd)/obj/releasedir/amd64/
---
build.sh | 3 +++
distrib/sets/maketars | 2 +-
external/gpl3/binutils/dist/bfd/doc/Makefile.in | 3 ++-
external/gpl3/binutils/dist/binutils/Makefile.in | 10 +++++-----
external/gpl3/gcc/lib/liblto_plugin/Makefile | 1 +
external/gpl3/gcc/usr.bin/Makefile.prog | 1 +
external/gpl3/gcc/usr.bin/backend/Makefile | 1 +
external/gpl3/gcc/usr.bin/common-target/Makefile | 1 +
external/gpl3/gcc/usr.bin/common/Makefile | 1 +
external/gpl3/gcc/usr.bin/frontend/Makefile | 1 +
external/gpl3/gcc/usr.bin/host-libiberty/Makefile | 4 +++-
external/gpl3/gcc/usr.bin/libcpp/Makefile | 1 +
external/gpl3/gcc/usr.bin/libdecnumber/Makefile | 1 +
external/gpl3/gdb/bin/gdb/Makefile | 1 +
external/gpl3/gdb/bin/gdbserver/Makefile | 1 +
external/gpl3/gdb/bin/gdbtui/Makefile | 1 +
external/gpl3/gdb/lib/libgdb/Makefile | 1 +
external/gpl3/gdb/lib/libgdbsupport/Makefile | 1 +
external/lgpl3/gmp/dist/Makefile.in | 12 ++++++------
external/lgpl3/gmp/lib/libgmp/Makefile | 12 ++++++------
tools/Makefile.gnuhost | 1 +
tools/binutils/Makefile | 1 +
tools/compat/Makefile | 10 +++++-----
tools/fdisk/Makefile | 2 +-
tools/gcc/Makefile | 4 +++-
tools/gmp/Makefile | 2 ++
tools/sunlabel/Makefile | 2 +-
tools/uudecode/Makefile | 2 +-
tools/vgrind/Makefile | 2 +-
tools/xz-include/Makefile | 2 +-
30 files changed, 56 insertions(+), 31 deletions(-)
diff --git a/build.sh b/build.sh
index bdda43c961e..11c8ad0d7a9 100755
--- a/build.sh
+++ b/build.sh
@@ -473,11 +473,14 @@ level of source directory"
# These variables can be overridden via "-V var=value" if
# you know what you are doing.
#
+ unsetmakeenv C_INCLUDE_PATH
+ unsetmakeenv CPLUS_INCLUDE_PATH
unsetmakeenv INFODIR
unsetmakeenv LESSCHARSET
unsetmakeenv MAKEFLAGS
unsetmakeenv TERMINFO
setmakeenv LC_ALL C
+ setmakeenv LIBRARY_PATH ${LIBRARY_PATH}
# Find information about the build platform. This should be
# kept in sync with _HOST_OSNAME, _HOST_OSREL, and _HOST_ARCH
diff --git a/distrib/sets/maketars b/distrib/sets/maketars
index 8f69da1ff14..224007b6e34 100755
--- a/distrib/sets/maketars
+++ b/distrib/sets/maketars
@@ -166,7 +166,7 @@ TMPFILES=
cleanup()
{
es=$?
- /bin/rm -rf "${SDIR}" ${TMPFILES}
+ rm -rf "${SDIR}" ${TMPFILES}
trap - 0
exit ${es}
}
diff --git a/external/gpl3/binutils/dist/bfd/doc/Makefile.in b/external/gpl3/binutils/dist/bfd/doc/Makefile.in
index 0839fbd8d94..1ea80401b79 100644
--- a/external/gpl3/binutils/dist/bfd/doc/Makefile.in
+++ b/external/gpl3/binutils/dist/bfd/doc/Makefile.in
@@ -934,7 +934,8 @@ uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
$(MKDOC): chew.stamp ; @true
chew.stamp: $(srcdir)/chew.c
$(CC_FOR_BUILD) -o chw$$$$$(EXEEXT_FOR_BUILD) $(CFLAGS_FOR_BUILD) \
- $(LDFLAGS_FOR_BUILD) $(H_CFLAGS) $(AM_CPPFLAGS) $(srcdir)/chew.c; \
+ $(LDFLAGS_FOR_BUILD) $(H_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(srcdir)/chew.c; \
$(SHELL) $(srcdir)/../../move-if-change \
chw$$$$$(EXEEXT_FOR_BUILD) $(MKDOC); \
touch $@
diff --git a/external/gpl3/binutils/dist/binutils/Makefile.in b/external/gpl3/binutils/dist/binutils/Makefile.in
index 69b9551787e..cbdd69f250a 100644
--- a/external/gpl3/binutils/dist/binutils/Makefile.in
+++ b/external/gpl3/binutils/dist/binutils/Makefile.in
@@ -1477,20 +1477,20 @@ sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sysroff.info
./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
sysinfo$(EXEEXT_FOR_BUILD): sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@
- $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@
+ $(CC_FOR_BUILD) $(CPPFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o
$@ sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@
syslex_wrap.@OBJEXT@: syslex_wrap.c syslex.c sysinfo.h config.h
- $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c
+ $(CC_FOR_BUILD) $(CPPFLAGS) -c -I. -I$(srcdir) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c
sysinfo.@OBJEXT@: sysinfo.c
if [ -r sysinfo.c ]; then \
- $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
+ $(CC_FOR_BUILD) $(CPPFLAGS) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
else \
- $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
+ $(CC_FOR_BUILD) $(CPPFLAGS) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
fi
bin2c$(EXEEXT_FOR_BUILD): bin2c.c
- $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c
+ $(CC_FOR_BUILD) $(CPPFLAGS) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS_FOR_BUILD)
$(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c
embedspu: embedspu.sh Makefile
awk '/^program_transform_name=/ {print "program_transform_name=\"$(program_transform_name)\""; next} {print}' < $< > $@
diff --git a/external/gpl3/gcc/lib/liblto_plugin/Makefile b/external/gpl3/gcc/lib/liblto_plugin/Makefile
index a136b8793d7..f0def9dfc51 100644
--- a/external/gpl3/gcc/lib/liblto_plugin/Makefile
+++ b/external/gpl3/gcc/lib/liblto_plugin/Makefile
@@ -46,6 +46,7 @@ config.h: Makefile
(cd .ab && \
AWK=${TOOL_AWK:Q} \
CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} \
+ CPPFLAGS=${HOST_CPPFLAGS:Q} \
MAKE=${MAKE:Q} \
CONFIG_SHELL=${HOST_SH:Q} \
${HOST_SH} ${DIST}/libiberty/configure \
diff --git a/external/gpl3/gcc/usr.bin/Makefile.prog b/external/gpl3/gcc/usr.bin/Makefile.prog
index 88527898738..dbc09428787 100644
--- a/external/gpl3/gcc/usr.bin/Makefile.prog
+++ b/external/gpl3/gcc/usr.bin/Makefile.prog
@@ -11,6 +11,7 @@ HOSTPROG_CXX= 1
# Force using C++ for this
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS}
diff --git a/external/gpl3/gcc/usr.bin/backend/Makefile b/external/gpl3/gcc/usr.bin/backend/Makefile
index cef0183f3b9..3f28e629557 100644
--- a/external/gpl3/gcc/usr.bin/backend/Makefile
+++ b/external/gpl3/gcc/usr.bin/backend/Makefile
@@ -222,6 +222,7 @@ auto-build.h: gmp.h Makefile
(cd .ab && \
AWK=${TOOL_AWK:Q} \
CC=${ORIGHOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} \
+ CPPFLAGS=${HOST_CPPFLAGS:Q} \
CXX=${HOST_CXX:Q} CXXFLAGS=${HOST_CXXFLAGS:Q} \
MAKE=${TOOL_GMAKE:Q} \
CONFIG_SHELL=${HOST_SH:Q} \
diff --git a/external/gpl3/gcc/usr.bin/common-target/Makefile b/external/gpl3/gcc/usr.bin/common-target/Makefile
index fa083deeed6..9723929a8c4 100644
--- a/external/gpl3/gcc/usr.bin/common-target/Makefile
+++ b/external/gpl3/gcc/usr.bin/common-target/Makefile
@@ -49,6 +49,7 @@ HOSTPROG_CXX= 1
# Force using C++ for this
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS}
diff --git a/external/gpl3/gcc/usr.bin/common/Makefile b/external/gpl3/gcc/usr.bin/common/Makefile
index 4f2251bc50e..55328b82733 100644
--- a/external/gpl3/gcc/usr.bin/common/Makefile
+++ b/external/gpl3/gcc/usr.bin/common/Makefile
@@ -34,6 +34,7 @@ ${SRCS}: ${GCCARCH}/defs.mk
# Force using C++ for this
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS}
diff --git a/external/gpl3/gcc/usr.bin/frontend/Makefile b/external/gpl3/gcc/usr.bin/frontend/Makefile
index 71d1787c6e2..8ccd184ec28 100644
--- a/external/gpl3/gcc/usr.bin/frontend/Makefile
+++ b/external/gpl3/gcc/usr.bin/frontend/Makefile
@@ -32,6 +32,7 @@ MKPICLIB:= no
# Force using C++ for this
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS}
diff --git a/external/gpl3/gcc/usr.bin/host-libiberty/Makefile b/external/gpl3/gcc/usr.bin/host-libiberty/Makefile
index aae4941a18c..a4137086b13 100644
--- a/external/gpl3/gcc/usr.bin/host-libiberty/Makefile
+++ b/external/gpl3/gcc/usr.bin/host-libiberty/Makefile
@@ -5,10 +5,12 @@ libiberty/libiberty.a:
(cd libiberty; \
CC=${HOST_CC:Q} \
CFLAGS=${HOST_CFLAGS:Q} \
+ CPPFLAGS=${HOST_CPPFLAGS:Q} \
MAKE=${MAKE:Q} \
CONFIG_SHELL=${HOST_SH:Q} \
${HOST_SH} ${DIST}/libiberty/configure \
- && CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} ${MAKE})
+ && CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} \
+ CPPFLAGS=${HOST_CPPFLAGS:Q} ${MAKE})
cleandir:
-rm -rf libiberty
diff --git a/external/gpl3/gcc/usr.bin/libcpp/Makefile b/external/gpl3/gcc/usr.bin/libcpp/Makefile
index 74a0d22f5ad..aef9abe8641 100644
--- a/external/gpl3/gcc/usr.bin/libcpp/Makefile
+++ b/external/gpl3/gcc/usr.bin/libcpp/Makefile
@@ -21,6 +21,7 @@ COPTS+= -Wno-stack-protector
# Force using C++ for this
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS}
diff --git a/external/gpl3/gcc/usr.bin/libdecnumber/Makefile b/external/gpl3/gcc/usr.bin/libdecnumber/Makefile
index 04e5c029178..8ec7c5262be 100644
--- a/external/gpl3/gcc/usr.bin/libdecnumber/Makefile
+++ b/external/gpl3/gcc/usr.bin/libdecnumber/Makefile
@@ -23,6 +23,7 @@ HOSTPROG_CXX= 1
# Force using C++ for this
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS}
diff --git a/external/gpl3/gdb/bin/gdb/Makefile b/external/gpl3/gdb/bin/gdb/Makefile
index 5911ed93461..ca2720d2f15 100644
--- a/external/gpl3/gdb/bin/gdb/Makefile
+++ b/external/gpl3/gdb/bin/gdb/Makefile
@@ -108,6 +108,7 @@ DPADD+= ${LIBEXPAT} ${LIBLZMA} ${LIBZ} ${LIBCURSES} ${LIBINTL} ${LIBM} ${LIBKVM
# Force c++
CWARNFLAGS.clang+= -Wno-deprecated
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS} -std=gnu++11 -Wno-error=stack-protector
diff --git a/external/gpl3/gdb/bin/gdbserver/Makefile b/external/gpl3/gdb/bin/gdbserver/Makefile
index f59786e540c..e7c0ef25cfe 100644
--- a/external/gpl3/gdb/bin/gdbserver/Makefile
+++ b/external/gpl3/gdb/bin/gdbserver/Makefile
@@ -56,6 +56,7 @@ DPADD+= ${LIBGDBSUPPORTDIR}/libgdbsupport.a \
# Force c++
CWARNFLAGS.clang+= -Wno-deprecated
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS} -std=gnu++11 -Wno-error=stack-protector -pthread
diff --git a/external/gpl3/gdb/bin/gdbtui/Makefile b/external/gpl3/gdb/bin/gdbtui/Makefile
index 14d80ce1bc1..4f6f760baa0 100644
--- a/external/gpl3/gdb/bin/gdbtui/Makefile
+++ b/external/gpl3/gdb/bin/gdbtui/Makefile
@@ -33,6 +33,7 @@ NOMAN= # defined
# Force c++
CWARNFLAGS.clang+= -Wno-deprecated
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS} -std=gnu++11 -Wno-error=stack-protector
diff --git a/external/gpl3/gdb/lib/libgdb/Makefile b/external/gpl3/gdb/lib/libgdb/Makefile
index d51c69f3e02..fde3185a64e 100644
--- a/external/gpl3/gdb/lib/libgdb/Makefile
+++ b/external/gpl3/gdb/lib/libgdb/Makefile
@@ -46,6 +46,7 @@ CWARNFLAGS.clang+= -Wno-switch
# Force c++
CWARNFLAGS.clang+= -Wno-deprecated
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS} -std=gnu++17 -Wno-error=stack-protector
diff --git a/external/gpl3/gdb/lib/libgdbsupport/Makefile b/external/gpl3/gdb/lib/libgdbsupport/Makefile
index 93bb029e412..dfa7106fd45 100644
--- a/external/gpl3/gdb/lib/libgdbsupport/Makefile
+++ b/external/gpl3/gdb/lib/libgdbsupport/Makefile
@@ -45,6 +45,7 @@ CWARNFLAGS.clang+= -Wno-switch
# Force c++
CWARNFLAGS.clang+= -Wno-deprecated
HOST_CC:= ${HOST_CXX}
+HOST_CFLAGS+= ${HOST_CXXFLAGS}
CC:= ${CXX}
CFLAGS:= ${CXXFLAGS} -std=gnu++11 -Wno-error=stack-protector
diff --git a/external/lgpl3/gmp/dist/Makefile.in b/external/lgpl3/gmp/dist/Makefile.in
index f6e40685d15..4de5d779f33 100644
--- a/external/lgpl3/gmp/dist/Makefile.in
+++ b/external/lgpl3/gmp/dist/Makefile.in
@@ -1452,7 +1452,7 @@ fac_table.h: gen-fac$(EXEEXT_FOR_BUILD)
./gen-fac $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >fac_table.h || (rm -f fac_table.h; exit 1)
gen-fac$(EXEEXT_FOR_BUILD): gen-fac$(U_FOR_BUILD).c bootstrap.c
- $(CC_FOR_BUILD) `test -f 'gen-fac$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fac$(U_FOR_BUILD).c -o gen-fac$(EXEEXT_FOR_BUILD)
+ $(CC_FOR_BUILD) $(CPPFLAGS) `test -f 'gen-fac$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fac$(U_FOR_BUILD).c -o gen-fac$(EXEEXT_FOR_BUILD)
fib_table.h: gen-fib$(EXEEXT_FOR_BUILD)
./gen-fib header $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >fib_table.h || (rm -f fib_table.h; exit 1)
@@ -1461,7 +1461,7 @@ mpn/fib_table.c: gen-fib$(EXEEXT_FOR_BUILD)
./gen-fib table $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/fib_table.c || (rm -f mpn/fib_table.c; exit 1)
gen-fib$(EXEEXT_FOR_BUILD): gen-fib$(U_FOR_BUILD).c bootstrap.c
- $(CC_FOR_BUILD) `test -f 'gen-fib$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fib$(U_FOR_BUILD).c -o gen-fib$(EXEEXT_FOR_BUILD)
+ $(CC_FOR_BUILD) $(CPPFLAGS) `test -f 'gen-fib$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fib$(U_FOR_BUILD).c -o gen-fib$(EXEEXT_FOR_BUILD)
mp_bases.h: gen-bases$(EXEEXT_FOR_BUILD)
./gen-bases header $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mp_bases.h || (rm
-f mp_bases.h; exit 1)
@@ -1470,25 +1470,25 @@ mpn/mp_bases.c: gen-bases$(EXEEXT_FOR_BUILD)
./gen-bases table $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/mp_bases.c || (rm -f mpn/mp_bases.c; exit 1)
gen-bases$(EXEEXT_FOR_BUILD): gen-bases$(U_FOR_BUILD).c bootstrap.c
- $(CC_FOR_BUILD) `test -f 'gen-bases$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-bases$(U_FOR_BUILD).c -o gen-bases$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
+ $(CC_FOR_BUILD) $(CPPFLAGS) `test -f 'gen-bases$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-bases$(U_FOR_BUILD).c -o gen-bases$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
trialdivtab.h: gen-trialdivtab$(EXEEXT_FOR_BUILD)
./gen-trialdivtab $(GMP_LIMB_BITS) 8000 >trialdivtab.h || (rm -f trialdivtab.h; exit 1)
gen-trialdivtab$(EXEEXT_FOR_BUILD): gen-trialdivtab$(U_FOR_BUILD).c bootstrap.c
- $(CC_FOR_BUILD) `test -f 'gen-trialdivtab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-trialdivtab$(U_FOR_BUILD).c -o gen-trialdivtab$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
+ $(CC_FOR_BUILD) $(CPPFLAGS) `test -f 'gen-trialdivtab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-trialdivtab$(U_FOR_BUILD).c -o gen-trialdivtab$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
mpn/jacobitab.h: gen-jacobitab$(EXEEXT_FOR_BUILD)
./gen-jacobitab >mpn/jacobitab.h || (rm -f mpn/jacobitab.h; exit 1)
gen-jacobitab$(EXEEXT_FOR_BUILD): gen-jacobitab$(U_FOR_BUILD).c
- $(CC_FOR_BUILD) `test -f 'gen-jacobitab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-jacobitab$(U_FOR_BUILD).c -o gen-jacobitab$(EXEEXT_FOR_BUILD)
+ $(CC_FOR_BUILD) $(CPPFLAGS) `test -f 'gen-jacobitab$(U_FOR_BUILD).c' ||
echo '$(srcdir)/'`gen-jacobitab$(U_FOR_BUILD).c -o gen-jacobitab$(EXEEXT_FOR_BUILD)
mpn/perfsqr.h: gen-psqr$(EXEEXT_FOR_BUILD)
./gen-psqr $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/perfsqr.h || (rm -f mpn/perfsqr.h; exit 1)
gen-psqr$(EXEEXT_FOR_BUILD): gen-psqr$(U_FOR_BUILD).c bootstrap.c
- $(CC_FOR_BUILD) `test -f 'gen-psqr$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-psqr$(U_FOR_BUILD).c -o gen-psqr$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
+ $(CC_FOR_BUILD) $(CPPFLAGS) `test -f 'gen-psqr$(U_FOR_BUILD).c' || echo
'$(srcdir)/'`gen-psqr$(U_FOR_BUILD).c -o gen-psqr$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
# Avoid: CVS - cvs directories
# *~ - emacs backups
diff --git a/external/lgpl3/gmp/lib/libgmp/Makefile b/external/lgpl3/gmp/lib/libgmp/Makefile
index 70a617c4d8c..cfbbc564597 100644
--- a/external/lgpl3/gmp/lib/libgmp/Makefile
+++ b/external/lgpl3/gmp/lib/libgmp/Makefile
@@ -160,13 +160,13 @@ DPSRCS= fac_table.h fib_table.h fib_table.c jacobitab.h mp_bases.h \
mp_bases.c perfsqr.h trialdivtab.h
gen-fac: gen-fac.c
- ${HOST_CC} -o ${.OBJDIR}/gen-fac ${.ALLSRC}
+ ${HOST_CC} ${HOST_CPPFLAGS} -o ${.OBJDIR}/gen-fac ${.ALLSRC}
fac_table.h: gen-fac
${.OBJDIR}/gen-fac ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/fac_table.h
gen-fib: gen-fib.c
- ${HOST_CC} -o ${.OBJDIR}/gen-fib ${.ALLSRC}
+ ${HOST_CC} ${HOST_CPPFLAGS} -o ${.OBJDIR}/gen-fib ${.ALLSRC}
fib_table.h: gen-fib
${.OBJDIR}/gen-fib header ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/fib_table.h
@@ -175,7 +175,7 @@ fib_table.c: gen-fib
${.OBJDIR}/gen-fib table ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/fib_table.c
gen-bases: gen-bases.c
- ${HOST_CC} -o ${.OBJDIR}/gen-bases ${.ALLSRC} -lm
+ ${HOST_CC} ${HOST_CPPFLAGS} -o ${.OBJDIR}/gen-bases ${.ALLSRC} -lm
mp_bases.h: gen-bases
${.OBJDIR}/gen-bases header ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/mp_bases.h
@@ -184,17 +184,17 @@ mp_bases.c: gen-bases
${.OBJDIR}/gen-bases table ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/mp_bases.c
gen-jacobitab: gen-jacobitab.c
- ${HOST_CC} -o ${.OBJDIR}/gen-jacobitab ${.ALLSRC} -lm
+ ${HOST_CC} ${HOST_CPPFLAGS} -o ${.OBJDIR}/gen-jacobitab ${.ALLSRC} -lm
jacobitab.h: gen-jacobitab
${.OBJDIR}/gen-jacobitab > ${.OBJDIR}/jacobitab.h
perfsqr.h: gen-psqr.c
- ${HOST_CC} -o ${.OBJDIR}/gen-psqr ${.ALLSRC}
+ ${HOST_CC} ${HOST_CPPFLAGS} -o ${.OBJDIR}/gen-psqr ${.ALLSRC}
${.OBJDIR}/gen-psqr ${GMP_LIMB_BITS} 0 > ${.OBJDIR}/perfsqr.h
gen-trialdivtab: gen-trialdivtab.c
- ${HOST_CC} -o ${.OBJDIR}/gen-trialdivtab ${.ALLSRC} -lm
+ ${HOST_CC} ${HOST_CPPFLAGS} -o ${.OBJDIR}/gen-trialdivtab ${.ALLSRC} -lm
trialdiv.c: trialdivtab.h
trialdivtab.h: gen-trialdivtab Makefile
diff --git a/tools/Makefile.gnuhost b/tools/Makefile.gnuhost
index a9d3417fc6d..0e9b5c0ad3e 100644
--- a/tools/Makefile.gnuhost
+++ b/tools/Makefile.gnuhost
@@ -63,6 +63,7 @@ CONFIGURE_ENV+= \
INSTALL=${HOST_INSTALL_FILE:Q} \
LDFLAGS=${HOST_LDFLAGS:Q} \
LEX=${LEX:Q} \
+ LIBRARY_PATH=${LIBRARY_PATH:Q} \
FLEX=${LEX:Q} \
M4=${TOOL_M4:Q} \
MAKE=${MAKE_PROGRAM:Q} \
diff --git a/tools/binutils/Makefile b/tools/binutils/Makefile
index 2213662fbce..a611b092465 100644
--- a/tools/binutils/Makefile
+++ b/tools/binutils/Makefile
@@ -36,6 +36,7 @@ INSTALL_TARGET+=install-gprof
CCADDFLAGS= -I${GNUHOSTDIST}/include -I${DESTDIR}/usr/include
CCADDFLAGS+= -B${DESTDIR}/usr/lib/
+CCADDFLAGS+= ${HOST_CPPFLAGS}
LDADDFLAGS= -L${DESTDIR}/lib -L${DESTDIR}/usr/lib
# Force avoiding possibly non-executable install-sh.
diff --git a/tools/compat/Makefile b/tools/compat/Makefile
index b42319b61f1..03a8e840852 100644
--- a/tools/compat/Makefile
+++ b/tools/compat/Makefile
@@ -31,13 +31,13 @@ BUILD_OSTYPE!= uname -s
# Disable use of pre-compiled headers on Darwin.
.if ${BUILD_OSTYPE} == "Darwin"
-CPPFLAGS+= -no-cpp-precomp
+HOST_CPPFLAGS+= -no-cpp-precomp
.endif
# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
# other file ops, on many systems, without changing function names.
-CPPFLAGS+= -I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
+HOST_CPPFLAGS+= -I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
.PATH: ${.CURDIR}/../../lib/libc/cdb \
@@ -84,7 +84,8 @@ CONFIGURE_ARGS+=--silent
config.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
rm -f ${.TARGET}
- CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q}
\
+ CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} CPPFLAGS=${HOST_CPPFLAGS:Q} \
+ LDFLAGS=${HOST_LDFLAGS:Q} \
${HOST_SH} ${.CURDIR}/configure ${CONFIGURE_ARGS}
defs.mk: config.cache
@@ -149,8 +150,7 @@ ${HOST_SHAREDIR}/compat/defs.mk: defs.mk
# bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS
-HOST_CPPFLAGS:= ${CPPFLAGS}
-CPPFLAGS:= # empty
+HOST_CPPFLAGS+= ${CPPFLAGS}
.include <bsd.hostlib.mk>
diff --git a/tools/fdisk/Makefile b/tools/fdisk/Makefile
index bf2ee742672..ed1794c136a 100644
--- a/tools/fdisk/Makefile
+++ b/tools/fdisk/Makefile
@@ -4,7 +4,7 @@ HOSTPROGNAME= ${MACHINE_GNU_PLATFORM}-fdisk
HOST_SRCDIR= sbin/fdisk
HOST_SRCS= disklabel.c
-HOST_CPPFLAGS= -DDEFAULT_BOOTDIR=\"${DESTDIR}/usr/mdec\"
+HOST_CPPFLAGS+= -DDEFAULT_BOOTDIR=\"${DESTDIR}/usr/mdec\"
.include "${.CURDIR}/../Makefile.nbincludes"
.include "${.CURDIR}/../Makefile.host"
diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
index e9e68ff089c..74fbcdc3c5f 100644
--- a/tools/gcc/Makefile
+++ b/tools/gcc/Makefile
@@ -71,7 +71,8 @@ CONFIGURE_ARGS+= \
--enable-languages="${GCC_LANGUAGES}"
GCC_CPPFLAGS= -DNETBSD_TOOLS -DTARGET_SYSTEM_ROOT=0 \
- -DTARGET_SYSTEM_ROOT_RELOCATABLE
+ -DTARGET_SYSTEM_ROOT_RELOCATABLE \
+ ${HOST_CPPFLAGS}
MAKE_ARGS= MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q} \
LIBGCC= LIBGCC1= LIBGCC1_TEST= LIBGCC2= INSTALL_LIBGCC= \
@@ -120,6 +121,7 @@ MKNATIVE_ENV= ${BINENV} ${CONFIGURE_ENV:NC*:NLD*} \
CXX=${CXX:Q}' '${CCADDFLAGS:Q}' '${CXXADDFLAGS:Q} \
CPP=${CPP:Q}' '-I${DESTDIR}/usr/include' '-I${DESTDIR}/usr/include/g++/bits \
CFLAGS= CPPFLAGS= CXXFLAGS= LDFLAGS= \
+ LIBRARY_PATH=${LIBRARY_PATH:Q} \
AS=${AS:Q} AWK=${TOOL_AWK:Q} LD=${LD:Q} \
MSGFMT=${TOOLDIR}/bin/${_TOOL_PREFIX}msgfmt \
NM=${NM:Q} OBJDUMP=${OBJDUMP:Q} \
diff --git a/tools/gmp/Makefile b/tools/gmp/Makefile
index 4e6f8205f32..1fbd57b079c 100644
--- a/tools/gmp/Makefile
+++ b/tools/gmp/Makefile
@@ -5,6 +5,8 @@ GNUHOSTDIST= ${.CURDIR}/../../external/lgpl3/gmp/dist
CONFIGURE_ARGS+=--disable-shared
+CPPFLAGS+= ${HOST_CPPFLAGS}
+
.include "${.CURDIR}/../Makefile.gnuhost"
# Don't override CFLAGS and CXXFLAGS, it breaks ABI detection.
diff --git a/tools/sunlabel/Makefile b/tools/sunlabel/Makefile
index 8cb2d8f6b08..b913948580b 100644
--- a/tools/sunlabel/Makefile
+++ b/tools/sunlabel/Makefile
@@ -2,6 +2,6 @@
HOSTPROGNAME= ${_TOOL_PREFIX}sunlabel
HOST_SRCDIR= usr.sbin/sunlabel
-HOST_CPPFLAGS= -DDISTRIB -DNO_S_COMMAND -DNO_TERMCAP_WIDTH
+HOST_CPPFLAGS+= -DDISTRIB -DNO_S_COMMAND -DNO_TERMCAP_WIDTH
.include "${.CURDIR}/../Makefile.host"
diff --git a/tools/uudecode/Makefile b/tools/uudecode/Makefile
index 0bc794fed8e..2f0c91e49a5 100644
--- a/tools/uudecode/Makefile
+++ b/tools/uudecode/Makefile
@@ -3,6 +3,6 @@
HOSTPROGNAME= ${_TOOL_PREFIX}uudecode
HOST_SRCDIR= usr.bin/uudecode
-HOST_CPPFLAGS= -DNO_BASE64
+HOST_CPPFLAGS+= -DNO_BASE64
.include "${.CURDIR}/../Makefile.host"
diff --git a/tools/vgrind/Makefile b/tools/vgrind/Makefile
index cf514ebd970..90a692de1b4 100644
--- a/tools/vgrind/Makefile
+++ b/tools/vgrind/Makefile
@@ -4,7 +4,7 @@ HOSTPROGNAME= ${_TOOL_PREFIX}vfontedpr
HOST_BINDIR= ${TOOLDIR}/libexec
HOST_SRCDIR= usr.bin/vgrind
HOST_FILESDIR= ${TOOLDIR}/share/misc
-HOST_CPPFLAGS= -D_PATH_VGRINDEFS=\"${HOST_FILESDIR}/vgrindefs\"
+HOST_CPPFLAGS+= -D_PATH_VGRINDEFS=\"${HOST_FILESDIR}/vgrindefs\"
HOSTFILES= vgrindefs vgrindefs.db
NOSHARE=# defined
CLEANFILES+= ${HOSTFILES}
diff --git a/tools/xz-include/Makefile b/tools/xz-include/Makefile
index de909583d62..6793f82a6d2 100644
--- a/tools/xz-include/Makefile
+++ b/tools/xz-include/Makefile
@@ -15,7 +15,7 @@ CONFIGURE_ARGS+= --silent
config.status: ${XZSRCDIR}/configure
${HOST_SH} ${XZSRCDIR}/configure ${CONFIGURE_ARGS} \
- CC=${HOST_CC:Q}
+ CC=${HOST_CC:Q} CPPFLAGS=${HOST_CPPFLAGS:Q}
CLEANFILES+= config.log config.status config.h libtool stamp-h1
--
2.31.1
Attachment:
OpenPGP_signature
Description: OpenPGP digital signature