1dnl Autoconf macros for libgpgme 2dnl $Id$ 3 4# Configure paths for GPGME 5# Shamelessly stolen from the one of XDELTA by Owen Taylor 6# Werner Koch 2000-11-17 7 8dnl AM_PATH_GPGME([MINIMUM-VERSION, 9dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) 10dnl Test for gpgme, and define GPGME_CFLAGS and GPGME_LIBS 11dnl 12AC_DEFUN([AM_PATH_GPGME], 13[dnl 14dnl Get the cflags and libraries from the gpgme-config script 15dnl 16 AC_ARG_WITH(gpgme-prefix, 17 [ --with-gpgme-prefix=PFX Prefix where gpgme is installed (optional)], 18 gpgme_config_prefix="$withval", gpgme_config_prefix="") 19 AC_ARG_ENABLE(gpgmetest, 20 [ --disable-gpgmetest Do not try to compile and run a test gpgme program], 21 , enable_gpgmetest=yes) 22 23 if test x$gpgme_config_prefix != x ; then 24 gpgme_config_args="$gpgme_config_args --prefix=$gpgme_config_prefix" 25 if test x${GPGME_CONFIG+set} != xset ; then 26 GPGME_CONFIG=$gpgme_config_prefix/bin/gpgme-config 27 fi 28 fi 29 30 AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no) 31 min_gpgme_version=ifelse([$1], ,1.0.0,$1) 32 AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version) 33 no_gpgme="" 34 if test "$GPGME_CONFIG" = "no" ; then 35 no_gpgme=yes 36 else 37 GPGME_CFLAGS=`$GPGME_CONFIG $gpgme_config_args --cflags` 38 GPGME_LIBS=`$GPGME_CONFIG $gpgme_config_args --libs` 39 gpgme_config_version=`$GPGME_CONFIG $gpgme_config_args --version` 40 if test "x$enable_gpgmetest" = "xyes" ; then 41 ac_save_CFLAGS="$CFLAGS" 42 ac_save_LIBS="$LIBS" 43 CFLAGS="$CFLAGS $GPGME_CFLAGS" 44 LIBS="$LIBS $GPGME_LIBS" 45dnl 46dnl Now check if the installed gpgme is sufficiently new. Also sanity 47dnl checks the results of gpgme-config to some extent 48dnl 49 rm -f conf.gpgmetest 50 AC_TRY_RUN([ 51#include <stdio.h> 52#include <stdlib.h> 53#include <string.h> 54#include <gpgme.h> 55 56int 57main () 58{ 59 system ("touch conf.gpgmetest"); 60 61 if( strcmp( gpgme_check_version(NULL), "$gpgme_config_version" ) ) 62 { 63 printf("\n" 64"*** 'gpgme-config --version' returned %s, but GPGME (%s) was found!\n", 65 "$gpgme_config_version", gpgme_check_version(NULL) ); 66 printf( 67"*** If gpgme-config was correct, then it is best to remove the old\n" 68"*** version of GPGME. You may also be able to fix the error\n" 69"*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n" 70"*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n" 71"*** required on your system.\n" 72"*** If gpgme-config was wrong, set the environment variable GPGME_CONFIG\n" 73"*** to point to the correct copy of gpgme-config, \n" 74"*** and remove the file config.cache before re-running configure\n" 75 ); 76 } 77 else if ( strcmp(gpgme_check_version(NULL), GPGME_VERSION ) ) 78 { 79 printf("\n*** GPGME header file (version %s) does not match\n", 80 GPGME_VERSION); 81 printf("*** library (version %s)\n", gpgme_check_version(NULL) ); 82 } 83 else 84 { 85 if ( gpgme_check_version( "$min_gpgme_version" ) ) 86 return 0; 87 printf("no\n" 88"*** An old version of GPGME (%s) was found.\n", gpgme_check_version(NULL) ); 89 printf( 90"*** You need a version of GPGME newer than %s.\n", "$min_gpgme_version" ); 91 printf( 92"*** The latest version of GPGME is always available at\n" 93"*** ftp://ftp.gnupg.org/pub/gcrypt/alpha/gpgme/\n" 94"*** \n" 95"*** If you have already installed a sufficiently new version, this error\n" 96"*** probably means that the wrong copy of the gpgme-config shell script is\n" 97"*** being found. The easiest way to fix this is to remove the old version\n" 98"*** of GPGME, but you can also set the GPGME_CONFIG environment to point to\n" 99"*** the correct copy of gpgme-config. (In this case, you will have to\n" 100"*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n" 101"*** so that the correct libraries are found at run-time).\n" 102 ); 103 } 104 return 1; 105} 106],, no_gpgme=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 107 CFLAGS="$ac_save_CFLAGS" 108 LIBS="$ac_save_LIBS" 109 fi 110 fi 111 if test "x$no_gpgme" = x ; then 112 AC_MSG_RESULT(yes) 113 ifelse([$2], , :, [$2]) 114 else 115 if test -f conf.gpgmetest ; then 116 : 117 else 118 AC_MSG_RESULT(no) 119 fi 120 if test "$GPGME_CONFIG" = "no" ; then 121 echo "*** The gpgme-config script installed by GPGME could not be found" 122 echo "*** If GPGME was installed in PREFIX, make sure PREFIX/bin is in" 123 echo "*** your path, or set the GPGME_CONFIG environment variable to the" 124 echo "*** full path to gpgme-config." 125 else 126 if test -f conf.gpgmetest ; then 127 : 128 else 129 echo "*** Could not run gpgme test program, checking why..." 130 CFLAGS="$CFLAGS $GPGME_CFLAGS" 131 LIBS="$LIBS $GPGME_LIBS" 132 AC_TRY_LINK([ 133#include <stdio.h> 134#include <stdlib.h> 135#include <string.h> 136#include <gpgme.h> 137], [ gpgme_check_version(NULL); return 0 ], 138 [ 139echo "*** The test program compiled, but did not run. This usually means" 140echo "*** that the run-time linker is not finding GPGME or finding the wrong" 141echo "*** version of GPGME. If it is not finding GPGME, you'll need to set your" 142echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 143echo "*** to the installed location Also, make sure you have run ldconfig if" 144echo "*** that is required on your system" 145echo "***" 146echo "*** If you have an old version installed, it is best to remove it," 147echo "*** although you may also be able to get things to work by" 148echo "*** modifying LD_LIBRARY_PATH" 149echo "***" 150 ], 151 [ 152echo "*** The test program failed to compile or link. See the file config.log" 153echo "*** for the exact error that occured. This usually means GPGME was" 154echo "*** incorrectly installed or that you have moved GPGME since it was" 155echo "*** installed. In the latter case, you may want to edit the" 156echo "*** gpgme-config script: $GPGME_CONFIG" 157 ]) 158 CFLAGS="$ac_save_CFLAGS" 159 LIBS="$ac_save_LIBS" 160 fi 161 fi 162 GPGME_CFLAGS="" 163 GPGME_LIBS="" 164 ifelse([$3], , :, [$3]) 165 fi 166 AC_SUBST(GPGME_CFLAGS) 167 AC_SUBST(GPGME_LIBS) 168 rm -f conf.gpgmetest 169]) 170 171