apenwarr-redo/redoconf/compile.od

53 lines
1.4 KiB
Text
Raw Permalink Normal View History

rc_include _all.rc
redo-ifchange _compile
# Subtle:
# - un-backslashed $ expansions ($foo, $(cmd)) are
# done *now*, while writing the script contents.
# - backslashed $ expansions (\$foo) are written
# verbatim into the script, to be interpreted at
# the time the script is run.
#
# We want to insert the variable contents into the
# script near the top, making sure they are not
# split or interpreted at that point (hence the
# $(shquote)).
#
# Further down, we want to disable wildcard expansion
# (set -f) and split on $NL (so we change $IFS),
# so we use backslash escapes but *not* quoting.
cat >$3 <<-EOF
#!/bin/sh -e
# Run the C/++ compiler.
t="\$1" d="\$2" i="\$3"
CPPFLAGS=$(shquote "$CPPFLAGS")
OPTFLAGS=$(shquote "$OPTFLAGS")
case \$i in
*.c|*.h)
CC=$(shquote "$CC")
CFLAGS=$(shquote "$CFLAGS")
CXXFLAGS=
PCH1=$(shquote "$CFLAGS_PCH")
PCH2=$(shquote "$CFLAGS_PCH_FPIC")
PCH3=$(shquote "$CFLAGS_PCH_LANG")
;;
*)
CC=$(shquote "$CXX")
[ -n "\$CC" ] || (echo "No C++ compiler available." >&2; exit 1)
CFLAGS=
CXXFLAGS=$(shquote "$CXXFLAGS")
PCH1=$(shquote "$CXXFLAGS_PCH")
PCH2=$(shquote "$CXXFLAGS_PCH_FPIC")
PCH3=$(shquote "$CXXFLAGS_PCH_LANG")
;;
esac
case \$PCH in
1) FLAGS_PCH=\$PCH1 ;;
2) FLAGS_PCH=\$PCH2 ;;
3) FLAGS_PCH=\$PCH3 ;;
esac
. ./_compile
EOF
chmod a+x "$3"
redo-stamp <$3