gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34128 - in gnunet: . m4 src src/datacache src/datastore sr


From: gnunet
Subject: [GNUnet-SVN] r34128 - in gnunet: . m4 src src/datacache src/datastore src/include src/namecache src/namestore src/postgres
Date: Sat, 9 Aug 2014 00:20:48 +0200

Author: harsha
Date: 2014-08-09 00:20:48 +0200 (Sat, 09 Aug 2014)
New Revision: 34128

Added:
   gnunet/m4/ax_lib_postgresql.m4
Modified:
   gnunet/configure.ac
   gnunet/src/Makefile.am
   gnunet/src/datacache/Makefile.am
   gnunet/src/datacache/plugin_datacache_postgres.c
   gnunet/src/datastore/Makefile.am
   gnunet/src/datastore/plugin_datastore_postgres.c
   gnunet/src/include/gnunet_postgres_lib.h
   gnunet/src/namecache/Makefile.am
   gnunet/src/namestore/Makefile.am
   gnunet/src/postgres/Makefile.am
Log:
Include libpq-fe.h instead of postgres/libpq-fe.h.

Also add a macro for checking libpq from Autoconf macro archives.


Modified: gnunet/configure.ac
===================================================================
--- gnunet/configure.ac 2014-08-08 14:23:45 UTC (rev 34127)
+++ gnunet/configure.ac 2014-08-08 22:20:48 UTC (rev 34128)
@@ -666,35 +666,11 @@
 
 # test for postgres
 postgres=false
-AC_MSG_CHECKING(for postgres)
-AC_ARG_WITH(postgres,
-  [  --with-postgres=PFX       base of postgres installation],
-  [AC_MSG_RESULT("$with_postgres")
-   case $with_postgres in
-   no)
-     ;;
-   yes)
-    AC_CHECK_HEADERS(postgresql/libpq-fe.h,
-     postgres=true)
-     ;;
-   *)
-    LDFLAGS="-L$with_postgres/lib $LDFLAGS"
-    CPPFLAGS="-I$with_postgres/include $CPPFLAGS"
-    AC_CHECK_HEADERS(postgresql/libpq-fe.h,
-     EXT_LIB_PATH="-L$with_postgres/lib $EXT_LIB_PATH"
-     POSTGRES_LDFLAGS="-L$with_postgres/lib"
-     POSTGRES_CPPFLAGS="-I$with_postgres/include"
-     postgres=true)
-    LDFLAGS=$SAVE_LDFLAGS
-    CPPFLAGS=$SAVE_CPPFLAGS
-    ;;
-   esac
-  ],
-  [AC_MSG_RESULT([--with-postgres not specified])
-    AC_CHECK_HEADERS(postgresql/libpq-fe.h, postgres=true)])
-AM_CONDITIONAL(HAVE_POSTGRES, test x$postgres = xtrue)
-AC_SUBST(POSTGRES_CPPFLAGS)
-AC_SUBST(POSTGRES_LDFLAGS)
+AX_LIB_POSTGRESQL([])
+if test "$found_postgresql" = "yes"; then
+  postgres=true
+fi
+AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue)
 
 # test for zlib
 SAVE_LDFLAGS=$LDFLAGS

