[moulette] the moulette should be niced.
[ozulis.git] / configure
blob76bbf41be5011c404745d05f5340123fc6c7fcef
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="$CPPFLAGS -DYYENABLE_NLS=1 -DENABLE_NLS=1"
11 CFLAGS="$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="$CXXFLAGS -W -Wall -pipe -Wundef -Wshadow -Wpointer-arith -Wabi -std=c++0x -fPIC"
16 LDFLAGS="$LDFLAGS"
17 PREFIX="/usr/local"
18 QTCREATOR=0
19 DOXYGEN=doxygen
20 BOOST_LIB_SUFFIX=""
22 function usage()
24 echo -n "usage: $0
25 --verbose verbose Makefiles
26 --no-color no colors
27 --release disable debug
28 --debug enables debug
29 --qt-creator generate build dir for qt-creator
30 --doxygen=<path> specify which binary use for doxygen
31 --boost-lib-suffix=<suffix>
33 --builddir=<dir> the build directory
34 --prefix=<dir> the installation prefix path
35 --bindir=<dir> the installation binary path
36 --libdir=<dir> the installation library path
37 --plugindir=<dir> the installation plugin path
38 --local=<dir> the installation locale path
40 exit
43 function update_install_path()
45 eval 'if [[ -z "$'"$1"'" ]] ; then
46 '"$1"'="${PREFIX}/$2"
47 fi'
50 until [[ $# -eq 0 ]] ;
52 case "$1" in
53 --verbose)
54 VERBOSE=ON
55 MAKEOPT="$(echo $MAKEOPT | sed s,--quiet,,g)"
57 --no-color)
58 COLOR=OFF
60 --release)
61 DEBUG=0
63 --debug)
64 DEBUG=1
66 --ccache)
67 CCACHE=ON
69 --no-ccache)
70 CCACHE=OFF
72 --qt-creator)
73 QTCREATOR=1
75 --doxygen=*)
76 DOXYGEN="${1/--doxygen=/}"
78 --boost-lib-suffix=*)
79 BOOST_LIB_SUFFIX="${1/--boost-lib-suffix=/}"
81 --build-dir=*)
82 BUILDDIR="${1/--build-dir=/}"
84 --prefix=*)
85 PREFIX="${1/--prefix=/}"
87 --libdir=*)
88 LIBDIR="${1/--libdir=/}"
90 --plugindir=*)
91 PLUGINDIR="${1/--plugindir=/}"
93 --bindir=*)
94 BINDIR="${1/--bindir=/}"
96 --localedir=*)
97 LOCALEDIR="${1/--localedir=/}"
99 -h|--help|help)
100 usage
103 echo wrong argument "$1"
104 usage
106 esac
107 shift
108 done
110 update_install_path LIBDIR lib
111 update_install_path PLUGINDIR lib/ozulis
112 update_install_path BINDIR bin
113 update_install_path LOCALEDIR share/locale
115 if ! which ccache 2>&1 >/dev/null; then
116 CCACHE=OFF
119 if [[ $DEBUG -eq 0 ]]; then
120 CFLAGS="$CFLAGS -DNDEBUG -O2 -fomit-frame-pointer -ftree-vectorize"
121 CXXFLAGS="$CXXFLAGS -DNDEBUG -O2 -fomit-frame-pointer -ftree-vectorize"
122 else
123 CFLAGS="$CFLAGS -ggdb3"
124 CXXFLAGS="$CXXFLAGS -ggdb3"
127 if [[ $CCACHE = "ON" ]] ; then
128 mkdir -p .ccache
129 ln -sf "$(which ccache)" .ccache/g++
130 ln -sf "$(which ccache)" .ccache/gcc
131 export CC="$PWD/.ccache/gcc"
132 export CXX="$PWD/.ccache/g++"
135 if [[ $QTCREATOR -eq 1 ]] ; then
136 CMAKE_GENERATOR="-GCodeBlocks - Unix Makefiles"
137 else
138 CMAKE_GENERATOR="-GUnix Makefiles"
141 CPPFLAGS="${CPPFLAGS} -include ${ROOTDIR}/src/config.hh"
142 CFLAGS="${CPPFLAGS} ${CFLAGS}"
143 CXXFLAGS="${CPPFLAGS} ${CXXFLAGS}"
145 cat >src/config.hh <<EOF
146 #ifndef CONFIG_HH
147 # define CONFIG_HH
149 # include <libintl.h>
151 # define OZULIS_BINDIR "${BINDIR}"
152 # define OZULIS_BINARY "${BINDIR}/ozulis"
153 # define OZULIS_LIBDIR "${LIBDIR}"
154 # define OZULIS_LOCALEDIR "${LOCALEDIR}"
155 # define OZULIS_PLUGINDIR "${PLUGINDIR}"
156 # define OZULIS_PREFIX "${PREFIX}"
158 # ifdef _
159 # undef _
160 # endif
161 # define _(Str) gettext(Str)
163 #endif /* !CONFIG_HH */
166 export CPPFLAGS
167 export CFLAGS
168 export CXXFLAGS
169 export LDFLAGS
170 rm -rf "$BUILDDIR"
171 mkdir "$BUILDDIR" &&
172 cd "$BUILDDIR" &&
173 cmake "$CMAKE_GENERATOR" "$ROOTDIR"
174 cmake \
175 -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE \
176 -DCMAKE_COLOR_MAKEFILE=$COLOR \
177 -DCMAKE_INSTALL_PREFIX="$PREFIX" \
178 -DBOOST_LIB_SUFFIX="$BOOST_LIB_SUFFIX" \
181 cd "$ROOTDIR" &&
182 cat >config.mk <<EOF
183 BUILDDIR=$BUILDDIR
184 MAKEOPT=$MAKEOPT
185 DOXYGEN=$DOXYGEN
187 rm -f ozulis
188 ln -sf "$BINDIR/ozulis"
189 ln -sf "$BUILDDIR/src/moulette/moulette" moulette