[patches] removed useless comment
[ozulis.git] / configure
blob251dfae92283a8b57e7259f3bf04b64d613e3c90
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
19 DOXYGEN=doxygen
21 function usage()
23 echo -n "usage: $0
24 --verbose verbose Makefiles
25 --no-color no colors
26 --release disable debug
27 --debug enables debug
28 --qt-creator generate build dir for qt-creator
29 --doxygen=<path> specify which binary use for doxygen
31 --builddir=<dir> the build directory
32 --prefix=<dir> the installation prefix path
33 --bindir=<dir> the installation binary path
34 --libdir=<dir> the installation library path
35 --plugindir=<dir> the installation plugin path
36 --local=<dir> the installation locale path
38 exit
41 function update_install_path()
43 eval 'if [[ -z "$'"$1"'" ]] ; then
44 '"$1"'="${PREFIX}/$2"
45 fi'
48 until [[ $# -eq 0 ]] ;
50 case "$1" in
51 --verbose)
52 VERBOSE=ON
53 MAKEOPT="$(echo $MAKEOPT | sed s,--quiet,,g)"
55 --no-color)
56 COLOR=OFF
58 --release)
59 DEBUG=0
61 --debug)
62 DEBUG=1
64 --ccache)
65 CCACHE=ON
67 --no-ccache)
68 CCACHE=OFF
70 --qt-creator)
71 QTCREATOR=1
73 --doxygen=*)
74 DOXYGEN="${1/--doxygen=/}"
76 --build-dir=*)
77 BUILDDIR="${1/--build-dir=/}"
79 --prefix=*)
80 PREFIX="${1/--prefix=/}"
82 --libdir=*)
83 LIBDIR="${1/--libdir=/}"
85 --plugindir=*)
86 PLUGINDIR="${1/--plugindir=/}"
88 --bindir=*)
89 BINDIR="${1/--bindir=/}"
91 --localedir=*)
92 LOCALEDIR="${1/--localedir=/}"
94 -h|--help|help)
95 usage
98 echo wrong argument "$1"
99 usage
101 esac
102 shift
103 done
105 update_install_path LIBDIR lib
106 update_install_path PLUGINDIR lib/ozulis
107 update_install_path BINDIR bin
108 update_install_path LOCALEDIR share/locale
110 if ! which ccache 2>&1 >/dev/null; then
111 CCACHE=OFF
114 if [[ $DEBUG -eq 0 ]]; then
115 CFLAGS="$CFLAGS -DNDEBUG -O2 -fomit-frame-pointer -ftree-vectorize"
116 CXXFLAGS="$CXXFLAGS -DNDEBUG -O2 -fomit-frame-pointer -ftree-vectorize"
117 else
118 CFLAGS="$CFLAGS -ggdb3"
119 CXXFLAGS="$CXXFLAGS -ggdb3"
122 if [[ $CCACHE = "ON" ]] ; then
123 mkdir -p .ccache
124 ln -sf "$(which ccache)" .ccache/g++
125 ln -sf "$(which ccache)" .ccache/gcc
126 export CC="$PWD/.ccache/gcc"
127 export CXX="$PWD/.ccache/g++"
130 if [[ $QTCREATOR -eq 1 ]] ; then
131 CMAKE_GENERATOR="-GCodeBlocks - Unix Makefiles"
132 else
133 CMAKE_GENERATOR="-GUnix Makefiles"
136 CPPFLAGS="${CPPFLAGS} -include ${ROOTDIR}/src/config.hh"
137 CFLAGS="${CPPFLAGS} ${CFLAGS}"
138 CXXFLAGS="${CPPFLAGS} ${CXXFLAGS}"
140 cat >src/config.hh <<EOF
141 #ifndef CONFIG_HH
142 # define CONFIG_HH
144 # include <libintl.h>
146 # define OZULIS_BINDIR "${BINDIR}"
147 # define OZULIS_BINARY "${BINDIR}/ozulis"
148 # define OZULIS_LIBDIR "${LIBDIR}"
149 # define OZULIS_LOCALEDIR "${LOCALEDIR}"
150 # define OZULIS_PLUGINDIR "${PLUGINDIR}"
151 # define OZULIS_PREFIX "${PREFIX}"
153 # ifdef _
154 # undef _
155 # endif
156 # define _(Str) gettext(Str)
158 #endif /* !CONFIG_HH */
161 export CPPFLAGS
162 export CFLAGS
163 export CXXFLAGS
164 export LDFLAGS
165 rm -rf "$BUILDDIR"
166 mkdir "$BUILDDIR" &&
167 cd "$BUILDDIR" &&
168 cmake "$CMAKE_GENERATOR" "$ROOTDIR"
169 cmake \
170 -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE \
171 -DCMAKE_COLOR_MAKEFILE=$COLOR \
172 -DCMAKE_INSTALL_PREFIX="$PREFIX" \
175 cd "$ROOTDIR" &&
176 cat >config.mk <<EOF
177 BUILDDIR=$BUILDDIR
178 MAKEOPT=$MAKEOPT
179 DOXYGEN=$DOXYGEN
181 rm -f ozulis
182 ln -sf "$BINDIR/ozulis"
183 ln -sf "$BUILDDIR/src/moulette/moulette" moulette