diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-07-27 19:01:18 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-07-27 19:01:18 -0400 |
commit | 3552b793e3b30f2bba0e77fbda45a86575f4dae6 (patch) | |
tree | 1d42f3b79cde76874dcddb948c5c733e6b4bdcbb /build/flags-if.sh | |
parent | bd8a345bed6b00f40547de44a1f76be2796f11be (diff) | |
download | bfs-3552b793e3b30f2bba0e77fbda45a86575f4dae6.tar.xz |
build/flags: Infrastructure to detect compiler flag support
Use it to detect -MD -MP support.
Diffstat (limited to 'build/flags-if.sh')
-rwxr-xr-x | build/flags-if.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/build/flags-if.sh b/build/flags-if.sh new file mode 100755 index 0000000..098b2d3 --- /dev/null +++ b/build/flags-if.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Copyright © Tavian Barnes <tavianator@tavianator.com> +# SPDX-License-Identifier: 0BSD + +# Add flags to a makefile if a build succeeds + +set -eu + +FLAGS=$(sed -n '\|^///|{s|^/// ||; s|[^=]*= ||; p}' "$1") + +if build/cc.sh "$@" $FLAGS; then + sed -n 's|^/// \(.*=.*\)|\1|p' "$1" +else + exit 1 +fi |