summaryrefslogtreecommitdiffstats
path: root/build/define-if.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build/define-if.sh')
-rwxr-xr-xbuild/define-if.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/build/define-if.sh b/build/define-if.sh
new file mode 100755
index 0000000..204cfa4
--- /dev/null
+++ b/build/define-if.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Copyright © Tavian Barnes <tavianator@tavianator.com>
+# SPDX-License-Identifier: 0BSD
+
+# Output a C preprocessor definition based on whether a command succeeds
+
+set -eu
+
+MACRO=$(printf 'BFS_%s' "$1" | tr '/a-z-' '_A-Z_')
+shift
+
+if "$@"; then
+ printf '#define %s true\n' "$MACRO"
+else
+ printf '#define %s false\n' "$MACRO"
+ exit 1
+fi