configure: add a proper configure script
It's not very good, but it supports all of the options by the previous far-worse Makefile configure targets, and also now supports out-of-tree builds. Also include the relevent updates to the .buildbot script and .gitignore.
This commit is contained in:
74
configure
vendored
Executable file
74
configure
vendored
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONFIG_MAK=config.mak
|
||||
MAKEFILE=Makefile
|
||||
|
||||
debug="no"
|
||||
coverage="no"
|
||||
release="no"
|
||||
output_dir=$(pwd)
|
||||
proj_dir=$(dirname "$BASH_SOURCE")
|
||||
|
||||
for arg in $@; do
|
||||
case $arg in
|
||||
--debug)
|
||||
debug="yes"
|
||||
;;
|
||||
--release)
|
||||
release="yes"
|
||||
;;
|
||||
--coverage)
|
||||
coverage="yes"
|
||||
;;
|
||||
*)
|
||||
echo "unknown option $arg"
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
add_define()
|
||||
{
|
||||
var=$1
|
||||
shift
|
||||
|
||||
if [[ $# -gt 0 ]]; then
|
||||
echo "$var=$@" >> $CONFIG_MAK
|
||||
else
|
||||
echo "# $var is not defined" >> CONFIG_MAK
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
quiet()
|
||||
{
|
||||
$@ 2> /dev/null 1> /dev/null
|
||||
}
|
||||
|
||||
quiet rm $CONFIG_MAK
|
||||
|
||||
if [[ ! -e $MAKEFILE ]]; then
|
||||
quiet ln -s $proj_dir/$MAKEFILE $MAKEFILE
|
||||
fi
|
||||
|
||||
ccflags_extra=""
|
||||
ldflags_extra=""
|
||||
|
||||
if [[ "$debug" == "yes" ]]; then
|
||||
ccflags_extra="$ccflags_extra -DLOG_LEVEL=5 -DDEBUG -O0 -ggdb"
|
||||
fi
|
||||
|
||||
if [[ "$coverage" == "yes" ]]; then
|
||||
ccflags_extra="$ccflags_extra --coverage -fprofile-arcs -ftest-coverage"
|
||||
ldflags_extra="$ldflags_extra -lgcov --coverage"
|
||||
fi
|
||||
|
||||
if [[ "$release" == "yes" ]]; then
|
||||
ccflags_extra="$ccflags_extra -O3"
|
||||
fi
|
||||
|
||||
add_define CCFLAGS_EXTRA "$ccflags_extra"
|
||||
add_define LDFLAGS_EXTRA "$ldflags_extra"
|
||||
add_define OUT "$output_dir"
|
||||
add_define SRC_DIR "$proj_dir/src"
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user