From 3552b793e3b30f2bba0e77fbda45a86575f4dae6 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 27 Jul 2024 19:01:18 -0400 Subject: build/flags: Infrastructure to detect compiler flag support Use it to detect -MD -MP support. --- build/flags-if.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 build/flags-if.sh (limited to 'build/flags-if.sh') 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 +# 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 -- cgit v1.2.3