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])
29 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
30 dnl Check whether a typedef exists and create a #define $2 if it exists
32 AC_DEFUN(GNUPG_CHECK_TYPEDEF,
33 [ AC_MSG_CHECKING(for $1 typedef)
34 AC_CACHE_VAL(gnupg_cv_typedef_$1,
35 [AC_TRY_COMPILE([#include <stdlib.h>
36 #include <sys/types.h>], [
39 ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
40 AC_MSG_RESULT($gnupg_cv_typedef_$1)
41 if test "$gnupg_cv_typedef_$1" = yes; then
43 [Define to 1 if $1 is defined in the <sys/types.h> header file.])
48 dnl ## GNU Pth - The GNU Portable Threads
49 dnl ## Copyright (c) 1999-2002 Ralf S. Engelschall <rse@engelschall.com>
51 dnl ## This file is part of GNU Pth, a non-preemptive thread scheduling
52 dnl ## library which can be found at http://www.gnu.org/software/pth/.
54 dnl ## This library is free software; you can redistribute it and/or
55 dnl ## modify it under the terms of the GNU Lesser General Public
56 dnl ## License as published by the Free Software Foundation; either
57 dnl ## version 2.1 of the License, or (at your option) any later version.
59 dnl ## This library is distributed in the hope that it will be useful,
60 dnl ## but WITHOUT ANY WARRANTY; without even the implied warranty of
61 dnl ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
62 dnl ## Lesser General Public License for more details.
64 dnl ## You should have received a copy of the GNU Lesser General Public
65 dnl ## License along with this library; if not, write to the Free Software
66 dnl ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
67 dnl ## USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
69 dnl ## pth.m4: Autoconf macro for locating GNU Pth from within
70 dnl ## configure.in of third-party software packages
75 dnl ## AC_CHECK_PTH([MIN-VERSION [, # minimum Pth version, e.g. 1.2.0
76 dnl ## DEFAULT-WITH-PTH [, # default value for --with-pth option
77 dnl ## DEFAULT-WITH-PTH-TEST [,# default value for --with-pth-test option
78 dnl ## EXTEND-VARS [, # whether CFLAGS/LDFLAGS/etc are extended
79 dnl ## ACTION-IF-FOUND [, # action to perform if Pth was found
80 dnl ## ACTION-IF-NOT-FOUND # action to perform if Pth was not found
83 dnl ## AC_CHECK_PTH(1.2.0)
84 dnl ## AC_CHECK_PTH(1.2.0,,,no,CFLAGS="$CFLAGS -DHAVE_PTH $PTH_CFLAGS")
85 dnl ## AC_CHECK_PTH(1.2.0,yes,yes,yes,CFLAGS="$CFLAGS -DHAVE_PTH")
88 dnl # auxilliary macros
89 AC_DEFUN(_AC_PTH_ERROR, [dnl
90 AC_MSG_RESULT([*FAILED*])
91 dnl define(_ac_pth_line,dnl
92 dnl "+------------------------------------------------------------------------+")
93 dnl echo " _ac_pth_line" 1>&2
94 cat <<EOT | sed -e 's/^[[ ]]*/ | /' -e 's/>>/ /' 1>&2
97 dnl echo " _ac_pth_line" 1>&2
98 dnl undefine(_ac_pth_line)
101 AC_DEFUN(_AC_PTH_VERBOSE, [dnl
102 if test ".$verbose" = .yes; then
107 AC_DEFUN(AC_CHECK_PTH, [dnl
110 AC_REQUIRE([AC_PROG_CC])dnl
111 AC_REQUIRE([AC_PROG_CPP])dnl
117 AC_SUBST(PTH_CPPFLAGS)
119 AC_SUBST(PTH_LDFLAGS)
121 dnl # command line options
122 AC_MSG_CHECKING(for GNU Pth)
125 [ --with-pth[=ARG] Build with GNU Pth Library (default=]ifelse([$2],,yes,$2)[)],dnl
127 with_pth="ifelse([$2],,yes,$2)"
129 AC_ARG_WITH(pth-test,dnl
130 [ --with-pth-test Perform GNU Pth Sanity Test (default=]ifelse([$3],,yes,$3)[)],dnl
132 with_pth_test="ifelse([$3],,yes,$3)"
134 _AC_PTH_VERBOSE([+ Command Line Options:])
135 _AC_PTH_VERBOSE([ o --with-pth=$with_pth])
136 _AC_PTH_VERBOSE([ o --with-pth-test=$with_pth_test])
139 if test ".$with_pth" != .no; then
146 _pth_subdir_opts=`echo $with_pth | sed -e 's/^subdir:[^ ]*[ ]*//'`
147 with_pth=`echo $with_pth | sed -e 's/^subdir:\([^ ]*\).*$/\1/'`
158 if test ".$with_pth" = .yes; then
159 # via config script in $PATH
161 _pth_version=`(pth-config --version) 2>/dev/null |\
162 sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
164 if test ".$_pth_version" != .; then
165 _pth_location=`pth-config --prefix`
166 _pth_type='installed'
167 _pth_cppflags=`pth-config --cflags`
168 _pth_cflags=`pth-config --cflags`
169 _pth_ldflags=`pth-config --ldflags`
170 _pth_libs=`pth-config --libs`
172 elif test -d "$with_pth"; then
173 with_pth=`echo $with_pth | sed -e 's;/*$;;'`
175 # via locally included source tree
176 if test ".$_pth_subdir" = .yes; then
177 _pth_location="$with_pth"
179 _pth_cppflags="-I$with_pth"
180 _pth_cflags="-I$with_pth"
181 if test -f "$with_pth/ltconfig"; then
182 _pth_ldflags="-L$with_pth/.libs"
184 _pth_ldflags="-L$with_pth"
188 _pth_version=`grep '^const char PTH_Hello' $with_pth/pth_vers.c |\
189 sed -e 's;^.*Version[ ]*\([0-9]*\.[0-9]*[.ab][0-9]*\)[ ].*$;\1;'`
192 ac_configure_args="$ac_configure_args --enable-subdir $_pth_subdir_opts"
195 # via config script under a specified directory
196 # (a standard installation, but not a source tree)
197 if test ".$_pth_found" = .no; then
198 for _dir in $with_pth/bin $with_pth; do
199 if test -f "$_dir/pth-config"; then
200 test -f "$_dir/pth-config.in" && continue # pth-config in source tree!
202 _pth_version=`($_dir/pth-config --version) 2>/dev/null |\
203 sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
205 if test ".$_pth_version" != .; then
206 _pth_location=`$_dir/pth-config --prefix`
207 _pth_type="installed"
208 _pth_cppflags=`$_dir/pth-config --cflags`
209 _pth_cflags=`$_dir/pth-config --cflags`
210 _pth_ldflags=`$_dir/pth-config --ldflags`
211 _pth_libs=`$_dir/pth-config --libs`
218 # in any subarea under a specified directory
219 # (either a special installation or a Pth source tree)
220 if test ".$_pth_found" = .no; then
223 for _file in x `find $with_pth -name "pth.h" -type f -print`; do
224 test .$_file = .x && continue
225 _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
226 _pth_version=`($_dir/pth-config --version) 2>/dev/null |\
227 sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
228 if test ".$_pth_version" = .; then
229 _pth_version=`grep '^#define PTH_VERSION_STR' $_file |\
230 sed -e 's;^#define[ ]*PTH_VERSION_STR[ ]*"\([0-9]*\.[0-9]*[.ab][0-9]*\)[ ].*$;\1;'`
232 _pth_cppflags="-I$_dir"
233 _pth_cflags="-I$_dir"
234 _pth_found=`expr $_pth_found + 1`
236 for _file in x `find $with_pth -name "libpth.[aso]" -type f -print`; do
237 test .$_file = .x && continue
238 _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
239 _pth_ldflags="-L$_dir"
241 _pth_found=`expr $_pth_found + 1`
244 if test ".$_pth_found" = .2; then
245 _pth_location="$with_pth"
246 _pth_type="uninstalled"
252 _AC_PTH_VERBOSE([+ Determined Location:])
253 _AC_PTH_VERBOSE([ o path: $_pth_location])
254 _AC_PTH_VERBOSE([ o type: $_pth_type])
255 if test ".$_pth_version" = .; then
256 if test ".$with_pth" != .yes; then
258 Unable to locate GNU Pth under $with_pth.
259 Please specify the correct path to either a GNU Pth installation tree
260 (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in
261 the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a
262 path to a pth-X.Y.Z/ directory; but make sure the package is already
263 built, i.e., the "configure; make" step was already performed there).])
266 Unable to locate GNU Pth in any system-wide location (see \$PATH).
267 Please specify the correct path to either a GNU Pth installation tree
268 (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in
269 the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a
270 path to a pth-X.Y.Z/ directory; but make sure the package is already
271 built, i.e., the "configure; make" step was already performed there).])
275 dnl # Check whether the found version is sufficiently new
277 _req_version="ifelse([$1],,1.0.0,$1)"
278 for _var in _pth_version _req_version; do
279 eval "_val=\"\$${_var}\""
280 _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
281 _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
282 _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
283 _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
289 _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
290 "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
291 eval "${_var}_hex=\"\$_hex\""
293 _AC_PTH_VERBOSE([+ Determined Versions:])
294 _AC_PTH_VERBOSE([ o existing: $_pth_version -> 0x$_pth_version_hex])
295 _AC_PTH_VERBOSE([ o required: $_req_version -> 0x$_req_version_hex])
297 if test ".$_pth_version_hex" != .; then
298 if test ".$_req_version_hex" != .; then
299 if test $_pth_version_hex -ge $_req_version_hex; then
304 if test ".$_ok" = .0; then
306 Found Pth version $_pth_version, but required at least version $_req_version.
307 Upgrade Pth under $_pth_location to $_req_version or higher first, please.])
310 dnl # Perform Pth Sanity Compile Check
312 if test ".$with_pth_test" = .yes; then
313 _ac_save_CPPFLAGS="$CPPFLAGS"
314 _ac_save_CFLAGS="$CFLAGS"
315 _ac_save_LDFLAGS="$LDFLAGS"
316 _ac_save_LIBS="$LIBS"
317 CPPFLAGS="$CPPFLAGS $_pth_cppflags"
318 CFLAGS="$CFLAGS $_pth_cflags"
319 LDFLAGS="$LDFLAGS $_pth_ldflags"
320 LIBS="$LIBS $_pth_libs"
321 _AC_PTH_VERBOSE([+ Test Build Environment:])
322 _AC_PTH_VERBOSE([ o CPPFLAGS=\"$CPPFLAGS\"])
323 _AC_PTH_VERBOSE([ o CFLAGS=\"$CFLAGS\"])
324 _AC_PTH_VERBOSE([ o LDFLAGS=\"$LDFLAGS\"])
325 _AC_PTH_VERBOSE([ o LIBS=\"$LIBS\"])
332 int main(int argc, char *argv[])
335 if (!(fp = fopen("conftestval", "w")))
341 if (!(fp = fopen("conftestval", "w")))
348 _AC_PTH_VERBOSE([+ Performing Sanity Checks:])
349 _AC_PTH_VERBOSE([ o pre-processor test])
350 AC_TRY_CPP(_code1, _ok=yes, _ok=no)
351 if test ".$_ok" != .yes; then
353 Found GNU Pth $_pth_version under $_pth_location, but
354 was unable to perform a sanity pre-processor check. This means
355 the GNU Pth header pth.h was not found.
356 We used the following build environment:
358 >> CPPFLAGS="$CPPFLAGS"
359 See config.log for possibly more details.])
361 _AC_PTH_VERBOSE([ o link check])
362 AC_TRY_LINK(_code1, _code2, _ok=yes, _ok=no)
363 if test ".$_ok" != .yes; then
365 Found GNU Pth $_pth_version under $_pth_location, but
366 was unable to perform a sanity linker check. This means
367 the GNU Pth library libpth.a was not found.
368 We used the following build environment:
371 >> LDFLAGS="$LDFLAGS"
373 See config.log for possibly more details.])
375 _AC_PTH_VERBOSE([ o run-time check])
376 AC_TRY_RUN(_code1 _code2, _ok=`cat conftestval`, _ok=no, _ok=no)
377 if test ".$_ok" != .yes; then
378 if test ".$_ok" = .no; then
380 Found GNU Pth $_pth_version under $_pth_location, but
381 was unable to perform a sanity execution check. This usually
382 means that the GNU Pth shared library libpth.so is present
383 but \$LD_LIBRARY_PATH is incomplete to execute a Pth test.
384 In this case either disable this test via --without-pth-test,
385 or extend \$LD_LIBRARY_PATH, or build GNU Pth as a static
386 library only via its --disable-shared Autoconf option.
387 We used the following build environment:
390 >> LDFLAGS="$LDFLAGS"
392 See config.log for possibly more details.])
395 Found GNU Pth $_pth_version under $_pth_location, but
396 was unable to perform a sanity run-time check. This usually
397 means that the GNU Pth library failed to work and possibly
398 caused a core dump in the test program. In this case it
399 is strongly recommended that you re-install GNU Pth and this
400 time make sure that it really passes its "make test" procedure.
401 We used the following build environment:
404 >> LDFLAGS="$LDFLAGS"
406 See config.log for possibly more details.])
409 _extendvars="ifelse([$4],,yes,$4)"
410 if test ".$_extendvars" != .yes; then
411 CPPFLAGS="$_ac_save_CPPFLAGS"
412 CFLAGS="$_ac_save_CFLAGS"
413 LDFLAGS="$_ac_save_LDFLAGS"
414 LIBS="$_ac_save_LIBS"
417 _extendvars="ifelse([$4],,yes,$4)"
418 if test ".$_extendvars" = .yes; then
419 if test ".$_pth_subdir" = .yes; then
420 CPPFLAGS="$CPPFLAGS $_pth_cppflags"
421 CFLAGS="$CFLAGS $_pth_cflags"
422 LDFLAGS="$LDFLAGS $_pth_ldflags"
423 LIBS="$LIBS $_pth_libs"
427 PTH_CPPFLAGS="$_pth_cppflags"
428 PTH_CFLAGS="$_pth_cflags"
429 PTH_LDFLAGS="$_pth_ldflags"
430 PTH_LIBS="$_pth_libs"
431 AC_SUBST(PTH_CPPFLAGS)
433 AC_SUBST(PTH_LDFLAGS)
435 _AC_PTH_VERBOSE([+ Final Results:])
436 _AC_PTH_VERBOSE([ o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"])
437 _AC_PTH_VERBOSE([ o PTH_CFLAGS=\"$PTH_CFLAGS\"])
438 _AC_PTH_VERBOSE([ o PTH_LDFLAGS=\"$PTH_LDFLAGS\"])
439 _AC_PTH_VERBOSE([ o PTH_LIBS=\"$PTH_LIBS\"])
441 if test ".$with_pth" != .no; then
442 AC_MSG_RESULT([version $_pth_version, $_pth_type under $_pth_location])
443 ifelse([$5], , :, [$5])
446 ifelse([$6], , :, [$6])