To test it out, try this: ./do -j10 build cd docs/cookbook/c redo -j10 test It should detect all the compilers on your system and make three separate builds for each one: normal, debug, and optimized. Then it tries to run a test program under each one. If there are windows cross compilers and you also have 'wine' installed, it'll try running the test program under wine as well. redoconf currently has no documentation other than the example program. We'll fix that later.
51 lines
1.3 KiB
Text
51 lines
1.3 KiB
Text
. ./redoconf.rc
|
|
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")
|
|
;;
|
|
*)
|
|
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")
|
|
;;
|
|
esac
|
|
case \$PCH in
|
|
1) FLAGS_PCH=\$PCH1 ;;
|
|
2) FLAGS_PCH=\$PCH2 ;;
|
|
esac
|
|
. ./_compile
|
|
EOF
|
|
chmod a+x "$3"
|
|
redo-stamp <$3
|