From 0035cc4ff492cab91adeb49d0c577fe5982064bd Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 18 Apr 2024 15:27:27 -0400 Subject: config: Check for program_invocation_short_name This lets us pick it up on musl too, since there's no __MUSL__ macro. Link: https://wiki.musl-libc.org/faq#Q:-Why-is-there-no-%3Ccode%3E__MUSL__%3C/code%3E-macro? --- config/header.mk | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 config/header.mk (limited to 'config/header.mk') diff --git a/config/header.mk b/config/header.mk new file mode 100644 index 0000000..3a1271e --- /dev/null +++ b/config/header.mk @@ -0,0 +1,38 @@ +# Copyright © Tavian Barnes +# SPDX-License-Identifier: 0BSD + +# Makefile that generates gen/config.h + +include config/prelude.mk +include ${GEN}/config.mk +include config/exports.mk + +# All header fragments we generate +HEADERS := \ + ${GEN}/getprogname.h \ + ${GEN}/getprogname-gnu.h + +${GEN}/config.h: ${HEADERS} + ${MSG} "[ GEN] ${TGT}" + printf '// %s\n' "${TGT}" >$@ + printf '#ifndef BFS_CONFIG_H\n' >>$@ + printf '#define BFS_CONFIG_H\n' >>$@ + cat ${.ALLSRC} >>$@ + printf '#endif // BFS_CONFIG_H\n' >>$@ + cat ${.ALLSRC:%=%.log} >$@.log + ${RM} ${.ALLSRC} ${.ALLSRC:%=%.log} + ${VCAT} $@ +.PHONY: ${GEN}/config.h + +# The C source file to attempt to compile +CSRC = ${@:${GEN}/%.h=config/%.c} + +${HEADERS}:: + config/cc-define.sh ${CSRC} >$@ 2>$@.log + if ! [ "${IS_V}" ]; then \ + if grep -q 'true$$' $@; then \ + printf '[ CC ] %-${MSG_WIDTH}s ✔\n' ${CSRC}; \ + else \ + printf '[ CC ] %-${MSG_WIDTH}s ✘\n' ${CSRC}; \ + fi; \ + fi -- cgit v1.2.3