summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-21 15:53:52 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-21 15:53:52 -0400
commitdd8e3b8b3e2d55c586e80e62d88719909bd8a568 (patch)
tree2a1de46f9e5b557a90e673e656f531340d0db962 /build
parentf9498086969d917a85452560173a0d9db3604c32 (diff)
downloadbfs-dd8e3b8b3e2d55c586e80e62d88719909bd8a568.tar.xz
build: Allow flags.mk to override command line variables
Previously, during something like ./configure LDFLAGS=..., any additions to LDFLAGS from the generated makefiles were ignored. I had thought that sub-make invocations would allow those variables to be overridden, but that is not the behaviour of make. So instead, set _LDFLAGS etc. in the generated files so that they don't conflict.
Diffstat (limited to 'build')
-rw-r--r--build/exports.mk8
-rw-r--r--build/flags.mk44
-rw-r--r--build/pkgs.mk6
3 files changed, 29 insertions, 29 deletions
diff --git a/build/exports.mk b/build/exports.mk
index ed19134..913a1aa 100644
--- a/build/exports.mk
+++ b/build/exports.mk
@@ -12,9 +12,9 @@ export XMKDIR=${MKDIR}
export XPKG_CONFIG=${PKG_CONFIG}
export XRM=${RM}
-export XCPPFLAGS=${CPPFLAGS}
-export XCFLAGS=${CFLAGS}
-export XLDFLAGS=${LDFLAGS}
-export XLDLIBS=${LDLIBS}
+export XCPPFLAGS=${_CPPFLAGS}
+export XCFLAGS=${_CFLAGS}
+export XLDFLAGS=${_LDFLAGS}
+export XLDLIBS=${_LDLIBS}
export XNOLIBS=${NOLIBS}
diff --git a/build/flags.mk b/build/flags.mk
index c911b22..8e359aa 100644
--- a/build/flags.mk
+++ b/build/flags.mk
@@ -109,28 +109,28 @@ APPEND = @append() { test -z "$$2" || printf '%s += %s\n' "$$1" "$$2" >>$@; }; a
gen/flags.mk::
${MSG} "[ GEN] $@"
@printf '# %s\n' "$@" >$@
- ${SETVAR} CPPFLAGS "$$BFS_CPPFLAGS"
- ${APPEND} CPPFLAGS "$$TSAN_CPPFLAGS"
- ${APPEND} CPPFLAGS "$$LINT_CPPFLAGS"
- ${APPEND} CPPFLAGS "$$RELEASE_CPPFLAGS"
- ${APPEND} CPPFLAGS "$$XCPPFLAGS"
- ${APPEND} CPPFLAGS "$$EXTRA_CPPFLAGS"
- ${SETVAR} CFLAGS "$$BFS_CFLAGS"
- ${APPEND} CFLAGS "$$ASAN_CFLAGS"
- ${APPEND} CFLAGS "$$LSAN_CFLAGS"
- ${APPEND} CFLAGS "$$MSAN_CFLAGS"
- ${APPEND} CFLAGS "$$TSAN_CFLAGS"
- ${APPEND} CFLAGS "$$UBSAN_CFLAGS"
- ${APPEND} CFLAGS "$$SAN_CFLAGS"
- ${APPEND} CFLAGS "$$GCOV_CFLAGS"
- ${APPEND} CFLAGS "$$LINT_CFLAGS"
- ${APPEND} CFLAGS "$$RELEASE_CFLAGS"
- ${APPEND} CFLAGS "$$XCFLAGS"
- ${APPEND} CFLAGS "$$EXTRA_CFLAGS"
- ${SETVAR} LDFLAGS "$$XLDFLAGS"
- ${SETVAR} LDLIBS "$$XLDLIBS"
- ${APPEND} LDLIBS "$$EXTRA_LDLIBS"
- ${APPEND} LDLIBS "$$BFS_LDLIBS"
+ ${SETVAR} _CPPFLAGS "$$BFS_CPPFLAGS"
+ ${APPEND} _CPPFLAGS "$$TSAN_CPPFLAGS"
+ ${APPEND} _CPPFLAGS "$$LINT_CPPFLAGS"
+ ${APPEND} _CPPFLAGS "$$RELEASE_CPPFLAGS"
+ ${APPEND} _CPPFLAGS "$$XCPPFLAGS"
+ ${APPEND} _CPPFLAGS "$$EXTRA_CPPFLAGS"
+ ${SETVAR} _CFLAGS "$$BFS_CFLAGS"
+ ${APPEND} _CFLAGS "$$ASAN_CFLAGS"
+ ${APPEND} _CFLAGS "$$LSAN_CFLAGS"
+ ${APPEND} _CFLAGS "$$MSAN_CFLAGS"
+ ${APPEND} _CFLAGS "$$TSAN_CFLAGS"
+ ${APPEND} _CFLAGS "$$UBSAN_CFLAGS"
+ ${APPEND} _CFLAGS "$$SAN_CFLAGS"
+ ${APPEND} _CFLAGS "$$GCOV_CFLAGS"
+ ${APPEND} _CFLAGS "$$LINT_CFLAGS"
+ ${APPEND} _CFLAGS "$$RELEASE_CFLAGS"
+ ${APPEND} _CFLAGS "$$XCFLAGS"
+ ${APPEND} _CFLAGS "$$EXTRA_CFLAGS"
+ ${SETVAR} _LDFLAGS "$$XLDFLAGS"
+ ${SETVAR} _LDLIBS "$$XLDLIBS"
+ ${APPEND} _LDLIBS "$$EXTRA_LDLIBS"
+ ${APPEND} _LDLIBS "$$BFS_LDLIBS"
${SETVAR} NOLIBS "$$XNOLIBS"
@test "${OS}-${SAN}" != FreeBSD-y || printf 'POSTLINK = elfctl -e +noaslr $$@\n' >>$@
${VCAT} $@
diff --git a/build/pkgs.mk b/build/pkgs.mk
index 39b550d..5a26548 100644
--- a/build/pkgs.mk
+++ b/build/pkgs.mk
@@ -15,9 +15,9 @@ gen/pkgs.mk: ${HEADERS}
@printf '# %s\n' "$@" >$@
@gen() { \
printf 'PKGS := %s\n' "$$*"; \
- printf 'CFLAGS += %s\n' "$$(build/pkgconf.sh --cflags "$$@")"; \
- printf 'LDFLAGS += %s\n' "$$(build/pkgconf.sh --ldflags "$$@")"; \
- printf 'LDLIBS := %s $${LDLIBS}\n' "$$(build/pkgconf.sh --ldlibs "$$@")"; \
+ printf '_CFLAGS += %s\n' "$$(build/pkgconf.sh --cflags "$$@")"; \
+ printf '_LDFLAGS += %s\n' "$$(build/pkgconf.sh --ldflags "$$@")"; \
+ printf '_LDLIBS := %s $${_LDLIBS}\n' "$$(build/pkgconf.sh --ldlibs "$$@")"; \
}; \
gen $$(grep -l ' true$$' ${.ALLSRC} | sed 's|.*/\(.*\)\.h|\1|') >>$@
${VCAT} $@