[i18n] renamed fr to fr_FR and updated configure to be able to change the locale dir
[ozulis.git] / configure
blobbb43d3c6087994d4a04ff1b0b759c9ffd87da553
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=""
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} -DOZULIS_PREFIX=\\\"${PREFIX}\\\" -DOZULIS_LIBDIR=\\\"${LIBDIR}\\\" -DOZULIS_PLUGINDIR=\\\"${PLUGINDIR}\\\" -DOZULIS_BINDIR=\\\"${BINDIR}\\\" -DOZULIS_LOCALEDIR=\\\"${LOCALEDIR}\\\""
132 CFLAGS="${CPPFLAGS} ${CFLAGS}"
133 CXXFLAGS="${CPPFLAGS} ${CXXFLAGS}"
135 export CPPFLAGS
136 export CFLAGS
137 export CXXFLAGS
138 export LDFLAGS
139 rm -rf "$BUILDDIR"
140 mkdir "$BUILDDIR" &&
141 cd "$BUILDDIR" &&
142 cmake "$CMAKE_GENERATOR" "$ROOTDIR"
143 cmake \
144 -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE \
145 -DCMAKE_COLOR_MAKEFILE=$COLOR \
146 -DCMAKE_INSTALL_PREFIX="$PREFIX" \
149 cd "$ROOTDIR" &&
150 cat >config.mk <<EOF
151 BUILDDIR=$BUILDDIR
152 MAKEOPT=$MAKEOPT
154 rm -f ozulis
155 ln -sf "$BINDIR/ozulis"
156 ln -sf "$BUILDDIR/src/moulette/moulette" moulette