d194eea300f9c56e82552cbe3d2064a3b8f5b7fc
[quassel.git] / src / contrib / libqxt-2007-10-24 / configure
1 #!/bin/bash
2
3 #====some defaults====
4 QMAKE_BIN=qmake
5 WHICH=which
6
7 NO_OPENSSL=0
8 NO_FFMPEG=0
9
10 if uname -a | grep -iq Darwin; then
11     DEFAULT_LIBS="/Library/Frameworks"
12     QMAKE_PARAMS="-spec macx-g++"
13 else
14     DEFAULT_LIBS="PREFIX/lib"
15     QMAKE_PARAMS=""
16 fi
17
18 # the directory of this script (the root)
19 PROJECT_ROOT=`dirname $0`
20 PROJECT_ROOT=`(cd "$relpath"; /bin/pwd)`
21 TESTDIR=$PROJECT_ROOT/config.tests
22 CONFIG_LOG=$PROJECT_ROOT/config.log
23
24 # Define some colors for neat output
25 C_RED='\e[1;31m'
26 C_BLUE='\e[1;34m'
27 C_GREEN='\e[1;32m'
28 C_CYAN='\e[1;36m'
29 C_NONE='\e[0m' # No Color
30
31 #====parse configure options====
32
33 echo "QXT_stability += unknown" > config.in
34
35 while (( $# > 0 )); do
36     if [ $1 == "-qmake-bin" ]; then
37         QMAKE_BIN=$2; shift
38     elif [ $1 == "-bootstrap" ]; then
39         echo "CONFIG += bootstrap" >> config.in; shift
40     elif [ $1 == "-nomake" ]; then
41         echo "QXT_BUILD -= $2" >> config.in; shift
42     elif [ $1 == "-prefix" ]; then
43         echo "QXTINSTALLDIR = $2" >> config.in; shift
44     elif [ $1 == "-libdir" ]; then
45         echo "target.path = $2" >> config.in; shift
46     elif [ $1 == "-docdir" ]; then
47         echo "docs.path = $2" >> config.in; shift
48     elif [ $1 == "-headerdir" ]; then
49         echo "include.path = $2" >> config.in; shift
50     elif [ $1 == "-bindir" ]; then
51         echo "bin.path = $2" >> config.in; shift
52     elif [ $1 == "-static" ]; then
53         echo "CONFIG += static staticlib" >> config.in
54     elif [ $1 == "-debug" ]; then
55         echo "CONFIG += debug" >> config.in
56     elif [ $1 == "-release" ]; then
57         echo "CONFIG += release" >> config.in
58     elif [ $1 == "-no-openssl" ]; then
59         echo "QXT_LIBS -= openssl" >> config.in
60         NO_OPENSSL=1
61     elif [ $1 == "-help" ] || [ $1 == "--help" ]; then
62         echo "Usage: configure [-prefix <dir>] [-libdir <dir>] [-docdir <dir>]"
63         echo "       [-bindir <dir>] [-headerdir <dir>] [-qmake-bin <path>]"
64         echo "       [-static] [-debug] [-release] [-no-openssl] [-nomake <module>]"
65         echo
66         echo "Installation options:"
67         echo
68         echo "-prefix <dir> ....... This will install everything relative to <dir>"
69         echo "                      default: /usr/local/Qxt"
70         echo "-libdir <dir> ....... Libraries will be installed to <dir>"
71         echo "                      default: $DEFAULT_LIBS"
72         echo "-docdir <dir> ....... Documentation will be installed to <dir>"
73         echo "                      default: PREFIX/share/doc"
74         echo "-bindir <dir> ....... Executables will be installed to <dir>"
75         echo "                      default: PREFIX/bin"
76         echo "-headerdir <dir> .... Include files will be installed to <dir>"
77         echo "                      default: PREFIX/include"
78         echo "-qmake-bin <path> ... Specifies the path to the qmake executable"
79         echo "                      default: search the system path"
80         echo "-static ............. Compile Qxt as a static library"
81         echo "-debug .............. Build Qxt with debugging symbols"
82         echo "-release ............ Build Qxt without debugging support"
83         echo "-no-openssl ......... Do not link to OpenSSL"
84         echo "-nomake <module> .... Do not compile the specified module"
85         echo "                      options: network gui sql media web designer"
86         echo "-bootstrap .......... That should not be needed for release versions."
87         echo "                      warning: will only work on bash > 3.2"
88
89         rm config.in
90         exit
91     else
92         echo "Unrecognized configure option: $1"
93         rm config.in
94         exit
95     fi
96     shift
97 done
98
99 #====begin some autodetection====
100 >$CONFIG_LOG
101
102 # qmake?
103 if ! $WHICH $QMAKE_BIN >>$CONFIG_LOG 2>&1; then
104         echo >&2 "You don't seem to have 'qmake' in your PATH."
105         echo >&2 "Cannot proceed."
106         exit 1
107 fi
108
109 # find a make command
110 if [ -z "$MAKE" ]; then
111     MAKE=
112     for mk in gmake make; do
113         if "$WHICH" $mk | grep -qv "no "; then
114             MAKE=`$WHICH $mk`
115             break
116         fi
117     done
118     if [ -z "$MAKE" ]; then
119         echo >&2 "You don't seem to have 'make' or 'gmake' in your PATH."
120         echo >&2 "Cannot proceed."
121         exit 1
122     fi
123 fi
124
125 configtest()
126 {
127         echo -en "checking for $1\t" 
128         echo -e  " \n\n $1\n" >>$CONFIG_LOG
129         cd $TESTDIR/$1
130         $QMAKE_BIN $QMAKE_PARAMS  >>$CONFIG_LOG 2>&1
131         echo -n "."
132         $MAKE clean >>$CONFIG_LOG 2>&1
133         [ -f ./$1 ] && rm ./$1
134         echo -n "."
135         $MAKE >>$CONFIG_LOG 2>&1
136         echo -n "."
137         if ./$1 >>$CONFIG_LOG 2>&1; then
138                 echo -e >&2 "  [${C_GREEN}success${C_NONE}] "
139                 echo "DEFINES+=HAVE_$2">>$PROJECT_ROOT/config.in
140         else
141                 echo -e >&2 "  [${C_RED}failure${C_NONE}] "
142         fi
143 }
144
145 configtest qt4     QT
146 if [[ "$NO_OPENSSL" == "0" ]]; then
147     configtest openssl OPENSSL
148 fi
149 #configtest curses  CURSES
150 configtest fcgi  FCGI
151
152
153 #====finaly running qmake====
154 echo "autodetection finished. running qmake."
155 cd  $PROJECT_ROOT
156
157 [ -f config.pri ] && mv config.pri config.pri.bak
158 mv config.in config.pri
159
160 $QMAKE_BIN $QMAKE_PARAMS -recursive 2>>$CONFIG_LOG
161
162 echo -e >&2 "${C_CYAN}configure finished. run $MAKE now.${C_NONE}\n"