1
dnl ------------------------------------------------------------------------
2
dnl Detect if this is a 64bit environment
6
dnl ------------------------------------------------------------------------
7
AC_DEFUN([AQ_CHECK_LIB64],
9
if test `echo ${libdir} | sed -e 's#.*lib64.*#64#'` = "64"; then
16
dnl ------------------------------------------------------------------------
19
dnl use AQ_CHECK_GDAL to detect GDAL and OGR
23
dnl ------------------------------------------------------------------------
25
# Check for GDAL and OGR compiler and linker flags
27
AC_DEFUN([AQ_CHECK_GDAL],
30
AC_HELP_STRING([--with-gdal=path],
31
[Full path to 'gdal-config' script, e.g. '--with-gdal=/usr/local/bin/gdal-config']),
32
[ac_gdal_config_path=$withval])
34
if test x"$ac_gdal_config_path" = x ; then
35
ac_gdal_config_path=`which gdal-config`
38
ac_gdal_config_path=`dirname $ac_gdal_config_path 2> /dev/null`
39
AC_PATH_PROG(GDAL_CONFIG, gdal-config, no, $ac_gdal_config_path)
41
if test x${GDAL_CONFIG} = xno ; then
42
AC_MSG_ERROR([gdal-config not found! Supply it with --with-gdal=PATH])
44
AC_MSG_CHECKING([for OGR in GDAL])
45
if test x`$GDAL_CONFIG --ogr-enabled` = "xno" ; then
46
AC_MSG_ERROR([GDAL must be compiled with OGR support and currently is not.])
49
AC_MSG_CHECKING([GDAL_CFLAGS])
50
GDAL_CFLAGS=`$GDAL_CONFIG --cflags`
51
AC_MSG_RESULT($GDAL_CFLAGS)
53
AC_MSG_CHECKING([GDAL_LDADD])
54
GDAL_LDADD=`$GDAL_CONFIG --libs`
55
AC_MSG_RESULT($GDAL_LDADD)
57
ac_gdalogr_version=`$GDAL_CONFIG --version`
65
dnl ------------------------------------------------------------------------
68
dnl use AQ_CHECK_GEOS to detect GEOS
72
dnl ------------------------------------------------------------------------
76
AC_DEFUN([AQ_CHECK_GEOS],
79
AC_HELP_STRING([--with-geos=path],
80
[Full path to 'geos-config' script, e.g. '--with-geos=/usr/local/bin/geos-config']),
81
[ac_geos_config_path=$withval])
83
if test x"$ac_geos_config_path" = x ; then
84
ac_geos_config_path=`which geos-config`
87
ac_geos_config_path=`dirname $ac_geos_config_path 2> /dev/null`
88
AC_PATH_PROG(GEOS_CONFIG, geos-config, no, $ac_geos_config_path)
90
if test x${GEOS_CONFIG} = xno ; then
91
AC_MSG_ERROR([geos-config not found! Supply it with --with-geos=PATH])
93
ac_geos_version=`${GEOS_CONFIG} --version`
94
if test `echo ${ac_geos_version} | sed -e 's#2\.[0-9].*#OK#'` != OK ; then
95
AC_MSG_ERROR([Geos Version 2.x.x is needed, but you have $ac_geos_version!])
97
AC_MSG_CHECKING([GEOS_CFLAGS])
98
GEOS_CFLAGS=`$GEOS_CONFIG --cflags`
99
AC_MSG_RESULT($GEOS_CFLAGS)
101
AC_MSG_CHECKING([GEOS_LDADD])
102
GEOS_LDADD=`$GEOS_CONFIG --libs`
103
AC_MSG_RESULT($GEOS_LDADD)
109
AC_SUBST(GEOS_CFLAGS)
113
dnl ------------------------------------------------------------------------
116
dnl use AQ_CHECK_QT to detect QT3
121
dnl QASSISTANTCLIENT_LDADD
122
dnl ------------------------------------------------------------------------
124
# Check for Qt compiler flags, linker flags, and binary packages
126
AC_DEFUN([AQ_CHECK_QT],
128
AC_REQUIRE([AC_PROG_CXX])
129
AC_REQUIRE([AC_PATH_X])
131
AC_MSG_CHECKING([QTDIR])
132
AC_ARG_WITH([qtdir], [ --with-qtdir=DIR Qt installation directory [default=/usr/local]], QTDIR=$withval)
133
# Check that QTDIR is defined or that --with-qtdir given
134
if test x$QTDIR = x ; then
135
QT_SEARCH=" /usr/lib/qt31 /usr/lib64/qt31 /usr/local/qt31 /usr/lib/qt3 /usr/lib64/qt3 /usr/local/qt3 /usr/lib/qt2 /usr/lib64/qt2 /usr/local/qt2 /usr/lib/qt /usr/lib64/qt /usr/local/qt /usr /usr/local"
136
for i in $QT_SEARCH; do
137
if test x$QTDIR = x; then
138
if test -f $i/include/qt/qglobal.h -o -f $i/include/qglobal.h -o -f $i/include/qt3/qglobal.h; then
144
if test x$QTDIR = x ; then
145
AC_MSG_ERROR([*** QTDIR must be defined, or --with-qtdir option given])
147
AC_MSG_RESULT([$QTDIR])
149
# Change backslashes in QTDIR to forward slashes to prevent escaping
150
# problems later on in the build process, mainly for Cygwin build
151
# environment using MSVC as the compiler
152
# TODO: Use sed instead of perl
153
QTDIR=`echo $QTDIR | perl -p -e 's/\\\\/\\//g'`
155
# Check for QT includedir
156
if test -f $QTDIR/include/qt/qglobal.h; then
157
QTINC=$QTDIR/include/qt
158
elif test -f $QTDIR/include/qt3/qglobal.h; then
159
QTINC=$QTDIR/include/qt3
164
# Figure out which version of Qt we are using
165
AC_MSG_CHECKING([Qt version])
166
QT_VER=`grep 'define.*QT_VERSION_STR\W' $QTINC/qglobal.h | perl -p -e 's/\D//g'`
178
AC_MSG_ERROR([*** Qt version 3.1.x or higher is required])
181
AC_MSG_RESULT([$QT_VER ($QT_MAJOR)])
183
# Check that moc is in path
184
AC_CHECK_PROG(MOC, moc, moc)
185
if test x$MOC = x ; then
186
AC_MSG_ERROR([*** moc must be in path])
188
# uic is the Qt user interface compiler
189
AC_CHECK_PROG(UIC, uic, uic)
190
if test x$UIC = x ; then
191
AC_MSG_ERROR([*** uic must be in path])
193
# qembed is the Qt data embedding utility.
194
# It is located in $QTDIR/tools/qembed, and must be compiled and installed
195
# manually, we'll let it slide if it isn't present
196
AC_CHECK_PROG(QEMBED, qembed, qembed)
197
# Calculate Qt include path
198
QT_CXXFLAGS="-I$QTINC"
200
# On unix, figure out if we're doing a static or dynamic link
203
AC_DEFINE_UNQUOTED(WIN32, "", Defined if on Win32 platform)
204
echo "$QTDIR/lib/qt-mt$QT_VER.lib"
205
if test -f "$QTDIR/lib/qt-mt$QT_VER.lib" ; then
206
QT_LIB="qt-mt$QT_VER.lib"
210
elif test -f "$QTDIR/lib/qt$QT_VER.lib" ; then
211
QT_LIB="qt$QT_VER.lib"
214
elif test -f "$QTDIR/lib/qt.lib" ; then
218
elif test -f "$QTDIR/lib/qt-mt.lib" ; then
225
# determin static or dynamic -- prefer dynamic
226
QT_IS_DYNAMIC=`ls $QTDIR/lib/libqt*.dylib 2> /dev/null`
227
if test "x$QT_IS_DYNAMIC" = x; then
228
QT_IS_STATIC=`ls $QTDIR/lib/libqt*.a 2> /dev/null`
229
if test "x$QT_IS_STATIC" = x; then
231
AC_MSG_ERROR([*** Couldn't find any Qt libraries in $QTDIR/${_lib}])
238
# set link parameters based on shared/mt libs or static lib
239
if test "x`ls $QTDIR/lib/libqt.a* 2> /dev/null`" != x ; then
242
elif test "x`ls $QTDIR/lib/libqt-mt.*.dylib 2> /dev/null`" != x ; then
245
elif test "x`ls $QTDIR/lib/libqt.*.dylib 2> /dev/null`" != x ; then
248
elif test "x`ls $QTDIR/lib/libqte.* 2> /dev/null`" != x ; then
252
elif test "x`ls $QTDIR/lib/libqte-mt.* 2> /dev/null`" != x ; then
259
# determin static or dynamic -- prefer dynamic
260
QT_IS_DYNAMIC=`ls $QTDIR/${_lib}/libqt*.so 2> /dev/null`
261
if test "x$QT_IS_DYNAMIC" = x; then
262
QT_IS_STATIC=`ls $QTDIR/${_lib}/libqt*.a 2> /dev/null`
263
if test "x$QT_IS_STATIC" = x; then
265
AC_MSG_ERROR([*** Couldn't find any Qt libraries in $QTDIR/${_lib}])
272
# set link parameters based on shared/mt libs or static lib
273
if test "x`ls $QTDIR/${_lib}/libqt.a* 2> /dev/null`" != x ; then
276
elif test "x`ls $QTDIR/${_lib}/libqt-mt.so* 2> /dev/null`" != x ; then
279
elif test "x`ls $QTDIR/${_lib}/libqt.so* 2> /dev/null`" != x ; then
282
elif test "x`ls $QTDIR/${_lib}/libqte.* 2> /dev/null`" != x ; then
286
elif test "x`ls $QTDIR/${_lib}/libqte-mt.* 2> /dev/null`" != x ; then
294
AC_MSG_CHECKING([if Qt is static])
295
AC_MSG_RESULT([$QT_IS_STATIC])
296
AC_MSG_CHECKING([if Qt is multithreaded])
297
AC_MSG_RESULT([$QT_IS_MT])
298
AC_MSG_CHECKING([if Qt is embedded])
299
AC_MSG_RESULT([$QT_IS_EMBEDDED])
302
QASSISTANTCLIENT_LDADD="-lqassistantclient"
306
if test $QT_IS_STATIC = yes ; then
307
QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE"
313
if test $QT_IS_STATIC = yes && test $QT_IS_EMBEDDED = no; then
314
QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl -ljpeg"
320
if test $QT_IS_STATIC = yes && test $QT_IS_EMBEDDED = no; then
321
QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl -ljpeg -lpthread"
323
QT_LIBS="$QT_LIBS -lpthread"
329
if test $QT_IS_STATIC = yes && test $QT_IS_EMBEDDED = no; then
330
QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl -ljpeg"
335
# Digital Unix (aka DGUX aka Tru64)
337
if test $QT_IS_STATIC = yes ; then
338
QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE"
344
if test $QT_IS_STATIC = yes ; then
345
QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -lresolv -lsocket -lnsl"
350
# linker flag to suppress console when linking a GUI app on Win32
351
QT_GUILINK="/subsystem:windows"
352
if test $QT_MAJOR = "3" ; then
353
if test $QT_IS_MT = yes ; then
354
QT_LIBS="/nodefaultlib:libcmt"
356
QT_LIBS="/nodefaultlib:libc"
360
if test $QT_IS_STATIC = yes ; then
361
QT_LIBS="$QT_LIBS $QT_LIB kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib shell32.lib imm32.lib advapi32.lib wsock32.lib winspool.lib winmm.lib netapi32.lib"
362
if test $QT_MAJOR = "3" ; then
363
QT_LIBS="$QT_LIBS qtmain.lib"
366
QT_LIBS="$QT_LIBS $QT_LIB"
367
if test $QT_MAJOR = "3" ; then
368
QT_CXXFLAGS="$QT_CXXFLAGS -DQT_DLL"
369
QT_LIBS="$QT_LIBS qtmain.lib qui.lib user32.lib netapi32.lib"
372
QASSISTANTCLIENT_LDADD="qassistantclient.lib"
376
if test x"$QT_IS_EMBEDDED" = "xyes" ; then
377
QT_CXXFLAGS="-DQWS $QT_CXXFLAGS"
380
if test x"$QT_IS_MT" = "xyes" ; then
381
QT_CXXFLAGS="$QT_CXXFLAGS -D_REENTRANT -DQT_THREAD_SUPPORT"
384
QT_LDADD="-L$QTDIR/${_lib} $QT_LIBS"
386
if test x$QT_IS_STATIC = xyes ; then
389
AC_CHECK_LIB(Xft, XftFontOpen, QT_LDADD="$QT_LDADD -lXft")
393
AC_MSG_CHECKING([QT_CXXFLAGS])
394
AC_MSG_RESULT([$QT_CXXFLAGS])
395
AC_MSG_CHECKING([QT_LDADD])
396
AC_MSG_RESULT([$QT_LDADD])
398
AC_SUBST(QT_CXXFLAGS)
401
AC_SUBST(QASSISTANTCLIENT_LDADD)
407
# Configure path for the GNU Scientific Library
408
# Christopher R. Gabriel <cgabriel@linux.it>, April 2000
411
AC_DEFUN([AM_PATH_GSL],
413
AC_ARG_WITH(gsl-prefix,[ --with-gsl-prefix=PFX Prefix where GSL is installed (optional)],
414
gsl_prefix="$withval", gsl_prefix="")
415
AC_ARG_WITH(gsl-exec-prefix,[ --with-gsl-exec-prefix=PFX Exec prefix where GSL is installed (optional)],
416
gsl_exec_prefix="$withval", gsl_exec_prefix="")
417
AC_ARG_ENABLE(gsltest, [ --disable-gsltest Do not try to compile and run a test GSL program],
418
, enable_gsltest=yes)
420
if test "x${GSL_CONFIG+set}" != xset ; then
421
if test "x$gsl_prefix" != x ; then
422
GSL_CONFIG="$gsl_prefix/bin/gsl-config"
424
if test "x$gsl_exec_prefix" != x ; then
425
GSL_CONFIG="$gsl_exec_prefix/bin/gsl-config"
429
AC_PATH_PROG(GSL_CONFIG, gsl-config, no)
430
min_gsl_version=ifelse([$1], ,0.2.5,$1)
431
AC_MSG_CHECKING(for GSL - version >= $min_gsl_version)
433
if test "$GSL_CONFIG" = "no" ; then
436
GSL_CFLAGS=`$GSL_CONFIG --cflags`
437
GSL_LIBS=`$GSL_CONFIG --libs`
439
gsl_major_version=`$GSL_CONFIG --version | \
440
sed 's/^\([[0-9]]*\).*/\1/'`
441
if test "x${gsl_major_version}" = "x" ; then
445
gsl_minor_version=`$GSL_CONFIG --version | \
446
sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\2/'`
447
if test "x${gsl_minor_version}" = "x" ; then
451
gsl_micro_version=`$GSL_CONFIG --version | \
452
sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\3/'`
453
if test "x${gsl_micro_version}" = "x" ; then
457
if test "x$enable_gsltest" = "xyes" ; then
458
ac_save_CFLAGS="$CFLAGS"
460
CFLAGS="$CFLAGS $GSL_CFLAGS"
461
LIBS="$LIBS $GSL_LIBS"
469
char* my_strdup (const char *str);
472
my_strdup (const char *str)
478
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
479
strcpy (new_str, str);
489
int major = 0, minor = 0, micro = 0;
493
system ("touch conf.gsltest");
495
/* HP/UX 9 (%@#!) writes to sscanf strings */
496
tmp_version = my_strdup("$min_gsl_version");
498
n = sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) ;
500
if (n != 2 && n != 3) {
501
printf("%s, bad version string\n", "$min_gsl_version");
505
if (($gsl_major_version > major) ||
506
(($gsl_major_version == major) && ($gsl_minor_version > minor)) ||
507
(($gsl_major_version == major) && ($gsl_minor_version == minor) && ($gsl_micro_version >= micro)))
513
printf("\n*** 'gsl-config --version' returned %d.%d.%d, but the minimum version\n", $gsl_major_version, $gsl_minor_version, $gsl_micro_version);
514
printf("*** of GSL required is %d.%d.%d. If gsl-config is correct, then it is\n", major, minor, micro);
515
printf("*** best to upgrade to the required version.\n");
516
printf("*** If gsl-config was wrong, set the environment variable GSL_CONFIG\n");
517
printf("*** to point to the correct copy of gsl-config, and remove the file\n");
518
printf("*** config.cache before re-running configure\n");
523
],, no_gsl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
524
CFLAGS="$ac_save_CFLAGS"
528
if test "x$no_gsl" = x ; then
530
ifelse([$2], , :, [$2])
533
if test "$GSL_CONFIG" = "no" ; then
534
echo "*** The gsl-config script installed by GSL could not be found"
535
echo "*** If GSL was installed in PREFIX, make sure PREFIX/bin is in"
536
echo "*** your path, or set the GSL_CONFIG environment variable to the"
537
echo "*** full path to gsl-config."
539
if test -f conf.gsltest ; then
542
echo "*** Could not run GSL test program, checking why..."
543
CFLAGS="$CFLAGS $GSL_CFLAGS"
544
LIBS="$LIBS $GSL_LIBS"
548
[ echo "*** The test program compiled, but did not run. This usually means"
549
echo "*** that the run-time linker is not finding GSL or finding the wrong"
550
echo "*** version of GSL. If it is not finding GSL, you'll need to set your"
551
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
552
echo "*** to the installed location Also, make sure you have run ldconfig if that"
553
echo "*** is required on your system"
555
echo "*** If you have an old version installed, it is best to remove it, although"
556
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
557
[ echo "*** The test program failed to compile or link. See the file config.log for the"
558
echo "*** exact error that occured. This usually means GSL was incorrectly installed"
559
echo "*** or that you have moved GSL since it was installed. In the latter case, you"
560
echo "*** may want to edit the gsl-config script: $GSL_CONFIG" ])
561
CFLAGS="$ac_save_CFLAGS"
567
ifelse([$3], , :, [$3])
574
dnl ------------------------------------------------------------------------
577
dnl use AQ_CHECK_QGIS to detect QGIS
581
dnl ------------------------------------------------------------------------
583
# Check for QGIS compiler and linker flags
584
# Jens Oberender <j.obi@troja.net> 2004
586
AC_DEFUN([AQ_CHECK_QGIS],
589
dnl Get the cflags and libraries from qgis-config
592
AC_HELP_STRING([--with-qgis=path],
593
[Full path to 'qgis-config', e.g. --with-qgis=/usr/local/bin/qgis-config]),
594
[ac_qgis_config_path=$withval])
596
if test x"$ac_qgis_config_path" = x ; then
597
ac_qgis_config_path=`which qgis-config`
600
ac_qgis_config_path=`dirname $ac_qgis_config_path 2> /dev/null`
601
AC_PATH_PROG(QGIS_CONFIG, qgis-config, no, $ac_qgis_config_path)
603
if test x"$QGIS_CONFIG" = xno ; then
604
if test x"$ac_qgis_config_path" = x ; then
605
AC_MSG_ERROR([qgis-config not found in $ac_qgis_config_path! Supply a path with --with-qgis=PATH])
607
AC_MSG_ERROR([qgis-config not found! Supply a path with --with-qgis=PATH])
610
AC_MSG_CHECKING([QGIS_CXXFLAGS])
611
QGIS_CXXFLAGS=`$QGIS_CONFIG --cflags`
612
AC_MSG_RESULT($QGIS_CXXFLAGS)
614
AC_MSG_CHECKING([QGIS_LDADD])
615
QGIS_LDADD=`$QGIS_CONFIG --libs`
616
AC_MSG_RESULT($QGIS_LDADD)
618
AC_MSG_CHECKING([QGIS_PREFIX])
619
QGIS_PREFIX=`$QGIS_CONFIG --prefix`
620
AC_MSG_RESULT($QGIS_PREFIX)
622
AC_MSG_CHECKING([QGIS_PLUGINPATH])
623
QGIS_PLUGINPATH=`$QGIS_CONFIG --plugindir`
624
AC_MSG_RESULT($QGIS_PLUGINPATH)
626
AC_MSG_CHECKING([QGIS_MAJOR_VERSION])
627
QGIS_MAJOR_VERSION=`$QGIS_CONFIG --major_version`
628
AC_MSG_RESULT($QGIS_MAJOR_VERSION)
630
AC_MSG_CHECKING([QGIS_MINOR_VERSION])
631
QGIS_MINOR_VERSION=`$QGIS_CONFIG --minor_version`
632
AC_MSG_RESULT($QGIS_MINOR_VERSION)
634
AC_MSG_CHECKING([QGIS_MICRO_VERSION])
635
QGIS_MICRO_VERSION=`$QGIS_CONFIG --micro_version`
636
AC_MSG_RESULT($QGIS_MICRO_VERSION)
638
ac_save_CXXFLAGS="$CXXFLAGS"
639
ac_save_LDFLAGS="$LDFLAGS"
640
CXXFLAGS="$CXXFLAGS $QGIS_CXXFLAGS $QT_CXXFLAGS"
641
LDFLAGS="$LDFLAGS $QGIS_LDADD $QT_LDADD $GDAL_LDADD"
645
LDFLAGS="$LDFALGS -flat_namespace -undefined suppress"
650
#include <qgsfeature.h>
651
int main(int argc, char *argv[]) {
652
QgsFeature * myQgsFeature = new QgsFeature(1);
655
], [ac_qgis_linked='yes'], [ac_qgis_linked='no'])
656
CXXFLAGS="$ac_save_CXXFLAGS"
657
LDFLAGS="$ac_save_LDFLAGS"
659
AC_MSG_CHECKING([if linking with QGIS works])
660
if test x$ac_qgis_linked = xyes ; then
667
AC_SUBST(QGIS_CXXFLAGS)
669
AC_SUBST(QGIS_PREFIX)
670
AC_SUBST(QGIS_PLUGINPATH)
671
AC_SUBST(QGIS_MAJOR_VERSION)
672
AC_SUBST(QGIS_MINOR_VERSION)
673
AC_SUBST(QGIS_MICRO_VERSION)