1 #######################################################################################################################
3 # Copyright (C) 2012 Continental Automotive Systems, Inc.
5 # Author: Ana.Chisca@continental-corporation.com
6 # Petrica.Manoila@continental-corporation.com
8 # Configure template for the persistence-common library
10 # Process this file with autoconf to produce a configure script.
12 # This Source Code Form is subject to the terms of the Mozilla Public
13 # License, v. 2.0. If a copy of the MPL was not distributed with this
14 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
16 #######################################################################################################################
18 dnl **************************************************************************
19 dnl *** First, define all of the version numbers up front ***
20 dnl *** In particular, this allows the version macro to be used in AC_INIT ***
21 dnl **************************************************************************
22 m4_define([LIBPERSOCOMMON_VERSION_S],[1.0.1])
23 m4_define([LIBPERSOCOMMON_VERSION_N],[1000001])
25 dnl ***************************
26 dnl *** Initialize autoconf ***
27 dnl ***************************
28 AC_INIT([persistence-common],[LIBPERSOCOMMON_VERSION_S()])
29 AC_COPYRIGHT([Copyright (c) 2012 Continental Automotive GmbH])
32 dnl ***************************
33 dnl *** Initialize automake ***
34 dnl ***************************
36 AC_USE_SYSTEM_EXTENSIONS()
37 AC_CONFIG_MACRO_DIR([m4])
38 AC_SUBST([ACLOCAL_AMFLAGS], ["$ACLOCAL_FLAGS -I m4"])
40 dnl *********************************
41 dnl *** Shared library versioning ***
42 dnl *********************************
43 PERSCOMMON_MAJOR=$((((LIBPERSOCOMMON_VERSION_N() / 1000) / 1000) % 1000 ))
44 PERSCOMMON_MINOR=$(( (LIBPERSOCOMMON_VERSION_N() / 1000) % 1000 ))
45 PERSCOMMON_MICRO=$(( LIBPERSOCOMMON_VERSION_N() % 1000 ))
46 GENERIC_LIBRARY_VERSION=$PERSCOMMON_MAJOR:$PERSCOMMON_MINOR:$PERSCOMMON_MICRO
47 AC_SUBST(GENERIC_LIBRARY_VERSION)
49 dnl ********************************
50 dnl *** Check for basic programs ***
51 dnl ********************************
57 dnl ***************************
58 dnl *** Initialize lib tool ***
59 dnl ***************************
63 dnl ***************************************
64 dnl *** Check for standard header files ***
65 dnl ***************************************
66 AC_CHECK_HEADERS([string.h])
68 dnl ***********************************
69 dnl *** Check for library functions ***
70 dnl ***********************************
73 AC_CHECK_FUNCS([memcpy])
74 AC_CHECK_FUNCS([memset])
76 dnl ********************************************************************
77 dnl *** Check for typedefs, structures, and compiler characteristics ***
78 dnl ********************************************************************
86 dnl ***********************************
87 dnl *** Check for required packages ***
88 dnl ***********************************
89 PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.30.0])
90 PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.30.0])
91 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.30.0])
92 PKG_CHECK_MODULES([DLT], [automotive-dlt >= 2.2.0])
94 dnl *************************************
95 dnl *** Database support ***
96 dnl *************************************
98 AC_ARG_WITH([database],
99 AS_HELP_STRING([--with-database=auto|itzam|sqlite|rawdb|key-value-store],[Choose database backend.]),[],[with_database=auto])
101 dnl ********** ITZAM **********
102 AS_IF([test "x$with_database" = "xauto" -o "x$with_database" = "xitzam"],
103 [PKG_CHECK_MODULES(ITZAM, [ libitzam >= 6.0.4 ], HAVE_ITZAM=1, HAVE_ITZAM=0)],
105 AS_IF([test "x$HAVE_ITZAM" = "x1"], with_database=itzam)
106 AS_IF([test "x$HAVE_ITZAM" = "x1"], ITZAM_LIBS="-litzam")
107 AS_IF([test "x$with_database" = "xitzam" -a "x$HAVE_ITZAM" = "x0"],
108 [AC_MSG_ERROR([*** itzam not found])])
110 AM_CONDITIONAL([HAVE_ITZAM], [test "x$HAVE_ITZAM" = x1])
112 dnl ********** SQLITE **********
113 AS_IF([test "x$with_database" = "xauto" -o "x$with_database" = "xsqlite"],
114 [PKG_CHECK_MODULES(SQLITE, [sqlite3 >= 3.7.5], HAVE_SQLITE=1, HAVE_SQLITE=0)],
116 AS_IF([test "x$HAVE_SQLITE" = "x1"], with_database=sqlite)
117 AS_IF([test "x$with_database" = "xsqlite" -a "x$HAVE_SQLITE" = "x0"],
118 [AC_MSG_ERROR([*** sqlite not found])])
120 AM_CONDITIONAL([HAVE_SQLITE], [test "x$HAVE_SQLITE" = x1])
122 dnl ********** RAWDB **********
123 AS_IF([test "x$with_database" = "xauto" -o "x$with_database" = "xrawdb"],
126 AS_IF([test "x$HAVE_RAWDB" = "x1"], with_database=rawdb)
127 AS_IF([test "x$with_database" = "xrawdb" -a "x$HAVE_RAWDB" = "x0"],
128 [AC_MSG_ERROR([*** rawdb not found])])
130 AM_CONDITIONAL([HAVE_RAWDB], [test "x$HAVE_RAWDB" = x1])
132 dnl ********** KEY-VALUE-STORE **********
133 AS_IF([test "x$with_database" = "xauto" -o "x$with_database" = "xkey-value-store"],
136 AS_IF([test "x$HAVE_KVS" = "x1"], with_database=key-value-store)
137 AS_IF([test "x$with_database" = "xkey-value-store" -a "x$HAVE_KVS" = "x0"],
138 [AC_MSG_ERROR([*** key-value-store not found])])
140 AM_CONDITIONAL([HAVE_KVS], [test "x$HAVE_KVS" = x1])
142 AS_IF([test "x$HAVE_ITZAM" != x1 -a "x$HAVE_SQLITE" != x1 -a "x$HAVE_RAWDB" != x1 -a "x$HAVE_KVS" != x1],
143 AC_MSG_ERROR([*** missing database backend]))
147 dnl ***************************************
148 dnl *** Check if test should be enabled ***
149 dnl ***************************************
150 AC_ARG_ENABLE([tests],
151 [AS_HELP_STRING([--enable-tests],[Enable tests])],
152 [enable_tests=$enableval],[enable_tests="no"])
154 AM_CONDITIONAL([WANT_TESTS], [test x"$enable_tests" = "xyes"])
155 # look if check framework exists
156 AC_ARG_WITH([localcheck],
157 [AS_HELP_STRING([--with-localcheck],[Path to local check])],
158 [localcheck=$withval],[localcheck=""])
160 if test "x$enable_tests" != "xno" ; then
161 if test -z "$localcheck" ; then
162 PKG_CHECK_MODULES(CHECK, check)
164 CHECK_CFLAGS="-I$localcheck/include"
165 CHECK_LIBS="-L$localcheck/lib -lcheck"
167 AC_SUBST(CHECK_CFLAGS)
170 AC_DEFINE_UNQUOTED([TESTS_ENABLED], [1], [tests enabled])
172 AC_DEFINE_UNQUOTED([TESTS_ENABLED], [0], [tests enabled])
174 AC_MSG_NOTICE([Tests enabled: $enable_tests])
175 AC_MSG_NOTICE([Local check enabled: $localcheck])
178 dnl **********************************************
179 dnl *** compile with debug information enabled ***
180 dnl **********************************************
182 AS_HELP_STRING([--enable-debug],
183 [enable debugging, default: no]),
184 [case "${enableval}" in
187 *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
191 AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")
195 dnl *************************************
196 dnl *** Define extra paths ***
197 dnl *************************************
198 AC_ARG_WITH([dbuspolicydir],
199 AS_HELP_STRING([--with-dbuspolicydirdir=DIR], [Directory for D-Bus system policy files]),
201 [with_dbuspolicydir=$(pkg-config --silence-errors --variable=sysconfdir dbus-1)/dbus-1/system.d])
202 AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
204 # Derive path for storing 'dbus' interface files (e. g. /usr/share/dbus-1/interfaces)
205 AC_ARG_WITH([dbusinterfacesdir],
206 AS_HELP_STRING([--with-dbusinterfacesdir=DIR], [Directory for D-Bus interface files]),
208 [with_dbusinterfacesdir=$(pkg-config --silence-errors --variable=interfaces_dir dbus-1)])
209 AC_SUBST([dbusinterfacesdir], [$with_dbusinterfacesdir])
211 dnl *******************************
212 dnl *** Define configure output ***
213 dnl *******************************
214 AC_CONFIG_FILES(Makefile src/Makefile test/Makefile generated/Makefile pkgconfig/libperscommon.pc)