1# 2# Configure paths for xmlsec1 3# H. Ronsdorf 2006-02-03 4# Adapted from: 5# 6dnl AM_PATH_XMLSEC1([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 7dnl Test for libxmlsec1, and define XMLSEC1_CFLAGS and XMLSEC1_LIBS 8dnl 9AC_DEFUN([AM_PATH_XMLSEC1],[ 10 11 AC_ARG_WITH(xmlsec1-prefix, 12 AC_HELP_STRING( 13 [--with-xmlsec1-prefix=PFX], 14 [Prefix where libxmlsec1 is installed (optional)] 15 ), 16 xmlsec1_config_prefix="$withval", xmlsec1_config_prefix="" 17 ) 18 19 AC_ARG_WITH(xmlsec1-exec-prefix, 20 AC_HELP_STRING( 21 [--with-xmlsec1-exec-prefix=PFX], 22 [Exec prefix where libxmlsec1 is installed (optional)] 23 ), 24 xmlsec1_config_exec_prefix="$withval", xmlsec1_config_exec_prefix="" 25 ) 26 27 AC_ARG_ENABLE(xmlsec1test, 28 AC_HELP_STRING( 29 [--disable-xmlsec1test], 30 [Do not try to compile and run a test cSOAP program] 31 ),, 32 enable_xmlsec1test=yes 33 ) 34 35 if test x$xmlsec1_config_exec_prefix != x ; then 36 xmlsec1_config_args="$xmlsec1_config_args --exec-prefix=$xmlsec1_config_exec_prefix" 37 if test x${XMLSEC1_CONFIG+set} != xset ; then 38 XMLSEC1_CONFIG=$xmlsec1_config_exec_prefix/bin/xmlsec1-config 39 fi 40 fi 41 if test x$xmlsec1_config_prefix != x ; then 42 xmlsec1_config_args="$xmlsec1_config_args --prefix=$xmlsec1_config_prefix" 43 if test x${XMLSEC1_CONFIG+set} != xset ; then 44 XMLSEC1_CONFIG=$xmlsec1_config_prefix/bin/xmlsec1-config 45 fi 46 fi 47 48 49 AC_PATH_PROG(XMLSEC1_CONFIG, xmlsec1-config, no) 50 min_xmlsec1_version=ifelse([$1], ,1.0.0,[$1]) 51 AC_MSG_CHECKING(for libxmlsec1 - version >= $min_xmlsec1_version) 52 no_xmlsec1="" 53 if test "$XMLSEC1_CONFIG" = "no" ; then 54 no_xmlsec1=yes 55 else 56 XMLSEC1_CFLAGS=`$XMLSEC1_CONFIG $xmlsec1_config_args --cflags` 57 XMLSEC1_LIBS=`$XMLSEC1_CONFIG $xmlsec1_config_args --libs` 58 xmlsec1_config_major_version=`$XMLSEC1_CONFIG $xmlsec1_config_args --version | \ 59 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 60 xmlsec1_config_minor_version=`$XMLSEC1_CONFIG $xmlsec1_config_args --version | \ 61 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 62 xmlsec1_config_micro_version=`$XMLSEC1_CONFIG $xmlsec1_config_args --version | \ 63 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 64 if test "x$enable_xmlsec1test" = "xyes" ; then 65 ac_save_CFLAGS="$CFLAGS" 66 ac_save_LIBS="$LIBS" 67 CFLAGS="$CFLAGS $XMLSEC1_CFLAGS" 68 LIBS="$XMLSEC1_LIBS $LIBS" 69dnl 70dnl Now check if the installed libxmlsec1 is sufficiently new. 71dnl (Also sanity checks the results of xmlsec1-config to some extent) 72dnl 73 rm -f conf.xmlsec1test 74 AC_TRY_RUN([ 75#include <stdlib.h> 76#include <stdio.h> 77#include <string.h> 78#include <libxml/tree.h> 79#include <xmlsec/xmlsec.h> 80 81int main(int argc, char **argv) { 82 83 int major, minor, micro; 84 char *tmp_version; 85 86 system("touch conf.xmlsec1test"); 87 88 /* Capture xmlsec1-config output via autoconf/configure variables */ 89 /* HP/UX 9 (%@#!) writes to sscanf strings */ 90 tmp_version = (char *)strdup("$min_xmlsec1_version"); 91 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 92 93 printf("%s, bad version string from xmlsec1-config\n", "$min_xmlsec1_version"); 94 exit(1); 95 } 96 free(tmp_version); 97 98 /* Test that the library is greater than our minimum version */ 99 if (($xmlsec1_config_major_version < major) || 100 (($xmlsec1_config_major_version == major) && ($xmlsec1_config_minor_version < minor)) || 101 (($xmlsec1_config_major_version == major) && ($xmlsec1_config_minor_version == minor) && ($xmlsec1_config_micro_version < micro))) { 102 103 printf("\n*** An old version of libxmlsec1 (%d.%d.%d) was found.\n", $xmlsec1_config_major_version, $xmlsec1_config_minor_version, $xmlsec1_config_micro_version); 104 printf("*** You need a version of libxmlsec1 newer than %d.%d.%d. The latest version of\n", major, minor, micro); 105 printf("*** libxmlsec1 is always available from http://xmlsec1.sf.net.\n\n"); 106 printf("*** If you have already installed a sufficiently new version, this error\n"); 107 printf("*** probably means that the wrong copy of the xmlsec1-config shell script is\n"); 108 printf("*** being found. The easiest way to fix this is to remove the old version\n"); 109 printf("*** of libxmlsec1, but you can also set the XMLSEC1_CONFIG environment to point to the\n"); 110 printf("*** correct copy of xmlsec1-config. (In this case, you will have to\n"); 111 printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n"); 112 printf("*** so that the correct libraries are found at run-time))\n"); 113 return 1; 114 } 115 else { 116 117 return 0; 118 } 119} 120],, no_xmlsec1=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 121 CFLAGS="$ac_save_CFLAGS" 122 LIBS="$ac_save_LIBS" 123 fi 124 fi 125 126 if test "x$no_xmlsec1" = x ; then 127 AC_MSG_RESULT(yes (version $xmlsec1_config_major_version.$xmlsec1_config_minor_version.$xmlsec1_config_micro_version)) 128 ifelse([$2], , :, [$2]) 129 else 130 AC_MSG_RESULT(no) 131 if test "$XMLSEC1_CONFIG" = "no" ; then 132 echo "*** The xmlsec1-config script installed by LIBXMLSEC1 could not be found" 133 echo "*** If libxmlsec1 was installed in PREFIX, make sure PREFIX/bin is in" 134 echo "*** your path, or set the XMLSEC1_CONFIG environment variable to the" 135 echo "*** full path to xmlsec1-config." 136 else 137 if test -f conf.xmlsec1test ; then 138 : 139 else 140 echo "*** Could not run libxmlsec1 test program, checking why..." 141 CFLAGS="$CFLAGS $XMLSEC1_CFLAGS" 142 LIBS="$LIBS $XMLSEC1_LIBS" 143 AC_TRY_LINK([ 144#include <libxmlsec1/version.h> 145#include <stdio.h> 146], [ soap_client_destroy(); return 0;], 147 [ echo "*** The test program compiled, but did not run. This usually means" 148 echo "*** that the run-time linker is not finding LIBXMLSEC1 or finding the wrong" 149 echo "*** version of LIBXMLSEC1. If it is not finding LIBXMLSEC1, you'll need to set your" 150 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 151 echo "*** to the installed location Also, make sure you have run ldconfig if that" 152 echo "*** is required on your system" 153 echo "***" 154 echo "*** If you have an old version installed, it is best to remove it, although" 155 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], 156 [ echo "*** The test program failed to compile or link. See the file config.log for the" 157 echo "*** exact error that occured. This usually means LIBXMLSEC1 was incorrectly installed" 158 echo "*** or that you have moved LIBXMLSEC1 since it was installed. In the latter case, you" 159 echo "*** may want to edit the xmlsec1-config script: $XMLSEC1_CONFIG" ]) 160 CFLAGS="$ac_save_CFLAGS" 161 LIBS="$ac_save_LIBS" 162 fi 163 fi 164 165 XMLSEC1_CFLAGS="" 166 XMLSEC1_LIBS="" 167 ifelse([$3], , :, [$3]) 168 fi 169 AC_SUBST(XMLSEC1_CFLAGS) 170 AC_SUBST(XMLSEC1_LIBS) 171 rm -f conf.xmlsec1test 172]) 173