diff options
-rwxr-xr-x | build/cc.sh | 9 | ||||
-rw-r--r-- | build/flags.mk | 10 | ||||
-rw-r--r-- | build/header.mk | 12 |
3 files changed, 19 insertions, 12 deletions
diff --git a/build/cc.sh b/build/cc.sh index 23a4c01..fd58393 100755 --- a/build/cc.sh +++ b/build/cc.sh @@ -5,5 +5,12 @@ # Run the compiler and check if it succeeded -set -eux +set -eu + +if [ "$1" = "-q" ]; then + shift +else + set -x +fi + $XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS "$@" $XLDLIBS diff --git a/build/flags.mk b/build/flags.mk index ad2a75e..504df63 100644 --- a/build/flags.mk +++ b/build/flags.mk @@ -123,6 +123,13 @@ gen/flags.mk: ${AUTO_FLAGS} ${VCAT} $@ .PHONY: gen/flags.mk +# Check that the C compiler works at all +cc:: + @build/cc.sh -q build/empty.c -o gen/.cc.out; \ + ret=$$?; \ + build/msg-if.sh "[ CC ] build/empty.c" test $$ret -eq 0; \ + exit $$ret + # The short name of the config test SLUG = ${@:gen/%.mk=%} # The source file to build @@ -130,7 +137,8 @@ CSRC = build/${SLUG}.c # The hidden output file name OUT = ${SLUG:flags/%=gen/flags/.%.out} -${AUTO_FLAGS}:: +${AUTO_FLAGS}: cc @${MKDIR} ${@D} @build/flags-if.sh ${CSRC} -o ${OUT} >$@ 2>$@.log; \ build/msg-if.sh "[ CC ] ${SLUG}.c" test $$? -eq 0 +.PHONY: ${AUTO_FLAGS} diff --git a/build/header.mk b/build/header.mk index b838f64..0bc4a3e 100644 --- a/build/header.mk +++ b/build/header.mk @@ -66,7 +66,7 @@ gen/config.h: ${PKG_HEADERS} ${HEADERS} @printf '#define BFS_CONFIG_H\n' >>$@ @cat ${.ALLSRC} >>$@ @printf '#endif // BFS_CONFIG_H\n' >>$@ - @cat gen/cc.log gen/flags.log ${.ALLSRC:%=%.log} >gen/config.log + @cat gen/flags.log ${.ALLSRC:%=%.log} >gen/config.log ${VCAT} $@ @printf '%s' "$$CONFFLAGS" | build/embed.sh >gen/confflags.i @printf '%s' "$$XCC" | build/embed.sh >gen/cc.i @@ -81,15 +81,7 @@ SLUG = ${@:gen/%.h=%} # The hidden output file name OUT = ${SLUG:has/%=gen/has/.%.out} -${HEADERS}: cc +${HEADERS}:: @${MKDIR} ${@D} @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 |