aboutsummaryrefslogtreecommitdiffstats
path: root/.vars.rc.do
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2021-08-05 18:30:33 +0100
committerTomasz Kramkowski <tk@the-tk.com>2021-08-05 20:17:48 +0100
commit8c58e5683cbd90d529eb1ea86fce019e553b2248 (patch)
treeb31e8754a56ab0a87170bfecffca3ef434850826 /.vars.rc.do
parent7e7bdc19e76a5f87bccf7a84872f8d45295ee5b7 (diff)
downloadpack-8c58e5683cbd90d529eb1ea86fce019e553b2248.tar.gz
pack-8c58e5683cbd90d529eb1ea86fce019e553b2248.tar.xz
pack-8c58e5683cbd90d529eb1ea86fce019e553b2248.zip
Cross compilation support
Diffstat (limited to '.vars.rc.do')
-rwxr-xr-x.vars.rc.do22
1 files changed, 16 insertions, 6 deletions
diff --git a/.vars.rc.do b/.vars.rc.do
index a5521e6..8a31fe7 100755
--- a/.vars.rc.do
+++ b/.vars.rc.do
@@ -3,9 +3,11 @@ set -e
# Ensure variables from the config aren't set before the config is read to
# avoid capturing transient state
-unset CC CFLAGS CPPFLAGS LDFLAGS LDLIBS colour debug optimise verbose warn werror
+unset {,T,H}{CC,CFLAGS,CPPFLAGS,LDFLAGS,LDLIBS} \
+ colour debug optimise verbose warn werror
-CFLAGS=(-std=c11 -fPIC)
+CFLAGS=(-std=c11)
+TCFLAGS=(-fPIC)
warnings=(
-Wall -Wcast-align -Wcast-qual -Wextra -Wpedantic -Wformat=2
@@ -13,7 +15,7 @@ warnings=(
-Wstrict-prototypes
)
-declare -a CFLAGS CPPFLAGS LDFLAGS LDLIBS
+declare -a {,T,H}{CFLAGS,CPPFLAGS,LDFLAGS,LDLIBS}
if [ -e config.rc ]; then
redo-ifchange config.rc
@@ -47,8 +49,8 @@ if [[ $debug ]]; then
LDFLAGS+=(-Og -g)
fi
if [[ $optimise ]]; then
- CFLAGS+=(-O2 -flto)
- LDFLAGS+=(-O2 -flto)
+ TCFLAGS+=(-O2 -flto)
+ TLDFLAGS+=(-O2 -flto)
fi
if [[ $warn ]]; then
CFLAGS+=("${warnings[@]}")
@@ -60,9 +62,17 @@ if [[ $werror ]]; then
CFLAGS+=(-Werror)
fi
+if [[ ! $TCC ]]; then TCC=$CC; fi
+if [[ ! $HCC ]]; then HCC=$CC; fi
+for p in T H; do
+ for v in CFLAGS CPPFLAGS LDFLAGS LDLIBS; do
+ eval "$p$v+=(\"\${$v[@]}\")"
+ done
+done
+
{
echo "# generated by $0"
- declare -p CC CFLAGS CPPFLAGS LDFLAGS LDLIBS
+ declare -p {T,H}{CC,CFLAGS,CPPFLAGS,LDFLAGS,LDLIBS}
} >"$3"
if [[ $verbose ]]; then