1 dnl AM_PATH_LIBFAME([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
2 dnl Test for libfame, and define LIBFAME_CFLAGS and LIBFAME_LIBS
3 dnl Vivien Chappelier 12/11/00
4 dnl stolen from ORBit autoconf
6 AC_DEFUN(AM_PATH_LIBFAME,
8 dnl Get the cflags and libraries from the libfame-config script
10 AC_ARG_WITH(libfame-prefix,[ --with-libfame-prefix=PFX Prefix where libfame is installed (optional)],
11 libfame_config_prefix="$withval", libfame_config_prefix="")
12 AC_ARG_WITH(libfame-exec-prefix,[ --with-libfame-exec-prefix=PFX Exec prefix where libfame is installed (optional)],
13 libfame_config_exec_prefix="$withval", libfame_config_exec_prefix="")
14 AC_ARG_ENABLE(libfametest, [ --disable-libfametest Do not try to compile and run a test libfame program],
15 , enable_libfametest=yes)
17 if test x$libfame_config_exec_prefix != x ; then
18 libfame_config_args="$libfame_config_args --exec-prefix=$libfame_config_exec_prefix"
19 if test x${LIBFAME_CONFIG+set} != xset ; then
20 LIBFAME_CONFIG=$libfame_config_exec_prefix/bin/libfame-config
23 if test x$libfame_config_prefix != x ; then
24 libfame_config_args="$libfame_config_args --prefix=$libfame_config_prefix"
25 if test x${LIBFAME_CONFIG+set} != xset ; then
26 LIBFAME_CONFIG=$libfame_config_prefix/bin/libfame-config
30 AC_PATH_PROG(LIBFAME_CONFIG, libfame-config, no)
31 min_libfame_version=ifelse([$1], , 0.9.0, $1)
32 AC_MSG_CHECKING(for libfame - version >= $min_libfame_version)
34 if test "$LIBFAME_CONFIG" = "no" ; then
37 LIBFAME_CFLAGS=`$LIBFAME_CONFIG $libfame_config_args --cflags`
38 LIBFAME_LIBS=`$LIBFAME_CONFIG $libfame_config_args --libs`
39 libfame_config_major_version=`$LIBFAME_CONFIG $libfame_config_args --version | \
40 sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
41 libfame_config_minor_version=`$LIBFAME_CONFIG $libfame_config_args --version | \
42 sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
43 libfame_config_micro_version=`$LIBFAME_CONFIG $libfame_config_args --version | \
44 sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
45 if test "x$enable_libfametest" = "xyes" ; then
46 ac_save_CFLAGS="$CFLAGS"
48 CFLAGS="$CFLAGS $LIBFAME_CFLAGS"
49 LIBS="$LIBFAME_LIBS $LIBS"
51 dnl Now check if the installed LIBFAME is sufficiently new. (Also sanity
52 dnl checks the results of libfame-config to some extent
54 rm -f conf.libfametest
63 int major, minor, micro;
66 system ("touch conf.libfametest");
68 /* HP/UX 9 (%@#!) writes to sscanf strings */
69 tmp_version = strdup("$min_libfame_version");
70 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
71 printf("%s, bad version string\n", "$min_libfame_version");
75 if ((libfame_major_version != $libfame_config_major_version) ||
76 (libfame_minor_version != $libfame_config_minor_version) ||
77 (libfame_micro_version != $libfame_config_micro_version))
79 printf("\n*** 'libfame-config --version' returned %d.%d.%d, but Libfame (%d.%d.%d)\n",
80 $libfame_config_major_version, $libfame_config_minor_version, $libfame_config_micro_version,
81 libfame_major_version, libfame_minor_version, libfame_micro_version);
82 printf ("*** was found! If libfame-config was correct, then it is best\n");
83 printf ("*** to remove the old version of libfame. You may also be able to fix the error\n");
84 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
85 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
86 printf("*** required on your system.\n");
87 printf("*** If libfame-config was wrong, set the environment variable LIBFAME_CONFIG\n");
88 printf("*** to point to the correct copy of libfame-config, and remove the file config.cache\n");
89 printf("*** before re-running configure\n");
91 #if defined (LIBFAME_MAJOR_VERSION) && defined (LIBFAME_MINOR_VERSION) && defined (LIBFAME_MICRO_VERSION)
92 else if ((libfame_major_version != LIBFAME_MAJOR_VERSION) ||
93 (libfame_minor_version != LIBFAME_MINOR_VERSION) ||
94 (libfame_micro_version != LIBFAME_MICRO_VERSION))
96 printf("*** libfame header files (version %d.%d.%d) do not match\n",
97 LIBFAME_MAJOR_VERSION, LIBFAME_MINOR_VERSION, LIBFAME_MICRO_VERSION);
98 printf("*** library (version %d.%d.%d)\n",
99 libfame_major_version, libfame_minor_version, libfame_micro_version);
101 #endif /* defined (LIBFAME_MAJOR_VERSION) ... */
104 if ((libfame_major_version > major) ||
105 ((libfame_major_version == major) && (libfame_minor_version > minor)) ||
106 ((libfame_major_version == major) && (libfame_minor_version == minor) && (libfame_micro_version >= micro)))
112 printf("\n*** An old version of libfame (%d.%d.%d) was found.\n",
113 libfame_major_version, libfame_minor_version, libfame_micro_version);
114 printf("*** You need a version of libfame newer than %d.%d.%d. The latest version of\n",
115 major, minor, micro);
116 printf("*** libfame is always available from http://www-eleves.enst-bretagne.fr/~chappeli/fame\n");
118 printf("*** If you have already installed a sufficiently new version, this error\n");
119 printf("*** probably means that the wrong copy of the libfame-config shell script is\n");
120 printf("*** being found. The easiest way to fix this is to remove the old version\n");
121 printf("*** of libfame, but you can also set the LIBFAME_CONFIG environment to point to the\n");
122 printf("*** correct copy of libfame-config. (In this case, you will have to\n");
123 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
124 printf("*** so that the correct libraries are found at run-time))\n");
129 ],, no_libfame=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
130 CFLAGS="$ac_save_CFLAGS"
134 if test "x$no_libfame" = x ; then
136 ifelse([$2], , :, [$2])
139 if test "$LIBFAME_CONFIG" = "no" ; then
140 echo "*** The libfame-config script installed by libfame could not be found"
141 echo "*** If libfame was installed in PREFIX, make sure PREFIX/bin is in"
142 echo "*** your path, or set the LIBFAME_CONFIG environment variable to the"
143 echo "*** full path to libfame-config."
145 if test -f conf.libfametest ; then
148 echo "*** Could not run libfame test program, checking why..."
149 CFLAGS="$CFLAGS $LIBFAME_CFLAGS"
150 LIBS="$LIBS $LIBFAME_LIBS"
154 ], [ return ((libfame_major_version) || (libfame_minor_version) || (libfame_micro_version)); ],
155 [ echo "*** The test program compiled, but did not run. This usually means"
156 echo "*** that the run-time linker is not finding libfame or finding the wrong"
157 echo "*** version of LIBFAME. If it is not finding libfame, you'll need to set your"
158 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
159 echo "*** to the installed location Also, make sure you have run ldconfig if that"
160 echo "*** is required on your system"
162 echo "*** If you have an old version installed, it is best to remove it, although"
163 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
165 [ echo "*** The test program failed to compile or link. See the file config.log for the"
166 echo "*** exact error that occured. This usually means libfame was incorrectly installed"
167 echo "*** or that you have moved libfame since it was installed. In the latter case, you"
168 echo "*** may want to edit the libfame-config script: $LIBFAME_CONFIG" ])
169 CFLAGS="$ac_save_CFLAGS"
175 ifelse([$3], , :, [$3])
178 AC_SUBST(LIBFAME_CFLAGS)
179 AC_SUBST(LIBFAME_LIBS)
180 rm -f conf.libfametest