diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-11-21 00:47:06 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-11-21 00:47:06 +0100 |
commit | 8a039e9e8142bd95779fd8beb1b316be1a46668f (patch) | |
tree | 6c190c9b3f53b425de3df9a79b33c878d20801aa | |
parent | c737a34c0f9fd5011048331ed5851b0524dec740 (diff) | |
download | gnunet-8a039e9e8142bd95779fd8beb1b316be1a46668f.tar.gz gnunet-8a039e9e8142bd95779fd8beb1b316be1a46668f.zip |
fixing #5440: updating postgres test m4 macro
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | m4/Makefile.am | 2 | ||||
-rw-r--r-- | m4/ax_compare_version.m4 | 177 | ||||
-rw-r--r-- | m4/ax_lib_postgresql.m4 | 272 | ||||
-rw-r--r-- | m4/pkg.m4 | 320 |
5 files changed, 636 insertions, 149 deletions
diff --git a/configure.ac b/configure.ac index 69a7d0c24..45b2024a5 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1067,14 +1067,12 @@ CPPFLAGS=$SAVE_CPPFLAGS | |||
1067 | # test for postgres | 1067 | # test for postgres |
1068 | postgres=false | 1068 | postgres=false |
1069 | # even running the check for postgres breaks emscripten ... | 1069 | # even running the check for postgres breaks emscripten ... |
1070 | if test "$taler_only" != yes; then | 1070 | AS_IF([test "$taler_only" != yes], |
1071 | AX_LIB_POSTGRESQL([9.5]) | 1071 | [AX_LIB_POSTGRESQL([9.5], |
1072 | if test "x$found_postgresql" = "xyes"; then | 1072 | [CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS" |
1073 | CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS" | 1073 | AC_CHECK_HEADERS([libpq-fe.h], |
1074 | AC_CHECK_HEADERS([libpq-fe.h], | 1074 | postgres=true) |
1075 | postgres=true) | 1075 | ])]) |
1076 | fi | ||
1077 | fi | ||
1078 | AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue) | 1076 | AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue) |
1079 | 1077 | ||
1080 | 1078 | ||
diff --git a/m4/Makefile.am b/m4/Makefile.am index bce01daae..d41788460 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am | |||
@@ -1,5 +1,7 @@ | |||
1 | # This Makefile.am is in the public domain | 1 | # This Makefile.am is in the public domain |
2 | EXTRA_DIST = glibc2.m4 intl.m4 intldir.m4 lock.m4 visibility.m4 \ | 2 | EXTRA_DIST = glibc2.m4 intl.m4 intldir.m4 lock.m4 visibility.m4 \ |
3 | ax_compare_version.m4 \ | ||
4 | ax_lib_postgresql.m4 \ | ||
3 | absolute-header.m4 \ | 5 | absolute-header.m4 \ |
4 | libunistring.m4 \ | 6 | libunistring.m4 \ |
5 | codeset.m4 \ | 7 | codeset.m4 \ |
diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4 new file mode 100644 index 000000000..ffb4997e8 --- /dev/null +++ b/m4/ax_compare_version.m4 | |||
@@ -0,0 +1,177 @@ | |||
1 | # =========================================================================== | ||
2 | # https://www.gnu.org/software/autoconf-archive/ax_compare_version.html | ||
3 | # =========================================================================== | ||
4 | # | ||
5 | # SYNOPSIS | ||
6 | # | ||
7 | # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) | ||
8 | # | ||
9 | # DESCRIPTION | ||
10 | # | ||
11 | # This macro compares two version strings. Due to the various number of | ||
12 | # minor-version numbers that can exist, and the fact that string | ||
13 | # comparisons are not compatible with numeric comparisons, this is not | ||
14 | # necessarily trivial to do in a autoconf script. This macro makes doing | ||
15 | # these comparisons easy. | ||
16 | # | ||
17 | # The six basic comparisons are available, as well as checking equality | ||
18 | # limited to a certain number of minor-version levels. | ||
19 | # | ||
20 | # The operator OP determines what type of comparison to do, and can be one | ||
21 | # of: | ||
22 | # | ||
23 | # eq - equal (test A == B) | ||
24 | # ne - not equal (test A != B) | ||
25 | # le - less than or equal (test A <= B) | ||
26 | # ge - greater than or equal (test A >= B) | ||
27 | # lt - less than (test A < B) | ||
28 | # gt - greater than (test A > B) | ||
29 | # | ||
30 | # Additionally, the eq and ne operator can have a number after it to limit | ||
31 | # the test to that number of minor versions. | ||
32 | # | ||
33 | # eq0 - equal up to the length of the shorter version | ||
34 | # ne0 - not equal up to the length of the shorter version | ||
35 | # eqN - equal up to N sub-version levels | ||
36 | # neN - not equal up to N sub-version levels | ||
37 | # | ||
38 | # When the condition is true, shell commands ACTION-IF-TRUE are run, | ||
39 | # otherwise shell commands ACTION-IF-FALSE are run. The environment | ||
40 | # variable 'ax_compare_version' is always set to either 'true' or 'false' | ||
41 | # as well. | ||
42 | # | ||
43 | # Examples: | ||
44 | # | ||
45 | # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) | ||
46 | # AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) | ||
47 | # | ||
48 | # would both be true. | ||
49 | # | ||
50 | # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) | ||
51 | # AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) | ||
52 | # | ||
53 | # would both be false. | ||
54 | # | ||
55 | # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) | ||
56 | # | ||
57 | # would be true because it is only comparing two minor versions. | ||
58 | # | ||
59 | # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) | ||
60 | # | ||
61 | # would be true because it is only comparing the lesser number of minor | ||
62 | # versions of the two values. | ||
63 | # | ||
64 | # Note: The characters that separate the version numbers do not matter. An | ||
65 | # empty string is the same as version 0. OP is evaluated by autoconf, not | ||
66 | # configure, so must be a string, not a variable. | ||
67 | # | ||
68 | # The author would like to acknowledge Guido Draheim whose advice about | ||
69 | # the m4_case and m4_ifvaln functions make this macro only include the | ||
70 | # portions necessary to perform the specific comparison specified by the | ||
71 | # OP argument in the final configure script. | ||
72 | # | ||
73 | # LICENSE | ||
74 | # | ||
75 | # Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu> | ||
76 | # | ||
77 | # Copying and distribution of this file, with or without modification, are | ||
78 | # permitted in any medium without royalty provided the copyright notice | ||
79 | # and this notice are preserved. This file is offered as-is, without any | ||
80 | # warranty. | ||
81 | |||
82 | #serial 13 | ||
83 | |||
84 | dnl ######################################################################### | ||
85 | AC_DEFUN([AX_COMPARE_VERSION], [ | ||
86 | AC_REQUIRE([AC_PROG_AWK]) | ||
87 | |||
88 | # Used to indicate true or false condition | ||
89 | ax_compare_version=false | ||
90 | |||
91 | # Convert the two version strings to be compared into a format that | ||
92 | # allows a simple string comparison. The end result is that a version | ||
93 | # string of the form 1.12.5-r617 will be converted to the form | ||
94 | # 0001001200050617. In other words, each number is zero padded to four | ||
95 | # digits, and non digits are removed. | ||
96 | AS_VAR_PUSHDEF([A],[ax_compare_version_A]) | ||
97 | A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ | ||
98 | -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ | ||
99 | -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ | ||
100 | -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ | ||
101 | -e 's/[[^0-9]]//g'` | ||
102 | |||
103 | AS_VAR_PUSHDEF([B],[ax_compare_version_B]) | ||
104 | B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ | ||
105 | -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ | ||
106 | -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ | ||
107 | -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ | ||
108 | -e 's/[[^0-9]]//g'` | ||
109 | |||
110 | dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary | ||
111 | dnl # then the first line is used to determine if the condition is true. | ||
112 | dnl # The sed right after the echo is to remove any indented white space. | ||
113 | m4_case(m4_tolower($2), | ||
114 | [lt],[ | ||
115 | ax_compare_version=`echo "x$A | ||
116 | x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` | ||
117 | ], | ||
118 | [gt],[ | ||
119 | ax_compare_version=`echo "x$A | ||
120 | x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` | ||
121 | ], | ||
122 | [le],[ | ||
123 | ax_compare_version=`echo "x$A | ||
124 | x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` | ||
125 | ], | ||
126 | [ge],[ | ||
127 | ax_compare_version=`echo "x$A | ||
128 | x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` | ||
129 | ],[ | ||
130 | dnl Split the operator from the subversion count if present. | ||
131 | m4_bmatch(m4_substr($2,2), | ||
132 | [0],[ | ||
133 | # A count of zero means use the length of the shorter version. | ||
134 | # Determine the number of characters in A and B. | ||
135 | ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` | ||
136 | ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` | ||
137 | |||
138 | # Set A to no more than B's length and B to no more than A's length. | ||
139 | A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` | ||
140 | B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` | ||
141 | ], | ||
142 | [[0-9]+],[ | ||
143 | # A count greater than zero means use only that many subversions | ||
144 | A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` | ||
145 | B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` | ||
146 | ], | ||
147 | [.+],[ | ||
148 | AC_WARNING( | ||
149 | [invalid OP numeric parameter: $2]) | ||
150 | ],[]) | ||
151 | |||
152 | # Pad zeros at end of numbers to make same length. | ||
153 | ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" | ||
154 | B="$B`echo $A | sed 's/./0/g'`" | ||
155 | A="$ax_compare_version_tmp_A" | ||
156 | |||
157 | # Check for equality or inequality as necessary. | ||
158 | m4_case(m4_tolower(m4_substr($2,0,2)), | ||
159 | [eq],[ | ||
160 | test "x$A" = "x$B" && ax_compare_version=true | ||
161 | ], | ||
162 | [ne],[ | ||
163 | test "x$A" != "x$B" && ax_compare_version=true | ||
164 | ],[ | ||
165 | AC_WARNING([invalid OP parameter: $2]) | ||
166 | ]) | ||
167 | ]) | ||
168 | |||
169 | AS_VAR_POPDEF([A])dnl | ||
170 | AS_VAR_POPDEF([B])dnl | ||
171 | |||
172 | dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. | ||
173 | if test "$ax_compare_version" = "true" ; then | ||
174 | m4_ifvaln([$4],[$4],[:])dnl | ||
175 | m4_ifvaln([$5],[else $5])dnl | ||
176 | fi | ||
177 | ]) dnl AX_COMPARE_VERSION | ||
diff --git a/m4/ax_lib_postgresql.m4 b/m4/ax_lib_postgresql.m4 index 11b6991f0..cc8e75086 100644 --- a/m4/ax_lib_postgresql.m4 +++ b/m4/ax_lib_postgresql.m4 | |||
@@ -1,10 +1,10 @@ | |||
1 | # =========================================================================== | 1 | # =========================================================================== |
2 | # http://www.gnu.org/software/autoconf-archive/ax_lib_postgresql.html | 2 | # https://www.gnu.org/software/autoconf-archive/ax_lib_postgresql.html |
3 | # =========================================================================== | 3 | # =========================================================================== |
4 | # | 4 | # |
5 | # SYNOPSIS | 5 | # SYNOPSIS |
6 | # | 6 | # |
7 | # AX_LIB_POSTGRESQL([MINIMUM-VERSION]) | 7 | # AX_LIB_POSTGRESQL([MINIMUM-VERSION],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) |
8 | # | 8 | # |
9 | # DESCRIPTION | 9 | # DESCRIPTION |
10 | # | 10 | # |
@@ -23,133 +23,225 @@ | |||
23 | # should be in the PATH) | 23 | # should be in the PATH) |
24 | # | 24 | # |
25 | # path - complete path to pg_config utility, use this option if pg_config | 25 | # path - complete path to pg_config utility, use this option if pg_config |
26 | # can't be found in the PATH | 26 | # can't be found in the PATH (You could set also PG_CONFIG variable) |
27 | # | 27 | # |
28 | # This macro calls: | 28 | # This macro calls: |
29 | # | 29 | # |
30 | # AC_SUBST(POSTGRESQL_CPPFLAGS) | 30 | # AC_SUBST(POSTGRESQL_CPPFLAGS) |
31 | # AC_SUBST(POSTGRESQL_LDFLAGS) | 31 | # AC_SUBST(POSTGRESQL_LDFLAGS) |
32 | # AC_SUBST(POSTGRESQL_LIBS) | ||
32 | # AC_SUBST(POSTGRESQL_VERSION) | 33 | # AC_SUBST(POSTGRESQL_VERSION) |
33 | # | 34 | # |
34 | # And sets: | 35 | # And sets: |
35 | # | 36 | # |
36 | # HAVE_POSTGRESQL | 37 | # HAVE_POSTGRESQL |
37 | # | 38 | # |
39 | # It execute if found ACTION-IF-FOUND (empty by default) and | ||
40 | # ACTION-IF-NOT-FOUND (AC_MSG_FAILURE by default) if not found. | ||
41 | # | ||
38 | # LICENSE | 42 | # LICENSE |
39 | # | 43 | # |
40 | # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net> | 44 | # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net> |
45 | # Copyright (c) 2014 Sree Harsha Totakura <sreeharsha@totakura.in> | ||
46 | # Copyright (c) 2018 Bastien Roucaries <rouca@debian.org> | ||
41 | # | 47 | # |
42 | # Copying and distribution of this file, with or without modification, are | 48 | # Copying and distribution of this file, with or without modification, are |
43 | # permitted in any medium without royalty provided the copyright notice | 49 | # permitted in any medium without royalty provided the copyright notice |
44 | # and this notice are preserved. This file is offered as-is, without any | 50 | # and this notice are preserved. This file is offered as-is, without any |
45 | # warranty. | 51 | # warranty. |
46 | 52 | ||
47 | #serial 9 | 53 | #serial 22 |
54 | |||
55 | AC_DEFUN([_AX_LIB_POSTGRESQL_OLD],[ | ||
56 | found_postgresql="no" | ||
57 | _AX_LIB_POSTGRESQL_OLD_fail="no" | ||
58 | while true; do | ||
59 | AC_CACHE_CHECK([for the pg_config program], [ac_cv_path_PG_CONFIG], | ||
60 | [AC_PATH_PROGS_FEATURE_CHECK([PG_CONFIG], [pg_config], | ||
61 | [[ac_cv_path_PG_CONFIG="";$ac_path_PG_CONFIG --includedir > /dev/null \ | ||
62 | && ac_cv_path_PG_CONFIG=$ac_path_PG_CONFIG ac_path_PG_CONFIG_found=:]], | ||
63 | [ac_cv_path_PG_CONFIG=""])]) | ||
64 | PG_CONFIG=$ac_cv_path_PG_CONFIG | ||
65 | AS_IF([test "X$PG_CONFIG" = "X"],[break]) | ||
66 | |||
67 | AC_CACHE_CHECK([for the PostgreSQL libraries CPPFLAGS],[ac_cv_POSTGRESQL_CPPFLAGS], | ||
68 | [ac_cv_POSTGRESQL_CPPFLAGS="-I`$PG_CONFIG --includedir`" || _AX_LIB_POSTGRESQL_OLD_fail=yes]) | ||
69 | AS_IF([test "X$_AX_LIB_POSTGRESQL_OLD_fail" = "Xyes"],[break]) | ||
70 | POSTGRESQL_CPPFLAGS="$ac_cv_POSTGRESQL_CPPFLAGS" | ||
71 | |||
72 | AC_CACHE_CHECK([for the PostgreSQL libraries LDFLAGS],[ac_cv_POSTGRESQL_LDFLAGS], | ||
73 | [ac_cv_POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir`" || _AX_LIB_POSTGRESQL_OLD_fail=yes]) | ||
74 | AS_IF([test "X$_AX_LIB_POSTGRESQL_OLD_fail" = "Xyes"],[break]) | ||
75 | POSTGRESQL_LDFLAGS="$ac_cv_POSTGRESQL_LDFLAGS" | ||
76 | |||
77 | AC_CACHE_CHECK([for the PostgreSQL libraries LIBS],[ac_cv_POSTGRESQL_LIBS], | ||
78 | [ac_cv_POSTGRESQL_LIBS="-lpq"]) | ||
79 | POSTGRESQL_LIBS="$ac_cv_POSTGRESQL_LIBS" | ||
80 | |||
81 | AC_CACHE_CHECK([for the PostgreSQL version],[ac_cv_POSTGRESQL_VERSION], | ||
82 | [ | ||
83 | ac_cv_POSTGRESQL_VERSION=`$PG_CONFIG --version | sed "s/^PostgreSQL[[[:space:]]][[[:space:]]]*\([[0-9.]][[0-9.]]*\).*/\1/"` \ | ||
84 | || _AX_LIB_POSTGRESQL_OLD_fail=yes | ||
85 | ]) | ||
86 | AS_IF([test "X$_AX_LIB_POSTGRESQL_OLD_fail" = "Xyes"],[break]) | ||
87 | POSTGRESQL_VERSION="$ac_cv_POSTGRESQL_VERSION" | ||
88 | |||
89 | |||
90 | dnl | ||
91 | dnl Check if required version of PostgreSQL is available | ||
92 | dnl | ||
93 | AS_IF([test X"$postgresql_version_req" != "X"],[ | ||
94 | AC_MSG_CHECKING([if PostgreSQL version $POSTGRESQL_VERSION is >= $postgresql_version_req]) | ||
95 | AX_COMPARE_VERSION([$POSTGRESQL_VERSION],[ge],[$postgresql_version_req], | ||
96 | [found_postgresql_req_version=yes],[found_postgresql_req_version=no]) | ||
97 | AC_MSG_RESULT([$found_postgresql_req_version]) | ||
98 | ]) | ||
99 | AS_IF([test "Xfound_postgresql_req_version" = "Xno"],[break]) | ||
100 | |||
101 | found_postgresql="yes" | ||
102 | break | ||
103 | done | ||
104 | ]) | ||
48 | 105 | ||
49 | AC_DEFUN([AX_LIB_POSTGRESQL], | 106 | AC_DEFUN([_AX_LIB_POSTGRESQL_PKG_CONFIG], |
50 | [ | 107 | [ |
51 | AC_ARG_WITH([postgresql], | 108 | AC_REQUIRE([PKG_PROG_PKG_CONFIG]) |
52 | AS_HELP_STRING([--with-postgresql=@<:@ARG@:>@], | 109 | found_postgresql=no |
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 | 110 | ||
68 | POSTGRESQL_CPPFLAGS="" | 111 | while true; do |
69 | POSTGRESQL_LDFLAGS="" | 112 | PKG_PROG_PKG_CONFIG |
70 | POSTGRESQL_VERSION="" | 113 | AS_IF([test X$PKG_CONFIG = X],[break]) |
71 | 114 | ||
72 | dnl | 115 | _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=no; |
73 | dnl Check PostgreSQL libraries (libpq) | 116 | AS_IF([test "X$postgresql_version_req" = "X"], |
74 | dnl | 117 | [PKG_CHECK_EXISTS([libpq],[found_postgresql_pkg_config=yes],[found_postgresql=no])], |
118 | [PKG_CHECK_EXISTS([libpq >= "$postgresql_version_req"], | ||
119 | [found_postgresql=yes],[found_postgresql=no])]) | ||
120 | AS_IF([test "X$found_postgresql" = "no"],[break]) | ||
121 | |||
122 | AC_CACHE_CHECK([for the PostgreSQL libraries CPPFLAGS],[ac_cv_POSTGRESQL_CPPFLAGS], | ||
123 | [ac_cv_POSTGRESQL_CPPFLAGS="`$PKG_CONFIG libpq --cflags-only-I`" || _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=yes]) | ||
124 | AS_IF([test "X$_AX_LIB_POSTGRESQL_PKG_CONFIG_fail" = "Xyes"],[break]) | ||
125 | POSTGRESQL_CPPFLAGS="$ac_cv_POSTGRESQL_CPPFLAGS" | ||
75 | 126 | ||
76 | if test "$want_postgresql" = "yes"; then | ||
77 | 127 | ||
78 | if test -z "$PG_CONFIG" -o test; then | 128 | AC_CACHE_CHECK([for the PostgreSQL libraries LDFLAGS],[ac_cv_POSTGRESQL_LDFLAGS], |
79 | AC_PATH_PROG([PG_CONFIG], [pg_config], []) | 129 | [ac_cv_POSTGRESQL_LDFLAGS="`$PKG_CONFIG libpq --libs-only-L --libs-only-other`" || _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=yes]) |
80 | fi | 130 | AS_IF([test "X$_AX_LIB_POSTGRESQL_PKG_CONFIG_fail" = "Xyes"],[break]) |
131 | POSTGRESQL_LDFLAGS="$ac_cv_POSTGRESQL_LDFLAGS" | ||
81 | 132 | ||
82 | if test ! -x "$PG_CONFIG"; then | ||
83 | dnl 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 | 133 | ||
88 | if test "$PG_CONFIG" != "no"; then | 134 | AC_CACHE_CHECK([for the PostgreSQL libraries LIBS],[ac_cv_POSTGRESQL_LIBS], |
89 | AC_MSG_CHECKING([for PostgreSQL libraries]) | 135 | [ac_cv_POSTGRESQL_LIBS="`$PKG_CONFIG libpq --libs-only-l`" || _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=ye]) |
136 | AS_IF([test "X$_AX_LIB_POSTGRESQL_PKG_CONFIG_fail" = "Xyes"],[break]) | ||
137 | POSTGRESQL_LIBS="$ac_cv_POSTGRESQL_LIBS" | ||
90 | 138 | ||
91 | POSTGRESQL_CPPFLAGS="-I`$PG_CONFIG --includedir`" | 139 | dnl already checked by exist but need to be recovered |
92 | POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir`" | 140 | AC_CACHE_CHECK([for the PostgreSQL version],[ac_cv_POSTGRESQL_VERSION], |
141 | [ac_cv_POSTGRESQL_VERSION="`$PKG_CONFIG libpq --modversion`" || _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=yes]) | ||
142 | AS_IF([test "X$_AX_LIB_POSTGRESQL_PKG_CONFIG_fail" = "Xyes"],[break]) | ||
143 | POSTGRESQL_VERSION="$ac_cv_POSTGRESQL_VERSION" | ||
93 | 144 | ||
94 | POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##' | awk '{print $1}'` | 145 | found_postgresql=yes |
146 | break; | ||
147 | done | ||
95 | 148 | ||
96 | AC_DEFINE([HAVE_POSTGRESQL], [1], | 149 | ]) |
97 | [Define to 1 if PostgreSQL libraries are available]) | ||
98 | 150 | ||
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 | 151 | ||
107 | dnl | ||
108 | dnl Check if required version of PostgreSQL is available | ||
109 | dnl | ||
110 | 152 | ||
153 | AC_DEFUN([AX_LIB_POSTGRESQL], | ||
154 | [ | ||
155 | AC_ARG_WITH([postgresql], | ||
156 | AS_HELP_STRING([--with-postgresql=@<:@ARG@:>@], | ||
157 | [use PostgreSQL library @<:@default=yes@:>@, optionally specify path to pg_config] | ||
158 | ), | ||
159 | [ | ||
160 | AS_CASE([$withval], | ||
161 | [[[nN]][[oO]]],[want_postgresql="no"], | ||
162 | [[[yY]][[eE]][[sS]]],[want_postgresql="yes"], | ||
163 | [ | ||
164 | want_postgresql="yes" | ||
165 | PG_CONFIG="$withval" | ||
166 | ]) | ||
167 | ], | ||
168 | [want_postgresql="yes"] | ||
169 | ) | ||
170 | |||
171 | AC_ARG_VAR([POSTGRESQL_CPPFLAGS],[cpp flags for PostgreSQL overriding detected flags]) | ||
172 | AC_ARG_VAR([POSTGRESQL_LIBFLAGS],[libs for PostgreSQL overriding detected flags]) | ||
173 | AC_ARG_VAR([POSTGRESQL_LDFLAGS],[linker flags for PostgreSQL overriding detected flags]) | ||
174 | |||
175 | # populate cache | ||
176 | AS_IF([test "X$POSTGRESQL_CPPFLAGS" != X],[ac_cv_POSTGRESQL_CPPFLAGS="$POSTGRESQL_CPPFLAGS"]) | ||
177 | AS_IF([test "X$POSTGRESQL_LDFLAGS" != X],[ac_cv_POSTGRESQL_LDFLAGS="$POSTGRESQL_LDFLAGS"]) | ||
178 | AS_IF([test "X$POSTGRESQL_LIBS" != X],[ac_cv_POSTGRESQL_LIBS="$POSTGRESQL_LIBS"]) | ||
111 | 179 | ||
112 | postgresql_version_req=ifelse([$1], [], [], [$1]) | 180 | postgresql_version_req=ifelse([$1], [], [], [$1]) |
181 | found_postgresql="no" | ||
113 | 182 | ||
114 | if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then | 183 | POSTGRESQL_VERSION="" |
115 | 184 | ||
116 | AC_MSG_CHECKING([if PostgreSQL version $POSTGRESQL_VERSION is >= $postgresql_version_req]) | 185 | dnl |
117 | 186 | dnl Check PostgreSQL libraries (libpq) | |
118 | dnl Decompose required version string of PostgreSQL | 187 | dnl |
119 | dnl and calculate its number representation | 188 | AS_IF([test X"$want_postgresql" = "Xyes"],[ |
120 | postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'` | 189 | _AX_LIB_POSTGRESQL_PKG_CONFIG |
121 | postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'` | 190 | |
122 | postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` | 191 | |
123 | if test "x$postgresql_version_req_micro" = "x"; then | 192 | AS_IF([test X"$found_postgresql" = "Xno"], |
124 | postgresql_version_req_micro="0" | 193 | [_AX_LIB_POSTGRESQL_OLD]) |
125 | fi | 194 | |
126 | 195 | AS_IF([test X"$found_postgresql" = Xyes],[ | |
127 | postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \ | 196 | _AX_LIB_POSTGRESQL_OLD_CPPFLAGS="$CPPFLAGS" |
128 | \+ $postgresql_version_req_minor \* 1000 \ | 197 | CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS" |
129 | \+ $postgresql_version_req_micro` | 198 | _AX_LIB_POSTGRESQL_OLD_LDFLAGS="$LDFLAGS" |
130 | 199 | LDFLAGS="$LDFLAGS $POSTGRESQL_LDFLAGS" | |
131 | dnl Decompose version string of installed PostgreSQL | 200 | _AX_LIB_POSTGRESQL_OLD_LIBS="$LIBS" |
132 | dnl and calculate its number representation | 201 | LIBS="$LIBS $POSTGRESQL_LIBS" |
133 | postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'` | 202 | while true; do |
134 | postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'` | 203 | dnl try to compile |
135 | postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` | 204 | AC_CHECK_HEADER([libpq-fe.h],[],[found_postgresql=no]) |
136 | if test "x$postgresql_version_micro" = "x"; then | 205 | AS_IF([test "X$found_postgresql" = "Xno"],[break]) |
137 | postgresql_version_micro="0" | 206 | dnl try now to link |
138 | fi | 207 | AC_CACHE_CHECK([for the PostgreSQL library linking is working],[ac_cv_postgresql_found], |
139 | 208 | [ | |
140 | postgresql_version_number=`expr $postgresql_version_major \* 1000000 \ | 209 | AC_LINK_IFELSE([ |
141 | \+ $postgresql_version_minor \* 1000 \ | 210 | AC_LANG_PROGRAM( |
142 | \+ $postgresql_version_micro` | 211 | [ |
143 | 212 | #include <libpq-fe.h> | |
144 | postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number` | 213 | ], |
145 | if test "$postgresql_version_check" = "1"; then | 214 | [[ |
146 | AC_MSG_RESULT([yes]) | 215 | char conninfo[]="dbname = postgres"; |
147 | else | 216 | PGconn *conn; |
148 | AC_MSG_RESULT([no]) | 217 | conn = PQconnectdb(conninfo); |
149 | fi | 218 | ]] |
150 | fi | 219 | ) |
220 | ],[ac_cv_postgresql_found=yes], | ||
221 | [ac_cv_postgresql_found=no]) | ||
222 | ]) | ||
223 | found_postgresql="$ac_cv_postgresql_found" | ||
224 | AS_IF([test "X$found_postgresql" = "Xno"],[break]) | ||
225 | break | ||
226 | done | ||
227 | CPPFLAGS="$_AX_LIB_POSTGRESQL_OLD_CPPFLAGS" | ||
228 | LDFLAGS="$_AX_LIB_POSTGRESQL_OLD_LDFLAGS" | ||
229 | LIBS="$_AX_LIB_POSTGRESQL_OLD_LIBS" | ||
230 | ]) | ||
231 | |||
232 | |||
233 | AS_IF([test "x$found_postgresql" = "xyes"],[ | ||
234 | AC_DEFINE([HAVE_POSTGRESQL], [1], | ||
235 | [Define to 1 if PostgreSQL libraries are available])]) | ||
236 | ]) | ||
151 | 237 | ||
152 | AC_SUBST([POSTGRESQL_VERSION]) | 238 | AC_SUBST([POSTGRESQL_VERSION]) |
153 | AC_SUBST([POSTGRESQL_CPPFLAGS]) | 239 | AC_SUBST([POSTGRESQL_CPPFLAGS]) |
154 | AC_SUBST([POSTGRESQL_LDFLAGS]) | 240 | AC_SUBST([POSTGRESQL_LDFLAGS]) |
241 | AC_SUBST([POSTGRESQL_LIBS]) | ||
242 | |||
243 | AS_IF([test "x$found_postgresql" = "xyes"], | ||
244 | [ifelse([$2], , :, [$2])], | ||
245 | [ifelse([$3], , AS_IF([test X"$want_postgresql" = "Xyes"],[AC_MSG_ERROR([Library requirements (PostgreSQL) not met.])],[:]), [$3])]) | ||
246 | |||
155 | ]) | 247 | ]) |
@@ -1,57 +1,275 @@ | |||
1 | dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- | ||
2 | dnl serial 11 (pkg-config-0.29) | ||
3 | dnl | ||
4 | dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>. | ||
5 | dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com> | ||
6 | dnl | ||
7 | dnl This program is free software; you can redistribute it and/or modify | ||
8 | dnl it under the terms of the GNU General Public License as published by | ||
9 | dnl the Free Software Foundation; either version 2 of the License, or | ||
10 | dnl (at your option) any later version. | ||
11 | dnl | ||
12 | dnl This program is distributed in the hope that it will be useful, but | ||
13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | dnl General Public License for more details. | ||
16 | dnl | ||
17 | dnl You should have received a copy of the GNU General Public License | ||
18 | dnl along with this program; if not, write to the Free Software | ||
19 | dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
20 | dnl 02111-1307, USA. | ||
21 | dnl | ||
22 | dnl As a special exception to the GNU General Public License, if you | ||
23 | dnl distribute this file as part of a program that contains a | ||
24 | dnl configuration script generated by Autoconf, you may include it under | ||
25 | dnl the same distribution terms that you use for the rest of that | ||
26 | dnl program. | ||
1 | 27 | ||
2 | dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) | 28 | dnl PKG_PREREQ(MIN-VERSION) |
3 | dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page | 29 | dnl ----------------------- |
4 | dnl also defines GSTUFF_PKG_ERRORS on error | 30 | dnl Since: 0.29 |
5 | AC_DEFUN([PKG_CHECK_MODULES], [ | 31 | dnl |
6 | succeeded=no | 32 | dnl Verify that the version of the pkg-config macros are at least |
7 | 33 | dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's | |
8 | if test -z "$PKG_CONFIG"; then | 34 | dnl installed version of pkg-config, this checks the developer's version |
9 | AC_PATH_PROG(PKG_CONFIG, pkg-config, no) | 35 | dnl of pkg.m4 when generating configure. |
10 | fi | 36 | dnl |
11 | 37 | dnl To ensure that this macro is defined, also add: | |
12 | if test "$PKG_CONFIG" = "no" ; then | 38 | dnl m4_ifndef([PKG_PREREQ], |
13 | echo "*** The pkg-config script could not be found. Make sure it is" | 39 | dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) |
14 | echo "*** in your path, or set the PKG_CONFIG environment variable" | 40 | dnl |
15 | echo "*** to the full path to pkg-config." | 41 | dnl See the "Since" comment for each macro you use to see what version |
16 | echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config." | 42 | dnl of the macros you require. |
17 | else | 43 | m4_defun([PKG_PREREQ], |
18 | PKG_CONFIG_MIN_VERSION=0.9.0 | 44 | [m4_define([PKG_MACROS_VERSION], [0.29]) |
19 | if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then | 45 | m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, |
20 | AC_MSG_CHECKING(for $2) | 46 | [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) |
21 | 47 | ])dnl PKG_PREREQ | |
22 | if $PKG_CONFIG --exists "$2" ; then | 48 | |
23 | AC_MSG_RESULT(yes) | 49 | dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) |
24 | succeeded=yes | 50 | dnl ---------------------------------- |
25 | 51 | dnl Since: 0.16 | |
26 | AC_MSG_CHECKING($1_CFLAGS) | 52 | dnl |
27 | $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` | 53 | dnl Search for the pkg-config tool and set the PKG_CONFIG variable to |
28 | AC_MSG_RESULT($$1_CFLAGS) | 54 | dnl first found in the path. Checks that the version of pkg-config found |
29 | 55 | dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is | |
30 | AC_MSG_CHECKING($1_LIBS) | 56 | dnl used since that's the first version where most current features of |
31 | $1_LIBS=`$PKG_CONFIG --libs "$2"` | 57 | dnl pkg-config existed. |
32 | AC_MSG_RESULT($$1_LIBS) | 58 | AC_DEFUN([PKG_PROG_PKG_CONFIG], |
33 | else | 59 | [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) |
34 | $1_CFLAGS="" | 60 | m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) |
35 | $1_LIBS="" | 61 | m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) |
36 | ## If we have a custom action on failure, don't print errors, but | 62 | AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) |
37 | ## do set a variable so people can do so. | 63 | AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) |
38 | $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` | 64 | AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) |
39 | ifelse([$4], ,echo $$1_PKG_ERRORS,) | 65 | |
66 | if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then | ||
67 | AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) | ||
68 | fi | ||
69 | if test -n "$PKG_CONFIG"; then | ||
70 | _pkg_min_version=m4_default([$1], [0.9.0]) | ||
71 | AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) | ||
72 | if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then | ||
73 | AC_MSG_RESULT([yes]) | ||
74 | else | ||
75 | AC_MSG_RESULT([no]) | ||
76 | PKG_CONFIG="" | ||
77 | fi | ||
78 | fi[]dnl | ||
79 | ])dnl PKG_PROG_PKG_CONFIG | ||
80 | |||
81 | dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) | ||
82 | dnl ------------------------------------------------------------------- | ||
83 | dnl Since: 0.18 | ||
84 | dnl | ||
85 | dnl Check to see whether a particular set of modules exists. Similar to | ||
86 | dnl PKG_CHECK_MODULES(), but does not set variables or print errors. | ||
87 | dnl | ||
88 | dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) | ||
89 | dnl only at the first occurence in configure.ac, so if the first place | ||
90 | dnl it's called might be skipped (such as if it is within an "if", you | ||
91 | dnl have to call PKG_CHECK_EXISTS manually | ||
92 | AC_DEFUN([PKG_CHECK_EXISTS], | ||
93 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl | ||
94 | if test -n "$PKG_CONFIG" && \ | ||
95 | AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then | ||
96 | m4_default([$2], [:]) | ||
97 | m4_ifvaln([$3], [else | ||
98 | $3])dnl | ||
99 | fi]) | ||
100 | |||
101 | dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) | ||
102 | dnl --------------------------------------------- | ||
103 | dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting | ||
104 | dnl pkg_failed based on the result. | ||
105 | m4_define([_PKG_CONFIG], | ||
106 | [if test -n "$$1"; then | ||
107 | pkg_cv_[]$1="$$1" | ||
108 | elif test -n "$PKG_CONFIG"; then | ||
109 | PKG_CHECK_EXISTS([$3], | ||
110 | [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` | ||
111 | test "x$?" != "x0" && pkg_failed=yes ], | ||
112 | [pkg_failed=yes]) | ||
113 | else | ||
114 | pkg_failed=untried | ||
115 | fi[]dnl | ||
116 | ])dnl _PKG_CONFIG | ||
117 | |||
118 | dnl _PKG_SHORT_ERRORS_SUPPORTED | ||
119 | dnl --------------------------- | ||
120 | dnl Internal check to see if pkg-config supports short errors. | ||
121 | AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], | ||
122 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) | ||
123 | if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then | ||
124 | _pkg_short_errors_supported=yes | ||
125 | else | ||
126 | _pkg_short_errors_supported=no | ||
127 | fi[]dnl | ||
128 | ])dnl _PKG_SHORT_ERRORS_SUPPORTED | ||
129 | |||
130 | |||
131 | dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], | ||
132 | dnl [ACTION-IF-NOT-FOUND]) | ||
133 | dnl -------------------------------------------------------------- | ||
134 | dnl Since: 0.4.0 | ||
135 | dnl | ||
136 | dnl Note that if there is a possibility the first call to | ||
137 | dnl PKG_CHECK_MODULES might not happen, you should be sure to include an | ||
138 | dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac | ||
139 | AC_DEFUN([PKG_CHECK_MODULES], | ||
140 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl | ||
141 | AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl | ||
142 | AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl | ||
143 | |||
144 | pkg_failed=no | ||
145 | AC_MSG_CHECKING([for $1]) | ||
146 | |||
147 | _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) | ||
148 | _PKG_CONFIG([$1][_LIBS], [libs], [$2]) | ||
149 | |||
150 | m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS | ||
151 | and $1[]_LIBS to avoid the need to call pkg-config. | ||
152 | See the pkg-config man page for more details.]) | ||
153 | |||
154 | if test $pkg_failed = yes; then | ||
155 | AC_MSG_RESULT([no]) | ||
156 | _PKG_SHORT_ERRORS_SUPPORTED | ||
157 | if test $_pkg_short_errors_supported = yes; then | ||
158 | $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` | ||
159 | else | ||
160 | $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` | ||
40 | fi | 161 | fi |
162 | # Put the nasty error message in config.log where it belongs | ||
163 | echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD | ||
164 | |||
165 | m4_default([$4], [AC_MSG_ERROR( | ||
166 | [Package requirements ($2) were not met: | ||
167 | |||
168 | $$1_PKG_ERRORS | ||
169 | |||
170 | Consider adjusting the PKG_CONFIG_PATH environment variable if you | ||
171 | installed software in a non-standard prefix. | ||
172 | |||
173 | _PKG_TEXT])[]dnl | ||
174 | ]) | ||
175 | elif test $pkg_failed = untried; then | ||
176 | AC_MSG_RESULT([no]) | ||
177 | m4_default([$4], [AC_MSG_FAILURE( | ||
178 | [The pkg-config script could not be found or is too old. Make sure it | ||
179 | is in your PATH or set the PKG_CONFIG environment variable to the full | ||
180 | path to pkg-config. | ||
181 | |||
182 | _PKG_TEXT | ||
183 | |||
184 | To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl | ||
185 | ]) | ||
186 | else | ||
187 | $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS | ||
188 | $1[]_LIBS=$pkg_cv_[]$1[]_LIBS | ||
189 | AC_MSG_RESULT([yes]) | ||
190 | $3 | ||
191 | fi[]dnl | ||
192 | ])dnl PKG_CHECK_MODULES | ||
193 | |||
194 | |||
195 | dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], | ||
196 | dnl [ACTION-IF-NOT-FOUND]) | ||
197 | dnl --------------------------------------------------------------------- | ||
198 | dnl Since: 0.29 | ||
199 | dnl | ||
200 | dnl Checks for existence of MODULES and gathers its build flags with | ||
201 | dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags | ||
202 | dnl and VARIABLE-PREFIX_LIBS from --libs. | ||
203 | dnl | ||
204 | dnl Note that if there is a possibility the first call to | ||
205 | dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to | ||
206 | dnl include an explicit call to PKG_PROG_PKG_CONFIG in your | ||
207 | dnl configure.ac. | ||
208 | AC_DEFUN([PKG_CHECK_MODULES_STATIC], | ||
209 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl | ||
210 | _save_PKG_CONFIG=$PKG_CONFIG | ||
211 | PKG_CONFIG="$PKG_CONFIG --static" | ||
212 | PKG_CHECK_MODULES($@) | ||
213 | PKG_CONFIG=$_save_PKG_CONFIG[]dnl | ||
214 | ])dnl PKG_CHECK_MODULES_STATIC | ||
215 | |||
216 | |||
217 | dnl PKG_INSTALLDIR([DIRECTORY]) | ||
218 | dnl ------------------------- | ||
219 | dnl Since: 0.27 | ||
220 | dnl | ||
221 | dnl Substitutes the variable pkgconfigdir as the location where a module | ||
222 | dnl should install pkg-config .pc files. By default the directory is | ||
223 | dnl $libdir/pkgconfig, but the default can be changed by passing | ||
224 | dnl DIRECTORY. The user can override through the --with-pkgconfigdir | ||
225 | dnl parameter. | ||
226 | AC_DEFUN([PKG_INSTALLDIR], | ||
227 | [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) | ||
228 | m4_pushdef([pkg_description], | ||
229 | [pkg-config installation directory @<:@]pkg_default[@:>@]) | ||
230 | AC_ARG_WITH([pkgconfigdir], | ||
231 | [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, | ||
232 | [with_pkgconfigdir=]pkg_default) | ||
233 | AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) | ||
234 | m4_popdef([pkg_default]) | ||
235 | m4_popdef([pkg_description]) | ||
236 | ])dnl PKG_INSTALLDIR | ||
237 | |||
238 | |||
239 | dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) | ||
240 | dnl -------------------------------- | ||
241 | dnl Since: 0.27 | ||
242 | dnl | ||
243 | dnl Substitutes the variable noarch_pkgconfigdir as the location where a | ||
244 | dnl module should install arch-independent pkg-config .pc files. By | ||
245 | dnl default the directory is $datadir/pkgconfig, but the default can be | ||
246 | dnl changed by passing DIRECTORY. The user can override through the | ||
247 | dnl --with-noarch-pkgconfigdir parameter. | ||
248 | AC_DEFUN([PKG_NOARCH_INSTALLDIR], | ||
249 | [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) | ||
250 | m4_pushdef([pkg_description], | ||
251 | [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) | ||
252 | AC_ARG_WITH([noarch-pkgconfigdir], | ||
253 | [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, | ||
254 | [with_noarch_pkgconfigdir=]pkg_default) | ||
255 | AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) | ||
256 | m4_popdef([pkg_default]) | ||
257 | m4_popdef([pkg_description]) | ||
258 | ])dnl PKG_NOARCH_INSTALLDIR | ||
41 | 259 | ||
42 | AC_SUBST($1_CFLAGS) | ||
43 | AC_SUBST($1_LIBS) | ||
44 | else | ||
45 | echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." | ||
46 | echo "*** See http://www.freedesktop.org/software/pkgconfig" | ||
47 | fi | ||
48 | fi | ||
49 | 260 | ||
50 | if test $succeeded = yes; then | 261 | dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, |
51 | ifelse([$3], , :, [$3]) | 262 | dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
52 | else | 263 | dnl ------------------------------------------- |
53 | ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4]) | 264 | dnl Since: 0.28 |
54 | fi | 265 | dnl |
55 | ]) | 266 | dnl Retrieves the value of the pkg-config variable for the given module. |
267 | AC_DEFUN([PKG_CHECK_VAR], | ||
268 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl | ||
269 | AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl | ||
56 | 270 | ||
271 | _PKG_CONFIG([$1], [variable="][$3]["], [$2]) | ||
272 | AS_VAR_COPY([$1], [pkg_cv_][$1]) | ||
57 | 273 | ||
274 | AS_VAR_IF([$1], [""], [$5], [$4])dnl | ||
275 | ])dnl PKG_CHECK_VAR | ||