blob: 81eb34559a2f57aba65607da530e72fc9253ffe5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/bin/sh
# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD
# Add flags to a makefile if a build succeeds
set -eu
build/cc.sh "$@" || exit 1
# If the build succeeded, print any lines like
#
# /// _CFLAGS += -foo
#
# (unless they're already set)
OLD_FLAGS="$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS $XLDLIBS"
while IFS="" read -r line; do
case "$line" in
///*=*)
flag="${line#*= }"
if [ "${OLD_FLAGS#*"$flag"}" = "$OLD_FLAGS" ]; then
printf '%s\n' "${line#/// }"
fi
;;
esac
done <"$1"
|