diff options
-rw-r--r-- | configure.ac | 34 | ||||
-rw-r--r-- | m4/ax_lib_postgresql.m4 | 155 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/datacache/Makefile.am | 10 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_postgres.c | 1 | ||||
-rw-r--r-- | src/datastore/Makefile.am | 6 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 1 | ||||
-rw-r--r-- | src/include/gnunet_postgres_lib.h | 2 | ||||
-rw-r--r-- | src/namecache/Makefile.am | 2 | ||||
-rw-r--r-- | src/namestore/Makefile.am | 2 | ||||
-rw-r--r-- | src/postgres/Makefile.am | 2 |
11 files changed, 173 insertions, 44 deletions
diff --git a/configure.ac b/configure.ac index 6eb0d0375..cefc48243 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -666,35 +666,11 @@ AC_SUBST(SQLITE_LDFLAGS) | |||
666 | 666 | ||
667 | # test for postgres | 667 | # test for postgres |
668 | postgres=false | 668 | postgres=false |
669 | AC_MSG_CHECKING(for postgres) | 669 | AX_LIB_POSTGRESQL([]) |
670 | AC_ARG_WITH(postgres, | 670 | if test "$found_postgresql" = "yes"; then |
671 | [ --with-postgres=PFX base of postgres installation], | 671 | postgres=true |
672 | [AC_MSG_RESULT("$with_postgres") | 672 | fi |
673 | case $with_postgres in | 673 | AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue) |
674 | no) | ||
675 | ;; | ||
676 | yes) | ||
677 | AC_CHECK_HEADERS(postgresql/libpq-fe.h, | ||
678 | postgres=true) | ||
679 | ;; | ||
680 | *) | ||
681 | LDFLAGS="-L$with_postgres/lib $LDFLAGS" | ||
682 | CPPFLAGS="-I$with_postgres/include $CPPFLAGS" | ||
683 | AC_CHECK_HEADERS(postgresql/libpq-fe.h, | ||
684 | EXT_LIB_PATH="-L$with_postgres/lib $EXT_LIB_PATH" | ||
685 | POSTGRES_LDFLAGS="-L$with_postgres/lib" | ||
686 | POSTGRES_CPPFLAGS="-I$with_postgres/include" | ||
687 | postgres=true) | ||
688 | LDFLAGS=$SAVE_LDFLAGS | ||
689 | CPPFLAGS=$SAVE_CPPFLAGS | ||
690 | ;; | ||
691 | esac | ||
692 | ], | ||
693 | [AC_MSG_RESULT([--with-postgres not specified]) | ||
694 | AC_CHECK_HEADERS(postgresql/libpq-fe.h, postgres=true)]) | ||
695 | AM_CONDITIONAL(HAVE_POSTGRES, test x$postgres = xtrue) | ||
696 | AC_SUBST(POSTGRES_CPPFLAGS) | ||
697 | AC_SUBST(POSTGRES_LDFLAGS) | ||
698 | 674 | ||
699 | # test for zlib | 675 | # test for zlib |
700 | SAVE_LDFLAGS=$LDFLAGS | 676 | SAVE_LDFLAGS=$LDFLAGS |
diff --git a/m4/ax_lib_postgresql.m4 b/m4/ax_lib_postgresql.m4 new file mode 100644 index 000000000..f02a13ac5 --- /dev/null +++ b/m4/ax_lib_postgresql.m4 | |||
@@ -0,0 +1,155 @@ | |||
1 | # =========================================================================== | ||
2 | # http://www.gnu.org/software/autoconf-archive/ax_lib_postgresql.html | ||
3 | # =========================================================================== | ||
4 | # | ||
5 | # SYNOPSIS | ||
6 | # | ||
7 | # AX_LIB_POSTGRESQL([MINIMUM-VERSION]) | ||
8 | # | ||
9 | # DESCRIPTION | ||
10 | # | ||
11 | # This macro provides tests of availability of PostgreSQL 'libpq' library | ||
12 | # of particular version or newer. | ||
13 | # | ||
14 | # AX_LIB_POSTGRESQL macro takes only one argument which is optional. If | ||
15 | # there is no required version passed, then macro does not run version | ||
16 | # test. | ||
17 | # | ||
18 | # The --with-postgresql option takes one of three possible values: | ||
19 | # | ||
20 | # no - do not check for PostgreSQL client library | ||
21 | # | ||
22 | # yes - do check for PostgreSQL library in standard locations (pg_config | ||
23 | # should be in the PATH) | ||
24 | # | ||
25 | # path - complete path to pg_config utility, use this option if pg_config | ||
26 | # can't be found in the PATH | ||
27 | # | ||
28 | # This macro calls: | ||
29 | # | ||
30 | # AC_SUBST(POSTGRESQL_CPPFLAGS) | ||
31 | # AC_SUBST(POSTGRESQL_LDFLAGS) | ||
32 | # AC_SUBST(POSTGRESQL_VERSION) | ||
33 | # | ||
34 | # And sets: | ||
35 | # | ||
36 | # HAVE_POSTGRESQL | ||
37 | # | ||
38 | # LICENSE | ||
39 | # | ||
40 | # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net> | ||
41 | # | ||
42 | # Copying and distribution of this file, with or without modification, are | ||
43 | # permitted in any medium without royalty provided the copyright notice | ||
44 | # and this notice are preserved. This file is offered as-is, without any | ||
45 | # warranty. | ||
46 | |||
47 | #serial 9 | ||
48 | |||
49 | AC_DEFUN([AX_LIB_POSTGRESQL], | ||
50 | [ | ||
51 | AC_ARG_WITH([postgresql], | ||
52 | AS_HELP_STRING([--with-postgresql=@<:@ARG@:>@], | ||
53 | [use PostgreSQL library @<:@default=yes@:>@, optionally specify path to pg_config] | ||
54 | ), | ||
55 | [ | ||
56 | if test "$withval" = "no"; then | ||
57 | want_postgresql="no" | ||
58 | elif test "$withval" = "yes"; then | ||
59 | want_postgresql="yes" | ||
60 | else | ||
61 | want_postgresql="yes" | ||
62 | PG_CONFIG="$withval" | ||
63 | fi | ||
64 | ], | ||
65 | [want_postgresql="yes"] | ||
66 | ) | ||
67 | |||
68 | POSTGRESQL_CPPFLAGS="" | ||
69 | POSTGRESQL_LDFLAGS="" | ||
70 | POSTGRESQL_VERSION="" | ||
71 | |||
72 | dnl | ||
73 | dnl Check PostgreSQL libraries (libpq) | ||
74 | dnl | ||
75 | |||
76 | if test "$want_postgresql" = "yes"; then | ||
77 | |||
78 | if test -z "$PG_CONFIG" -o test; then | ||
79 | AC_PATH_PROG([PG_CONFIG], [pg_config], []) | ||
80 | fi | ||
81 | |||
82 | if test ! -x "$PG_CONFIG"; then | ||
83 | AC_MSG_ERROR([$PG_CONFIG does not exist or it is not an exectuable file]) | ||
84 | PG_CONFIG="no" | ||
85 | found_postgresql="no" | ||
86 | fi | ||
87 | |||
88 | if test "$PG_CONFIG" != "no"; then | ||
89 | AC_MSG_CHECKING([for PostgreSQL libraries]) | ||
90 | |||
91 | POSTGRESQL_CPPFLAGS="-I`$PG_CONFIG --includedir`" | ||
92 | POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir`" | ||
93 | |||
94 | POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` | ||
95 | |||
96 | AC_DEFINE([HAVE_POSTGRESQL], [1], | ||
97 | [Define to 1 if PostgreSQL libraries are available]) | ||
98 | |||
99 | found_postgresql="yes" | ||
100 | AC_MSG_RESULT([yes]) | ||
101 | else | ||
102 | found_postgresql="no" | ||
103 | AC_MSG_RESULT([no]) | ||
104 | fi | ||
105 | fi | ||
106 | |||
107 | dnl | ||
108 | dnl Check if required version of PostgreSQL is available | ||
109 | dnl | ||
110 | |||
111 | |||
112 | postgresql_version_req=ifelse([$1], [], [], [$1]) | ||
113 | |||
114 | if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then | ||
115 | |||
116 | AC_MSG_CHECKING([if PostgreSQL version is >= $postgresql_version_req]) | ||
117 | |||
118 | dnl Decompose required version string of PostgreSQL | ||
119 | dnl and calculate its number representation | ||
120 | postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'` | ||
121 | postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'` | ||
122 | postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` | ||
123 | if test "x$postgresql_version_req_micro" = "x"; then | ||
124 | postgresql_version_req_micro="0" | ||
125 | fi | ||
126 | |||
127 | postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \ | ||
128 | \+ $postgresql_version_req_minor \* 1000 \ | ||
129 | \+ $postgresql_version_req_micro` | ||
130 | |||
131 | dnl Decompose version string of installed PostgreSQL | ||
132 | dnl and calculate its number representation | ||
133 | postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'` | ||
134 | postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'` | ||
135 | postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` | ||
136 | if test "x$postgresql_version_micro" = "x"; then | ||
137 | postgresql_version_micro="0" | ||
138 | fi | ||
139 | |||
140 | postgresql_version_number=`expr $postgresql_version_major \* 1000000 \ | ||
141 | \+ $postgresql_version_minor \* 1000 \ | ||
142 | \+ $postgresql_version_micro` | ||
143 | |||
144 | postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number` | ||
145 | if test "$postgresql_version_check" = "1"; then | ||
146 | AC_MSG_RESULT([yes]) | ||
147 | else | ||
148 | AC_MSG_RESULT([no]) | ||
149 | fi | ||
150 | fi | ||
151 | |||
152 | AC_SUBST([POSTGRESQL_VERSION]) | ||
153 | AC_SUBST([POSTGRESQL_CPPFLAGS]) | ||
154 | AC_SUBST([POSTGRESQL_LDFLAGS]) | ||
155 | ]) | ||
diff --git a/src/Makefile.am b/src/Makefile.am index 902c3290b..18f8aeef2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -42,7 +42,7 @@ if HAVE_MYSQL | |||
42 | MYSQL_DIR = mysql | 42 | MYSQL_DIR = mysql |
43 | endif | 43 | endif |
44 | 44 | ||
45 | if HAVE_POSTGRES | 45 | if HAVE_POSTGRESQL |
46 | POSTGRES_DIR = postgres | 46 | POSTGRES_DIR = postgres |
47 | endif | 47 | endif |
48 | 48 | ||
diff --git a/src/datacache/Makefile.am b/src/datacache/Makefile.am index 7a89da852..941072396 100644 --- a/src/datacache/Makefile.am +++ b/src/datacache/Makefile.am | |||
@@ -19,7 +19,7 @@ endif | |||
19 | if HAVE_SQLITE | 19 | if HAVE_SQLITE |
20 | SQLITE_PLUGIN = libgnunet_plugin_datacache_sqlite.la | 20 | SQLITE_PLUGIN = libgnunet_plugin_datacache_sqlite.la |
21 | endif | 21 | endif |
22 | if HAVE_POSTGRES | 22 | if HAVE_POSTGRESQL |
23 | POSTGRES_PLUGIN = libgnunet_plugin_datacache_postgres.la | 23 | POSTGRES_PLUGIN = libgnunet_plugin_datacache_postgres.la |
24 | endif | 24 | endif |
25 | 25 | ||
@@ -68,11 +68,11 @@ libgnunet_plugin_datacache_postgres_la_LIBADD = \ | |||
68 | $(top_builddir)/src/postgres/libgnunetpostgres.la \ | 68 | $(top_builddir)/src/postgres/libgnunetpostgres.la \ |
69 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 69 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
70 | $(top_builddir)/src/util/libgnunetutil.la \ | 70 | $(top_builddir)/src/util/libgnunetutil.la \ |
71 | $(GN_PLUGIN_LDFLAGS) $(POSTGRES_LDFLAGS) -lpq | 71 | $(GN_PLUGIN_LDFLAGS) -lpq |
72 | libgnunet_plugin_datacache_postgres_la_CPPFLAGS = \ | 72 | libgnunet_plugin_datacache_postgres_la_CPPFLAGS = \ |
73 | $(POSTGRES_CPPFLAGS) $(AM_CPPFLAGS) | 73 | $(POSTGRESQL_CPPFLAGS) $(AM_CPPFLAGS) |
74 | libgnunet_plugin_datacache_postgres_la_LDFLAGS = \ | 74 | libgnunet_plugin_datacache_postgres_la_LDFLAGS = \ |
75 | $(GN_PLUGIN_LDFLAGS) $(POSTGRES_LDFLAGS) -lpq | 75 | $(GN_PLUGIN_LDFLAGS) $(POSTGRESQL_LDFLAGS) |
76 | 76 | ||
77 | libgnunet_plugin_datacache_template_la_SOURCES = \ | 77 | libgnunet_plugin_datacache_template_la_SOURCES = \ |
78 | plugin_datacache_template.c | 78 | plugin_datacache_template.c |
@@ -104,7 +104,7 @@ HEAP_TESTS = \ | |||
104 | test_datacache_quota_heap \ | 104 | test_datacache_quota_heap \ |
105 | $(HEAP_BENCHMARKS) | 105 | $(HEAP_BENCHMARKS) |
106 | 106 | ||
107 | if HAVE_POSTGRES | 107 | if HAVE_POSTGRESQL |
108 | if HAVE_BENCHMARKS | 108 | if HAVE_BENCHMARKS |
109 | POSTGRES_BENCHMARKS = \ | 109 | POSTGRES_BENCHMARKS = \ |
110 | perf_datacache_postgres | 110 | perf_datacache_postgres |
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c index 150a9d5dc..9e6774142 100644 --- a/src/datacache/plugin_datacache_postgres.c +++ b/src/datacache/plugin_datacache_postgres.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_postgres_lib.h" | 28 | #include "gnunet_postgres_lib.h" |
29 | #include "gnunet_datacache_plugin.h" | 29 | #include "gnunet_datacache_plugin.h" |
30 | #include <postgresql/libpq-fe.h> | ||
31 | 30 | ||
32 | #define LOG(kind,...) GNUNET_log_from (kind, "datacache-postgres", __VA_ARGS__) | 31 | #define LOG(kind,...) GNUNET_log_from (kind, "datacache-postgres", __VA_ARGS__) |
33 | 32 | ||
diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am index 7044cb46a..dc06790ae 100644 --- a/src/datastore/Makefile.am +++ b/src/datastore/Makefile.am | |||
@@ -85,7 +85,7 @@ endif | |||
85 | $(SQLITE_BENCHMARKS) | 85 | $(SQLITE_BENCHMARKS) |
86 | endif | 86 | endif |
87 | endif | 87 | endif |
88 | if HAVE_POSTGRES | 88 | if HAVE_POSTGRESQL |
89 | POSTGRES_PLUGIN = libgnunet_plugin_datastore_postgres.la | 89 | POSTGRES_PLUGIN = libgnunet_plugin_datastore_postgres.la |
90 | if HAVE_TESTING | 90 | if HAVE_TESTING |
91 | if HAVE_BENCHMARKS | 91 | if HAVE_BENCHMARKS |
@@ -146,9 +146,9 @@ libgnunet_plugin_datastore_postgres_la_LIBADD = \ | |||
146 | $(top_builddir)/src/postgres/libgnunetpostgres.la \ | 146 | $(top_builddir)/src/postgres/libgnunetpostgres.la \ |
147 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lpq | 147 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lpq |
148 | libgnunet_plugin_datastore_postgres_la_LDFLAGS = \ | 148 | libgnunet_plugin_datastore_postgres_la_LDFLAGS = \ |
149 | $(GN_PLUGIN_LDFLAGS) $(POSTGRES_LDFLAGS) -lpq | 149 | $(GN_PLUGIN_LDFLAGS) $(POSTGRESQL_LDFLAGS) |
150 | libgnunet_plugin_datastore_postgres_la_CPPFLAGS = \ | 150 | libgnunet_plugin_datastore_postgres_la_CPPFLAGS = \ |
151 | $(POSTGRES_CPPFLAGS) $(AM_CPPFLAGS) | 151 | $(POSTGRESQL_CPPFLAGS) $(AM_CPPFLAGS) |
152 | 152 | ||
153 | 153 | ||
154 | libgnunet_plugin_datastore_template_la_SOURCES = \ | 154 | libgnunet_plugin_datastore_template_la_SOURCES = \ |
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 54e5df375..e9495d35e 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_datastore_plugin.h" | 28 | #include "gnunet_datastore_plugin.h" |
29 | #include "gnunet_postgres_lib.h" | 29 | #include "gnunet_postgres_lib.h" |
30 | #include <postgresql/libpq-fe.h> | ||
31 | 30 | ||
32 | 31 | ||
33 | /** | 32 | /** |
diff --git a/src/include/gnunet_postgres_lib.h b/src/include/gnunet_postgres_lib.h index e2fc6b0e5..498d9857c 100644 --- a/src/include/gnunet_postgres_lib.h +++ b/src/include/gnunet_postgres_lib.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #define GNUNET_POSTGRES_LIB_H | 26 | #define GNUNET_POSTGRES_LIB_H |
27 | 27 | ||
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include <postgresql/libpq-fe.h> | 29 | #include <libpq-fe.h> |
30 | 30 | ||
31 | #ifdef __cplusplus | 31 | #ifdef __cplusplus |
32 | extern "C" | 32 | extern "C" |
diff --git a/src/namecache/Makefile.am b/src/namecache/Makefile.am index 921274593..eee9885d0 100644 --- a/src/namecache/Makefile.am +++ b/src/namecache/Makefile.am | |||
@@ -26,7 +26,7 @@ SQLITE_TESTS = test_plugin_namecache_sqlite | |||
26 | endif | 26 | endif |
27 | endif | 27 | endif |
28 | 28 | ||
29 | if HAVE_POSTGRES | 29 | if HAVE_POSTGRESQL |
30 | POSTGRES_PLUGIN = libgnunet_plugin_namecache_postgres.la | 30 | POSTGRES_PLUGIN = libgnunet_plugin_namecache_postgres.la |
31 | if HAVE_TESTING | 31 | if HAVE_TESTING |
32 | POSTGRES_TESTS = test_plugin_namecache_postgres | 32 | POSTGRES_TESTS = test_plugin_namecache_postgres |
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 17bd534c7..90e95f41c 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -26,7 +26,7 @@ SQLITE_TESTS = test_plugin_namestore_sqlite | |||
26 | endif | 26 | endif |
27 | endif | 27 | endif |
28 | 28 | ||
29 | if HAVE_POSTGRES | 29 | if HAVE_POSTGRESQL |
30 | # postgres doesn't even build yet; thus: experimental! | 30 | # postgres doesn't even build yet; thus: experimental! |
31 | POSTGRES_PLUGIN = libgnunet_plugin_namestore_postgres.la | 31 | POSTGRES_PLUGIN = libgnunet_plugin_namestore_postgres.la |
32 | if HAVE_TESTING | 32 | if HAVE_TESTING |
diff --git a/src/postgres/Makefile.am b/src/postgres/Makefile.am index a9a7cdfae..d005866b2 100644 --- a/src/postgres/Makefile.am +++ b/src/postgres/Makefile.am | |||
@@ -8,7 +8,7 @@ if USE_COVERAGE | |||
8 | AM_CFLAGS = --coverage | 8 | AM_CFLAGS = --coverage |
9 | endif | 9 | endif |
10 | 10 | ||
11 | if HAVE_POSTGRES | 11 | if HAVE_POSTGRESQL |
12 | lib_LTLIBRARIES = libgnunetpostgres.la | 12 | lib_LTLIBRARIES = libgnunetpostgres.la |
13 | endif | 13 | endif |
14 | 14 | ||