1dnl -*- Mode: autoconf -*-
2dnl
3dnl configure.ac - autoconf file for rasqal
4dnl (Process this file with autoconf to produce a configure script.)
5dnl
6dnl Copyright (C) 2003-2011, David Beckett http://www.dajobe.org/
7dnl Copyright (C) 2003-2005, University of Bristol, UK http://www.bristol.ac.uk/
8dnl
9dnl This package is Free Software and part of Redland http://librdf.org/
10dnl
11dnl It is licensed under the following three licenses as alternatives:
12dnl   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
13dnl   2. GNU General Public License (GPL) V2 or any newer version
14dnl   3. Apache License, V2.0 or any newer version
15dnl
16dnl You may not use this file except in compliance with at least one of
17dnl the above three licenses.
18dnl
19dnl See LICENSE.html or LICENSE.txt at the top of this package for the
20dnl complete terms and further detail along with the license texts for
21dnl the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
22dnl
23
24
25AC_PREREQ([2.62])
26AC_INIT([Rasqal RDF Query Library],[0.9.33],[http://bugs.librdf.org/],[rasqal])
27AC_CONFIG_SRCDIR([src/rasqal_general.c])
28AC_CONFIG_HEADERS([src/rasqal_config.h])
29AC_CONFIG_AUX_DIR(build)
30AC_CONFIG_MACRO_DIR(build)
31AM_INIT_AUTOMAKE([1.11 check-news std-options -Wobsolete -Wportability -Wsyntax -Wunsupported -Wextra-portability])
32
33AM_MAINTAINER_MODE
34
35release_version=no
36AC_ARG_ENABLE(release, [  --enable-release        Turn on optimizations (for maintainer).  ], \
37 if test "$enableval" = "yes"; then \
38	  release_version=yes
39fi;)
40
41if test "$USE_MAINTAINER_MODE" = yes -a $release_version = no; then
42  CFLAGS=`echo $CFLAGS | sed -e "s/-O[A-Za-z0-9]*//"`
43  CXXFLAGS=`echo $CXXFLAGS | sed -e "s/-O[A-Za-z0-9]*//"`
44  CPPFLAGS=`echo $CPPFLAGS | sed -e "s/-O[A-Za-z0-9]*//"`
45fi
46
47dnl Checks for programs.
48AC_CANONICAL_HOST
49AM_SANITY_CHECK
50AM_PROG_AR
51AC_PROG_CC
52AM_PROG_CC_C_O
53AC_MSG_CHECKING(whether $CC is clang)
54
55dnl Initialize libtool
56LT_INIT
57
58AC_PROG_INSTALL
59AC_PROG_LN_S
60AC_PROG_MAKE_SET
61
62
63FLEX_MIN_VERSION=2.5.19
64FLEX_REC_VERSION=2.5.36
65
66# Do not want AM_PROG_LEX which adds 'missing' to LEX if it's not around
67AC_PROG_LEX
68AC_MSG_CHECKING(flex)
69if test "$USE_MAINTAINER_MODE" = yes; then
70  # maintainer mode - flex is required
71  if test "X$LEX" = "X:" ; then
72    AC_MSG_RESULT(not present)
73    AC_MSG_WARN(Please get flex from http://flex.sourceforge.net/)
74    AC_MSG_WARN(version $FLEX_MIN_VERSION ($FLEX_REC_VERSION recommended))
75    AC_MSG_FAILURE(flex not present)
76  fi
77
78  # some kind of lexer is present
79  if echo "$LEX" | grep flex >/dev/null 2>&1; then
80    # flex is present
81    FLEX_VERSION=`$LEX -V 2>&1 | $AWK '{print $2}'`
82    FLEX_VERSION_DEC=`echo $FLEX_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
83
84    FLEX_MIN_VERSION_DEC=`echo $FLEX_MIN_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
85
86    if test $FLEX_VERSION_DEC -ge $FLEX_MIN_VERSION_DEC; then
87      AC_MSG_RESULT($FLEX_VERSION - OK)
88    else
89      AC_MSG_RESULT(version $FLEX_VERSION - too old)
90      AC_MSG_WARN(Please get flex from http://flex.sourceforge.net/)
91      AC_MSG_WARN(version $FLEX_MIN_VERSION ($FLEX_REC_VERSION recommended))
92      AC_MSG_FAILURE(flex is too old)
93    fi
94  else
95    AC_MSG_RESULT(present - but is not flex)
96    AC_MSG_WARN(Please get flex from http://flex.sourceforge.net/)
97    AC_MSG_WARN(version $FLEX_MIN_VERSION ($FLEX_REC_VERSION recommended))
98    AC_MSG_FAILURE($LEX is not not flex)
99  fi
100else
101  # not maintainer mode; flex is not required
102  AC_MSG_RESULT(not present - not required for non maintainer builds)
103  LEX="$SHELL $missing_dir/missing flex"
104  AC_SUBST(LEX_OUTPUT_ROOT, lex.yy)
105  AC_SUBST(LEXLIB, '')
106  FLEX_VERSION_DEC=00000
107fi
108AC_DEFINE_UNQUOTED(FLEX_VERSION_DECIMAL, $FLEX_VERSION_DEC, [Flex version as a decimal])
109
110
111BISON_MIN_VERSION=3.0.0
112AC_CHECK_PROGS(BISON, bison3 bison)
113if test "$USE_MAINTAINER_MODE" = yes; then
114  AC_MSG_CHECKING(for GNU bison)
115  # Match these styles of versions
116  # GNU Bison version 1.28
117  # bison (GNU Bison) 1.875
118dnl need to change quotes to allow square brackets
119changequote(<<, >>)dnl
120  BISON_VERSION=`$BISON --version 2>&1 | sed -ne 's/^.*GNU Bison[^0-9]*//p'`
121changequote([, ])dnl
122  if test "X$BISON_VERSION" != X; then
123    BISON_VERSION_DEC=`echo $BISON_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
124
125    BISON_MIN_VERSION_DEC=`echo $BISON_MIN_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
126
127    if test $BISON_VERSION_DEC -ge $BISON_MIN_VERSION_DEC; then
128      AC_MSG_RESULT($BISON_VERSION - OK)
129    else
130      AC_MSG_RESULT(version $BISON_VERSION is too old)
131      AC_MSG_WARN(Please get GNU Bison from http://www.gnu.org/software/bison/)
132      AC_MSG_WARN(version $BISON_MIN_VERSION or newer)
133      AC_MSG_FAILURE(GNU Bison too old)
134    fi
135  else
136    AC_MSG_FAILURE($BISON is not GNU bison)
137  fi
138fi
139AC_SUBST(BISON)
140
141AC_CHECK_PROGS(AWK, awk gawk nawk)
142# Find a tar command for 'make dist'
143AC_CHECK_PROGS(TAR, gnutar gtar tar)
144AC_CHECK_PROGS(PERL, perl)
145
146AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
147AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
148AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
149AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
150
151AC_CHECK_PROGS(RECHO, echo)
152RECHO_C=
153RECHO_N=
154case `$RECHO -n x` in
155  -n*)
156    case `$RECHO 'xy\c'` in
157      *c*)
158         ;;
159      xy)
160         RECHO_C='\c'
161         ;;
162    esac;;
163  *)
164    RECHO_N='-n'
165    ;;
166esac
167
168
169
170dnl compiler checks
171
172AC_DEFUN([REDLAND_CC_TRY_FLAG], [
173  AC_MSG_CHECKING([whether $CC supports $1])
174
175  ## backup CFLAGS and werror status
176  redland_save_CFLAGS="$CFLAGS"
177  redland_save_ac_c_werror_flag="${ac_c_werror_flag}"
178  AC_LANG_WERROR
179
180  CFLAGS="$CFLAGS $1"
181  AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ])], [redland_cc_flag=yes], [redland_cc_flag=no])
182
183  ## restore CFLAGS and werror status
184  CFLAGS="$redland_save_CFLAGS"
185  ac_c_werror_flag="${redland_save_ac_c_werror_flag}"
186
187  if test "X$redland_cc_flag" = "Xyes"; then
188    ifelse([$2], , :, [$2])
189  else
190    ifelse([$3], , :, [$3])
191  fi
192  AC_MSG_RESULT($redland_cc_flag)
193])
194
195# GCC warning options
196# http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
197#
198# Too noisy:
199#
200#  -Wconversion        : cases that need RASQAL_GOOD/BAD_CAST etc.
201#  -Wcast-qual         : cases that need RASQAL_GOOD/BAD_CAST etc.
202#  -Wswitch-default    : noisy cases in flex output
203#  -Wsystem-headers    : not debugging system
204#  -Wunused-parameter  : variables can be marked  __attribute__('unused')
205#
206# Apple gcc specific (probably): -Wshorten-64-to-32
207possible_warnings="\
208-Wall \
209-Wc++-compat \
210-Wextra \
211-Wunused \
212\
213-Waggregate-return \
214-Wbad-function-cast \
215-Wcast-align \
216-Wdeclaration-after-statement \
217-Wdisabled-optimization \
218-Wdiv-by-zero \
219-Wendif-labels \
220-Werror-implicit-function-declaration \
221-Wfloat-equal \
222-Wformat=2 \
223-Wframe-larger-than=4096 \
224-Winit-self \
225-Winline \
226-Wmissing-declarations \
227-Wmissing-format-attribute \
228-Wmissing-noreturn \
229-Wmissing-prototypes \
230-Wnested-externs \
231-Wold-style-definition \
232-Wpacked \
233-Wpointer-arith \
234-Wredundant-decls \
235-Wshadow \
236-Wsign-compare \
237-Wstrict-prototypes \
238-Wswitch-enum \
239-Wundef \
240-Wunreachable-code \
241-Wunsafe-loop-optimizations \
242-Wwrite-strings \
243\
244-Wshorten-64-to-32
245\
246-Wno-conversion \
247-Wno-cast-qual \
248-Wno-switch-default \
249-Wno-system-headers \
250-Wno-unused-parameter \
251-Wc90-c99-compat \
252-Wc99-c11-compat \
253"
254
255warning_cflags=
256if test "$USE_MAINTAINER_MODE" = yes; then
257  AC_MSG_CHECKING(for supported $CC warning flags)
258  AC_MSG_RESULT($warning_cflags)
259  for warning in $possible_warnings; do
260    REDLAND_CC_TRY_FLAG([$warning], [warning_cflags="$warning_cflags $warning"])
261  done
262  AC_MSG_CHECKING($CC supports warning flags)
263  AC_MSG_RESULT($warning_cflags)
264fi
265
266STANDARD_CFLAGS=
267MAINTAINER_CPPFLAGS="$warning_cflags"
268
269# Externally linked libraries - appear in rasqal-config
270# -Dfoo -Idir
271RASQAL_CPPFLAGS=$CPPFLAGS
272# -Ldir
273RASQAL_LDFLAGS=$LDFLAGS
274# -llib
275RASQAL_LIBS=$LIBS
276
277# Internally linked libraries - never given to users
278# -Dfoo -Idir
279RASQAL_INTERNAL_CPPFLAGS=
280# -Ldir -llib
281RASQAL_INTERNAL_LIBS=
282
283# Libraries linked externally also may be internal - just raptor
284# -Ldir -llib
285RASQAL_EXTERNAL_LIBS=
286# Extra pkgconfig requires
287PKGCONFIG_REQUIRES=
288PKGCONFIG_LIBS=
289PKGCONFIG_CFLAGS=
290
291dnl Checks for header files.
292AC_HEADER_STDC
293AC_CHECK_HEADERS(errno.h stddef.h stdlib.h stdint.h unistd.h string.h strings.h getopt.h regex.h sys/time.h time.h math.h limits.h errno.h float.h)
294AC_HEADER_TIME
295
296if test "$ac_cv_header_sys_time_h" = "yes"; then
297  HAVE_SYS_TIME_H=1
298else
299  HAVE_SYS_TIME_H=0
300fi
301AC_SUBST(HAVE_SYS_TIME_H)
302if test "$ac_cv_header_time_h" = "yes"; then
303  HAVE_TIME_H=1
304else
305  HAVE_TIME_H=0
306fi
307AC_SUBST(HAVE_TIME_H)
308
309
310dnl Checks for typedefs, structures, and compiler characteristics.
311AC_C_CONST
312AC_C_BIGENDIAN
313
314AC_MSG_CHECKING(whether __FUNCTION__ is available)
315AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() { printf(__FUNCTION__); }])],
316    [AC_DEFINE([HAVE___FUNCTION__], [1], [Is __FUNCTION__ available])
317     AC_MSG_RESULT(yes)],
318    [AC_MSG_RESULT(no)])
319
320
321# Libtool versioning
322#
323# CURRENT
324#      The most recent interface number that this library implements.
325#
326# REVISION
327#      The implementation number of the CURRENT interface.
328#
329# AGE
330#      The difference between the newest and oldest interfaces that this
331#      library implements.  In other words, the library implements all the
332#      interface numbers in the range from number `CURRENT - AGE' to
333#      `CURRENT'.
334#
335# Rules:
336#  1. Start with version information of `0:0:0' for each libtool library.
337#
338#  2. Update the version information only immediately before a public
339#     release of your software.  More frequent updates are unnecessary,
340#     and only guarantee that the current interface number gets larger
341#     faster.
342#
343#  3. If the library source code has changed at all since the last
344#     update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
345#
346#  4. If any interfaces have been added, removed, or changed since the
347#     last update, increment CURRENT, and set REVISION to 0.
348#
349#  5. If any interfaces have been added since the last public release,
350#     then increment AGE.
351#
352#  6. If any interfaces have been removed since the last public release,
353#     then set AGE to 0.
354#
355# syntax: CURRENT[:REVISION[:AGE]]
356RASQAL_LIBTOOL_VERSION=3:0:0
357AC_SUBST(RASQAL_LIBTOOL_VERSION)
358
359
360dnl need to change quotes to allow square brackets
361changequote(<<, >>)dnl
362version_major=`echo $VERSION | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\1/'`
363version_minor=`echo $VERSION | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\2/'`
364version_release=`echo $VERSION | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\3/'`
365changequote([, ])dnl
366
367version_decimal=`expr $version_major \* 10000 + $version_minor \* 100 + $version_release`
368
369AC_DEFINE_UNQUOTED(RASQAL_VERSION_MAJOR, $version_major, [Major version number])
370AC_DEFINE_UNQUOTED(RASQAL_VERSION_MINOR, $version_minor, [Minor version number])
371AC_DEFINE_UNQUOTED(RASQAL_VERSION_RELEASE, $version_release, [Release version number])
372AC_DEFINE_UNQUOTED(RASQAL_VERSION_DECIMAL, $version_decimal, [Release version as a decimal])
373
374# for rasqal-config.in
375RASQAL_VERSION_MAJOR=$version_major
376RASQAL_VERSION_MINOR=$version_minor
377RASQAL_VERSION_RELEASE=$version_release
378RASQAL_VERSION_DECIMAL=$version_decimal
379AC_SUBST(RASQAL_VERSION)
380AC_SUBST(RASQAL_VERSION_MAJOR)
381AC_SUBST(RASQAL_VERSION_MINOR)
382AC_SUBST(RASQAL_VERSION_RELEASE)
383AC_SUBST(RASQAL_VERSION_DECIMAL)
384
385
386dnl Checks for library functions.
387AC_CHECK_FUNCS(getopt getopt_long stricmp strcasecmp vsnprintf initstate_r initstate random_r random gmtime_r rand_r rand srand timegm gettimeofday)
388
389AM_CONDITIONAL(STRCASECMP, test $ac_cv_func_stricmp = no -a $ac_cv_func_strcasecmp = no)
390AM_CONDITIONAL(GETOPT, test $ac_cv_func_getopt = no -a $ac_cv_func_getopt_long = no)
391AM_CONDITIONAL(TIMEGM, test $ac_cv_func_timegm = no)
392dnl Windows only version
393AM_CONDITIONAL(GETTIMEOFDAY, test $ac_cv_func_gettimeofday = no)
394
395
396AC_MSG_CHECKING(whether need to declare optind)
397AC_LINK_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_GETOPT_H
398#include <getopt.h>
399#endif
400#ifdef HAVE_UNISTD_H
401#include <unistd.h>
402#endif
403]], [[int x=optind;]])],[AC_MSG_RESULT(no)],[AC_DEFINE(NEED_OPTIND_DECLARATION, 1, need 'extern int optind' declaration?)
404            AC_MSG_RESULT(yes)])
405
406
407AC_MSG_CHECKING(whether struct tm has tm_gmtoff field)
408AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_TIME_H
409#include <time.h>
410#endif
411#ifdef HAVE_SYS_TIME_H
412#include <sys/time.h>
413#endif
414]], [[struct tm my_time; my_time.tm_gmtoff = 0;]])],[have_tm_gmtoff="yes"],[have_tm_gmtoff="no"])
415AC_MSG_RESULT($have_tm_gmtoff)
416if test $have_tm_gmtoff = "yes" ; then
417  AC_DEFINE(HAVE_TM_GMTOFF, 1, [struct tm has tm_gmtoff field])
418fi
419
420
421# raptor V2 is REQUIRED; --enable-raptor2 option was removed
422RAPTOR_MIN_VERSION=2.0.7
423
424
425PKG_PROG_PKG_CONFIG
426
427PKG_CHECK_MODULES([RAPTOR2],[raptor2],[
428  RAPTOR_VERSION=`$PKG_CONFIG raptor2 --modversion 2>/dev/null`
429  raptor_too_old=0
430  AS_VERSION_COMPARE([$RAPTOR_VERSION], $RAPTOR_MIN_VERSION, raptor_too_old="1")
431  if test $raptor_too_old = 1; then
432    AC_MSG_ERROR(Raptor $RAPTOR_VERSION is too old - see http://librdf.org/raptor/ to get a $RAPTOR_MIN_VERSION or newer)
433  fi
434],[
435  AC_MSG_ERROR(Raptor is not installed - see http://librdf.org/raptor/ to get $RAPTOR_MIN_VERSION or newer)
436])
437AC_SUBST(RAPTOR2_CFLAGS)
438AC_SUBST(RAPTOR2_LIBS)
439
440RAPTOR_VERSION_DEC=`echo $RAPTOR_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
441AC_SUBST(RAPTOR_VERSION_DEC)
442AC_SUBST(RAPTOR_MIN_VERSION)
443
444AM_CONDITIONAL(RASQAL_SORT, test $RAPTOR_VERSION_DEC '<' 20015)
445
446dnl Checks for regex libraries
447have_regex_pcre=0
448have_regex_posix=0
449need_regex_pcre=0
450need_regex_posix=0
451
452AC_ARG_ENABLE(pcre,
453	[  --disable-pcre                  Disable PCRE support (default auto)],
454	[enable_pcre=$enableval], [enable_pcre="auto"])
455
456if test "x$enable_pcre" != "xno" ; then
457
458  AC_ARG_WITH(pcre-config, [  --with-pcre-config=PATH     Location of PCRE pcre-config (auto)], pcre_config="$withval", pcre_config="")
459
460  if test "X$pcre_config" != "Xno" ; then
461    if test "X$pcre_config" != "X" ; then
462      AC_MSG_CHECKING(for $pcre_config)
463
464      if test -x $pcre_config ; then
465	PCRE_CONFIG=$pcre_config
466	AC_MSG_RESULT(yes)
467      else
468	AC_MSG_ERROR([pcre-config not found at specified path $pcre_config])
469      fi
470    fi
471    if test "X$PCRE_CONFIG" = "X" ; then
472      AC_CHECK_PROGS(PCRE_CONFIG, pcre-config)
473    fi
474  fi
475
476  AC_MSG_CHECKING(for pcre)
477  PCRE_VERSION=`$PCRE_CONFIG --version 2>/dev/null`
478  PCRE_MIN_VERSION=3.9
479
480  PCRE_VERSION_DEC=`echo $PCRE_VERSION | $AWK -F. '{printf("%d\n", 100*$1 + $2)};'`
481  PCRE_MIN_VERSION_DEC=`echo $PCRE_MIN_VERSION | $AWK -F. '{printf("%d\n", 100*$1 + $2)};'`
482  if test "X$PCRE_VERSION" = X; then
483    AC_MSG_RESULT(not present)
484  elif test "X$PCRE_VERSION" -a $PCRE_VERSION_DEC -ge $PCRE_MIN_VERSION_DEC; then
485    have_regex_pcre=1
486    AC_MSG_RESULT($PCRE_VERSION)
487  else
488    AC_MSG_WARN($PCRE_VERSION - too old - need $PCRE_MIN_VERSION)
489  fi
490
491  if test $have_regex_pcre = 1; then
492    AC_DEFINE(HAVE_REGEX_PCRE, 1, [have PCRE regex - Perl Compatible Regular Expressions])
493  elif test "x$enable_pcre" = "xyes"; then
494    AC_MSG_ERROR(PCRE requested but not found)
495  fi
496
497fi
498
499
500AC_MSG_CHECKING(for posix regex library)
501oLIBS="$LIBS"
502if test $ac_cv_header_regex_h = yes; then
503  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
504              #include <regex.h>]], [[regex_t reg; char *pat="abc"; regcomp(&reg, pat, 0);]])],[worked=yes],[worked=no])
505  if test $worked = yes; then
506    have_regex_posix=1
507  fi
508fi
509
510LIBS="$oLIBS"
511
512if test $have_regex_posix = 1; then
513  AC_MSG_RESULT(yes)
514  AC_DEFINE(HAVE_REGEX_POSIX, 1, [have POSIX regex library])
515else
516  AC_MSG_RESULT(no)
517fi
518
519
520
521AC_ARG_WITH(regex-library, [  --with-regex-library=NAME   Use regex library - posix, pcre (auto)], regex_library="$withval", regex_library="")
522
523for regex_library_name in $regex_library pcre posix; do
524  case $regex_library_name in
525    pcre)
526      if test $have_regex_pcre = 1; then
527        need_regex_pcre=1
528        AC_DEFINE(RASQAL_REGEX_PCRE, 1, [Use PCRE regex library])
529        break
530      fi
531      ;;
532
533    posix)
534      if test $have_regex_posix = 1; then
535        need_regex_posix=1
536        AC_DEFINE(RASQAL_REGEX_POSIX, 1, [Use POSIX regex library])
537        break
538      fi
539      ;;
540
541    *)
542      AC_MSG_ERROR(No such regex library $regex_library_name)
543      ;;
544esac
545done
546
547
548
549AC_MSG_CHECKING(regex library to use)
550regex_library=
551if test $need_regex_pcre = 1; then
552  regex_library=pcre
553elif test $need_regex_posix = 1; then
554  regex_library=posix
555else
556  regex_library=none
557  AC_DEFINE(RASQAL_REGEX_NONE, 1, [Use no regex library])
558  AC_MSG_WARN(No regex library available - please install pcre or a POSIX regex library)
559fi
560AC_MSG_RESULT($regex_library)
561
562
563dnl Checks for message digest libraries
564have_digest_mhash=no
565have_digest_gcrypt=no
566dnl always available
567have_digest_internal=yes
568need_digest_mhash=no
569need_digest_gcrypt=no
570need_digest_internal=no
571
572AC_ARG_WITH(mhash,
573        [  --with-mhash=DIR  mhash installation prefix (no default)],
574	[mhash_dir=$withval], [mhash_dir=""])
575
576oCPPFLAGS="$CPPFLAGS"
577oLIBS="$LIBS"
578if test "X$mhash_dir" != "X" ; then
579  CPPFLAGS="$CPPFLAGS -I$mhash_dir/include"
580  LIBS="$LIBS -L$mhash_dir/lib"
581fi
582LIBS="$LIBS -lmhash"
583
584AC_CHECK_HEADERS(mhash.h)
585
586AC_MSG_CHECKING(for mhash)
587
588AC_LINK_IFELSE([AC_LANG_PROGRAM([[
589#undef PACKAGE
590#undef PACKAGE_BUGREPORT
591#undef PACKAGE_NAME
592#undef PACKAGE_STRING
593#undef PACKAGE_TARNAME
594#undef PACKAGE_VERSION
595#undef VERSION
596#include <mhash.h>]], [[ MHASH m; mhash_init(MHASH_MD5); ]])],[have_digest_mhash=yes],[have_digest_mhash=no])
597
598AC_MSG_RESULT($have_digest_mhash)
599
600CPPFLAGS="$oCPPFLAGS"
601LIBS="$oLIBS"
602
603
604AC_ARG_WITH(libgcrypt-config, [  --with-libgcrypt-config=PATH     Location of GCRYPT libgcrypt-config (auto)], libgcrypt_config="$withval", libgcrypt_config="")
605if test "X$libgcrypt_config" != "Xno" ; then
606  if test "X$libgcrypt_config" != "X" ; then
607    AC_MSG_CHECKING(for $libgcrypt_config)
608
609    if test -x $libgcrypt_config ; then
610	LIBGCRYPT_CONFIG=$libgcrypt_config
611	AC_MSG_RESULT(yes)
612    else
613	AC_MSG_ERROR([libgcrypt-config not found at specified path $libgcrypt_config])
614    fi
615  fi
616  if test "X$LIBGCRYPT_CONFIG" = "X" ; then
617    AC_CHECK_PROGS(LIBGCRYPT_CONFIG, libgcrypt-config)
618  fi
619fi
620
621AC_CHECK_HEADERS(gcrypt.h)
622
623AC_MSG_CHECKING(for gcrypt)
624GCRYPT_VERSION=`$LIBGCRYPT_CONFIG --version 2>/dev/null`
625if test "X$GCRYPT_VERSION" = X; then
626  have_digest_gcrypt=no
627elif test "$ac_cv_header_gcrypt_h" = "yes"; then
628  oCPPFLAGS="$CPPFLAGS"
629  oLIBS="$LIBS"
630  CPPFLAGS="$CPPFLAGS `$LIBGCRYPT_CONFIG --cflags`"
631  LIBS="$LIBS `$LIBGCRYPT_CONFIG --libs`"
632
633  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
634  #include <gcrypt.h>]], [[ gcry_md_hd_t hash; gcry_md_open(hash, GCRY_MD_MD5, 0); ]])],[have_digest_gcrypt=yes],[have_digest_gcrypt=no])
635
636  CPPFLAGS="$oCPPFLAGS"
637  LIBS="$oLIBS"
638else
639  have_digest_gcrypt=no
640fi
641AC_MSG_RESULT($have_digest_gcrypt)
642
643
644AC_ARG_WITH(digest-library, [  --with-digest-library=NAME   Use message digest library - mhash, gcrypt, internal (auto)], digest_library="$withval", digest_library="")
645
646for digest_library_name in $digest_library mhash gcrypt internal; do
647  case $digest_library_name in
648    mhash)
649      if test $have_digest_mhash = yes; then
650        need_digest_mhash=yes
651        AC_DEFINE(RASQAL_DIGEST_MHASH, 1, [Use mhash library for message digests])
652        break
653      fi
654      ;;
655
656    gcrypt)
657      if test $have_digest_gcrypt = yes; then
658        need_digest_gcrypt=yes
659        AC_DEFINE(RASQAL_DIGEST_GCRYPT, 1, [Use gcrypt library for message digests])
660        break
661      fi
662      ;;
663
664    internal)
665      need_digest_internal=yes
666      AC_DEFINE(RASQAL_DIGEST_INTERNAL, 1, [Use internal routines for message digests])
667      break
668      ;;
669
670    *)
671      AC_MSG_ERROR(No such message digest library $digest_library_name)
672      ;;
673esac
674done
675
676AC_MSG_CHECKING(message digest library to use)
677digest_library=
678if test $need_digest_mhash = yes; then
679  digest_library=mhash
680elif test $need_digest_gcrypt = yes; then
681  digest_library=gcrypt
682elif test $need_digest_internal = yes; then
683  digest_library=internal
684else
685  digest_library=none
686  AC_DEFINE(RASQAL_DIGEST_NONE, 1, [Use no message digest library])
687  AC_MSG_WARN(No message digest library selected - no message digest support will work)
688fi
689AC_MSG_RESULT($digest_library)
690
691AM_CONDITIONAL(RASQAL_DIGEST_INTERNAL, test $digest_library = internal)
692
693
694dnl Check for uuid libraries
695have_uuid_libuuid=no
696have_uuid_libc=no
697have_uuid_ossp=no
698need_uuid_libuuid=no
699need_uuid_libc=no
700need_uuid_internal=no
701need_uuid_ossp=no
702
703PKG_CHECK_MODULES(UUID, uuid, [
704  LIBUUID_VERSION=`$PKG_CONFIG uuid --modversion 2>/dev/null`
705
706  oCPPFLAGS="$CPPFLAGS"
707  oLIBS="$LIBS"
708
709  CPPFLAGS="$CPPFLAGS `$PKG_CONFIG uuid --cflags`"
710  LIBS="$LIBS `$PKG_CONFIG uuid --libs`"
711
712  dnl check for OSSP uuid defines and error out so we only get linux libuuid
713  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
714  #include <uuid.h>]], [[
715  #if defined(UUID_LEN_BIN) && defined(UUID_VERSION)
716  FAIL
717  #endif
718  uuid_t data; uuid_clear(&data); ]])],[have_uuid_libuuid=yes],[have_uuid_libuuid=no])
719
720  CPPFLAGS="$oCPPFLAGS"
721  LIBS="$oLIBS"
722], [have_uuid_libuuid=no])
723AC_MSG_CHECKING(for libuuid)
724AC_MSG_RESULT($have_uuid_libuuid)
725
726AC_CHECK_PROGS(UUID_CONFIG, uuid-config)
727AC_MSG_CHECKING(for ossp libuuid)
728if test "X$UUID_CONFIG" != X; then
729  OSSP_UUID_VERSION=`$UUID_CONFIG --version 2>/dev/null`
730
731  oCPPFLAGS="$CPPFLAGS"
732  oLIBS="$LIBS"
733
734  CPPFLAGS="$CPPFLAGS `$UUID_CONFIG --cflags`"
735  LIBS="$LIBS `$UUID_CONFIG --ldflags --libs`"
736
737  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
738  #include <uuid.h>]], [[ uuid_t *data; uuid_create(&data); ]])],[have_uuid_ossp=yes],[have_uuid_ossp=no])
739
740  CPPFLAGS="$oCPPFLAGS"
741  LIBS="$oLIBS"
742fi
743AC_MSG_RESULT($have_uuid_ossp)
744
745AC_CHECK_HEADERS(uuid/uuid.h)
746AC_MSG_CHECKING(for UUID in libc)
747if test "$ac_cv_header_uuid_uuid_h" = "yes"; then
748  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
749  #include <uuid/uuid.h>]], [[ uuid_t data; uuid_clear(&data); ]])],[have_uuid_libc=yes],[have_uuid_libc=no])
750fi
751AC_MSG_RESULT($have_uuid_libc)
752
753
754AC_ARG_WITH(uuid-library, [  --with-uuid-library=NAME   Use UUID library - libuuid, libc (auto)], uuid_library="$withval", uuid_library="")
755
756for uuid_library_name in $uuid_library libuuid ossp libc internal; do
757  case $uuid_library_name in
758    libuuid)
759      if test $have_uuid_libuuid = yes; then
760        need_uuid_libuuid=yes
761        AC_DEFINE(RASQAL_UUID_LIBUUID, 1, [Use libuuid library for UUID])
762        break
763      fi
764      ;;
765
766    ossp)
767      if test $have_uuid_ossp = yes; then
768        need_uuid_ossp=yes
769        AC_DEFINE(RASQAL_UUID_OSSP, 1, [Use OSSP library for UUID])
770        break
771      fi
772      ;;
773
774    libc)
775      if test $have_uuid_libc = yes; then
776        need_uuid_libc=yes
777        AC_DEFINE(RASQAL_UUID_LIBC, 1, [Use UUID in libc library for UUID])
778        break
779      fi
780      ;;
781
782    internal)
783      need_uuid_internal=yes
784      AC_DEFINE(RASQAL_UUID_INTERNAL, 1, [Use internal routines for UUID])
785      break
786      ;;
787
788    *)
789      AC_MSG_ERROR(No such UUID library $uuid_library_name)
790      ;;
791esac
792done
793
794AC_MSG_CHECKING(UUID library to use)
795uuid_library=
796if test $need_uuid_libuuid = yes; then
797  uuid_library="libuuid $LIBUUID_VERSION"
798elif test $need_uuid_ossp = yes; then
799  uuid_library="ossp $OSSP_UUID_VERSION"
800elif test $need_uuid_libc = yes; then
801  uuid_library=libc
802elif test $need_uuid_internal = yes; then
803  uuid_library=internal
804else
805  uuid_library=none
806  AC_DEFINE(RASQAL_UUID_NONE, 1, [Use no UUID library])
807  AC_MSG_WARN(No UUID library selected - no UUID support will work)
808fi
809AC_MSG_RESULT($uuid_library)
810
811
812
813have_libxml=0
814need_libxml=0
815
816AC_ARG_ENABLE(xml2,
817	[  --disable-xml2                  Disable XML2 support (default auto)],
818	[enable_xml2=$enableval], [enable_xml2="auto"])
819
820if test "x$enable_xml2" != "xno" ; then
821
822  AC_ARG_WITH(xml2-config, [  --with-xml2-config=PATH     Location of libxml xml2-config ()], xml2_config="$withval", xml2_config="")
823
824  if test "X$xml2_config" != "X" ; then
825    AC_MSG_CHECKING(for $xml2_config)
826
827    if test -x $xml2_config ; then
828      XML_CONFIG=$xml2_config
829      AC_MSG_RESULT(yes)
830    else
831      AC_MSG_ERROR([xml2-config not found at specified path $xml2_config])
832    fi
833  fi
834  if test "X$XML_CONFIG" = "X"; then
835    AC_CHECK_PROGS(XML_CONFIG, xml2-config)
836  fi
837
838
839  LIBXML_MIN_VERSION=2.6.8
840  AC_MSG_CHECKING(for libxml2 library)
841  oCPPFLAGS="$CPPFLAGS"
842  oLIBS="$LIBS"
843  if test "X$XML_CONFIG" != X; then
844    LIBS="$LIBS `$XML_CONFIG --libs`"
845    CPPFLAGS="`$XML_CONFIG --cflags` $CPPFLAGS"
846    LIBXML_VERSION=`$XML_CONFIG --version`
847    libxml_version_dec=`echo $LIBXML_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
848    LIBXML_MIN_VERSION_dec=`echo $LIBXML_MIN_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
849    AC_MSG_RESULT(yes - version $LIBXML_VERSION)
850    if test $libxml_version_dec -lt $LIBXML_MIN_VERSION_dec; then
851       AC_MSG_WARN(Using libxml $LIBXML_VERSION is unsupported - $LIBXML_MIN_VERSION or newer required.)
852    else
853      AC_CHECK_HEADERS(libxml/xmlschemas.h libxml/xmlschemastypes.h libxml/schemasInternals.h)
854      if test "$ac_cv_header_libxml_xmlschemas_h" = no; then
855        AC_MSG_WARN(libxml library found but not xml schema headers - disabling)
856      else
857        have_libxml=1
858      fi
859    fi
860  else
861    AC_MSG_RESULT(no)
862  fi
863  CPPFLAGS="$oCPPFLAGS"
864  LIBS="$oLIBS"
865
866  if test $have_libxml = 0 && test "x$enable_xml2" = "xyes" ; then
867    AC_MSG_ERROR(libxml2 requested but not found)
868  fi
869
870fi
871
872
873dnl RDF Query Languages
874sparql_query_language=no
875laqrs_query_language=no
876
877rdf_query_languages_available="sparql laqrs"
878rdf_query_languages_enabled=
879
880
881# This is needed because autoheader can't work out which computed
882# symbols must be pulled from acconfig.h into config.h.in
883if test "x" = "y"; then
884  AC_DEFINE(RASQAL_QUERY_LAQRS, 1, [Building LAQRS query])
885  AC_DEFINE(RASQAL_QUERY_SPARQL, 1, [Building SPARQL query])
886fi
887
888AC_MSG_CHECKING(query languages required)
889AC_ARG_ENABLE(query-languages, [  --enable-query-languages=LIST   Enable query languages (default=all)], query_languages="$enableval")
890if test "X$query_languages" = Xall -o "X$query_languages" = X; then
891  query_languages="$rdf_query_languages_available"
892  AC_MSG_RESULT(all)
893else
894  AC_MSG_RESULT($query_languages)
895fi
896
897for query_language in $query_languages; do
898  p=$query_language
899  eval $p'_query_language=yes'
900  NAME=`echo $p | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
901  n=RASQAL_QUERY_${NAME}
902  AC_DEFINE_UNQUOTED($n)
903  rdf_query_languages_enabled="$rdf_query_languages_enabled $query_language"
904done
905
906AM_CONDITIONAL(RASQAL_QUERY_LAQRS, test $laqrs_query_language = yes)
907AM_CONDITIONAL(RASQAL_QUERY_SPARQL, test $sparql_query_language = yes)
908
909
910
911RASQAL_INTERNAL_CPPFLAGS="$RASQAL_INTERNAL_CPPFLAGS $RAPTOR2_CFLAGS"
912RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS $RAPTOR2_LIBS"
913
914
915if test $need_regex_pcre = 1; then
916  C=`$PCRE_CONFIG --cflags`
917  L=`$PCRE_CONFIG --libs`
918  RASQAL_INTERNAL_CPPFLAGS="$RASQAL_INTERNAL_CPPFLAGS $C"
919  RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS $L"
920
921  PKGCONFIG_CFLAGS="$PKGCONFIG_CFLAGS $C"
922  PKGCONFIG_LIBS="$PKGCONFIG_LIBS $L"
923  unset C
924  unset L
925fi
926
927
928if test $need_digest_mhash = yes; then
929  C=""
930  L="-lmhash"
931  if test "X$mhash_dir" != "X" ; then
932    C="-I$mhash_dir/include"
933    L="-L$mhash_dir/lib $L"
934  fi
935
936  RASQAL_INTERNAL_CPPFLAGS="$RASQAL_INTERNAL_CPPFLAGS $C"
937  RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS $L"
938
939  unset C
940  unset L
941fi
942
943
944if test $need_digest_gcrypt = yes; then
945  C=`$LIBGCRYPT_CONFIG --cflags`
946  L=`$LIBGCRYPT_CONFIG --libs`
947  RASQAL_INTERNAL_CPPFLAGS="$RASQAL_INTERNAL_CPPFLAGS $C"
948  RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS $L"
949
950  unset C
951  unset L
952fi
953
954
955if test $need_uuid_libuuid = yes; then
956  RASQAL_INTERNAL_CPPFLAGS="$RASQAL_INTERNAL_CPPFLAGS $UUID_CFLAGS"
957  RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS $UUID_LIBS"
958
959  PKGCONFIG_CFLAGS="$PKGCONFIG_CFLAGS $UUID_CFLAGS"
960  PKGCONFIG_LIBS="$PKGCONFIG_LIBS $UUID_LIBS"
961fi
962
963
964if test $need_uuid_ossp = yes; then
965  C=`$UUID_CONFIG --cflags`
966  L=`$UUID_CONFIG --ldflags --libs`
967  RASQAL_INTERNAL_CPPFLAGS="$RASQAL_INTERNAL_CPPFLAGS $C"
968  RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS $L"
969
970  unset C
971  unset L
972fi
973
974
975gmp_lib_dir=
976gmp_include_dir=
977AC_ARG_WITH(gmp, [  --with-gmp=DIR          GMP install area], gmp_prefix="$withval", gmp_prefix="none")
978if test "X$gmp_prefix" != "Xnone" ; then
979  gmp_libs="-L$gmp_prefix/lib"
980  gmp_includes="-I$gmp_prefix/include"
981fi
982
983mpfr_lib_dir=
984mpfr_include_dir=
985AC_ARG_WITH(mpfr, [  --with-mpfr=DIR          MPFR install area], mpfr_prefix="$withval", mpfr_prefix="none")
986if test "X$mpfr_prefix" != "Xnone" ; then
987  mpfr_libs="-L$mpfr_prefix/lib"
988  mpfr_includes="-I$mpfr_prefix/include"
989fi
990
991oCPPFLAGS="$CPPFLAGS"
992CPPFLAGS="$CPPFLAGS $gmp_includes"
993AC_CHECK_HEADERS(gmp.h)
994CPPFLAGS="$oCPPFLAGS"
995
996CPPFLAGS="$CPPFLAGS $mpfr_includes"
997AC_CHECK_HEADERS([mpfr.h], [], [], [
998#ifdef HAVE_GMP_H
999#include <gmp.h>
1000#endif
1001])
1002CPPFLAGS="$oCPPFLAGS"
1003
1004
1005have_mpfr=0
1006have_gmp=0
1007
1008oCPPFLAGS="$CPPFLAGS"
1009oLIBS="$LIBS"
1010if test "$ac_cv_header_mpfr_h" = yes; then
1011  CPPFLAGS="$CPPFLAGS $mpfr_includes"
1012  LIBS="$LIBS $mpfr_libs -lmpfr"
1013  AC_CHECK_FUNC(mpfr_init, have_mpfr_init=yes, have_mpfr_init=no)
1014  # Several functions are used that are not in GMP version of MPFR:
1015  #   mpfr_get_default_rounding_mode mpfr_equal_p mpfr_free_str
1016  #     MPFR 2.1.0 released 3 Nov 2004 http://www.mpfr.org/mpfr-2.1.0/
1017  #   mpfr_snprintf
1018  #     MPFR 2.4.0 released 26 January 2009 http://www.mpfr.org/mpfr-2.4.0/
1019  # so just test for the latter.
1020  AC_CHECK_FUNC(mpfr_snprintf, have_mpfr_snprintf=yes, have_mpfr_snprintf=no)
1021  LIBS="$oLIBS"
1022  CPPFLAGS="$oCPPFLAGS"
1023  AC_MSG_CHECKING(for working MPFR library)
1024  if test $have_mpfr_init = yes -a $have_mpfr_snprintf = yes; then
1025    have_mpfr=1
1026    AC_MSG_RESULT(yes)
1027  else
1028    AC_MSG_RESULT(no)
1029  fi
1030fi
1031CPPFLAGS="$oCPPFLAGS"
1032LIBS="$oLIBS"
1033
1034have_gmp_version=0
1035have_gmp_random=no
1036if test "$ac_cv_header_gmp_h" = yes; then
1037  CPPFLAGS="$CPPFLAGS $gmp_includes"
1038  LIBS="$LIBS $gmp_libs -lgmp"
1039  AC_MSG_CHECKING(for working GNU MP library)
1040  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[mpz_t n; mpz_init(n);]])],[have_gmp=1
1041	      AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
1042  AC_MSG_CHECKING(for GNU MP library random support)
1043  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[
1044gmp_randstate_t r;
1045unsigned int ui = 12345;
1046mpz_t iresult;
1047mpz_t n;
1048mpf_t fresult;
1049
1050gmp_randinit_default(r);
1051
1052gmp_randseed_ui(r, ui);
1053mpz_init(iresult);
1054mpz_init_set_ui(n, 12345);
1055mpz_urandomm(iresult, r, n);
1056mpz_clear(iresult);
1057
1058mpf_urandomb(fresult, r, 5);
1059mpf_clear(fresult);
1060mpz_clear(n);
1061
1062gmp_randclear(r);
1063]])],[have_gmp_random=yes
1064	      AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
1065  AC_MSG_CHECKING(for gmp_version)
1066  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[const char* v=gmp_version; ]])],[have_gmp_version=1
1067	      AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
1068fi
1069CPPFLAGS="$oCPPFLAGS"
1070LIBS="$oLIBS"
1071
1072if test $have_gmp_version = 1; then
1073  AC_DEFINE(HAVE_GMP_VERSION, 1, [Have gmp_version constant])
1074fi
1075
1076need_mpfr=0
1077need_gmp=0
1078
1079AC_ARG_WITH(decimal, [  --with-decimal=NAME           Use decimal library - mpfr (default), gmp, none], decimal="$withval", decimal="mpfr")
1080for decimal_name in $decimal mpfr gmp none; do
1081  case $decimal_name in
1082    mpfr)
1083      if test $have_mpfr = 1; then
1084        need_mpfr=1
1085        AC_DEFINE([RASQAL_DECIMAL_MPFR], 1, [Decimal from MPFR library])
1086        break
1087      fi
1088      ;;
1089
1090    gmp)
1091      if test $have_gmp = 1; then
1092        need_gmp=1
1093	AC_DEFINE([RASQAL_DECIMAL_GMP], 1, [Decimal from GNU MP library])
1094        break
1095      fi
1096      ;;
1097
1098    none)
1099      need_mpfr=0
1100      need_gmp=0
1101      AC_DEFINE([RASQAL_DECIMAL_NONE], 1, [Decimal without a library])
1102      break
1103      ;;
1104
1105    *)
1106      AC_MSG_ERROR(No such decimal library $decimal_name)
1107      ;;
1108esac
1109done
1110
1111
1112AC_MSG_CHECKING(decimal libraries available)
1113decimal_libraries_available=
1114if test $have_mpfr = 1; then
1115  decimal_libraries_available="$decimal_libraries_available mpfr"
1116fi
1117if test $have_gmp = 1; then
1118  decimal_libraries_available="$decimal_libraries_available gmp"
1119fi
1120AC_MSG_RESULT($decimal_libraries_available)
1121
1122
1123need_libm=0
1124AC_MSG_CHECKING(decimal library to use)
1125decimal_library=
1126if test $need_mpfr = 1; then
1127  decimal_library="mpfr $MPFR_VERSION"
1128elif test $need_gmp = 1; then
1129  decimal_library="gmp $GMP_VERSION"
1130else
1131  decimal_library=none
1132fi
1133AC_MSG_RESULT($decimal_library)
1134
1135
1136
1137dnl Random generator
1138random_approaches="mtwist"
1139if test "$have_gmp_random" = yes; then
1140  random_approaches="$random_approaches gmp"
1141fi
1142random_approaches="$random_approaches random_r rand_r random rand"
1143
1144AC_ARG_WITH(random-approach, [  --with-random-approach=NAME   Use random approach - mtwist, random_r, rand_r, random, rand (auto)], random_with="$withval", random_with="")
1145
1146AC_MSG_CHECKING(random approach)
1147random_approach=none
1148need_mtwist=no
1149for random_algo in $random_with $random_approaches; do
1150  case $random_algo in
1151    mtwist)
1152      random_approach="Internal Mersenne Twister"
1153      need_mtwist=yes
1154      AC_DEFINE(RANDOM_ALGO_MTWIST, 1, [Use internal Mersenne Twister])
1155      break
1156      ;;
1157
1158    gmp)
1159      if test "$have_gmp_random" = yes; then
1160        random_approach="GMP gmp_randseed_ui and mpz_urandomm()"
1161	AC_DEFINE(RANDOM_ALGO_GMP_RAND, 1, [Use GMP gmp_randseed_ui() and mpz_urandomm()])
1162        break
1163      fi
1164      ;;
1165
1166    random_r)
1167      if test "$ac_cv_func_initstate_r" = "yes" -a "$ac_cv_func_random_r" = "yes"; then
1168        random_approach="glibc initstate_r() and random_r()"
1169	AC_DEFINE(RANDOM_ALGO_RANDOM_R, 1, [Use glibc initstate_r() and random_r()])
1170        break
1171      fi
1172      ;;
1173
1174    rand_r)
1175      if test "$ac_cv_func_rand_r" = "yes"; then
1176        random_approach="POSIX rand_r()"
1177	AC_DEFINE(RANDOM_ALGO_RAND_R, 1, [Use POSIX rand_r()])
1178        break
1179      fi
1180      ;;
1181
1182    random)
1183      if test "$ac_cv_func_initstate" = "yes" -a "$ac_cv_func_random" = "yes"; then
1184	 random_approach="BSD initstate() and random()"
1185         AC_DEFINE(RANDOM_ALGO_RANDOM, 1, [Use BSD initstate() and random()])
1186        break
1187      fi
1188      ;;
1189
1190    rand)
1191      if test "$ac_cv_func_srand" = "yes" -a "$ac_cv_func_rand" = "yes"; then
1192          random_approach="POSIX srand() and rand()"
1193          AC_DEFINE(RANDOM_ALGO_RAND, 1, [Use POSIX srand() and rand()])
1194          break
1195      fi
1196      ;;
1197
1198    *)
1199      ;;
1200esac
1201done
1202
1203if test "$random_approach" = none; then
1204    AC_MSG_ERROR(No random number generator approach. POSIX rand should always be available)
1205fi
1206AC_MSG_RESULT($random_approach)
1207
1208AM_CONDITIONAL(RASQAL_MTWIST, test $need_mtwist = yes)
1209
1210
1211
1212
1213dnl Always need ceil, floor and round in rasqal_literal_ceil() etc.
1214AC_MSG_CHECKING([for ceil, floor and round in default libs])
1215ceil_lib=none
1216AC_RUN_IFELSE([AC_LANG_PROGRAM([[
1217#ifdef HAVE_MATH_H
1218#include <math.h>
1219#endif
1220#ifdef HAVE_STDLIB_H
1221#include <stdlib.h>
1222#endif
1223]], [[
1224extern char **environ;
1225double t = strtod(environ[0], NULL);
1226return (int)(ceil(t) * floor(t) * round(t));
1227]])],
1228   AC_MSG_RESULT(yes)
1229   ceil_lib=libc,
1230   AC_MSG_RESULT(no),
1231   ceil_lib=cross)
1232if test $ceil_lib = none; then
1233  LIBS="$LIBS -lm"
1234  AC_MSG_CHECKING([for ceil, floor and round with -lm])
1235  AC_RUN_IFELSE([AC_LANG_PROGRAM([[
1236#ifdef HAVE_MATH_H
1237#include <math.h>
1238#endif
1239#ifdef HAVE_STDLIB_H
1240#include <stdlib.h>
1241#endif
1242]], [[
1243extern char **environ;
1244double t = strtod(environ[0], NULL);
1245return (int)(ceil(t) * floor(t) * round(t));
1246]])],
1247     AC_MSG_RESULT(yes)
1248     need_libm=1
1249     ceil_lib=libm,
1250     AC_MSG_RESULT(no),
1251     ceil_lib=cross)
1252  LIBS="$oLIBS"
1253fi
1254if test $ceil_lib = cross; then
1255  AC_MSG_WARN([Assuming ceil, floor and round are in default libs for cross compiling])
1256  ceil_lib=libc
1257elif test $ceil_lib = none; then
1258  AC_MSG_ERROR([Could not find ceil, floor, round in default libs or with -lm])
1259fi
1260if test $need_libm = 1; then
1261  RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS -lm"
1262fi
1263
1264
1265DECIMAL_INCLUDES=
1266DECIMAL_LIBS=
1267if test $need_mpfr = 1; then
1268  DECIMAL_INCLUDES="$mpfr_includes"
1269  DECIMAL_LIBS="$mpfr_libs -lmpfr"
1270fi
1271if test $need_gmp = 1; then
1272  DECIMAL_INCLUDES="$gmp_includes"
1273  DECIMAL_LIBS="$gmp_libs -lgmp"
1274fi
1275RASQAL_INTERNAL_CPPFLAGS="$RASQAL_INTERNAL_CPPFLAGS $DECIMAL_INCLUDES"
1276RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS $DECIMAL_LIBS"
1277
1278
1279if test $need_libxml = 1; then
1280  RASQAL_INTERNAL_CPPFLAGS="$RASQAL_INTERNAL_CPPFLAGS `$XML_CONFIG --cflags`"
1281  RASQAL_EXTERNAL_LIBS="$RASQAL_EXTERNAL_LIBS `$XML_CONFIG --libs`"
1282  if test "X$PKGCONFIG_REQUIRES" != X; then
1283    PKGCONFIG_REQUIRES="$PKGCONFIG_REQUIRES,"
1284  fi
1285  PKGCONFIG_REQUIRES="$PKGCONFIG_REQUIRES libxml-2.0 >= $LIBXML_MIN_VERSION"
1286fi
1287
1288
1289# Make final changes to cflags
1290MEM=
1291MEM_LIBS=
1292CPPFLAGS="-DRASQAL_INTERNAL=1 $CPPFLAGS"
1293
1294debug_messages=no
1295
1296AC_ARG_ENABLE(debug, [  --enable-debug          Enable debug messages (default no).  ], debug_messages=$enableval)
1297if test "$debug_messages" = "yes"; then
1298  CPPFLAGS="-g -DRASQAL_DEBUG=1 $CPPFLAGS"
1299fi
1300
1301AC_ARG_WITH(memory-signing, [  --with-memory-signing       Sign allocated memory (default=no)], use_memory_signing="$withval", use_memory_signing="no")
1302AC_MSG_CHECKING(using memory signing)
1303AC_MSG_RESULT($use_memory_signing);
1304if test $use_memory_signing = yes; then
1305  MEM=-DRASQAL_MEMORY_SIGN=1
1306  MEM_LIBS=
1307fi
1308
1309STANDARD_CFLAGS="$STANDARD_CFLAGS $CFLAGS"
1310if test "$USE_MAINTAINER_MODE" = yes; then
1311  CPPFLAGS="-DMAINTAINER_MODE $MAINTAINER_CPPFLAGS $CPPFLAGS"
1312fi
1313
1314AC_SUBST(RASQAL_EXTERNAL_LIBS)
1315
1316AC_SUBST(RASQAL_INTERNAL_CPPFLAGS)
1317AC_SUBST(RASQAL_INTERNAL_LIBS)
1318
1319AC_SUBST(MEM)
1320AC_SUBST(MEM_LIBS)
1321AC_SUBST(STANDARD_CFLAGS)
1322
1323AC_SUBST(RECHO)
1324AC_SUBST(RECHO_N)
1325AC_SUBST(RECHO_C)
1326
1327RASQAL_LIBTOOLLIBS=librasqal.la
1328AC_SUBST(RASQAL_LIBTOOLLIBS)
1329
1330AC_SUBST(PKGCONFIG_REQUIRES)
1331AC_SUBST(PKGCONFIG_LIBS)
1332AC_SUBST(PKGCONFIG_CFLAGS)
1333
1334abs_top_srcdir=`cd $srcdir; pwd`
1335AC_SUBST(abs_top_srcdir)
1336abs_top_builddir=`pwd`
1337AC_SUBST(abs_top_builddir)
1338
1339dnl automake 1.11
1340AM_SILENT_RULES([no])
1341
1342AC_CONFIG_FILES([Makefile
1343data/Makefile
1344docs/Makefile
1345docs/version.xml
1346scripts/Makefile
1347libsv/Makefile
1348libmtwist/Makefile
1349getopt/Makefile
1350src/Makefile
1351src/rasqal.h
1352src/win32_rasqal_config.h
1353tests/Makefile
1354tests/algebra/Makefile
1355tests/engine/Makefile
1356tests/laqrs/Makefile
1357tests/laqrs/syntax/Makefile
1358tests/sparql/Makefile
1359tests/sparql/bugs/Makefile
1360tests/sparql/simple/Makefile
1361tests/sparql/part1/Makefile
1362tests/sparql/examples/Makefile
1363tests/sparql/syntax/Makefile
1364tests/sparql/bound/Makefile
1365tests/sparql/survey/Makefile
1366tests/sparql/SyntaxFull/Makefile
1367tests/sparql/sort/Makefile
1368tests/sparql/ValueTesting/Makefile
1369tests/sparql/regex/Makefile
1370tests/sparql/Expr1/Makefile
1371tests/sparql/Expr2/Makefile
1372tests/sparql/ExprBuiltins/Makefile
1373tests/sparql/ExprEquals/Makefile
1374tests/sparql/SyntaxDev/Makefile
1375tests/sparql/SyntaxDev/Syntax-SPARQL/Makefile
1376tests/sparql/SyntaxDev/Syntax-SPARQL2/Makefile
1377tests/sparql/SyntaxDev/Syntax-SPARQL3/Makefile
1378tests/sparql/update/Makefile
1379tests/sparql/aggregate/Makefile
1380tests/sparql/sparql11/Makefile
1381tests/sparql/federated/Makefile
1382tests/sparql/warnings/Makefile
1383utils/Makefile
1384win32/Makefile
1385rasqal.spec
1386rasqal.rdf
1387rasqal.pc])
1388AC_CONFIG_FILES([src/rasqal-config], [chmod +x src/rasqal-config])
1389AC_CONFIG_FILES([rasqal-src-config], [chmod +x rasqal-src-config])
1390
1391dnl Check for gtk-doc and docbook
1392GTK_DOC_CHECK([1.3])
1393
1394AC_OUTPUT
1395
1396AC_MSG_RESULT([
1397Rasqal build summary:
1398  RDF query languages available : $rdf_query_languages_available
1399  RDF query languages enabled   :$rdf_query_languages_enabled
1400  Raptor version                : $RAPTOR_VERSION
1401  Decimal library               : $decimal_library
1402  Regex library                 : $regex_library
1403  Message digest library        : $digest_library
1404  UUID library                  : $uuid_library
1405  Random approach               : $random_approach
1406  ceil, floor, round source     : $ceil_lib
1407])
1408