summaryrefslogtreecommitdiffstats
path: root/build/flags-if.sh
blob: 098b2d343aa235bfd3e945a5b9d926b0b3169661 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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