diff options
Diffstat (limited to 'build')
-rwxr-xr-x | build/cc.sh | 11 | ||||
-rw-r--r-- | build/config.mk | 8 | ||||
-rw-r--r-- | build/deps.mk | 2 | ||||
-rw-r--r-- | build/header.mk | 23 | ||||
-rwxr-xr-x | build/pkgconf.sh | 2 |
5 files changed, 26 insertions, 20 deletions
diff --git a/build/cc.sh b/build/cc.sh index 45d51ca..23a4c01 100755 --- a/build/cc.sh +++ b/build/cc.sh @@ -5,12 +5,5 @@ # Run the compiler and check if it succeeded -set -eu - -TMP=$(mktemp) -trap 'rm -f "$TMP"' EXIT - -( - set -x - $XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS "$@" $XLDLIBS -o "$TMP" -) +set -eux +$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS "$@" $XLDLIBS diff --git a/build/config.mk b/build/config.mk index 24873ec..80206c7 100644 --- a/build/config.mk +++ b/build/config.mk @@ -7,7 +7,7 @@ include build/prelude.mk include build/exports.mk # All configuration steps -config: gen/config.mk gen/config.h +config: gen/config.mk .PHONY: config # Makefile fragments generated by `./configure` @@ -18,10 +18,10 @@ MKS := \ gen/pkgs.mk # The main configuration file, which includes the others -gen/config.mk: ${MKS} +gen/config.mk: ${MKS} gen/config.h ${MSG} "[ GEN] $@" @printf '# %s\n' "$@" >$@ - @printf 'include %s\n' ${.ALLSRC} >>$@ + @printf 'include %s\n' ${MKS} >>$@ ${VCAT} gen/config.mk .PHONY: gen/config.mk @@ -57,6 +57,6 @@ gen/pkgs.mk: gen/flags.mk .PHONY: gen/pkgs.mk # Compile-time feature detection -gen/config.h: gen/config.mk +gen/config.h: gen/pkgs.mk @+XMAKEFLAGS="$$MAKEFLAGS" ${MAKE} -sf build/header.mk $@ .PHONY: gen/config.h diff --git a/build/deps.mk b/build/deps.mk index d382f5d..a6ea673 100644 --- a/build/deps.mk +++ b/build/deps.mk @@ -11,7 +11,7 @@ include build/exports.mk gen/deps.mk:: ${MSG} "[ GEN] $@" @printf '# %s\n' "$@" >$@ - @if build/cc.sh -MD -MP -MF /dev/null build/empty.c; then \ + @if build/cc.sh -MD -MP build/empty.c -o gen/.deps.out; then \ printf '_CPPFLAGS += -MD -MP\n'; \ fi >>$@ 2>$@.log ${VCAT} $@ diff --git a/build/header.mk b/build/header.mk index 75fda41..afd04d0 100644 --- a/build/header.mk +++ b/build/header.mk @@ -4,7 +4,10 @@ # Makefile that generates gen/config.h include build/prelude.mk -include gen/config.mk +include gen/vars.mk +include gen/flags.mk +include gen/deps.mk +include gen/pkgs.mk include build/exports.mk # All header fragments we generate @@ -61,9 +64,9 @@ gen/config.h: ${PKG_HEADERS} ${HEADERS} @printf '#define BFS_CONFIG_H\n' >>$@ @cat ${.ALLSRC} >>$@ @printf '#endif // BFS_CONFIG_H\n' >>$@ - @cat ${.ALLSRC:%=%.log} >gen/config.log + @cat gen/cc.log ${.ALLSRC:%=%.log} >gen/config.log ${VCAT} $@ - @printf '%s' "$$CONFIG" | build/embed.sh >gen/config.i + @printf '%s' "$$CONFFLAGS" | build/embed.sh >gen/confflags.i @printf '%s' "$$XCC" | build/embed.sh >gen/cc.i @printf '%s' "$$XCPPFLAGS" | build/embed.sh >gen/cppflags.i @printf '%s' "$$XCFLAGS" | build/embed.sh >gen/cflags.i @@ -73,8 +76,18 @@ gen/config.h: ${PKG_HEADERS} ${HEADERS} # The short name of the config test SLUG = ${@:gen/%.h=%} +# The hidden output file name +OUT = ${SLUG:has/%=gen/has/.%.out} -${HEADERS}:: +${HEADERS}: cc @${MKDIR} ${@D} - @build/define-if.sh ${SLUG} build/cc.sh build/${SLUG}.c >$@ 2>$@.log; \ + @build/define-if.sh ${SLUG} build/cc.sh build/${SLUG}.c -o ${OUT} >$@ 2>$@.log; \ build/msg-if.sh "[ CC ] ${SLUG}.c" test $$? -eq 0 +.PHONY: ${HEADERS} + +# Check that the C compiler works at all +cc:: + @build/cc.sh build/empty.c -o gen/.cc.out 2>gen/cc.log; \ + ret=$$?; \ + build/msg-if.sh "[ CC ] build/empty.c" test $$ret -eq 0; \ + exit $$ret diff --git a/build/pkgconf.sh b/build/pkgconf.sh index 244c95d..a8a3341 100755 --- a/build/pkgconf.sh +++ b/build/pkgconf.sh @@ -37,7 +37,7 @@ if [ -z "$MODE" ]; then CFLAGS=$("$0" --cflags "$LIB") || exit 1 LDFLAGS=$("$0" --ldflags "$LIB") || exit 1 LDLIBS=$("$0" --ldlibs "$LIB") || exit 1 - build/cc.sh $CFLAGS $LDFLAGS build/with/$LIB.c $LDLIBS || exit 1 + build/cc.sh $CFLAGS $LDFLAGS "build/with/$LIB.c" $LDLIBS -o "gen/with/.$LIB.out" || exit 1 done fi |