summaryrefslogtreecommitdiff
path: root/configure
blob: 17021accdb9a22f1716059793e326cd62fef1ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /bin/sh
#
# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file COPYING for the full license text.
#
#~  Usage:
#~    ./configure [OPTIONS]
#~  Options:
#~    --prefix=PREFIX        Installation prefix
#~    --enable-gtk3          Use GTK+3
#~    --disable-zeitgeist    Disable Zeitgeist history integration
#~    --enable-granite       Fancy notebook and pop-overs
#~    --enable-apidocs       API documentation
#~
#~  Environment:
#~    VALAC if defined the valac executable to use, for example valac-0.16
#

if [ -z `command -v cmake` ]; then
    echo Fatal: cmake not installed
    exit 1
fi

while [ $# != 0 ]; do
    case $1 in
        --enable-gtk3)
            ARGS="$ARGS -DUSE_GTK3=1";;
        --disable-zeitgeist)
            ARGS="$ARGS -DUSE_ZEITGEIST=0";;
        --enable-granite)
            ARGS="$ARGS -DUSE_GRANITE=1";;
        --enable-apidocs)
            ARGS="$ARGS -DUSE_APIDOCS=1";;
        --extra-warnings)
            ARGS="$ARGS -DEXTRA_WARNINGS=1";;
        --prefix=*)
            ARGS="$ARGS -DCMAKE_INSTALL_PREFIX=${1#*=}";;
        *)
            grep -e '^#~' $0 | sed s/#~//
            exit
    esac
    shift
done

BUILD_DIR="_build"

if [ ! -f GNUmakefile ]; then
    cp -v GNUmakefile.in GNUmakefile || exit 1
fi

# cmake was invoked in toplevel folder before
# clean up cmake generated build files to prevent conflicts
if [ -f CMakeCache.txt ]; then
    echo
    echo '####################################################################################'
    echo 'CMake build files detected in toplevel folder !!'
    echo 'Please always run "cmake" command from distinct folder when you use cmake yourself.'
    echo '####################################################################################'
    echo
    echo 'Cleaning up...'
    echo

    rm -fr $BUILD_DIR
    rm CMakeCache.txt config.h Makefile
    find . -iname CMakeFiles -type d|xargs rm -fr
    find . -iname cmake_install.cmake -exec rm {} \;
    find . -iname CTestTestfile.cmake -exec rm {} \;

    find . -iname *-folders -type d|xargs rm -fr
    rm -fr data/logo-shade
fi

mkdir -p $BUILD_DIR && cd $BUILD_DIR || exit 1
cmake $ARGS .. || exit 1

echo
echo "Configuring done, run \"make\" to compile"