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
64 int major, minor, micro;
67 system ("touch conf.libfametest");
69 /* HP/UX 9 (%@#!) writes to sscanf strings */
70 tmp_version = strdup("$min_libfame_version");
71 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
72 printf("%s, bad version string\n", "$min_libfame_version");
76 if ((libfame_major_version != $libfame_config_major_version) ||
77 (libfame_minor_version != $libfame_config_minor_version) ||
78 (libfame_micro_version != $libfame_config_micro_version))
80 printf("\n*** 'libfame-config --version' returned %d.%d.%d, but Libfame (%d.%d.%d)\n",
81 $libfame_config_major_version, $libfame_config_minor_version, $libfame_config_micro_version,
82 libfame_major_version, libfame_minor_version, libfame_micro_version);
83 printf ("*** was found! If libfame-config was correct, then it is best\n");
84 printf ("*** to remove the old version of libfame. You may also be able to fix the error\n");
85 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
86 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
87 printf("*** required on your system.\n");
88 printf("*** If libfame-config was wrong, set the environment variable LIBFAME_CONFIG\n");
89 printf("*** to point to the correct copy of libfame-config, and remove the file config.cache\n");
90 printf("*** before re-running configure\n");
92 #if defined (LIBFAME_MAJOR_VERSION) && defined (LIBFAME_MINOR_VERSION) && defined (LIBFAME_MICRO_VERSION)
93 else if ((libfame_major_version != LIBFAME_MAJOR_VERSION) ||
94 (libfame_minor_version != LIBFAME_MINOR_VERSION) ||
95 (libfame_micro_version != LIBFAME_MICRO_VERSION))
97 printf("*** libfame header files (version %d.%d.%d) do not match\n",
98 LIBFAME_MAJOR_VERSION, LIBFAME_MINOR_VERSION, LIBFAME_MICRO_VERSION);
99 printf("*** library (version %d.%d.%d)\n",
100 libfame_major_version, libfame_minor_version, libfame_micro_version);
102 #endif /* defined (LIBFAME_MAJOR_VERSION) ... */
105 if ((libfame_major_version > major) ||
106 ((libfame_major_version == major) && (libfame_minor_version > minor)) ||
107 ((libfame_major_version == major) && (libfame_minor_version == minor) && (libfame_micro_version >= micro)))
113 printf("\n*** An old version of libfame (%d.%d.%d) was found.\n",
114 libfame_major_version, libfame_minor_version, libfame_micro_version);
115 printf("*** You need a version of libfame newer than %d.%d.%d. The latest version of\n",
116 major, minor, micro);
117 printf("*** libfame is always available from http://www-eleves.enst-bretagne.fr/~chappeli/fame\n");
119 printf("*** If you have already installed a sufficiently new version, this error\n");
120 printf("*** probably means that the wrong copy of the libfame-config shell script is\n");
121 printf("*** being found. The easiest way to fix this is to remove the old version\n");
122 printf("*** of libfame, but you can also set the LIBFAME_CONFIG environment to point to the\n");
123 printf("*** correct copy of libfame-config. (In this case, you will have to\n");
124 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
125 printf("*** so that the correct libraries are found at run-time))\n");
130 ],, no_libfame=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
131 CFLAGS="$ac_save_CFLAGS"
135 if test "x$no_libfame" = x ; then
137 ifelse([$2], , :, [$2])
140 if test "$LIBFAME_CONFIG" = "no" ; then
141 echo "*** The libfame-config script installed by libfame could not be found"
142 echo "*** If libfame was installed in PREFIX, make sure PREFIX/bin is in"
143 echo "*** your path, or set the LIBFAME_CONFIG environment variable to the"
144 echo "*** full path to libfame-config."
146 if test -f conf.libfametest ; then
149 echo "*** Could not run libfame test program, checking why..."
150 CFLAGS="$CFLAGS $LIBFAME_CFLAGS"
151 LIBS="$LIBS $LIBFAME_LIBS"
155 ], [ return ((libfame_major_version) || (libfame_minor_version) || (libfame_micro_version)); ],
156 [ echo "*** The test program compiled, but did not run. This usually means"
157 echo "*** that the run-time linker is not finding libfame or finding the wrong"
158 echo "*** version of LIBFAME. If it is not finding libfame, you'll need to set your"
159 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
160 echo "*** to the installed location Also, make sure you have run ldconfig if that"
161 echo "*** is required on your system"
163 echo "*** If you have an old version installed, it is best to remove it, although"
164 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
166 [ echo "*** The test program failed to compile or link. See the file config.log for the"
167 echo "*** exact error that occured. This usually means libfame was incorrectly installed"
168 echo "*** or that you have moved libfame since it was installed. In the latter case, you"
169 echo "*** may want to edit the libfame-config script: $LIBFAME_CONFIG" ])
170 CFLAGS="$ac_save_CFLAGS"
176 ifelse([$3], , :, [$3])
179 AC_SUBST(LIBFAME_CFLAGS)
180 AC_SUBST(LIBFAME_LIBS)
181 rm -f conf.libfametest