summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile107
1 files changed, 52 insertions, 55 deletions
diff --git a/Makefile b/Makefile
index ed59126..0df7ce5 100644
--- a/Makefile
+++ b/Makefile
@@ -166,12 +166,6 @@ _XCFLAGS := ${CFLAGS}
_XLDFLAGS := ${LDFLAGS}
_XLDLIBS := ${LDLIBS}
-_XUSE_LIBACL := ${USE_LIBACL}
-_XUSE_LIBCAP := ${USE_LIBCAP}
-_XUSE_LIBSELINUX := ${USE_LIBSELINUX}
-_XUSE_LIBURING := ${USE_LIBURING}
-_XUSE_ONIGURUMA := ${USE_ONIGURUMA}
-
# GNU make supports `export VAR`, but BSD make requires `export VAR=value`.
# Sadly, GNU make gives a recursion error on `export VAR=${VAR}`.
@@ -197,40 +191,26 @@ export XCFLAGS=${_XCFLAGS}
export XLDFLAGS=${_XLDFLAGS}
export XLDLIBS=${_XLDLIBS}
-export XUSE_LIBACL=${_XUSE_LIBACL}
-export XUSE_LIBCAP=${_XUSE_LIBCAP}
-export XUSE_LIBSELINUX=${_XUSE_LIBSELINUX}
-export XUSE_LIBURING=${_XUSE_LIBURING}
-export XUSE_ONIGURUMA=${_XUSE_ONIGURUMA}
-
# The configuration file generated by `make config`
CONFIG := ${GEN}/config.mk
-include ${CONFIG}
## Configuration phase (`make config`)
-# External dependencies
-PKGS := \
- ${GEN}/libacl.mk \
- ${GEN}/libcap.mk \
- ${GEN}/libselinux.mk \
- ${GEN}/liburing.mk \
- ${GEN}/oniguruma.mk
-
# Makefile fragments generated by `make config`
MKS := \
${GEN}/vars.mk \
${GEN}/deps.mk \
${GEN}/objs.mk \
- ${PKGS}
+ ${GEN}/pkgs.mk
# The configuration goal itself
config: ${MKS}
- @printf 'include $${GEN}/%s\n' ${MKS:${GEN}/%=%} >${CONFIG}
+ @printf 'include $${GEN}/%s\n' ${.ALLSRC:${GEN}/%=%} >${CONFIG}
.PHONY: config
# Saves the configurable variables
-${GEN}/vars.mk::
+${GEN}/vars.mk:
@${XMKDIR} ${@D}
@printf 'PREFIX := %s\n' "$$XPREFIX" >$@
@printf 'MANDIR := %s\n' "$$XMANDIR" >>$@
@@ -240,50 +220,67 @@ ${GEN}/vars.mk::
@printf 'INSTALL := %s\n' "$$XINSTALL" >>$@
@printf 'MKDIR := %s\n' "$$XMKDIR" >>$@
@printf 'RM := %s\n' "$$XRM" >>$@
- @printf 'CPPFLAGS := %s\n' "$$BFS_CPPFLAGS" >>$@
- @test "${TSAN}" != y || printf 'CPPFLAGS += %s\n' "$$TSAN_CPPFLAGS" >>$@
- @test "${LINT}" != y || printf 'CPPFLAGS += %s\n' "$$LINT_CPPFLAGS" >>$@
- @test "${RELEASE}" != y || printf 'CPPFLAGS += %s\n' "$$RELEASE_CPPFLAGS" >>$@
- @test -z "$$XCPPFLAGS" || printf 'CPPFLAGS += %s\n' "$$XCPPFLAGS" >>$@
- @test -z "$$EXTRA_CPPFLAGS" || printf 'CPPFLAGS += %s\n' "$$EXTRA_CPPFLAGS" >>$@
- @printf 'CFLAGS := %s\n' "$$BFS_CFLAGS" >>$@
- @test "${ASAN}" != y || printf 'CFLAGS += %s\n' "$$ASAN_CFLAGS" >>$@
- @test "${LSAN}" != y || printf 'CFLAGS += %s\n' "$$LSAN_CFLAGS" >>$@
- @test "${MSAN}" != y || printf 'CFLAGS += %s\n' "$$MSAN_CFLAGS" >>$@
- @test "${TSAN}" != y || printf 'CFLAGS += %s\n' "$$TSAN_CFLAGS" >>$@
- @test "${UBSAN}" != y || printf 'CFLAGS += %s\n' "$$UBSAN_CFLAGS" >>$@
- @case "${SAN}" in *y*) printf 'CFLAGS += %s\n' "$$SAN_CFLAGS" >>$@ ;; esac
- @test "${GCOV}" != y || printf 'CFLAGS += %s\n' "$$GCOV_CFLAGS" >>$@
- @test "${LINT}" != y || printf 'CFLAGS += %s\n' "$$LINT_CFLAGS" >>$@
- @test "${RELEASE}" != y || printf 'CFLAGS += %s\n' "$$RELEASE_CFLAGS" >>$@
- @test -z "$$XCFLAGS" || printf 'CFLAGS += %s\n' "$$XCFLAGS" >>$@
- @test -z "$$EXTRA_CFLAGS" || printf 'CFLAGS += %s\n' "$$EXTRA_CFLAGS" >>$@
- @printf 'LDFLAGS := %s\n' "$$XLDFLAGS" >>$@
- @test -z "$$EXTRA_LDFLAGS" || printf 'LDFLAGS += %s\n' "$$EXTRA_LDFLAGS" >>$@
- @printf 'LDLIBS := %s\n' "$$XLDLIBS" >>$@
- @test -z "$$EXTRA_LDLIBS" || printf 'LDLIBS += %s\n' "$$EXTRA_LDLIBS" >>$@
- @test -z "$$BFS_LDLIBS" || printf 'LDLIBS += %s\n' "$$BFS_LDLIBS" >>$@
+ @printf '# BFS_CPPFLAGS\nCPPFLAGS := %s\n' "$$BFS_CPPFLAGS" >>$@
+ @test "${TSAN}" != y || printf '# TSAN\nCPPFLAGS += %s\n' "$$TSAN_CPPFLAGS" >>$@
+ @test "${LINT}" != y || printf '# LINT\nCPPFLAGS += %s\n' "$$LINT_CPPFLAGS" >>$@
+ @test "${RELEASE}" != y || printf '# RELEASE\nCPPFLAGS += %s\n' "$$RELEASE_CPPFLAGS" >>$@
+ @printf '# CPPFLAGS\nCPPFLAGS += %s\n' "$$XCPPFLAGS" >>$@
+ @printf '# EXTRA_CPPFLAGS\nCPPFLAGS += %s\n' "$$EXTRA_CPPFLAGS" >>$@
+ @printf '# BFS_CFLAGS\nCFLAGS := %s\n' "$$BFS_CFLAGS" >>$@
+ @test "${ASAN}" != y || printf '# ASAN\nCFLAGS += %s\n' "$$ASAN_CFLAGS" >>$@
+ @test "${LSAN}" != y || printf '# LSAN\nCFLAGS += %s\n' "$$LSAN_CFLAGS" >>$@
+ @test "${MSAN}" != y || printf '# MSAN\nCFLAGS += %s\n' "$$MSAN_CFLAGS" >>$@
+ @test "${TSAN}" != y || printf '# TSAN\nCFLAGS += %s\n' "$$TSAN_CFLAGS" >>$@
+ @test "${UBSAN}" != y || printf '# UBSAN\nCFLAGS += %s\n' "$$UBSAN_CFLAGS" >>$@
+ @case "${SAN}" in *y*) printf '# *SAN\nCFLAGS += %s\n' "$$SAN_CFLAGS" >>$@ ;; esac
+ @test "${GCOV}" != y || printf '# GCOV\nCFLAGS += %s\n' "$$GCOV_CFLAGS" >>$@
+ @test "${LINT}" != y || printf '# LINT\nCFLAGS += %s\n' "$$LINT_CFLAGS" >>$@
+ @test "${RELEASE}" != y || printf '# RELEASE\nCFLAGS += %s\n' "$$RELEASE_CFLAGS" >>$@
+ @printf '# CFLAGS\nCFLAGS += %s\n' "$$XCFLAGS" >>$@
+ @printf '# EXTRA_CFLAGS\nCFLAGS += %s\n' "$$EXTRA_CFLAGS" >>$@
+ @printf '# LDFLAGS\nLDFLAGS := %s\n' "$$XLDFLAGS" >>$@
+ @printf '# EXTRA_LDFLAGS\nLDFLAGS += %s\n' "$$EXTRA_LDFLAGS" >>$@
+ @printf '# LDLIBS\nLDLIBS := %s\n' "$$XLDLIBS" >>$@
+ @printf '# EXTRA_LDLIBS\nLDLIBS += %s\n' "$$EXTRA_LDLIBS" >>$@
+ @printf '# BFS_LDLIBS\nLDLIBS += %s\n' "$$BFS_LDLIBS" >>$@
+ @printf 'PKGS :=\n' >>$@
@case "${OS}-${SAN}" in FreeBSD-*y*) printf 'POSTLINK = elfctl -e +noaslr $$@\n' >>$@ ;; esac
@cat $@
+.PHONY: ${GEN}/vars.mk
# Check for dependency generation support
-${GEN}/deps.mk::
- @${MKDIR} ${@D}
- @if config/cc.sh -MD -MP -MF /dev/null config/empty.c; then \
- echo 'DEPFLAGS = -MD -MP -MF $${@:.o=.d}'; \
- fi 2>$@.log | tee $@
+${GEN}/deps.mk: ${GEN}/vars.mk
+ @+${MAKE} -rs -f config/deps.mk TARGET=$@
+ @cat $@
@printf -- '-include %s\n' ${OBJS:.o=.d} >>$@
+.PHONY: ${GEN}/deps.mk
# Lists file.o: file.c dependencies
-${GEN}/objs.mk::
+${GEN}/objs.mk:
@${MKDIR} ${@D}
@for obj in ${OBJS:${OBJ}/%.o=%}; do printf '$${OBJ}/%s.o: %s.c\n' "$$obj" "$$obj"; done >$@
+.PHONY: ${GEN}/objs.mk
+
+# External dependencies
+PKG_MKS := \
+ ${GEN}/libacl.mk \
+ ${GEN}/libcap.mk \
+ ${GEN}/libselinux.mk \
+ ${GEN}/liburing.mk \
+ ${GEN}/oniguruma.mk
# Auto-detect dependencies and their build flags
-${PKGS}::
- @${MKDIR} ${@D}
- @config/pkg.sh ${@:${GEN}/%.mk=%} >$@ 2>$@.log
+${GEN}/pkgs.mk: ${PKG_MKS}
+ @printf 'include $${GEN}/%s\n' ${.ALLSRC:${GEN}/%=%} >$@
+ @+${MAKE} -rs -f config/pkgs.mk TARGET=$@
+ @grep -v '^include' $@ || :
+.PHONY: ${GEN}/pkgs.mk
+
+# Auto-detect dependencies
+${PKG_MKS}: ${GEN}/vars.mk
+ @+${MAKE} -rs -f config/pkg.mk TARGET=$@
@cat $@
+.PHONY: ${PKG_MKS}
# bfs used to have flag-like targets (`make release`, `make asan ubsan`, etc.).
# Direct users to the new configuration system.