1 # Configure paths for CLN
2 # Richard Kreckel 11/17/2000
3 # stolen from Christian Bauer
4 # stolen from Sam Lantinga
5 # stolen from Manish Singh
6 # stolen back from Frank Belew
7 # stolen from Manish Singh
8 # Shamelessly stolen from Owen Taylor
10 dnl AC_PATH_LIBCLN([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
11 dnl Test for installed CLN library, and define LIBCLN_CPPFLAGS and LIBCLN_LIBS
13 AC_DEFUN(AC_PATH_LIBCLN,
15 dnl Get the cppflags and libraries from the cln-config script
17 AC_ARG_WITH(cln-prefix,[ --with-cln-prefix=PFX Prefix where CLN is installed (optional)],
18 cln_config_prefix="$withval", cln_config_prefix="")
19 AC_ARG_WITH(cln-exec-prefix,[ --with-cln-exec-prefix=PFX Exec prefix where CLN is installed (optional)],
20 cln_config_exec_prefix="$withval", cln_config_exec_prefix="")
21 AC_ARG_ENABLE(clntest, [ --disable-clntest Do not try to compile and run a test CLN program],
24 if test x$cln_config_exec_prefix != x ; then
25 cln_config_args="$cln_config_args --exec-prefix=$cln_config_exec_prefix"
26 if test x${CLN_CONFIG+set} != xset ; then
27 CLN_CONFIG=$cln_config_exec_prefix/bin/cln-config
30 if test x$cln_config_prefix != x ; then
31 cln_config_args="$cln_config_args --prefix=$cln_config_prefix"
32 if test x${CLN_CONFIG+set} != xset ; then
33 CLN_CONFIG=$cln_config_prefix/bin/cln-config
37 AC_PATH_PROG(CLN_CONFIG, cln-config, no)
38 min_cln_version=ifelse([$1], ,1.1.0,$1)
39 AC_MSG_CHECKING(for CLN - version >= $min_cln_version)
41 if test "$CLN_CONFIG" = "no" ; then
44 LIBCLN_CPPFLAGS=`$CLN_CONFIG $cln_config_args --cppflags`
45 LIBCLN_LIBS=`$CLN_CONFIG $cln_config_args --libs`
46 cln_config_major_version=`$CLN_CONFIG $cln_config_args --version | \
47 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
48 cln_config_minor_version=`$CLN_CONFIG $cln_config_args --version | \
49 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
50 cln_config_micro_version=`$CLN_CONFIG $cln_config_args --version | \
51 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
52 if test "x$enable_clntest" = "xyes" ; then
53 ac_save_CPPFLAGS="$CPPFLAGS"
55 CPPFLAGS="$CPPFLAGS $LIBCLN_CPPFLAGS"
56 LIBS="$LIBS $LIBCLN_LIBS"
58 dnl Now check if the installed CLN is sufficiently new. (Also sanity
59 dnl checks the results of cln-config to some extent
65 #include <cln/config.h>
67 /* we do not #include <stdlib.h> because autoconf in C++ mode inserts a
68 prototype for exit() that conflicts with the one in stdlib.h */
69 extern "C" int system(const char *);
71 char* my_strdup (char *str)
76 new_str = new char[(strlen (str) + 1) * sizeof(char)];
77 strcpy (new_str, str);
86 int major, minor, micro;
89 system("touch conf.clntest");
91 /* HP/UX 9 (%@#!) writes to sscanf strings */
92 tmp_version = my_strdup("$min_cln_version");
93 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
94 printf("%s, bad version string\n", "$min_cln_version");
98 if (($cln_config_major_version > major) ||
99 (($cln_config_major_version == major) && ($cln_config_minor_version > minor)) ||
100 (($cln_config_major_version == major) && ($cln_config_minor_version == minor) && ($cln_config_micro_version >= micro))) {
101 if ((CL_VERSION_MAJOR == $cln_config_major_version) &&
102 (CL_VERSION_MINOR == $cln_config_minor_version) &&
103 (CL_VERSION_PATCHLEVEL == $cln_config_micro_version)) {
106 printf("\n*** 'cln-config --version' returned %d.%d.%d, but the header file I found\n", $cln_config_major_version, $cln_config_minor_version, $cln_config_micro_version);
107 printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of CLN\n", CL_VERSION_MAJOR, CL_VERSION_MINOR, CL_VERSION_PATCHLEVEL);
108 printf("*** is corrupted. Please inquire and consider reinstalling CLN.\n");
112 printf("\n*** 'cln-config --version' returned %d.%d.%d, but the minimum version\n", $cln_config_major_version, $cln_config_minor_version, $cln_config_micro_version);
113 printf("*** of CLN required is %d.%d.%d. If cln-config is correct, then it is\n", major, minor, micro);
114 printf("*** best to upgrade to the required version.\n");
115 printf("*** If cln-config was wrong, set the environment variable CLN_CONFIG\n");
116 printf("*** to point to the correct copy of cln-config, and remove the file\n");
117 printf("*** config.cache before re-running configure\n");
121 ],, no_cln=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
122 CPPFLAGS="$ac_save_CPPFLAGS"
126 if test "x$no_cln" = x ; then
127 AC_MSG_RESULT([yes, `$CLN_CONFIG --version`])
128 ifelse([$2], , :, [$2])
131 if test "$CLN_CONFIG" = "no" ; then
132 echo "*** The cln-config script installed by CLN could not be found"
133 echo "*** If CLN was installed in PREFIX, make sure PREFIX/bin is in"
134 echo "*** your path, or set the CLN_CONFIG environment variable to the"
135 echo "*** full path to cln-config."
137 if test -f conf.clntest ; then
140 echo "*** Could not run CLN test program, checking why..."
141 CPPFLAGS="$CFLAGS $LIBCLN_CPPFLAGS"
142 LIBS="$LIBS $LIBCLN_LIBS"
147 [ echo "*** The test program compiled, but did not run. This usually means"
148 echo "*** that the run-time linker is not finding CLN or finding the wrong"
149 echo "*** version of CLN. If it is not finding CLN, 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"
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 CLN was incorrectly installed"
158 echo "*** or that you have moved CLN since it was installed. In the latter case, you"
159 echo "*** may want to edit the cln-config script: $CLN_CONFIG" ])
160 CPPFLAGS="$ac_save_CPPFLAGS"
166 ifelse([$3], , :, [$3])
168 AC_SUBST(LIBCLN_CPPFLAGS)
169 AC_SUBST(LIBCLN_LIBS)