Teach configure.sh to probe paths, factor a bit.

This commit is contained in:
Graydon Hoare 2011-03-16 17:36:49 -07:00
parent 6a6a30b792
commit 320ac6b8eb

68
src/configure.sh Normal file → Executable file
View File

@ -3,37 +3,59 @@
CFG_SRC_DIR=${0%${0##*/}}
CFG_BUILD_DIR=$PWD
CFG_OSTYPE=$(uname -s)
CFG_CPUTYPE=$(uname -m)
echo "configure: recreating config.mk"
echo '' >config.mk
echo "configuring on $CFG_CPUTYPE $CFG_OSTYPE"
echo "setting up build directories"
for i in boot/{fe,me,be,driver,util} \
rt/{isaac,bigint,sync,test} \
stage{0,1,2} \
test/{run-pass,compile-{pass,fail}}
echo "configure: making directories"
for i in \
boot/fe boot/me boot/be boot/driver boot/util \
rt/isaac rt/bigint rt/sync rt/test \
stage0 stage1 stage2 \
test/run-pass test/compile-pass test/compile-fail
do
mkdir -p -v $i
done
CFG_VALGRIND=$(sh which valgrind)
CFG_OCAMLC_OPT=$(sh which ocamlc.opt)
echo "copying Makefile"
echo "configure: copying Makefile"
cp -v ${CFG_SRC_DIR}Makefile.in ./Makefile
echo "writing config.mk"
cat >config.mk <<EOF
putvar() {
local T
eval T=\$$1
printf "%-20s := %s\n" $1 $T
printf "%-20s := %s\n" $1 $T >>config.mk
}
CFG_OSTYPE := $CFG_OSTYPE
CFG_CPUTYPE := $CFG_CPUTYPE
CFG_SRC_DIR := $CFG_SRC_DIR
CFG_BUILD_DIR := $CFG_BUILD_DIR
probe() {
local V=$1
local P=$2
local T
T=$(which $P 2>&1)
if [ $? -ne 0 ]
then
T=""
fi
eval $V=\$T
putvar $V
}
CFG_VALGRIND := $CFG_VALGRIND
CFG_OCAMLC_OPT := $CFG_OCAMLC_OPT
echo "configure: inspecting environment"
EOF
CFG_OSTYPE=$(uname -s)
CFG_CPUTYPE=$(uname -m)
echo "configured ok"
putvar CFG_SRC_DIR
putvar CFG_BUILD_DIR
putvar CFG_OSTYPE
putvar CFG_CPUTYPE
echo "configure: looking for programs"
probe CFG_VALGRIND valgrind
probe CFG_OCAMLC ocamlc
probe CFG_OCAMLC_OPT ocamlc.opt
probe CFG_OCAMLOPT ocamlopt
probe CFG_OCAMLOPT_OPT ocamlopt.opt
probe CFG_FLEXLINK flexlink
probe CFG_LLVM_CONFIG llvm-config
echo "configure: complete"