3 export SCRIPT_BASE
=$
(dirname `readlink -f $0`)
4 export BASE
=${SCRIPT_BASE}/..
5 export CONFIG_BASE
=${SCRIPT_BASE}/buildconf.d
7 # takes default value if provided by the environment
8 export BUILD_DIR
=${BUILD_DIR:-${BASE}/build}
10 # ask system about number of processors, accept already specified number
11 export NUM_PROC
=${NUM_PROC:-$(cat /proc/cpuinfo | grep -E "^processor" | wc -l)}
13 function valid_target
()
15 for t
in ${CONFIG_BASE}/* ; do
16 if [ "x$1" == "x$(basename $t)" ] ; then
24 # read command line arguments
34 echo "error: parameters. aborting." >&2
45 while [ $# -ne 0 ] ; do
49 echo "usage: $(basename $0) [option] [target]"
52 echo " --help|-h : print help information"
53 echo " --list|-l : list all targets"
54 echo " --prepare : prepares the build, does not build"
55 echo " --build : prepares and builds, does not perform tests"
60 for t
in ${CONFIG_BASE}/* ; do
72 if [ $# -gt 1 ] ; then
80 # check specified target
82 if [ -z "$target" ] ; then
83 echo "error: no target specified. aborting." >&2
87 if [ $
(valid_target
"$target") != "found" ] ; then
88 echo "error: invalid target specified: $target. aborting." >&2
93 if [ -z "$(which cmake)" ] ; then
94 echo "error: no cmake found. aborting."
97 if [ -z "$(which make)" ] ; then
98 echo "error: no make found. aborting."
103 if [ -d ${BUILD_DIR} ] ; then
106 mkdir
-p ${BUILD_DIR}
108 cmake
-G "Unix Makefiles" \
109 -DCMAKE_INSTALL_PREFIX=${BUILD_DIR}/local \
110 $
(cat ${CONFIG_BASE}/${target}) \
111 -DCMAKE_EXPORT_COMPILE_COMMANDS=YES \
114 # only prepare, do not build or test
115 if [ "$only_prepare" == "yes" ] ; then exit 0 ; fi
118 cmake
--build .
-- -j ${NUM_PROC}
120 # only build, do not test
121 if [ "$only_build" == "yes" ] ; then exit 0 ; fi
123 # perform tests if not disabled
124 if [[ $
(cat "${CONFIG_BASE}/${target}" |
grep -E "ENABLE_TESTS=OFF") ]] ; then
125 echo "tests disabled"
127 cmake
--build .
--target unittest
128 cmake
--build .
--target test