Added: gnunet/m4/ax_lib_postgresql.m4
===================================================================
--- gnunet/m4/ax_lib_postgresql.m4                              (rev 0)
+++ gnunet/m4/ax_lib_postgresql.m4      2014-08-08 22:20:48 UTC (rev 34128)
@@ -0,0 +1,155 @@
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_lib_postgresql.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_LIB_POSTGRESQL([MINIMUM-VERSION])
+#
+# DESCRIPTION
+#
+#   This macro provides tests of availability of PostgreSQL 'libpq' library
+#   of particular version or newer.
+#
+#   AX_LIB_POSTGRESQL macro takes only one argument which is optional. If
+#   there is no required version passed, then macro does not run version
+#   test.
+#
+#   The --with-postgresql option takes one of three possible values:
+#
+#   no - do not check for PostgreSQL client library
+#
+#   yes - do check for PostgreSQL library in standard locations (pg_config
+#   should be in the PATH)
+#
+#   path - complete path to pg_config utility, use this option if pg_config
+#   can't be found in the PATH
+#
+#   This macro calls:
+#
+#     AC_SUBST(POSTGRESQL_CPPFLAGS)
+#     AC_SUBST(POSTGRESQL_LDFLAGS)
+#     AC_SUBST(POSTGRESQL_VERSION)
+#
+#   And sets:
+#
+#     HAVE_POSTGRESQL
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Mateusz Loskot <address@hidden>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 9
+
+AC_DEFUN([AX_LIB_POSTGRESQL],
+[
+    AC_ARG_WITH([postgresql],
+        AS_HELP_STRING([--with-postgresql=@<:@ARG@:>@],
+            [use PostgreSQL library @<:@default=yes@:>@, optionally specify 
path to pg_config]
+        ),
+        [
+        if test "$withval" = "no"; then
+            want_postgresql="no"
+        elif test "$withval" = "yes"; then
+            want_postgresql="yes"
+        else
+            want_postgresql="yes"
+            PG_CONFIG="$withval"
+        fi
+        ],
+        [want_postgresql="yes"]
+    )
+
+    POSTGRESQL_CPPFLAGS=""
+    POSTGRESQL_LDFLAGS=""
+    POSTGRESQL_VERSION=""
+
+    dnl
+    dnl Check PostgreSQL libraries (libpq)
+    dnl
+
+    if test "$want_postgresql" = "yes"; then
+
+        if test -z "$PG_CONFIG" -o test; then
+            AC_PATH_PROG([PG_CONFIG], [pg_config], [])
+        fi
+
+        if test ! -x "$PG_CONFIG"; then
+            AC_MSG_ERROR([$PG_CONFIG does not exist or it is not an exectuable 
file])
+            PG_CONFIG="no"
+            found_postgresql="no"
+        fi
+
+        if test "$PG_CONFIG" != "no"; then
+            AC_MSG_CHECKING([for PostgreSQL libraries])
+
+            POSTGRESQL_CPPFLAGS="-I`$PG_CONFIG --includedir`"
+            POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir`"
+
+            POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL 
##'`
+
+            AC_DEFINE([HAVE_POSTGRESQL], [1],
+                [Define to 1 if PostgreSQL libraries are available])
+
+            found_postgresql="yes"
+            AC_MSG_RESULT([yes])
+        else
+            found_postgresql="no"
+            AC_MSG_RESULT([no])
+        fi
+    fi
+
+    dnl
+    dnl Check if required version of PostgreSQL is available
+    dnl
+
+
+    postgresql_version_req=ifelse([$1], [], [], [$1])
+
+    if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then
+
+        AC_MSG_CHECKING([if PostgreSQL version is >= $postgresql_version_req])
+
+        dnl Decompose required version string of PostgreSQL
+        dnl and calculate its number representation
+        postgresql_version_req_major=`expr $postgresql_version_req : 
'\([[0-9]]*\)'`
+        postgresql_version_req_minor=`expr $postgresql_version_req : 
'[[0-9]]*\.\([[0-9]]*\)'`
+        postgresql_version_req_micro=`expr $postgresql_version_req : 
'[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+        if test "x$postgresql_version_req_micro" = "x"; then
+            postgresql_version_req_micro="0"
+        fi
+
+        postgresql_version_req_number=`expr $postgresql_version_req_major \* 
1000000 \
+                                   \+ $postgresql_version_req_minor \* 1000 \
+                                   \+ $postgresql_version_req_micro`
+
+        dnl Decompose version string of installed PostgreSQL
+        dnl and calculate its number representation
+        postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'`
+        postgresql_version_minor=`expr $POSTGRESQL_VERSION : 
'[[0-9]]*\.\([[0-9]]*\)'`
+        postgresql_version_micro=`expr $POSTGRESQL_VERSION : 
'[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+        if test "x$postgresql_version_micro" = "x"; then
+            postgresql_version_micro="0"
+        fi
+
+        postgresql_version_number=`expr $postgresql_version_major \* 1000000 \
+                                   \+ $postgresql_version_minor \* 1000 \
+                                   \+ $postgresql_version_micro`
+
+        postgresql_version_check=`expr $postgresql_version_number \>\= 
$postgresql_version_req_number`
+        if test "$postgresql_version_check" = "1"; then
+            AC_MSG_RESULT([yes])
+        else
+            AC_MSG_RESULT([no])
+        fi
+    fi
+
+    AC_SUBST([POSTGRESQL_VERSION])
+    AC_SUBST([POSTGRESQL_CPPFLAGS])
+    AC_SUBST([POSTGRESQL_LDFLAGS])
+])

Modified: gnunet/src/Makefile.am
===================================================================
--- gnunet/src/Makefile.am      2014-08-08 14:23:45 UTC (rev 34127)
+++ gnunet/src/Makefile.am      2014-08-08 22:20:48 UTC (rev 34128)
@@ -42,7 +42,7 @@
  MYSQL_DIR = mysql
 endif
 
-if HAVE_POSTGRES
+if HAVE_POSTGRESQL
  POSTGRES_DIR = postgres
 endif
 

Modified: gnunet/src/datacache/Makefile.am
===================================================================
--- gnunet/src/datacache/Makefile.am    2014-08-08 14:23:45 UTC (rev 34127)
+++ gnunet/src/datacache/Makefile.am    2014-08-08 22:20:48 UTC (rev 34128)
@@ -19,7 +19,7 @@
 if HAVE_SQLITE
   SQLITE_PLUGIN = libgnunet_plugin_datacache_sqlite.la
 endif
-if HAVE_POSTGRES
+if HAVE_POSTGRESQL
   POSTGRES_PLUGIN = libgnunet_plugin_datacache_postgres.la
 endif
 
@@ -68,11 +68,11 @@
   $(top_builddir)/src/postgres/libgnunetpostgres.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/util/libgnunetutil.la \
-  $(GN_PLUGIN_LDFLAGS) $(POSTGRES_LDFLAGS) -lpq
+  $(GN_PLUGIN_LDFLAGS) -lpq
 libgnunet_plugin_datacache_postgres_la_CPPFLAGS = \
- $(POSTGRES_CPPFLAGS) $(AM_CPPFLAGS)
+ $(POSTGRESQL_CPPFLAGS) $(AM_CPPFLAGS)
 libgnunet_plugin_datacache_postgres_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS) $(POSTGRES_LDFLAGS) -lpq
+ $(GN_PLUGIN_LDFLAGS) $(POSTGRESQL_LDFLAGS)
 
 libgnunet_plugin_datacache_template_la_SOURCES = \
   plugin_datacache_template.c
@@ -104,7 +104,7 @@
  test_datacache_quota_heap \
  $(HEAP_BENCHMARKS)
 
-if HAVE_POSTGRES
+if HAVE_POSTGRESQL
 if HAVE_BENCHMARKS
  POSTGRES_BENCHMARKS = \
   perf_datacache_postgres

Modified: gnunet/src/datacache/plugin_datacache_postgres.c
===================================================================
--- gnunet/src/datacache/plugin_datacache_postgres.c    2014-08-08 14:23:45 UTC 
(rev 34127)
+++ gnunet/src/datacache/plugin_datacache_postgres.c    2014-08-08 22:20:48 UTC 
(rev 34128)
@@ -27,7 +27,6 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_postgres_lib.h"
 #include "gnunet_datacache_plugin.h"
-#include <postgresql/libpq-fe.h>
 
 #define LOG(kind,...) GNUNET_log_from (kind, "datacache-postgres", __VA_ARGS__)
 

Modified: gnunet/src/datastore/Makefile.am
===================================================================
--- gnunet/src/datastore/Makefile.am    2014-08-08 14:23:45 UTC (rev 34127)
+++ gnunet/src/datastore/Makefile.am    2014-08-08 22:20:48 UTC (rev 34128)
@@ -85,7 +85,7 @@
   $(SQLITE_BENCHMARKS)
 endif
 endif
-if HAVE_POSTGRES
+if HAVE_POSTGRESQL
  POSTGRES_PLUGIN = libgnunet_plugin_datastore_postgres.la
 if HAVE_TESTING
 if HAVE_BENCHMARKS
@@ -146,9 +146,9 @@
   $(top_builddir)/src/postgres/libgnunetpostgres.la \
   $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lpq
 libgnunet_plugin_datastore_postgres_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS) $(POSTGRES_LDFLAGS) -lpq
+ $(GN_PLUGIN_LDFLAGS) $(POSTGRESQL_LDFLAGS)
 libgnunet_plugin_datastore_postgres_la_CPPFLAGS = \
- $(POSTGRES_CPPFLAGS) $(AM_CPPFLAGS)
+ $(POSTGRESQL_CPPFLAGS) $(AM_CPPFLAGS)
 
 
 libgnunet_plugin_datastore_template_la_SOURCES = \

Modified: gnunet/src/datastore/plugin_datastore_postgres.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_postgres.c    2014-08-08 14:23:45 UTC 
(rev 34127)
+++ gnunet/src/datastore/plugin_datastore_postgres.c    2014-08-08 22:20:48 UTC 
(rev 34128)
@@ -27,7 +27,6 @@
 #include "platform.h"
 #include "gnunet_datastore_plugin.h"
 #include "gnunet_postgres_lib.h"
-#include <postgresql/libpq-fe.h>
 
 
 /**

Modified: gnunet/src/include/gnunet_postgres_lib.h
===================================================================
--- gnunet/src/include/gnunet_postgres_lib.h    2014-08-08 14:23:45 UTC (rev 
34127)
+++ gnunet/src/include/gnunet_postgres_lib.h    2014-08-08 22:20:48 UTC (rev 
34128)
@@ -26,7 +26,7 @@
 #define GNUNET_POSTGRES_LIB_H
 
 #include "gnunet_util_lib.h"
-#include <postgresql/libpq-fe.h>
+#include <libpq-fe.h>
 
 #ifdef __cplusplus
 extern "C"

Modified: gnunet/src/namecache/Makefile.am
===================================================================
--- gnunet/src/namecache/Makefile.am    2014-08-08 14:23:45 UTC (rev 34127)
+++ gnunet/src/namecache/Makefile.am    2014-08-08 22:20:48 UTC (rev 34128)
@@ -26,7 +26,7 @@
 endif
 endif
 
-if HAVE_POSTGRES
+if HAVE_POSTGRESQL
 POSTGRES_PLUGIN = libgnunet_plugin_namecache_postgres.la
 if HAVE_TESTING
 POSTGRES_TESTS = test_plugin_namecache_postgres

Modified: gnunet/src/namestore/Makefile.am
===================================================================
--- gnunet/src/namestore/Makefile.am    2014-08-08 14:23:45 UTC (rev 34127)
+++ gnunet/src/namestore/Makefile.am    2014-08-08 22:20:48 UTC (rev 34128)
@@ -26,7 +26,7 @@
 endif
 endif
 
-if HAVE_POSTGRES
+if HAVE_POSTGRESQL
 # postgres doesn't even build yet; thus: experimental!
 POSTGRES_PLUGIN = libgnunet_plugin_namestore_postgres.la
 if HAVE_TESTING

Modified: gnunet/src/postgres/Makefile.am
===================================================================
--- gnunet/src/postgres/Makefile.am     2014-08-08 14:23:45 UTC (rev 34127)
+++ gnunet/src/postgres/Makefile.am     2014-08-08 22:20:48 UTC (rev 34128)
@@ -8,7 +8,7 @@
   AM_CFLAGS = --coverage
 endif
 
-if HAVE_POSTGRES
+if HAVE_POSTGRESQL
 lib_LTLIBRARIES = libgnunetpostgres.la
 endif
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]