1m4_define(major, 5)
2m4_define(minor, 2)
3m4_define(micro, 10)
4m4_define([gda_stable],
5	m4_if(m4_eval(minor % 2), [0], [yes], [no]))
6AC_CONFIG_MACRO_DIR([m4])
7m4_include(m4/vapigen.m4)
8m4_include(m4/dk-warn.m4)
9m4_include(m4/mdbtools.m4)
10m4_include(m4/bdb.m4)
11m4_include(m4/mysql.m4)
12m4_include(m4/postgresql.m4)
13m4_include(m4/firebird.m4)
14m4_include(m4/oracle.m4)
15m4_include(m4/java.m4)
16m4_include(m4/ldap.m4)
17
18AC_INIT([GNU Data Access],[major.minor.micro],[https://bugzilla.gnome.org/enter_bug.cgi?product=libgda],[libgda],[http://www.gnome-db.org])
19AC_PREREQ([2.68])
20AC_CONFIG_SRCDIR(libgda/libgda.h.in)
21AM_PROG_AR
22AM_INIT_AUTOMAKE([1.11.1 -Wall no-define no-dist-gzip dist-xz])
23
24m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
25
26dnl http://people.gnome.org/~walters/docs/build-api.txt
27echo \#buildapi-variable-no-builddir >/dev/null
28
29AC_SUBST(GDA_VERSION, major.minor.micro)
30
31# ABI version:
32# Careful. Changing these will break ABI, because it is used for the library name and header install path:
33# This allows us to do a 3.2 version that is ABI-compatible with 3.0, but with API additions.
34AC_SUBST(GDA_ABI_MAJOR_VERSION, 5)
35AC_SUBST(GDA_ABI_MINOR_VERSION, 0)
36#AC_SUBST(GDA_MICRO_VERSION, micro)
37LIBGDA_ABI_VERSION=$GDA_ABI_MAJOR_VERSION.$GDA_ABI_MINOR_VERSION
38AC_SUBST(GDA_ABI_VERSION, $LIBGDA_ABI_VERSION)
39LIBGDA_ABI_NAME="\\\"libgda-$LIBGDA_ABI_VERSION\\\""
40
41gdasysconfdir="$sysconfdir"
42AC_SUBST(gdasysconfdir)
43
44m4_undefine([major])
45m4_undefine([minor])
46m4_undefine([micro])
47
48dnl required versions of other tools.
49m4_define([req_ver_glib],[2.32.0])
50
51#
52# Making releases:
53# - If interfaces have been changed or added, set GDA_CURRENT += 1 and GDA_AGE += 1, set GDA_REVISION to 0.
54# - If binary compatibility has been broken (e.g. removed or changed interfaces), set GDA_CURRENT += 1, GDA_REVISION and GDA_AGE to 0
55# - If interfaces is the same as the previous version, set GDA_REVISION += 1
56#
57GDA_CURRENT=5
58GDA_REVISION=1
59GDA_AGE=1
60
61AC_SUBST(GDA_CURRENT)
62AC_SUBST(GDA_REVISION)
63AC_SUBST(GDA_AGE)
64
65IT_PROG_INTLTOOL([0.40.6])
66AC_SUBST(INTLTOOL_XML_RULE)
67AC_CHECK_SIZEOF(unsigned int,0)
68AC_CHECK_SIZEOF(unsigned long int,0)
69AC_CHECK_SIZEOF([int *],0)
70AC_CHECK_TYPE(uint8_t, unsigned char)
71AC_CHECK_FUNCS(localtime_r localtime_s)
72AC_CHECK_HEADER(sys/mman.h,
73    AC_CHECK_FUNC(mlock, [AC_DEFINE(USE_MLOCK, 1, [Use POSIX memory locking])]))
74
75dnl **********************
76dnl Cross compilation test
77dnl **********************
78AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
79AC_MSG_CHECKING([for a C compiler for build tools])
80if test $cross_compiling = yes; then
81  AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
82  CC_FOR_BUILD="CPATH=\"\" $CC_FOR_BUILD"
83else
84  CC_FOR_BUILD=$CC
85fi
86AC_MSG_RESULT([$CC_FOR_BUILD])
87AC_SUBST(CC_FOR_BUILD)
88
89AC_MSG_CHECKING([for suffix of executable build tools])
90if test $cross_compiling = yes; then
91  cat >conftest.c <<\_______EOF
92int
93main ()
94{
95  exit (0);
96}
97_______EOF
98  for i in .exe ""; do
99    compile="$CC_FOR_BUILD conftest.c -o conftest$i"
100    if AC_TRY_EVAL(compile); then
101      if (./conftest) 2>&AS_MESSAGE_LOG_FD; then
102	EXEEXT_FOR_BUILD=$i
103	break
104      fi
105    fi
106  done
107  rm -f conftest*
108  if test "${EXEEXT_FOR_BUILD+set}" != set; then
109    EXEEXT_FOR_BUILD=
110  fi
111else
112  EXEEXT_FOR_BUILD=$EXEEXT
113fi
114AC_MSG_RESULT([$EXEEXT_FOR_BUILD])
115AC_SUBST(EXEEXT_FOR_BUILD)
116
117dnl ******************************
118dnl Checks for programs
119dnl ******************************
120AC_SEARCH_LIBS([strerror],[cposix])
121AC_PROG_CC
122AC_PROG_CXX
123AM_PROG_CC_C_O
124AC_HEADER_STDC
125LT_PREREQ([2.2.6])
126LT_INIT([disable-static])
127AC_PROG_MAKE_SET
128
129dnl -- Initialize help system
130AC_ARG_WITH(help,
131AS_HELP_STRING([--with-help], [Enable building help (GdaBrowser)]),
132	[with_gdu=$withval]
133	,with_gdu=yes)
134if test x$with_gdu != xno; then
135   YELP_HELP_INIT
136   AC_DEFINE(HAVE_GDU, [1], [Help (GdaBrowser documentation) is built])
137fi
138AM_CONDITIONAL(HAVE_GDU, test x$with_gdu != xno)
139
140dnl ******************************
141dnl glib utilities
142dnl ******************************
143AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
144AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
145
146dnl ******************************
147dnl Translations
148dnl ******************************
149GETTEXT_PACKAGE=libgda-$LIBGDA_ABI_VERSION
150AC_SUBST(GETTEXT_PACKAGE)
151AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE")
152AM_GLIB_GNU_GETTEXT
153
154
155dnl ******************************
156dnl Check for pkg-config version; want >= 0.18 because we need PKG_CHECK_EXISTS
157dnl ******************************
158PKG_PROG_PKG_CONFIG([0.18])
159
160dnl ******************************
161dnl Checks for required libraries
162dnl ******************************
163
164PKG_CHECK_MODULES(COREDEPS, [
165	glib-2.0	>= req_ver_glib
166	gobject-2.0	>= req_ver_glib
167	gthread-2.0	>= req_ver_glib
168	gmodule-no-export-2.0	>= req_ver_glib
169	libxml-2.0
170])
171TST_CFLAGS="$COREDEPS_CFLAGS"
172COREDEPS_CFLAGS="$COREDEPS_CFLAGS -DLIBGDA_ABI_NAME=$LIBGDA_ABI_NAME"
173
174
175dnl ******************************
176dnl Checks for UI extension
177dnl ******************************
178have_ui=no
179have_goocanvas=no
180have_graphviz=no
181have_sourceview=no
182have_glade=no
183AC_ARG_WITH(ui,
184	AS_HELP_STRING([--with-ui], [Enable GTK+ extension and tools]),
185	[
186		with_ui=$withval
187	],
188	[
189		with_ui=auto
190	])
191
192if test x"$with_ui" = xauto -o x"$with_ui" = xyes
193then
194	GTK_MODULES="gtk+-3.0 >= 3.0.0"
195	PKG_CHECK_MODULES(GTK, $GTK_MODULES, [
196		AC_DEFINE(HAVE_UI, [1], [GTK+ support enabled])
197		have_ui=yes], [
198		if test "$with_ui" = "yes"
199		then
200			AC_MSG_ERROR([GTK+ support requested but not found.])
201		fi
202		have_ui=no])
203fi
204AM_CONDITIONAL(HAVE_UI, test x"$have_ui" = "xyes")
205AC_SUBST(GTK_CFLAGS)
206AC_SUBST(GTK_LIBS)
207
208AC_ARG_WITH(gtksourceview,
209AS_HELP_STRING([--with-gtksourceview], [Enable using GtkSourceView]),
210	[with_sourceview=$withval]
211	,with_sourceview=auto)
212
213AC_ARG_WITH(goocanvas,
214AS_HELP_STRING([--with-goocanvas], [Enable using GooCanvas]),
215	[with_goo=$withval]
216	,with_goo=auto)
217
218AC_ARG_WITH(graphviz,
219AS_HELP_STRING([--with-graphviz], [Enable using Graphviz]),
220	[with_graphviz=$withval]
221	,with_graphviz=auto)
222
223if test x"$have_ui" = "xyes"
224then
225	PKG_CHECK_MODULES(GDKPIXBUF, "gdk-pixbuf-2.0", [
226			AC_DEFINE(HAVE_GDKPIXBUF, [1], [Gdkpixbuf support enabled])
227			have_gdkpixbuf=yes], [have_gdkpixbuf=no])
228
229	if test "$with_sourceview" = "auto" -o "$with_sourceview" = "yes"
230	then
231		PKG_CHECK_MODULES(GTKSOURCEVIEW, "gtksourceview-3.0", [
232			AC_DEFINE(HAVE_GTKSOURCEVIEW, [1], [GtkSourceView support enabled])
233			have_sourceview=yes], [
234			if test "$with_sourceview" = "yes"
235			then
236				AC_MSG_ERROR([GtkSourceview support requested but not found.])
237			fi
238			have_sourceview=no])
239	fi
240
241	if test "$with_goo" = "auto" -o "$with_goo" = "yes"
242	then
243		PKG_CHECK_MODULES(GOOCANVAS, "goocanvas-2.0", [
244			AC_DEFINE(HAVE_GOOCANVAS, [1], [GooCanvas support enabled])
245			have_goocanvas=yes], [
246			if test "$with_goo" = "yes"
247			then
248				AC_MSG_ERROR([GooCanvas support requested but not found.])
249			fi
250			have_goocanvas=no])
251	fi
252
253	if test "$with_graphviz" = "auto" -o "$with_graphviz" = "yes"
254	then
255		PKG_CHECK_MODULES(GRAPHVIZ, "libgvc", [
256			AC_DEFINE(HAVE_GRAPHVIZ, [1], [Graphviz support enabled])
257			have_graphviz=yes], [
258			if test "$with_graphviz" = "yes"
259			then
260				AC_MSG_ERROR([Graphviz support requested but not found.])
261			fi
262			have_graphviz=no])
263		if test "x$have_graphviz" = "xyes"
264		then
265			dnl test if new API is supported
266			AC_MSG_CHECKING([whether Graphviz's new API is supported])
267			graphviz_save_CFLAGS=$CFLAGS
268			CFLAGS="$CFLAGS $GRAPHVIZ_CFLAGS"
269			AC_COMPILE_IFELSE([AC_LANG_SOURCE([
270#include <gvc.h>
271int main() {
272    Agraph_t *graph;
273    graph = agopen ("BrowserCanvasLayout", Agdirected, NULL);
274    return 0;
275}
276])],
277                        graphviz_new_api=yes, graphviz_new_api=no)
278			CLFAGS=$graphviz_save_CFLAGS
279
280			AC_MSG_RESULT($graphviz_new_api)
281			if test "$graphviz_new_api" = "yes"; then
282			   	AC_DEFINE(GRAPHVIZ_NEW_API,[1],[define if Graphviz's new API is available])
283			fi
284		fi
285	fi
286
287	PKG_CHECK_MODULES(GLADE, "gladeui-2.0", [
288			AC_DEFINE(HAVE_GLADE, [1], [Install Glade Catalog])
289			have_glade=yes
290			GLADE_CATALOG=`$PKG_CONFIG --variable=catalogdir gladeui-2.0`
291			GLADE_PIXMAP=`$PKG_CONFIG --variable=pixmapdir gladeui-2.0`], [have_glade=no])
292fi
293
294AM_CONDITIONAL(HAVE_GDKPIXBUF, test x"$have_gdkpixbuf" = "xyes")
295AC_SUBST(GDKPIXBUF_CFLAGS)
296AC_SUBST(GDKPIXBUF_LIBS)
297
298AM_CONDITIONAL(HAVE_GTKSOURCEVIEW, test x"$have_sourceview" = "xyes")
299AC_SUBST(GTKSOURCEVIEW_CFLAGS)
300AC_SUBST(GTKSOURCEVIEW_LIBS)
301
302AM_CONDITIONAL(HAVE_GOOCANVAS, test x"$have_goocanvas" = "xyes")
303AC_SUBST(GOOCANVAS_CFLAGS)
304AC_SUBST(GOOCANVAS_LIBS)
305
306
307AM_CONDITIONAL(HAVE_GRAPHVIZ, test x"$have_graphviz" = "xyes")
308AC_SUBST(GRAPHVIZ_CFLAGS)
309AC_SUBST(GRAPHVIZ_LIBS)
310
311AM_CONDITIONAL(HAVE_GLADE, test x"$have_glade" = "xyes")
312AC_SUBST(GLADE_CFLAGS)
313AC_SUBST(GLADE_LIBS)
314AC_SUBST(GLADE_CATALOG)
315AC_SUBST(GLADE_PIXMAP)
316
317
318dnl ******************************
319dnl Checks for iso codes
320dnl ******************************
321
322ISO_CODES_MODULES="iso-codes"
323PKG_CHECK_MODULES(ISO_CODES, $ISO_CODES_MODULES, have_iso_codes=yes, have_iso_codes=no)
324if test x"$have_iso_codes" = "xyes"
325then
326        AC_MSG_CHECKING([whether iso-codes has iso-4217 domain])
327        if $PKG_CONFIG --variable=domains iso-codes | grep -q 4217 ; then
328                AC_MSG_RESULT([yes])
329                AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix])
330        else
331                AC_MSG_RESULT([no])
332                AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],"")
333        fi
334else
335        AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],"")
336fi
337
338dnl ******************************
339dnl Check for Operating System
340dnl ******************************
341dnl linklibext is the shared link library extension, which varies by platform
342
343EXPORT_SYM_REGEX='-export-symbols-regex "^(gda_|fnYM49765777344607__gda).*"'
344EXPORT_PROV_SYM_REGEX='-export-symbols-regex "^(plugin_|Java_|g_module|gdaprov_).*"'
345EXPORT_UI_SYM_REGEX='-export-symbols-regex "^(gdaui_).*"'
346AC_MSG_CHECKING([for platform])
347platform_win32=no
348platform_carbon=no
349have_ige=no
350linklibext=".so"
351case "$host" in
352*-cygwin*)
353    AC_MSG_RESULT([Win32 - cygwin])
354    NO_UNDEFINED='-no-undefined'
355    LIBTOOL_EXPORT_OPTIONS=$EXPORT_SYM_REGEX
356    LIBTOOL_PROV_EXPORT_OPTIONS=$EXPORT_PROV_SYM_REGEX
357    LIBTOOL_UI_EXPORT_OPTIONS=$EXPORT_UI_SYM_REGEX
358    linklibext=".dll.a"
359    AC_MSG_RESULT([Win32])
360    ;;
361*-mingw*)
362    AC_MSG_RESULT([Win32 - MinGW])
363    platform_win32=yes
364    AC_DEFINE(USING_MINGW)
365    NO_UNDEFINED='-no-undefined'
366    LIBTOOL_EXPORT_OPTIONS=
367    LIBTOOL_PROV_EXPORT_OPTIONS=
368    LIBTOOL_UI_EXPORT_OPTIONS=
369    linklibext=".dll"
370    AC_CHECK_TOOL(WINDRES, windres, windres)
371    AC_SUBST(WINDRES)
372    AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool)
373    AC_SUBST(DLLTOOL)
374    ;;
375*-*-darwin*)
376    dnl Darwin based distributions (including Mac OS X)
377    AC_MSG_RESULT([Mac OS X - carbon])
378    platform_carbon=yes
379    if test "$enable_binreloc" != "no"
380    then
381	AC_DEFINE(ENABLE_BINRELOC)
382	br_cv_binreloc=yes
383    fi
384    PKG_CHECK_MODULES(MAC_INTEGRATION, ige-mac-integration, have_ige=yes, have_ige=no)
385    if test x"$have_ige" = "xyes"
386    then
387	AC_DEFINE(HAVE_MAC_INTEGRATION)
388	AC_SUBST(MAC_INTEGRATION_CFLAGS)
389	AC_SUBST(MAC_INTEGRATION_LIBS)
390    fi
391    LIBTOOL_EXPORT_OPTIONS=$EXPORT_SYM_REGEX
392    LIBTOOL_PROV_EXPORT_OPTIONS=$EXPORT_PROV_SYM_REGEX
393    LIBTOOL_UI_EXPORT_OPTIONS=$EXPORT_UI_SYM_REGEX
394    AC_DEFINE(HAVE_CARBON)
395    COREDEPS_LIBS="$COREDEPS_LIBS -framework Carbon"
396  ;;
397*)
398    AC_MSG_RESULT([Unix])
399    NO_UNDEFINED=''
400    AM_BINRELOC
401    LIBTOOL_EXPORT_OPTIONS=$EXPORT_SYM_REGEX
402    LIBTOOL_PROV_EXPORT_OPTIONS=$EXPORT_PROV_SYM_REGEX
403    LIBTOOL_UI_EXPORT_OPTIONS=$EXPORT_UI_SYM_REGEX
404    ;;
405esac
406
407AM_CONDITIONAL(PLATFORM_WIN32, [test $platform_win32 = yes])
408AM_CONDITIONAL(PLATFORM_CARBON, [test $platform_carbon = yes])
409AM_CONDITIONAL(HAVE_IGE, [test $have_ige = yes])
410AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
411AC_SUBST(LIBTOOL_PROV_EXPORT_OPTIONS)
412AC_SUBST(LIBTOOL_UI_EXPORT_OPTIONS)
413AC_SUBST(NO_UNDEFINED)
414
415dnl ******************************
416dnl Option to avoid building tools
417dnl See bug #684895
418dnl ******************************
419AC_ARG_ENABLE([tools],
420	AS_HELP_STRING([--disable-tools], [Disable building and installing Libgda's associated tools (gda-sql, control-center, browser, ...)]),
421	[enable_tools=$enableval],[enable_tools=yes])
422
423AM_CONDITIONAL(ENABLE_TOOLS, [test "$enable_tools" = "yes"])
424
425dnl *******************************************************
426dnl Checks for GIO
427dnl *******************************************************
428
429GIO_MODULES="gio-2.0 >= 2.16"
430PKG_CHECK_MODULES(GIO, $GIO_MODULES, have_gio=yes, have_gio=no)
431AM_CONDITIONAL(HAVE_GIO, test x"$have_gio" = "xyes")
432if test x"$have_gio" = "xyes"
433then
434        GIO_CFLAGS="$GIO_CFLAGS -DHAVE_GIO"
435else
436        AC_MSG_WARN([Libgda depends on Gio to provide notification when configuration files are changed, without Gio support any application using Libgda will have to be restarted when configuration files are changed to take into account those changes])
437fi
438AC_SUBST(GIO_CFLAGS)
439AC_SUBST(GIO_LIBS)
440
441dnl ******************************
442dnl Checks for libxslt
443dnl ******************************
444
445LIBXSLT_MODULES="libxslt"
446PKG_CHECK_MODULES(LIBXSLT, $LIBXSLT_MODULES, have_xslt=yes, have_xslt=no)
447AM_CONDITIONAL(HAVE_LIBXSLT, test x"$have_xslt" = "xyes")
448if test x"$have_xslt" = "xyes"
449then
450        LIBXSLT_CFLAGS="$LIBXSLT_CFLAGS -DHAVE_LIBXSLT"
451fi
452AC_SUBST(LIBXSLT_CFLAGS)
453AC_SUBST(LIBXSLT_LIBS)
454
455dnl ******************************
456dnl Checks for json-glib
457dnl ******************************
458have_json=no
459AC_ARG_ENABLE([json],
460	AS_HELP_STRING([--enable-json], [Enable support for JSON, disabled by default]),
461	[enable_json=$enableval],[enable_json=no])
462
463if test "x$enable_json" = xyes
464then
465    JSON_GLIB_MODULES="json-glib-1.0"
466    PKG_CHECK_MODULES(JSON_GLIB, $JSON_GLIB_MODULES,
467	AC_DEFINE(HAVE_JSON_GLIB, [], [Defined if JSON support is enabled])
468	have_json=yes,
469	AC_MSG_ERROR([JSON support requested but not found])
470    )
471fi
472AM_CONDITIONAL(HAVE_JSON_GLIB, [test "$have_json" = "yes"])
473AC_SUBST(JSON_GLIB_CFLAGS)
474AC_SUBST(JSON_GLIB_LIBS)
475
476dnl *********************************
477dnl Check for GObject Introspection
478dnl *********************************
479GOBJECT_INTROSPECTION_CHECK([1.30.0])
480
481AC_ARG_ENABLE([gdaui-gi],
482    AS_HELP_STRING([--disable-gdaui-gi[=@<:@yes/no@:>@]], [Disable GObject Introspection for libgda-ui [default=no]]),
483    [
484      if test x$enableval = xyes
485      then
486        disable_gdaui_gi=no
487      else
488        disable_gdaui_gi=yes
489      fi
490    ],[
491      disable_gdaui_gi=no
492    ])
493
494if test x$found_introspection != xyes
495then
496  disable_gda_gi=yes
497  disable_gdaui_gi=yes
498fi
499
500AM_CONDITIONAL(ENABLE_GDA_GI, [test x$disable_gda_gi != xyes])
501
502if test x$have_ui != xyes
503then
504	disable_gdaui_gi=yes
505fi
506
507AM_CONDITIONAL(ENABLE_GDAUI_GI, [test x$disable_gdaui_gi != xyes])
508
509dnl ******************************
510dnl Check for Vala Compiler
511dnl ******************************
512
513AC_ARG_ENABLE([vala],
514    AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]], [Generate Vala bindings and extensions]),
515    [enable_vala=$enableval],[enable_vala=no])
516
517AC_PATH_PROG([VALAC], [valac], [no])
518
519if test "x$enable_vala" = "xyes" -a "x$VALAC" = "xno"
520then
521	AC_MSG_NOTICE([Vala's compiler not found, disabling Vala Bindigs and extensions])
522	enable_vala=no
523fi
524
525AC_PATH_PROG(VAPIGEN, [vapigen], [no])
526
527if test x$VAPIGEN = xno -a x$enable_vala = xyes
528then
529	AC_MSG_NOTICE([vapigen not found, disabling Vala bindings and extensions])
530	enable_vala=no
531fi
532
533AM_CONDITIONAL(ENABLE_VAPIGEN, test x$enable_vala = xyes)
534
535AC_ARG_ENABLE([gdaui-vala],
536    AS_HELP_STRING([--disable-gdaui-vala[=@<:@yes/no@:>@]], [Generate Vala bindings and extensions]),
537    [
538      if test x$enableval = xyes
539      then
540        disable_gdaui_vala=no
541      else
542        disable_gdaui_vala=yes
543      fi
544      ],
545      [
546        disable_gdaui_vala=no
547      ])
548
549if test x$enable_vala != xyes -o x$disable_gdaui_gi = xyes -o x$have_ui = xno
550then
551	disable_gdaui_vala=yes
552fi
553
554AM_CONDITIONAL(ENABLE_GDAUI_VALA, test x$disable_gdaui_vala != xyes)
555
556
557dnl ******************************
558dnl Checks for libcrypto
559dnl ******************************
560AC_ARG_ENABLE([crypto],
561	AS_HELP_STRING([--disable-crypto], [Disable SQLCipher database provider (using the libcrypto library, part of OpenSSL)]),
562	[enable_crypto=$enableval],[enable_crypto=yes])
563
564if test "x$enable_crypto" = xyes
565then
566        LIBCRYPTO_MODULES="libcrypto"
567	PKG_CHECK_MODULES(LIBCRYPTO, $LIBCRYPTO_MODULES,
568	        if test "$enable_crypto" = "yes"
569	        then
570		        AC_DEFINE(HAVE_LIBCRYPTO, [], [Defined if cryptographic support is enabled])
571	        fi,
572	        if test "$enable_crypto" = "yes"
573	        then
574			AC_MSG_ERROR([libcrypto support requested but not found])
575	        fi)
576fi
577
578AM_CONDITIONAL(HAVE_LIBCRYPTO, [test "$enable_crypto" = "yes"])
579AC_SUBST(LIBCRYPTO_CFLAGS)
580AC_SUBST(LIBCRYPTO_LIBS)
581
582dnl ******************************
583dnl Checks for libgcrypt
584dnl ******************************
585LIBGCRYPT_CFLAGS=""
586LIBGCRYPT_LIBS=""
587if test x$platform_win32 != xyes; then
588	AC_DEFUN([VERSION_TO_NUMBER],[`$1 | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`])
589	AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
590	if test "$LIBGCRYPT_CONFIG" != "no" ; then
591   		LIBGCRYPT_VERSION=`$LIBGCRYPT_CONFIG --version`
592		if test VERSION_TO_NUMBER(echo $LIBGCRYPT_VERSION) -lt VERSION_TO_NUMBER(echo "1.1.42") ; then
593			LIBGCRYPT_CFLAGS=""
594			LIBGCRYPT_LIBS=""
595			AM_CONDITIONAL(HAVE_LIBGCRYPT, 0)
596			echo "Password entry plugin will not be compiled, install libgcrypt >= 1.1.42 and reconfigure to make available."
597      		else
598			LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --cflags`
599        		LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --libs`
600			AM_CONDITIONAL(HAVE_LIBGCRYPT, true)
601        	fi
602	else
603	LIBGCRYPT_CFLAGS=""
604      	LIBGCRYPT_LIBS=""
605      	AM_CONDITIONAL(HAVE_LIBGCRYPT, 0)
606      	echo "Password entry plugin will not be compiled, install libgcrypt and reconfigure to make available."
607	fi
608else
609	AM_CONDITIONAL(HAVE_LIBGCRYPT, false)
610fi
611
612AC_SUBST(LIBGCRYPT_CFLAGS)
613AC_SUBST(LIBGCRYPT_LIBS)
614
615dnl ******************************
616dnl gtk-doc
617dnl ******************************
618
619GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
620
621dnl ******************************
622dnl Vala documentation
623dnl ******************************
624enable_vala_doc="no"
625AC_PATH_PROG(YELP_BUILD, [yelp-build], [no])
626if test "x$enable_gtk_doc" = "xyes"
627then
628dnl Find yelp-build program
629    if test "x$YELP_BUILD" = "xno";
630    then
631        AC_MSG_RESULT([Vala documentation not build because yelp-build has not been found])
632    else
633        AC_SUBST(YELP_BUILD)
634        enable_vala_doc="yes"
635    fi
636fi
637AM_CONDITIONAL(ENABLE_VALA_DOC, [test "$enable_vala_doc" = "yes"])
638
639dnl ******************************
640dnl Checks for providers
641dnl ******************************
642
643AC_ARG_WITH(libdir-name,
644    AS_HELP_STRING([--with-libdir-name[=@<:@<dir. name>@:>@]],
645                   [Speficy the library name used to locate libraries, relative to the prefix of each install (for example lib64)]),
646                   [lib=$withval],
647		   [lib=""])
648
649dnl Test for Berkeley DB
650BDB_CHECK($lib)
651
652dnl Test for MySQL
653MYSQL_CHECK($lib)
654
655dnl Test for PostgreSQL
656POSTGRES_CHECK($lib)
657
658dnl test for ORACLE
659ORACLE_CHECK($lib)
660
661dnl Test for JAVA and JDBC
662JAVA_CHECK()
663
664dnl Test for LDAP
665LDAP_CHECK($lib)
666
667dnl test for FireBird
668FIREBIRD_CHECK($lib)
669
670dnl Test for MDB Tools (for MS Access files)
671MDBTOOLS_CHECK([$lib])
672
673dnl test for system-installed SQLite
674dnl If no SQLite is found or if the SQLite found does not have the sqlite3_table_column_metadata()
675dnl function call, then use the embedded version
676dnl also, on Win32, always use the embedded version
677if test x"$platform_win32" = "xyes"
678then
679        AM_CONDITIONAL(HAVE_SQLITE, false)
680else
681	AC_ARG_ENABLE(system-sqlite,
682		AS_HELP_STRING([--enable-system-sqlite], [Use SQLite installed on the system [default=no]]),
683        	[use_syst_sqlite=$enableval], [use_syst_sqlite="yes"])
684
685	if test "x$use_syst_sqlite" = "xyes"; then
686		SQLITE_MODULES="sqlite3 >= 3.10.2"
687		PKG_CHECK_MODULES(SQLITE, $SQLITE_MODULES, have_sqlite=yes, have_sqlite=no)
688		if test x"$have_sqlite" = "xyes"
689		then
690			AC_CHECK_LIB(sqlite3, sqlite3_table_column_metadata,[sqlite3_api=1], [sqlite3_api=0], $SQLITE_CFLAGS $SQLITE_LIBS)
691
692			if test $sqlite3_api = 0
693        		then
694				AC_MSG_RESULT([Installed SQLite was not compiled with the SQLITE_ENABLE_COLUMN_METADATA, using embedded SQLite])
695                		have_sqlite=no
696        		else
697                		AC_MSG_RESULT([Note: using system installed version of SQLite, meta data for functions will not be available])
698				have_sqlite=yes
699                		SQLITE_CFLAGS="$SQLITE_CFLAGS -DHAVE_SQLITE"
700				SQLITE_PATH=`pkg-config --variable=libdir sqlite3`
701                		AC_SUBST(SQLITE_CFLAGS)
702                		AC_SUBST(SQLITE_LIBS)
703                		AC_SUBST(SQLITE_VERS)
704                		AC_SUBST(SQLITE_PATH)
705        		fi
706		fi
707	fi
708	AM_CONDITIONAL(HAVE_SQLITE, test x"$have_sqlite" = "xyes")
709fi
710
711dnl ************************
712dnl Check for libsoup
713dnl ************************
714
715AC_ARG_WITH(libsoup,
716	AS_HELP_STRING([--with-libsoup], [Enable libsoup support]),
717	[
718		with_libsoup=$withval
719	],
720	[
721		with_libsoup=auto
722	])
723
724if test "$with_libsoup" = "auto" -o "$with_libsoup" = "yes"
725then
726	PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4, [
727		AC_DEFINE(HAVE_LIBSOUP, [1], [libsoup support enabled])
728		have_libsoup=yes], [
729		if test "$with_libsoup" = "yes"
730		then
731			AC_MSG_ERROR([libsoup support requested but not found.])
732		fi
733		have_libsoup=no])
734fi
735AM_CONDITIONAL(LIBSOUP, test "$have_libsoup" = "yes")
736AC_SUBST(LIBSOUP_CFLAGS)
737AC_SUBST(LIBSOUP_LIBS)
738
739
740dnl ************************************
741dnl Check for libsecret or gnome-keyring
742dnl ************************************
743
744AC_ARG_WITH(libsecret,
745	AS_HELP_STRING([--with-libsecret], [Enable libsecret support]),
746	[
747		with_libsecret=$withval
748	],[
749		with_libsecret=auto
750	])
751
752AC_ARG_WITH(gnome-keyring,
753	AS_HELP_STRING([--with-gnome-keyring], [Enable gnome-keyring support]),
754	[
755		with_gnome_keyring=$withval
756	],[
757		with_gnome_keyring=auto
758	])
759
760if test "$with_libsecret" = "auto" -o "$with_libsecret" = "yes"
761then
762	PKG_CHECK_MODULES(LIBSECRET, libsecret-1, [
763		AC_DEFINE(HAVE_LIBSECRET, [1], [libsecret support enabled])
764		have_libsecret=yes], [
765		if test "$with_libsecret" = "yes"
766		then
767			AC_MSG_ERROR([libsecret support requested but not found.])
768		fi
769		have_libsecret=no])
770else
771	have_libsecret=no
772fi
773AM_CONDITIONAL(LIBSECRET, test "$have_libsecret" = "yes")
774AC_SUBST(LIBSECRET_CFLAGS)
775AC_SUBST(LIBSECRET_LIBS)
776
777if test x$have_libsecret = xno
778then
779    if test x$with_gnome_keyring = xauto -o x$with_gnome_keyring = xyes
780    then
781	PKG_CHECK_MODULES(GNOME_KEYRING, gnome-keyring-1, [
782		AC_DEFINE(HAVE_GNOME_KEYRING, [1], [gnome-keyring support enabled])
783		have_gnome_keyring=yes], [
784		if test x$with_gnome_keyring = xyes
785		then
786			AC_MSG_ERROR([gnome-keyring support requested but not found.])
787		fi
788		have_gnome_keyring=no])
789    fi
790fi
791AM_CONDITIONAL(GNOME_KEYRING, test "$have_gnome_keyring" = "yes")
792AC_SUBST(GNOME_KEYRING_CFLAGS)
793AC_SUBST(GNOME_KEYRING_LIBS)
794
795
796dnl **************************
797dnl Check for readline/history
798dnl **************************
799if test x"$platform_win32" = "xyes"; then
800	if test $cross_compiling = yes; then
801  		AC_CHECK_LIB(readline, readline, READLINE_LIB='-lreadline', [])
802	else
803  		AC_CHECK_LIB(readline, readline, READLINE_LIB='-lreadline -lcurses', [], -lcurses)
804	fi
805else
806	AC_CHECK_LIB(ncurses, initscr, curses_lib='-lncurses', curses_lib='')
807	if test "x$curses_lib" = "x"; then
808		AC_CHECK_LIB(curses, initscr, curses_lib='-lcurses', [])
809        fi
810	if test "x$curses_lib" != "x"; then
811		AC_CHECK_LIB(readline, readline, READLINE_LIB="-lreadline ${curses_lib}", [], $curses_lib)
812	fi
813fi
814if test ! x"$READLINE_LIB" = x ; then
815   	AC_DEFINE(HAVE_READLINE)
816fi
817AM_CONDITIONAL(READLINE_LIB, test ! "x$READLINE_LIB" = "x")
818AC_SUBST(READLINE_LIB)
819
820AC_CHECK_LIB(history,add_history,HISTORY_LIB=-lhistory)
821if test ! x"$HISTORY_LIB" = x ; then
822   	AC_DEFINE(HAVE_HISTORY)
823fi
824AM_CONDITIONAL(HISTORY_LIB, test ! "x$HISTORY_LIB" = "x")
825AC_SUBST(HISTORY_LIB)
826
827
828dnl
829dnl TERMIOS.H
830dnl
831AC_CHECK_HEADERS([termios.h])
832
833dnl
834dnl where to install DTD files
835dnl
836LIBGDA_DTDDIR=${datadir}/libgda-$LIBGDA_ABI_VERSION/dtd
837AC_SUBST(LIBGDA_DTDDIR)
838
839dnl
840dnl Check if lib should be build with the debug mode
841dnl
842gda_debug_flags=""
843AC_ARG_ENABLE(debug,
844	AS_HELP_STRING([--enable-debug], [Enable debug mode [default=no]]),
845        [use_debug=$enableval], [use_debug="no"])
846
847if test "x$use_debug" = "xyes"
848then
849	AC_DEFINE(GDA_DEBUG)
850	GDA_DEBUG_FLAGS=-DGDA_DEBUG
851	AC_SUBST(GDA_DEBUG_FLAGS)
852fi
853
854AC_ARG_ENABLE(mutex-debug,
855	AS_HELP_STRING([--enable-mutex-debug], [Enable debug mode for GdaMutex [default=no]]),
856        [use_debug=$enableval], [use_debug="no"])
857
858if test "x$use_debug" = "xyes"
859then
860	AC_DEFINE(GDA_DEBUG_MUTEX)
861	GDA_DEBUG_FLAGS="$GDA_DEBUG_FLAGS -DGDA_DEBUG_MUTEX"
862	GDA_DEBUG_LDFLAGS=-rdynamic
863	AC_SUBST(GDA_DEBUG_FLAGS)
864	AC_SUBST(GDA_DEBUG_LDFLAGS)
865fi
866
867dnl Disable rebuild of glib-mkenum -generated source code:
868AC_ARG_ENABLE(rebuilds,
869	AS_HELP_STRING([--disable-rebuilds], [disable all source autogeneration rules]),
870	[enable_rebuilds=$enableval], [enable_rebuilds=yes])
871
872# define a MAINT-like variable REBUILD which is set if Perl
873# is found, so autogenerated sources can be rebuilt
874AC_CHECK_PROGS(PERL, perl5 perl)
875
876REBUILD=\#
877if test "x$enable_rebuilds" = "xyes" && \
878     test -n "$PERL" && \
879     $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 ; then
880  REBUILD=
881fi
882AC_SUBST(REBUILD)
883
884#
885# enable setting the Gda SQL console as default version (makes a symlink)
886#
887AC_ARG_ENABLE(default-binary,
888	AS_HELP_STRING([--enable-default-binary], [install binaries as default (default=gda_stable)]),
889	[enable_default_binary=$enableval], [enable_default_binary=gda_stable])
890
891AM_CONDITIONAL(DEFAULT_BINARY, test "x$enable_default_binary" = xyes)
892
893# We use -Wno-address because SQLITE3_CALL() has an ifdefed definition that
894#   makes it hard to always avoid the warning.
895# We use -Wno-unused-variable because the lemon parser generator (in libgda's sources),
896#   creates some generic macros that declare variables that are not always used.
897# We use -Wno-unused-parameter because the lemon parser generator (in libgda's sources),
898#   produces generic code, and it's hard to fix that generated code.
899# We use -Wno-pointer-sign because the sqlite source code (copied into libgda's sources)
900#   has problems but we do not want to patch that code.
901# We use -Wno-missing-field-initializers because recent glib versions introduced this
902#  and they refuse to fix it: https://bugzilla.gnome.org/show_bug.cgi?id=662797
903#  We should remove -Wno-missing-field-initializers when we replace the use of
904#  the deprecated G_STATIC_MUTEX_INIT macro.
905DK_ARG_ENABLE_WARNINGS([COREDEPS_WFLAGS],
906	[-Wall],
907	[-Wall -Wextra -Wformat-security -Wno-address -Wno-unused-variable -Wno-unused-parameter -Wno-pointer-sign -Wno-missing-field-initializers -DGSEAL_ENABLE],
908	[PANGO G GDK GDK_PIXBUF GTK])
909
910AC_SUBST(COREDEPS_CFLAGS)
911AC_SUBST(COREDEPS_LIBS)
912
913AC_CONFIG_FILES([
914Makefile
915libgda.spec
916libgda-5.0.pc
917libgda-ui-5.0.pc
918libgda-report-5.0.pc
919libgda-xslt-5.0.pc
920po/Makefile.in
921libgda/Makefile
922libgda/libgda.h
923libgda/binreloc/Makefile
924libgda/handlers/Makefile
925libgda/providers-support/Makefile
926libgda/sql-parser/Makefile
927libgda/sqlite/Makefile
928libgda/sqlite/sqlite-src/Makefile
929libgda/sqlite/virtual/libgda-virtual.h
930libgda/sqlite/virtual/Makefile
931libgda/thread-wrapper/Makefile
932providers/Makefile
933providers/reuseable/Makefile
934providers/reuseable/postgres/Makefile
935providers/reuseable/mysql/Makefile
936providers/bdb/Makefile
937providers/bdb/libgda-bdb-5.0.pc
938providers/bdbsql/Makefile
939providers/bdbsql/libgda-bdbsql-5.0.pc
940providers/mdb/Makefile
941providers/mdb/libmdb-src/Makefile
942providers/mdb/libgda-mdb-5.0.pc
943providers/mysql/Makefile
944providers/mysql/libgda-mysql-5.0.pc
945providers/oracle/Makefile
946providers/oracle/libgda-oracle-5.0.pc
947providers/postgres/Makefile
948providers/postgres/libgda-postgres-5.0.pc
949providers/firebird/Makefile
950providers/firebird/libgda-firebird-5.0.pc
951providers/sqlite/Makefile
952providers/sqlite/libgda-sqlite-5.0.pc
953providers/jdbc/Makefile
954providers/jdbc/libgda-jdbc-5.0.pc
955providers/ldap/Makefile
956providers/ldap/libgda-ldap-5.0.pc
957providers/web/Makefile
958providers/web/libgda-web-5.0.pc
959providers/skel-implementation/Makefile
960providers/skel-implementation/capi/Makefile
961providers/skel-implementation/capi/libgda-capi-5.0.pc
962providers/skel-implementation/models/Makefile
963providers/skel-implementation/models/libgda-models-5.0.pc
964providers/sqlcipher/Makefile
965providers/sqlcipher/libgda-sqlcipher-5.0.pc
966libgda-report/Makefile
967libgda-report/engine/Makefile
968libgda-report/DocBook/Makefile
969libgda-report/RML/Makefile
970libgda-report/RML/trml2html/Makefile
971libgda-report/RML/trml2pdf/Makefile
972libgda-xslt/Makefile
973libgda-ui/Makefile
974libgda-ui/marshallers/Makefile
975libgda-ui/internal/Makefile
976libgda-ui/data-entries/Makefile
977libgda-ui/data-entries/plugins/Makefile
978libgda-ui/data/Makefile
979libgda-ui/demos/Makefile
980libgda-ui/demos/geninclude.pl
981libgda-ui/glade/Makefile
982control-center/Makefile
983control-center/data/Makefile
984tools/Makefile
985tools/gda-sql-5.0.1:tools/gda-sql.1.in
986tools/cmdtool/Makefile
987tools/help/Makefile
988tools/browser/Makefile
989tools/browser/data/Makefile
990tools/browser/common/Makefile
991tools/browser/schema-browser/Makefile
992tools/browser/query-exec/Makefile
993tools/browser/data-manager/Makefile
994tools/browser/ldap-browser/Makefile
995tools/browser/dummy-perspective/Makefile
996tools/browser/canvas/Makefile
997tools/browser/doc/Makefile
998tools/browser/help/Makefile
999testing/Makefile
1000tests/Makefile
1001tests/parser/Makefile
1002tests/data-models/Makefile
1003tests/providers/Makefile
1004tests/value-holders/Makefile
1005tests/meta-store/Makefile
1006tests/multi-threading/Makefile
1007tests/ui/Makefile
1008doc/Makefile
1009doc/C/Makefile
1010doc/C/libgda.types
1011doc/C/version.xml
1012data/Makefile
1013stamp.h
1014])
1015AC_OUTPUT
1016
1017
1018dnl Dirty work to be able to build documentation
1019chmod -R u+w ${srcdir}/doc/C
1020cp doc/C/version.xml ${srcdir}/doc/C/version.xml.tmp
1021mv ${srcdir}/doc/C/version.xml.tmp ${srcdir}/doc/C/version.xml
1022
1023cp ${srcdir}/doc/C/libgda-sections.txt doc/C/libgda-5.0-sections.txt
1024echo "" >> doc/C/libgda-5.0-sections.txt
1025cat ${srcdir}/doc/C/libgda-ui-sections.txt >> doc/C/libgda-5.0-sections.txt
1026cp doc/C/libgda-5.0-sections.txt ${srcdir}/doc/C/libgda-5.0-sections.txt.tmp
1027mv ${srcdir}/doc/C/libgda-5.0-sections.txt.tmp ${srcdir}/doc/C/libgda-5.0-sections.txt
1028
1029cp doc/C/libgda.types doc/C/libgda-5.0.types
1030if test x$have_ui != xno
1031then
1032	echo "" >> doc/C/libgda-5.0.types
1033	cat ${srcdir}/doc/C/libgda-ui.types >> doc/C/libgda-5.0.types
1034fi
1035
1036
1037dnl Print configuration summary
1038echo ""
1039echo " Configuration summary for version $GDA_VERSION"
1040echo "   Installation prefix = $prefix"
1041echo "   Building GTK+ UI extension: `if test x$have_ui != xno; then echo yes; else echo no; fi`"
1042echo "   Installing Glade GTK+ UI extension catalog: `if test x$have_glade != xno; then echo yes; else echo no; fi`"
1043echo "   Building Libxslt extension: `if test x$have_xslt != xno; then echo yes; else echo no; fi`"
1044echo "   Building libgda GObject Introspection: `if test x$disable_gda_gi != xyes; then echo yes; else echo no; fi`"
1045echo "   Building libgda-ui GObject Introspection: `if test x$disable_gdaui_gi != xyes; then echo yes; else echo no; fi`"
1046echo "   Building Gtk-Doc: `if test x$enable_gtk_doc != xno; then echo yes; else echo no; fi`"
1047echo "   Building Help (GdaBrowser): `if test x$with_gdu != xno; then echo yes; else echo no; fi`"
1048echo "   Building GDA Vala Bindings (--enable-vala): `if test x$enable_vala = xno; then echo no; else echo yes; fi`"
1049echo "   Building GDA-UI Vala Bindings: `if test x$disable_gdaui_vala = xyes; then echo no; else echo yes; fi`"
1050echo "   Building Vala Documentation: `if test x$enable_vala_doc != xno; then echo yes; else echo no; fi`"
1051echo "   Building Building Libgda's associated tools: `if test x$enable_tools = xyes; then echo yes; else echo no; fi`"
1052echo "   Compiled providers:"
1053echo "      Berkeley DB = $bdb_found"
1054echo "      Berkeley DB SQL = $bdbsql_found"
1055echo "      FireBird (client)= $firebird_client_found"
1056echo "      FireBird (embed)= $firebird_embed_found"
1057echo "      MDB (MS Access) = $mdbtools_found"
1058echo "      MySQL = $mysql_found"
1059echo "      Oracle = $oracle_found"
1060echo "      PostgreSQL = $postgres_found"
1061echo "      SQLite = yes `if test x$have_sqlite = xyes; then echo '(from system installation)'; else echo '(embedded)'; fi`"
1062echo "      SQLCipher = `if test x$enable_crypto != xyes; then echo no; else echo yes; fi`"
1063echo "      JDBC = $java_found"
1064echo "      WEB = `if test x$have_libsoup = xyes; then echo yes; else echo no; fi`"
1065echo "      LDAP = `if test x$ldap_found = xyes; then echo yes; else echo no; fi`"
1066echo "   With LIBSECRET = `if test x$have_libsecret = xyes; then echo yes; else echo no; fi`"
1067echo "   With GNOME KEYRING = `if test x$have_gnome_keyring = xyes; then echo yes; else echo no; fi`"
1068if test x"$br_cv_binreloc" != "xyes" -a x"$platform_win32" != "xyes"
1069then
1070       echo "   Binreloc support is disabled: Libgda will not be relocatable. To enable binreloc support re-run with --enable-binreloc (see http://autopackage.org/docs/binreloc for more information)"
1071fi
1072echo ""
1073