-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·396 lines (350 loc) · 12.2 KB
/
configure
File metadata and controls
executable file
·396 lines (350 loc) · 12.2 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
#!/bin/bash
################################################################################
# This file is part of the MagiCBuild configuration and build system. #
# #
# Copyright (C) 2003 Marko Gr�nroos <magi@iki.fi> #
# #
################################################################################
# #
# This library is free software; you can redistribute it and/or #
# modify it under the terms of the GNU Library General Public #
# License as published by the Free Software Foundation; either #
# version 2 of the License, or (at your option) any later version. #
# #
# This library is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
# Library General Public License for more details. #
# #
# You should have received a copy of the GNU Library General Public #
# License along with this library; see the file COPYING.LIB. If #
# not, write to the Free Software Foundation, Inc., 59 Temple Place #
# - Suite 330, Boston, MA 02111-1307, USA. #
# #
################################################################################
################################################################################
# Exits the program
################################################################################
function exit_conf () {
# Return from subconfiguration
if [ $SUBCONF ]; then
echo "<<<<<<<<<<<<< Returning from $SUBCONF"
fi
exit $1
}
################################################################################
# Prints help
################################################################################
function print_help () {
echo "Usage: ./configure [<option> ...]";
echo "Where an <Option> is one of the following:"
echo " --help This help."
echo " --prefix=<path> Defines installation path. (Default is"
echo " /usr/local for root and \$HOME for others)"
echo " --debug Make debug build."
}
################################################################################
# Parse command-line arguments
################################################################################
BUILDTYPE="release"
SUBCONFFLAGS=""
while [ "$*" != "" ]; do
if [ "${1:0:9}" == "--prefix=" ]; then
INSTALLDIR=${1:9};
elif [ "${1:0:10}" == "--subconf=" ]; then
SUBCONF=${1:10};
elif [ "${1:0:11}" == "--mainconf=" ]; then
MAINCONF=${1:11};
elif [ "$1" == "--debug" ]; then
BUILDTYPE="debug"
DEBUGBUILD=1
SUBCONFFLAGS="$SUBCONFFLAGS --debug"
elif [ "$1" == "--help" ]; then
print_help;
exit_conf 0;
else
echo "Unknown argument '$1'."
print_help;
exit_conf 1;
fi
shift;
done
################################################################################
# General definitions
################################################################################
# Set builddir
BUILDDIR="/var/tmp/$USER/build"
# Set configuration output file name
if [ $SUBCONF ]; then
echo ">>>>>>>>>>>>> Entering $SUBCONF"
. $MAINCONF
FULLSUBCONFDIR=$BUILDDIR/$PLATFORM-$ARCH/$BUILDTYPE/configs/$SUBCONF
mkdir -p $FULLSUBCONFDIR
MKCONFIG="$FULLSUBCONFDIR/config.mk"
else
MKCONFIG="build/config.mk"
fi
# Determine SRCDIR directory
SRCDIR="`pwd`"
################################################################################
# Determine correct ARCH
################################################################################
if [ $ARCH ] ; then
echo "ARCH ok"
else
ARCH=`uname -m`
fi
################################################################################
# Determine correct system
################################################################################
if [ $PLATFORM ] ; then
echo "PLATFORM ok"
else
PLATFORM=`uname -s`
fi
################################################################################
# Determine correct MAGICDIR directory
################################################################################
if [ $MAGICDIR ] && [ -d $MAGICDIR ] ; then
echo "MAGICDIR provided properly."
else
# Not provided, have to resolve
#echo "MAGICDIR not provided."
releasedir="$BUILDDIR/$PLATFORM-$ARCH/$BUILDTYPE"
# See if it's here; we're compiling magiclib itself
if [ -d libmagic ] ; then
echo "Compiling MagicLib itself."
MAGICDIR="`pwd`"
SRCDIR=$MAGICDIR
elif [ -d $releasedir/include/magic ] ; then
MAGICDIR="$releasedir"
fi
#elif [ -d ../magic ] ; then
#MAGICDIR="`pwd`/../magic"
#elif [ -d ../../magic ] ; then
#MAGICDIR="`pwd`/../../magic"
#fi
if [ "$MAGICDIR" != "" ]; then
echo "MAGICDIR=$MAGICDIR";
fi
fi
################################################################################
# Determine correct INSTALLDIR directory
################################################################################
if [ $INSTALLDIR ] && [ -d $INSTALLDIR ] ; then
echo "Installation prefix is $INSTALLDIR"
else
# Not provided, have to resolve
if [ $USER == "root" ] ; then
INSTALLDIR="/usr/local"
else
INSTALLDIR=$HOME
fi
echo "INSTALLDIR (--prefix) not provided, using $INSTALLDIR"
fi
################################################################################
# Extra directories
################################################################################
function add_include_dir () {
if [ $EXTRA_INCLUDE_DIRS ] ; then
EXTRA_INCLUDE_DIRS="$EXTRA_INCLUDE_DIRS -I$1"
else
EXTRA_INCLUDE_DIRS="-I$1"
fi
}
function add_library_dir () {
if [ $EXTRA_LIB_DIRS ] ; then
EXTRA_LIB_DIRS="$EXTRA_LIB_DIRS -L$1"
else
EXTRA_LIB_DIRS="-L$1"
fi
}
function add_library () {
if [ $EXTRA_LIBS ] ; then
EXTRA_LIBS="$EXTRA_LIBS -l$1"
else
EXTRA_LIBS="-l$1"
fi
}
################################################################################
# Determine C++ compiler
################################################################################
function check_for_cpp () {
echo -n "checking for c++ compiler... "
if g++ -v 2>/dev/null ; then
CXX="g++"
else
if gcc -v 2>/dev/null ; then
CXX="gcc"
else
echo "No C++ compiler exists"
exit_conf 1
fi
fi
# Check C++ compiler version
cxx_version_line=`$CXX -v 2>&1| tail -1|cut -d ' ' -f 3`
echo "$CXX (version $cxx_version_line)"
# Find C++ compiler resource path
cxx_specs_raw=`$CXX -v 2>&1| head -1`
if [[ "$cxx_specs_raw" =~ "built-in" ]]; then
cxx_specs=""
echo "! WARNING. No path for $CXX. This may lead to problems."
else
cxx_specs=`echo "$cxx_specs_raw"|cut -d ' ' -f 4`
cxx_path=`dirname $cxx_specs`
echo "checking $CXX path... $cxx_path"
fi
}
check_for_cpp
################################################################################
# Check for Qt
################################################################################
function check_for_qt () {
echo -n "Checking for qt... "
QT_DIRS_SET=0
QT4=0
# Check various user and system directories
if [ -d /usr/include/qt4 ] ; then
QTDIR="/usr/lib/qt4"
add_include_dir "/usr/include/qt4"
QT_DIRS_SET=1
QT4=1
elif [ -d /usr/include/qt3 ] ; then
QTDIR="/usr/lib/qt3"
add_include_dir "/usr/include/qt3"
QT_DIRS_SET=1
elif [ -d /usr/lib/qt-3.1 ] ; then
QTDIR="/usr/lib/qt-3.1"
elif [ -d /usr/lib/qt3 ] ; then
QTDIR="/usr/lib/qt3"
elif [ -d /usr/lib/qt2 ] ; then
QTDIR="/usr/lib/qt2"
elif [ -d /usr/lib/qt ] ; then
QTDIR="/usr/lib/qt"
fi
echo "QTDIR = $QTDIR"
# Make settings if found
if [ $QTDIR ] ; then
echo "yes"
echo "Qt directory is $QTDIR"
if [ $QT_DIRS_SET == 0 ] ; then
add_include_dir "$QTDIR/include"
add_library_dir "$QTDIR/lib"
fi
if [ $QT4 == 0 ] ; then
add_library "qt-mt"
else
add_library "QtCore"
add_library "QtGui"
fi
else
echo "ERROR: Qt is required"
exit_conf 1
fi
# Try to compile a simple Qt application
echo -n "Trying to compile a simple Qt application... "
cat > qttest.cc <<EOF
#include <Qt/qapplication.h>
int main (int argc, char* argv[]) {
QApplication qapp (argc, argv);
return 0;
}
EOF
CMD="$CXX -o qttest qttest.cc $EXTRA_INCLUDE_DIRS $EXTRA_LIB_DIRS $EXTRA_LIBS"
if $CMD ; then
echo "succeeded"
else
echo "Checking Qt failed with command:"
echo "$CMD"
exit_conf 1
fi
# Try to run it
echo -n "Trying to run a simple Qt application... "
if ./qttest ; then
echo "succeeded"
else
echo "failed"
exit_conf 1
fi
rm -f qttest.cc qttest
}
################################################################################
# Check for libjpeg
################################################################################
function check_for_libjpeg () {
echo -n "checking for libjpeg... "
if [ -f /usr/lib/libjpeg.a ] ; then
LIBJPEG_FOUND="yes"
elif [ -f /usr/local/lib/libjpeg.a ] ; then
LIBJPEG_FOUND="yes"
else
LIBJPEG_FOUND="no"
fi
echo "$LIBJPEG_FOUND"
# Make settings if found
if [ $LIBJPEG_FOUND == "no" ] ; then
echo "ERROR: libjpeg is required"
exit_conf 1
fi
}
################################################################################
# Call project-specific configure scripts
################################################################################
if [ ! $SUBCONF ]; then
if [ -f build/conf-reqs.sh ] ; then
. build/conf-reqs.sh
fi
else
. $SUBCONF/build/subconf-reqs.sh
fi
################################################################################
# Generate config.mk main data
################################################################################
echo "creating $MKCONFIG..."
if ! eval echo "#">$MKCONFIG ; then
echo "Creating configuration file $MKCONFIG failed."
exit_conf 1
fi
echo "#################################################################################" >> $MKCONFIG
echo "# This is a configuration generated by 'configure'" >> $MKCONFIG
echo "#################################################################################" >> $MKCONFIG
echo "export MAGICDIR=$MAGICDIR" >> $MKCONFIG
echo "export SRCDIR=$SRCDIR" >> $MKCONFIG
echo "export BUILDDIR=$BUILDDIR" >> $MKCONFIG
echo "export INSTALLDIR=$INSTALLDIR" >> $MKCONFIG
echo "export PLATFORM=$PLATFORM" >> $MKCONFIG
echo "export ARCH=$ARCH" >> $MKCONFIG
echo "export CXX=$CXX" >> $MKCONFIG
echo "export CXX_PATH=$cxx_path" >> $MKCONFIG
if [ $WRITE_CUSTOM_CONFIG ] ; then
$WRITE_CUSTOM_CONFIG
fi
if [ $DEBUGBUILD ] ; then
echo "export DEBUG=1" >> $MKCONFIG
echo "export BUILDTYPE=debug" >> $MKCONFIG
fi
################################################################################
# Generate rest of config.mk
################################################################################
if [ "$EXTRA_INCLUDE_DIRS" ] ; then
echo "export EXTRA_INCLUDE_DIRS=$EXTRA_INCLUDE_DIRS" >> $MKCONFIG
fi
if [ $EXTRA_LIB_DIRS ] ; then
echo "export EXTRA_LIB_DIRS=$EXTRA_LIB_DIRS" >> $MKCONFIG
fi
if [ "$EXTRA_LIBS" ] ; then
echo "export EXTRA_LIBS=$EXTRA_LIBS" >> $MKCONFIG
fi
################################################################################
# Create subconfigurations
################################################################################
if [ ! $SUBCONF ]; then
CONFREQFILES=`find . -name 'subconf-reqs.sh'`
for CONFREQFILE in $CONFREQFILES; do
CONFREQFILE=${CONFREQFILE:2}
SUBCONFDIR=${CONFREQFILE/\/build\/subconf-reqs.sh/}
./configure --subconf=$SUBCONFDIR --mainconf=$MKCONFIG $SUBCONFFLAGS
done
fi
echo "Done."
exit_conf 0