1 dnl Macros to configure gpgme
3 dnl GNUPG_FIX_HDR_VERSION(FILE, NAME)
4 dnl Make the version number in gcrypt/gcrypt.h the same as the one here.
5 dnl (this is easier than to have a .in file just for one substitution)
6 dnl We must use a temp file in the current directory because make distcheck
7 dnl install all sourcefiles RO.
9 AC_DEFUN(GNUPG_FIX_HDR_VERSION,
10 [ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > fixhdr.tmp
11 if cmp -s $srcdir/$1 fixhdr.tmp 2>/dev/null; then
15 if mv fixhdr.tmp $srcdir/$1 ; then
20 *** Failed to fix the version string macro $2 in $1.
21 *** The old file has been saved as fixhdr.tmp
24 AC_MSG_WARN([fixed the $2 macro in $1])
30 dnl ## GNU Pth - The GNU Portable Threads
31 dnl ## Copyright (c) 1999-2002 Ralf S. Engelschall <rse@engelschall.com>
33 dnl ## This file is part of GNU Pth, a non-preemptive thread scheduling
34 dnl ## library which can be found at http://www.gnu.org/software/pth/.
36 dnl ## This library is free software; you can redistribute it and/or
37 dnl ## modify it under the terms of the GNU Lesser General Public
38 dnl ## License as published by the Free Software Foundation; either
39 dnl ## version 2.1 of the License, or (at your option) any later version.
41 dnl ## This library is distributed in the hope that it will be useful,
42 dnl ## but WITHOUT ANY WARRANTY; without even the implied warranty of
43 dnl ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 dnl ## Lesser General Public License for more details.
46 dnl ## You should have received a copy of the GNU Lesser General Public
47 dnl ## License along with this library; if not, write to the Free Software
48 dnl ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
49 dnl ## USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
51 dnl ## pth.m4: Autoconf macro for locating GNU Pth from within
52 dnl ## configure.in of third-party software packages
57 dnl ## AC_CHECK_PTH([MIN-VERSION [, # minimum Pth version, e.g. 1.2.0
58 dnl ## DEFAULT-WITH-PTH [, # default value for --with-pth option
59 dnl ## DEFAULT-WITH-PTH-TEST [,# default value for --with-pth-test option
60 dnl ## EXTEND-VARS [, # whether CFLAGS/LDFLAGS/etc are extended
61 dnl ## ACTION-IF-FOUND [, # action to perform if Pth was found
62 dnl ## ACTION-IF-NOT-FOUND # action to perform if Pth was not found
65 dnl ## AC_CHECK_PTH(1.2.0)
66 dnl ## AC_CHECK_PTH(1.2.0,,,no,CFLAGS="$CFLAGS -DHAVE_PTH $PTH_CFLAGS")
67 dnl ## AC_CHECK_PTH(1.2.0,yes,yes,yes,CFLAGS="$CFLAGS -DHAVE_PTH")
70 dnl # auxilliary macros
71 AC_DEFUN(_AC_PTH_ERROR, [dnl
72 AC_MSG_RESULT([*FAILED*])
73 dnl define(_ac_pth_line,dnl
74 dnl "+------------------------------------------------------------------------+")
75 dnl echo " _ac_pth_line" 1>&2
76 cat <<EOT | sed -e 's/^[[ ]]*/ | /' -e 's/>>/ /' 1>&2
79 dnl echo " _ac_pth_line" 1>&2
80 dnl undefine(_ac_pth_line)
83 AC_DEFUN(_AC_PTH_VERBOSE, [dnl
84 if test ".$verbose" = .yes; then
89 AC_DEFUN(AC_CHECK_PTH, [dnl
92 AC_REQUIRE([AC_PROG_CC])dnl
93 AC_REQUIRE([AC_PROG_CPP])dnl
99 AC_SUBST(PTH_CPPFLAGS)
101 AC_SUBST(PTH_LDFLAGS)
103 dnl # command line options
104 AC_MSG_CHECKING(for GNU Pth)
107 [ --with-pth[=ARG] Build with GNU Pth Library (default=]ifelse([$2],,yes,$2)[)],dnl
109 with_pth="ifelse([$2],,yes,$2)"
111 AC_ARG_WITH(pth-test,dnl
112 [ --with-pth-test Perform GNU Pth Sanity Test (default=]ifelse([$3],,yes,$3)[)],dnl
114 with_pth_test="ifelse([$3],,yes,$3)"
116 _AC_PTH_VERBOSE([+ Command Line Options:])
117 _AC_PTH_VERBOSE([ o --with-pth=$with_pth])
118 _AC_PTH_VERBOSE([ o --with-pth-test=$with_pth_test])
121 if test ".$with_pth" != .no; then
128 _pth_subdir_opts=`echo $with_pth | sed -e 's/^subdir:[^ ]*[ ]*//'`
129 with_pth=`echo $with_pth | sed -e 's/^subdir:\([^ ]*\).*$/\1/'`
140 if test ".$with_pth" = .yes; then
141 # via config script in $PATH
143 _pth_version=`(pth-config --version) 2>/dev/null |\
144 sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
146 if test ".$_pth_version" != .; then
147 _pth_location=`pth-config --prefix`
148 _pth_type='installed'
149 _pth_cppflags=`pth-config --cflags`
150 _pth_cflags=`pth-config --cflags`
151 _pth_ldflags=`pth-config --ldflags`
152 _pth_libs=`pth-config --libs`
154 elif test -d "$with_pth"; then
155 with_pth=`echo $with_pth | sed -e 's;/*$;;'`
157 # via locally included source tree
158 if test ".$_pth_subdir" = .yes; then
159 _pth_location="$with_pth"
161 _pth_cppflags="-I$with_pth"
162 _pth_cflags="-I$with_pth"
163 if test -f "$with_pth/ltconfig"; then
164 _pth_ldflags="-L$with_pth/.libs"
166 _pth_ldflags="-L$with_pth"
170 _pth_version=`grep '^const char PTH_Hello' $with_pth/pth_vers.c |\
171 sed -e 's;^.*Version[ ]*\([0-9]*\.[0-9]*[.ab][0-9]*\)[ ].*$;\1;'`
174 ac_configure_args="$ac_configure_args --enable-subdir $_pth_subdir_opts"
177 # via config script under a specified directory
178 # (a standard installation, but not a source tree)
179 if test ".$_pth_found" = .no; then
180 for _dir in $with_pth/bin $with_pth; do
181 if test -f "$_dir/pth-config"; then
182 test -f "$_dir/pth-config.in" && continue # pth-config in source tree!
184 _pth_version=`($_dir/pth-config --version) 2>/dev/null |\
185 sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
187 if test ".$_pth_version" != .; then
188 _pth_location=`$_dir/pth-config --prefix`
189 _pth_type="installed"
190 _pth_cppflags=`$_dir/pth-config --cflags`
191 _pth_cflags=`$_dir/pth-config --cflags`
192 _pth_ldflags=`$_dir/pth-config --ldflags`
193 _pth_libs=`$_dir/pth-config --libs`
200 # in any subarea under a specified directory
201 # (either a special installation or a Pth source tree)
202 if test ".$_pth_found" = .no; then
205 for _file in x `find $with_pth -name "pth.h" -type f -print`; do
206 test .$_file = .x && continue
207 _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
208 _pth_version=`($_dir/pth-config --version) 2>/dev/null |\
209 sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
210 if test ".$_pth_version" = .; then
211 _pth_version=`grep '^#define PTH_VERSION_STR' $_file |\
212 sed -e 's;^#define[ ]*PTH_VERSION_STR[ ]*"\([0-9]*\.[0-9]*[.ab][0-9]*\)[ ].*$;\1;'`
214 _pth_cppflags="-I$_dir"
215 _pth_cflags="-I$_dir"
216 _pth_found=`expr $_pth_found + 1`
218 for _file in x `find $with_pth -name "libpth.[aso]" -type f -print`; do
219 test .$_file = .x && continue
220 _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
221 _pth_ldflags="-L$_dir"
223 _pth_found=`expr $_pth_found + 1`
226 if test ".$_pth_found" = .2; then
227 _pth_location="$with_pth"
228 _pth_type="uninstalled"
234 _AC_PTH_VERBOSE([+ Determined Location:])
235 _AC_PTH_VERBOSE([ o path: $_pth_location])
236 _AC_PTH_VERBOSE([ o type: $_pth_type])
237 if test ".$_pth_version" = .; then
240 dnl if test ".$with_pth" != .yes; then
241 dnl _AC_PTH_ERROR([dnl
242 dnl Unable to locate GNU Pth under $with_pth.
243 dnl Please specify the correct path to either a GNU Pth installation tree
244 dnl (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in
245 dnl the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a
246 dnl path to a pth-X.Y.Z/ directory; but make sure the package is already
247 dnl built, i.e., the "configure; make" step was already performed there).])
249 dnl _AC_PTH_ERROR([dnl
250 dnl Unable to locate GNU Pth in any system-wide location (see \$PATH).
251 dnl Please specify the correct path to either a GNU Pth installation tree
252 dnl (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in
253 dnl the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a
254 dnl path to a pth-X.Y.Z/ directory; but make sure the package is already
255 dnl built, i.e., the "configure; make" step was already performed there).])
259 dnl # Check whether the found version is sufficiently new
261 _req_version="ifelse([$1],,1.0.0,$1)"
262 for _var in _pth_version _req_version; do
263 eval "_val=\"\$${_var}\""
264 _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
265 _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
266 _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
267 _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
273 _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
274 "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
275 eval "${_var}_hex=\"\$_hex\""
277 _AC_PTH_VERBOSE([+ Determined Versions:])
278 _AC_PTH_VERBOSE([ o existing: $_pth_version -> 0x$_pth_version_hex])
279 _AC_PTH_VERBOSE([ o required: $_req_version -> 0x$_req_version_hex])
281 if test ".$_pth_version_hex" != .; then
282 if test ".$_req_version_hex" != .; then
283 if test $_pth_version_hex -ge $_req_version_hex; then
288 if test ".$_ok" = .0; then
290 Found Pth version $_pth_version, but required at least version $_req_version.
291 Upgrade Pth under $_pth_location to $_req_version or higher first, please.])
294 dnl # Perform Pth Sanity Compile Check
296 if test ".$with_pth_test" = .yes; then
297 _ac_save_CPPFLAGS="$CPPFLAGS"
298 _ac_save_CFLAGS="$CFLAGS"
299 _ac_save_LDFLAGS="$LDFLAGS"
300 _ac_save_LIBS="$LIBS"
301 CPPFLAGS="$CPPFLAGS $_pth_cppflags"
302 CFLAGS="$CFLAGS $_pth_cflags"
303 LDFLAGS="$LDFLAGS $_pth_ldflags"
304 LIBS="$LIBS $_pth_libs"
305 _AC_PTH_VERBOSE([+ Test Build Environment:])
306 _AC_PTH_VERBOSE([ o CPPFLAGS=\"$CPPFLAGS\"])
307 _AC_PTH_VERBOSE([ o CFLAGS=\"$CFLAGS\"])
308 _AC_PTH_VERBOSE([ o LDFLAGS=\"$LDFLAGS\"])
309 _AC_PTH_VERBOSE([ o LIBS=\"$LIBS\"])
316 int main(int argc, char *argv[])
319 if (!(fp = fopen("conftestval", "w")))
325 if (!(fp = fopen("conftestval", "w")))
332 _AC_PTH_VERBOSE([+ Performing Sanity Checks:])
333 _AC_PTH_VERBOSE([ o pre-processor test])
334 AC_TRY_CPP(_code1, _ok=yes, _ok=no)
335 if test ".$_ok" != .yes; then
337 Found GNU Pth $_pth_version under $_pth_location, but
338 was unable to perform a sanity pre-processor check. This means
339 the GNU Pth header pth.h was not found.
340 We used the following build environment:
342 >> CPPFLAGS="$CPPFLAGS"
343 See config.log for possibly more details.])
345 _AC_PTH_VERBOSE([ o link check])
346 AC_TRY_LINK(_code1, _code2, _ok=yes, _ok=no)
347 if test ".$_ok" != .yes; then
349 Found GNU Pth $_pth_version under $_pth_location, but
350 was unable to perform a sanity linker check. This means
351 the GNU Pth library libpth.a was not found.
352 We used the following build environment:
355 >> LDFLAGS="$LDFLAGS"
357 See config.log for possibly more details.])
359 _AC_PTH_VERBOSE([ o run-time check])
360 AC_TRY_RUN(_code1 _code2, _ok=`cat conftestval`, _ok=no, _ok=no)
361 if test ".$_ok" != .yes; then
362 if test ".$_ok" = .no; then
364 Found GNU Pth $_pth_version under $_pth_location, but
365 was unable to perform a sanity execution check. This usually
366 means that the GNU Pth shared library libpth.so is present
367 but \$LD_LIBRARY_PATH is incomplete to execute a Pth test.
368 In this case either disable this test via --without-pth-test,
369 or extend \$LD_LIBRARY_PATH, or build GNU Pth as a static
370 library only via its --disable-shared Autoconf option.
371 We used the following build environment:
374 >> LDFLAGS="$LDFLAGS"
376 See config.log for possibly more details.])
379 Found GNU Pth $_pth_version under $_pth_location, but
380 was unable to perform a sanity run-time check. This usually
381 means that the GNU Pth library failed to work and possibly
382 caused a core dump in the test program. In this case it
383 is strongly recommended that you re-install GNU Pth and this
384 time make sure that it really passes its "make test" procedure.
385 We used the following build environment:
388 >> LDFLAGS="$LDFLAGS"
390 See config.log for possibly more details.])
393 _extendvars="ifelse([$4],,yes,$4)"
394 if test ".$_extendvars" != .yes; then
395 CPPFLAGS="$_ac_save_CPPFLAGS"
396 CFLAGS="$_ac_save_CFLAGS"
397 LDFLAGS="$_ac_save_LDFLAGS"
398 LIBS="$_ac_save_LIBS"
401 _extendvars="ifelse([$4],,yes,$4)"
402 if test ".$_extendvars" = .yes; then
403 if test ".$_pth_subdir" = .yes; then
404 CPPFLAGS="$CPPFLAGS $_pth_cppflags"
405 CFLAGS="$CFLAGS $_pth_cflags"
406 LDFLAGS="$LDFLAGS $_pth_ldflags"
407 LIBS="$LIBS $_pth_libs"
411 PTH_CPPFLAGS="$_pth_cppflags"
412 PTH_CFLAGS="$_pth_cflags"
413 PTH_LDFLAGS="$_pth_ldflags"
414 PTH_LIBS="$_pth_libs"
415 AC_SUBST(PTH_CPPFLAGS)
417 AC_SUBST(PTH_LDFLAGS)
419 _AC_PTH_VERBOSE([+ Final Results:])
420 _AC_PTH_VERBOSE([ o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"])
421 _AC_PTH_VERBOSE([ o PTH_CFLAGS=\"$PTH_CFLAGS\"])
422 _AC_PTH_VERBOSE([ o PTH_LDFLAGS=\"$PTH_LDFLAGS\"])
423 _AC_PTH_VERBOSE([ o PTH_LIBS=\"$PTH_LIBS\"])
426 if test ".$with_pth" != .no; then
427 AC_MSG_RESULT([version $_pth_version, $_pth_type under $_pth_location])
428 ifelse([$5], , :, [$5])
431 ifelse([$6], , :, [$6])
435 dnl GNUPG_CHECK_VA_COPY()
436 dnl Do some check on how to implement va_copy.
437 dnl May define MUST_COPY_VA_BY_VAL.
438 dnl Actual test code taken from glib-1.1.
439 AC_DEFUN(GNUPG_CHECK_VA_COPY,
440 [ AC_MSG_CHECKING(whether va_lists must be copied by value)
441 AC_CACHE_VAL(gnupg_cv_must_copy_va_byval,[
442 gnupg_cv_must_copy_va_byval=no
447 va_list args1, args2;
450 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
461 ],gnupg_cv_must_copy_va_byval=yes)
463 if test "$gnupg_cv_must_copy_va_byval" = yes; then
464 AC_DEFINE(MUST_COPY_VA_BYVAL,1,[used to implement the va_copy macro])
466 AC_MSG_RESULT($gnupg_cv_must_copy_va_byval)
470 # glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40)
471 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
472 dnl This file is free software, distributed under the terms of the GNU
473 dnl General Public License. As a special exception to the GNU General
474 dnl Public License, this file may be distributed as part of a program
475 dnl that contains a configuration script generated by Autoconf, under
476 dnl the same distribution terms as the rest of that program.
478 # Test for the GNU C Library, version 2.1 or newer.
481 AC_DEFUN([jm_GLIBC21],
483 AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
484 ac_cv_gnu_library_2_1,
485 [AC_EGREP_CPP([Lucky GNU user],
487 #include <features.h>
488 #ifdef __GNU_LIBRARY__
489 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
494 ac_cv_gnu_library_2_1=yes,
495 ac_cv_gnu_library_2_1=no)
499 GLIBC21="$ac_cv_gnu_library_2_1"
504 dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
505 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
506 dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
508 dnl taken from libgpg-error 0.6
510 AC_DEFUN(AM_PATH_GPG_ERROR,
511 [ AC_ARG_WITH(gpg-error-prefix,
512 AC_HELP_STRING([--with-gpg-error-prefix=PFX],
513 [prefix where GPG Error is installed (optional)]),
514 gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
515 if test x$gpg_error_config_prefix != x ; then
516 if test x${GPG_ERROR_CONFIG+set} != xset ; then
517 GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
521 AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
522 min_gpg_error_version=ifelse([$1], ,0.0,$1)
523 AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
525 if test "$GPG_ERROR_CONFIG" != "no" ; then
526 req_major=`echo $min_gpg_error_version | \
527 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
528 req_minor=`echo $min_gpg_error_version | \
529 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
530 gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
531 major=`echo $gpg_error_config_version | \
532 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
533 minor=`echo $gpg_error_config_version | \
534 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
535 if test "$major" -gt "$req_major"; then
538 if test "$major" -eq "$req_major"; then
539 if test "$minor" -ge "$req_minor"; then
545 if test $ok = yes; then
546 GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
547 GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
549 ifelse([$2], , :, [$2])
554 ifelse([$3], , :, [$3])
556 AC_SUBST(GPG_ERROR_CFLAGS)
557 AC_SUBST(GPG_ERROR_LIBS)