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_prefix="$withval", cln_prefix="")
19 AC_ARG_WITH(cln-exec-prefix,[ --with-cln-exec-prefix=PFX Exec prefix where CLN is installed (optional)],
20 cln_exec_prefix="$withval", cln_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_exec_prefix != x ; then
25 cln_args="$cln_args --exec-prefix=$cln_exec_prefix"
26 if test x${CLN_CONFIG+set} != xset ; then
27 CLN_CONFIG=$cln_exec_prefix/bin/cln-config
30 if test x$cln_prefix != x ; then
31 cln_args="$cln_args --prefix=$cln_prefix"
32 if test x${CLN_CONFIG+set} != xset ; then
33 CLN_CONFIG=$cln_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 $clnconf_args --cppflags`
45 LIBCLN_LIBS=`$CLN_CONFIG $clnconf_args --libs`
47 cln_major_version=`$CLN_CONFIG $cln_args --version | \
48 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
49 cln_minor_version=`$CLN_CONFIG $cln_args --version | \
50 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
51 cln_micro_version=`$CLN_CONFIG $cln_config_args --version | \
52 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
53 if test "x$enable_clntest" = "xyes" ; then
54 ac_save_CPPFLAGS="$CPPFLAGS"
56 CPPFLAGS="$CPPFLAGS $LIBCLN_CPPFLAGS"
57 LIBS="$LIBS $LIBCLN_LIBS"
59 dnl Now check if the installed CLN is sufficiently new. (Also sanity
60 dnl checks the results of cln-config to some extent
67 #include <cln/config.h>
71 int major, minor, micro;
74 system("touch conf.clntest");
76 tmp_version = strdup("$min_cln_version");
77 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
78 printf("%s, bad version string\n", "$min_cln_version");
82 if (($cln_major_version > major) ||
83 (($cln_major_version == major) && ($cln_minor_version > minor)) ||
84 (($cln_major_version == major) && ($cln_minor_version == minor) && ($cln_micro_version >= micro))) {
85 if ((CL_VERSION_MAJOR == $cln_major_version) &&
86 (CL_VERSION_MINOR == $cln_minor_version) &&
87 (CL_VERSION_PATCHLEVEL == $cln_micro_version)) {
90 printf("\n*** 'cln-config --version' returned %d.%d.%d, but the header file I found\n", $cln_major_version, $cln_minor_version, $cln_micro_version);
91 printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of CLN\n", CL_VERSION_MAJOR, CL_VERSION_MINOR, CL_VERSION_PATCHLEVEL);
92 printf("*** is corrupted. Please inquire and consider reinstalling CLN.\n");
96 printf("\n*** 'cln-config --version' returned %d.%d.%d, but the minimum version\n", $cln_major_version, $cln_minor_version, $cln_micro_version);
97 printf("*** of CLN required is %d.%d.%d. If cln-config is correct, then it is\n", major, minor, micro);
98 printf("*** best to upgrade to the required version.\n");
99 printf("*** If cln-config was wrong, set the environment variable CLN_CONFIG\n");
100 printf("*** to point to the correct copy of cln-config, and remove the file\n");
101 printf("*** config.cache before re-running configure\n");
105 ],, no_cln=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
106 CPPFLAGS="$ac_save_CPPFLAGS"
110 if test "x$no_cln" = x ; then
112 ifelse([$2], , :, [$2])
115 if test "$CLN_CONFIG" = "no" ; then
116 echo "*** The cln-config script installed by CLN could not be found"
117 echo "*** If CLN was installed in PREFIX, make sure PREFIX/bin is in"
118 echo "*** your path, or set the CLN_CONFIG environment variable to the"
119 echo "*** full path to cln-config."
121 if test -f conf.clntest ; then
124 echo "*** Could not run CLN test program, checking why..."
125 CPPFLAGS="$CFLAGS $LIBCLN_CPPFLAGS"
126 LIBS="$LIBS $LIBCLN_LIBS"
131 [ echo "*** The test program compiled, but did not run. This usually means"
132 echo "*** that the run-time linker is not finding CLN or finding the wrong"
133 echo "*** version of CLN. If it is not finding CLN, you'll need to set your"
134 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
135 echo "*** to the installed location Also, make sure you have run ldconfig if that"
136 echo "*** is required on your system"
138 echo "*** If you have an old version installed, it is best to remove it, although"
139 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
140 [ echo "*** The test program failed to compile or link. See the file config.log for the"
141 echo "*** exact error that occured. This usually means CLN was incorrectly installed"
142 echo "*** or that you have moved CLN since it was installed. In the latter case, you"
143 echo "*** may want to edit the cln-config script: $CLN_CONFIG" ])
144 CPPFLAGS="$ac_save_CPPFLAGS"
150 ifelse([$3], , :, [$3])
152 AC_SUBST(LIBCLN_CPPFLAGS)
153 AC_SUBST(LIBCLN_LIBS)