diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-04-18 15:27:27 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-04-19 15:50:45 -0400 |
commit | 0035cc4ff492cab91adeb49d0c577fe5982064bd (patch) | |
tree | 6fcd6b48b00ceb4ae696a5a3d9d03e23c9676a70 /config/cc-define.sh | |
parent | d7d5e1c474e4e110172b7180de9c41e5ebbf93f6 (diff) | |
download | bfs-0035cc4ff492cab91adeb49d0c577fe5982064bd.tar.xz |
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?
Diffstat (limited to 'config/cc-define.sh')
-rwxr-xr-x | config/cc-define.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/config/cc-define.sh b/config/cc-define.sh new file mode 100755 index 0000000..edb5c87 --- /dev/null +++ b/config/cc-define.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# Copyright © Tavian Barnes <tavianator@tavianator.com> +# SPDX-License-Identifier: 0BSD + +# Output a C preprocessor definition based on whether a C source file could be +# compiled successfully + +set -eu + +SLUG="${1#config/}" +SLUG="${SLUG%.c}" +MACRO="BFS_HAS_$(printf '%s' "$SLUG" | tr 'a-z-' 'A-Z_')" + +if config/cc.sh "$1"; then + printf '#define %s true\n' "$MACRO" +else + printf '#define %s false\n' "$MACRO" +fi |