diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-07-27 19:01:18 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-07-27 19:01:18 -0400 |
commit | 3552b793e3b30f2bba0e77fbda45a86575f4dae6 (patch) | |
tree | 1d42f3b79cde76874dcddb948c5c733e6b4bdcbb /build/flags.mk | |
parent | bd8a345bed6b00f40547de44a1f76be2796f11be (diff) | |
download | bfs-3552b793e3b30f2bba0e77fbda45a86575f4dae6.tar.xz |
build/flags: Infrastructure to detect compiler flag support
Use it to detect -MD -MP support.
Diffstat (limited to 'build/flags.mk')
-rw-r--r-- | build/flags.mk | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/build/flags.mk b/build/flags.mk index c50b077..95d5673 100644 --- a/build/flags.mk +++ b/build/flags.mk @@ -103,7 +103,11 @@ _LDLIBS := ${LDLIBS} ${EXTRA_LDLIBS} ${_LDLIBS} include build/exports.mk -gen/flags.mk:: +# Conditionally-supported flags +AUTO_FLAGS := \ + gen/flags/deps.mk + +gen/flags.mk: ${AUTO_FLAGS} ${MSG} "[ GEN] $@" @printf '# %s\n' "$@" >$@ @printf '_CPPFLAGS := %s\n' "$$XCPPFLAGS" >>$@ @@ -112,4 +116,18 @@ gen/flags.mk:: @printf '_LDLIBS := %s\n' "$$XLDLIBS" >>$@ @printf 'NOLIBS := %s\n' "$$XNOLIBS" >>$@ @test "${OS}-${SAN}" != FreeBSD-y || printf 'POSTLINK = elfctl -e +noaslr $$@\n' >>$@ + @cat ${.ALLSRC} >>$@ ${VCAT} $@ +.PHONY: gen/flags.mk + +# The short name of the config test +SLUG = ${@:gen/%.mk=%} +# The source file to build +CSRC = build/${SLUG}.c +# The hidden output file name +OUT = ${SLUG:flags/%=gen/flags/.%.out} + +${AUTO_FLAGS}:: + @${MKDIR} ${@D} + @build/flags-if.sh ${CSRC} -o ${OUT} >$@ 2>$@.log; \ + build/msg-if.sh "[ CC ] ${SLUG}.c" test $$? -eq 0 |