Debian Codegraph @

configure

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 #!/bin/sh
2 # Copyright 2007-2008 David Johnson
3 # Configuration script for use with qt/qmake projects. This configure
4 # script is free software; the author gives unlimited permission to
5 # copy, distribute and modify it. Portions of this script adapted
6 # from the Qt configuration script.
7
8 PACKAGE=qbrew
9 PROFILE=qbrew.pro
10 PREFIX=/usr/local
11 QTMINVER=4.3.0
12 LOGFILE=config.log
13 BUILDDIR=.config
14
15 ### Messages ########################################################
16
17 usage() {
18 cat <<EOT
19 Usage: $0 [OPTION]...
20
21 This script creates the necessary configuration files for building
22
23 Main options:
24 --prefix=[path] Base path for build/install. Default: /usr/local
25 --bindir=[path] Directory for binaries. Default: PREFIX/bin
26 --datadir=[path] Directory for data. Default: PREFIX/share
27 --docdir=[path] Directory for docs. Default: PREFIX/share/doc
28 --qtdir=[path] Directory where Qt is installed
29 --spec=[spec] Spec to use for QMAKESPEC
30 --debug Enable debug output
31 --help This help text
32
33 EOT
34 }
35
36 qt_info() {
37 cat <<EOF
38 Be sure you have a properly configured Qt build environment. This application
39 requires a Qt library version of $QTMINVER or greater. Some systems split Qt
40 into separate runtime and development packages. If this is your case, make sure
41 you have both. The 'qmake' command should be in your path, and you may need to
42 use either the QTDIR environment variable or the --qtdir configure option. It
43 may be necessary to use the --spec option if qmake cannot determine your build
44 system. If your qmake has been installed under a different name, then it may be
45 necessary to use the QMAKE variable.
46 EOF
47 }
48
49 ### Tests ###########################################################
50
51 make_test() {
52 if [ -z "$MAKE" ] ; then
53 for mk in gmake make; do
54 if which $mk >/dev/null 2>&1; then
55 MAKE=`which $mk`
56 break
57 fi
58 done
59 if [ -z "$MAKE" ] ; then
60 echo "ERROR: cannot find 'make' or 'gmake'. Exiting"
61 echo "ERROR: cannot find 'make' or 'gmake'. Exiting" >> $LOGFILE
62 exit 1
63 fi
64 fi
65 }
66
67 qmake_test() {
68 echo -n "Checking for qmake..."
69
70 # check QTDIR
71 if [ -z "$QMAKE" ] ; then
72 result=$QTDIR/bin/qmake
73 if [ -x "$result" ] ; then
74 QMAKE=$result
75 fi
•76 result=$QTDIR/bin/lrelease
77 if [ -x "$result" ] ; then
78 LRELEASE=$result
79 fi
80 fi
81
82 # check PATH
83 if [ -z "$QMAKE" ] ; then
84 result=`which qmake 2>/dev/null`
85 if [ -x "$result" ] ; then
86 QMAKE=$result
87 fi
•88 result=`which lrelease 2>/dev/null`
89 if [ -x "$result" ] ; then
90 LRELEASE=$result
91 fi
92 fi
93
94 # check common rename
95 if [ -z "$QMAKE" ] ; then
96 result=`which qmake-q4 2>/dev/null`
97 if [ -x "$result" ] ; then
98 QMAKE=$result
99 fi
•100 result=`which lrelease-q4 2>/dev/null`
101 if [ -x "$result" ] ; then
102 LRELEASE=$result
103 fi
104 fi
105
106 # check pkg-config
107 if [ -z "$QMAKE" ] ; then
108 result=`pkg-config QtCore --variable=exec_prefix 2>/dev/null`
109 if [ ! -z "$result" ] ; then
110 result=$result/bin/qmake
111 if [ -x "$result" ] ; then
112 QMAKE=$result
113 fi
•114 result=$result/bin/lrelease
115 if [ -x "$result" ] ; then
116 LRELEASE=$result
117 fi
118 fi
119 fi
120
121 if [ -z "$QMAKE" ] ; then
122 echo "no!"
123 echo "ERROR: unable to find the 'qmake' tool"
124 echo "ERROR: unable to find the 'qmake' tool" >> $LOGFILE
125 qt_info
126 exit 1;
127 fi
128
129 echo "yes"
130 echo "found qmake at $QMAKE" >> $LOGFILE
•131 echo "found lrelease at $LRELEASE" >> $LOGFILE
132 }
133
134 qtversion_test() {
135 echo -n "Checking Qt version..."
136
137 result=`$QMAKE -query QT_VERSION`
138 if [ "$result" '<' "$QTMINVER" ] ; then
139 echo "no!"
140 echo "ERROR: incorrect Qt version found: $result"
141 echo "ERROR: incorrect Qt version found: $result" >> $LOGFILE
142 qt_info
143 exit 1;
144 fi
145 echo "$result"
146 echo "found Qt version $result" >> $LOGFILE
147 }
148
149 build_test() {
150 echo -n "Checking if a simple Qt program builds..."
151 cwd=`pwd`
152 rm -rf $BUILDDIR
153 mkdir -p $BUILDDIR
154 cd $BUILDDIR
155
156 # write it
157 cat >config.pro <<EOT
158 TARGET = config
159 CONFIG += qt $BUILDMODE
160 CONFIG -= app_bundle
161 QT -= gui
162 HEADERS += config.h
163 SOURCES += config.cpp
164 EOT
165
166 cat >config.h <<EOT
167 #include <QtCore>
168 class Config : public QCoreApplication {
169 public:
170 Config(int &argc, char **argv);
171 };
172 EOT
173
174 cat >config.cpp <<EOT
175 #include "config.h"
176 Config::Config(int &argc, char **argv)
177 : QCoreApplication(argc,argv) {setApplicationName("config");}
178 int main(int argc, char **argv)
179 {
180 Config app(argc,argv);
181 return 0;
182 }
183 EOT
184
185 # build it
186 $QMAKE config.pro > /dev/null
187 $MAKE >>$LOGFILE 2>&1
188 result=$?
189
190 cd $cwd
191 rm -rf $BUILDDIR
192
193 if [ "$result" != "0" ] ; then
194 echo "no!"
195 echo "ERROR: could not build a simple Qt program. See config.log"
196 echo "ERROR: could not build a simple Qt program" >> $LOGFILE
197 qt_info
198 exit 1;
199 fi
200 echo "yes"
201 echo "built simple Qt program" >> $LOGFILE
202 }
203
204 ### Parse options ###################################################
205
206 parse_options() {
207 while [ $# -gt 0 ] ; do
208 case "$1" in
209 --prefix=*)
210 PREFIX="${1#--prefix=}"
211 shift
212 ;;
213
214 --bindir=*)
215 BINDIR="${1#--bindir=}"
216 shift
217 ;;
218
219 --datadir=*)
220 DATADIR="${1#--datadir=}"
221 shift
222 ;;
223
224 --docdir=*)
225 DOCDIR="${1#--docdir=}"
226 shift
227 ;;
228
229 --qtdir=*)
230 QTDIR="${1#--qtdir=}"
231 shift
232 ;;
233
234 --spec=*)
235 QMAKESPEC="${1#--spec=}"
236 shift
237 ;;
238
239 --debug=*)
240 ENABLE_DEBUG="${1#--debug=}"
241 shift
242 ;;
243
244 --debug)
245 ENABLE_DEBUG="yes"
246 shift
247 ;;
248
249 --help) usage; exit ;;
250 *) usage; exit 1 ;;
251 esac
252 done
253 }
254
255 ### Main ############################################################
256
257 echo "Configuring $PACKAGE package..."
258
259 ### initialize
260
261 SOURCEPATH=`dirname $0`
262 SOURCEPATH=`(cd $SOURCEPATH; /bin/pwd)`
263 BUILDDIR=$SOURCEPATH/$BUILDDIR
264 LOGFILE=$SOURCEPATH/$LOGFILE
265
266 if [ -e $LOGFILE ] ; then rm $LOGFILE ; fi
267 echo "configure command: $0 $@" > $LOGFILE
268 echo `date` >>$LOGFILE
269
270 ### parse command options
271
272 parse_options $@
273
274 QMAKE=${QMAKE:-}
•275 LRELEASE=${LRELEASE:-}
276 PREFIX=${PREFIX:-/usr/local}
277 BINDIR=${BINDIR:-$PREFIX/bin}
278 DATADIR=${DATADIR:-$PREFIX/share/$PACKAGE}
279 DOCDIR=${DOCDIR:-$PREFIX/share/doc/$PACKAGE}
280
281 if [ "$ENABLE_DEBUG" = "yes" ] ; then
282 BUILDMODE="debug"
283 else
284 BUILDMODE="release"
285 fi
286
287 echo >> $LOGFILE
288 echo PREFIX=$PREFIX >> $LOGFILE
289 echo BINDIR=$BINDIR >> $LOGFILE
290 echo DATADIR=$DATADIR >> $LOGFILE
291 echo DOCDIR=$DOCDIR >> $LOGFILE
292 echo QTDIR=$QTDIR >> $LOGFILE
293 echo QMAKESPEC=$QMAKESPEC >> $LOGFILE
294 echo ENABLE_DEBUG=$ENABLE_DEBUG >> $LOGFILE
295 echo BUILDMODE=$BUILDMODE >> $LOGFILE
296 echo >> $LOGFILE
297
298 ### tests
299
300 make_test
301 qmake_test
302 qtversion_test
303 build_test
304
305 ### export variables
306
307 export BINDIR
308 export DATADIR
309 export DOCDIR
310 if [ ! -z $QTDIR ] ; then
311 export QTDIR
312 fi
313 if [ ! -z $QMAKESPEC ] ; then
314 export QMAKESPEC
315 fi
316
•317 ### create translation
318
319 echo "Creating translations"
320
321 $LRELEASE $PROFILE > /dev/null 2>> $LOGFILE
322
323 ### create Makefile
324
325 echo "Creating Makefile"
326
•327 $QMAKE "QMAKE_CXXFLAGS=\"$CXXFLAGS\"" "QMAKE_LFLAGS=\"$LDFLAGS\"" \
328 -o $SOURCEPATH/Makefile "CONFIG+=$BUILDMODE configure" \
329 $PROFILE > /dev/null 2>> $LOGFILE
330
331 if [ $? != "0" ] ; then
332 echo "ERROR: could not create Makefile. See config.log"
333 echo "ERROR: could not create Makefile." >> $LOGFILE
334 echo "Command: $QMAKE -o $SOURCEPATH/Makefile \"CONFIG+=$BUILDMODE\" $PROFILE" >> $LOGFILE
335 exit 1
336 fi
337
338 ### finished
339
340 echo
341 echo "$PACKAGE configured successfully"
342 echo "Relax, don't worry, have a homebrew!"
•343 echo