From 8c58e5683cbd90d529eb1ea86fce019e553b2248 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Thu, 5 Aug 2021 18:30:33 +0100 Subject: Cross compilation support --- .vars.rc.do | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to '.vars.rc.do') 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 -- cgit v1.2.3-54-g00ecf