[build] make check starts the moulette on tests/lang/test-suite
[ozulis.git] / configure
blobb56a0f20b25a6a88bff04b24a60086814a821a56
1 #! /bin/sh
3 ROOTDIR="$PWD"
4 BUILDDIR=build
5 VERBOSE=OFF
6 COLOR=ON
7 CCACHE=ON
8 DEBUG=1
9 MAKEOPT="--quiet -j$(($(grep processor /proc/cpuinfo | wc -l) + 1))"
10 CPPFLAGS="-DYYENABLE_NLS=1 -DENABLE_NLS=1"
11 CFLAGS="-W -Wall -Wstrict-prototypes -pipe"
12 CFLAGS="$CFLAGS -Wfloat-equal -Wundef -Wshadow -Wpointer-arith"
13 CFLAGS="$CFLAGS -Wmissing-declarations -Wnested-externs"
14 CFLAGS="$CFLAGS -Wmissing-prototypes -fPIC"
15 CXXFLAGS="-W -Wall -pipe -Wundef -Wshadow -Wpointer-arith -Wabi -std=c++0x -fPIC"
16 LDFLAGS=""
17 PREFIX="/usr/local"
18 QTCREATOR=0
20 function usage()
22 echo -n "usage: $0
23 --verbose verbose Makefiles
24 --no-color no colors
25 --release disable debug
26 --debug enables debug
27 --qt-creator generate build dir for qt-creator
29 --builddir=<dir> the build directory
30 --prefix=<dir> the installation prefix path
31 --bindir=<dir> the installation binary path
32 --libdir=<dir> the installation library path
33 --plugindir=<dir> the installation plugin path
34 --local=<dir> the installation locale path
36 exit
39 function update_install_path()
41 eval 'if [[ -z "$'"$1"'" ]] ; then
42 '"$1"'="${PREFIX}/$2"
43 fi'
46 until [[ $# -eq 0 ]] ;
48 case "$1" in
49 --verbose)
50 VERBOSE=ON
51 MAKEOPT="$(echo $MAKEOPT | sed s,--quiet,,g)"
53 --no-color)
54 COLOR=OFF
56 --release)
57 DEBUG=0
59 --debug)
60 DEBUG=1
62 --ccache)
63 CCACHE=ON
65 --no-ccache)
66 CCACHE=OFF
68 --qt-creator)
69 QTCREATOR=1
71 --build-dir=*)
72 BUILDDIR="${1/--build-dir=/}"
74 --prefix=*)
75 PREFIX="${1/--prefix=/}"
77 --libdir=*)
78 LIBDIR="${1/--libdir=/}"
80 --plugindir=*)
81 PLUGINDIR="${1/--plugindir=/}"
83 --bindir=*)
84 BINDIR="${1/--bindir=/}"
86 --localedir=*)
87 LOCALEDIR="${1/--localedir=/}"
89 -h|--help|help)
90 usage
93 echo wrong argument "$1"
94 usage
96 esac
97 shift
98 done
100 update_install_path LIBDIR lib
101 update_install_path PLUGINDIR lib/ozulis
102 update_install_path BINDIR bin
103 update_install_path LOCALEDIR share/locale
105 if ! which ccache 2>&1 >/dev/null; then
106 CCACHE=OFF
109 if [[ $DEBUG -eq 0 ]]; then
110 CFLAGS="$CFLAGS -DNDEBUG -O2 -fomit-frame-pointer -ftree-vectorize"
111 CXXFLAGS="$CXXFLAGS -DNDEBUG -O2 -fomit-frame-pointer -ftree-vectorize"
112 else
113 CFLAGS="$CFLAGS -ggdb3"
114 CXXFLAGS="$CXXFLAGS -ggdb3"
117 if [[ $CCACHE = "ON" ]] ; then
118 mkdir -p .ccache
119 ln -sf "$(which ccache)" .ccache/g++
120 ln -sf "$(which ccache)" .ccache/gcc
121 export CC="$PWD/.ccache/gcc"
122 export CXX="$PWD/.ccache/g++"
125 if [[ $QTCREATOR -eq 1 ]] ; then
126 CMAKE_GENERATOR="-GCodeBlocks - Unix Makefiles"
127 else
128 CMAKE_GENERATOR="-GUnix Makefiles"
131 CPPFLAGS="${CPPFLAGS} -include ${ROOTDIR}/src/config.hh"
132 CFLAGS="${CPPFLAGS} ${CFLAGS}"
133 CXXFLAGS="${CPPFLAGS} ${CXXFLAGS}"
135 cat >src/config.hh <<EOF
136 #ifndef CONFIG_HH
137 # define CONFIG_HH
139 # include <libintl.h>
141 # define OZULIS_BINDIR "${BINDIR}"
142 # define OZULIS_BINARY "${BINDIR}/ozulis"
143 # define OZULIS_LIBDIR "${LIBDIR}"
144 # define OZULIS_LOCALEDIR "${LOCALEDIR}"
145 # define OZULIS_PLUGINDIR "${PLUGINDIR}"
146 # define OZULIS_PREFIX "${PREFIX}"
148 # ifdef _
149 # undef _
150 # endif
151 # define _(Str) gettext(Str)
153 #endif /* !CONFIG_HH */
156 export CPPFLAGS
157 export CFLAGS
158 export CXXFLAGS
159 export LDFLAGS
160 rm -rf "$BUILDDIR"
161 mkdir "$BUILDDIR" &&
162 cd "$BUILDDIR" &&
163 cmake "$CMAKE_GENERATOR" "$ROOTDIR"
164 cmake \
165 -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE \
166 -DCMAKE_COLOR_MAKEFILE=$COLOR \
167 -DCMAKE_INSTALL_PREFIX="$PREFIX" \
170 cd "$ROOTDIR" &&
171 cat >config.mk <<EOF
172 BUILDDIR=$BUILDDIR
173 MAKEOPT=$MAKEOPT
175 rm -f ozulis
176 ln -sf "$BINDIR/ozulis"
177 ln -sf "$BUILDDIR/src/moulette/moulette" moulette