5 kx # Configure paths for AALIB
5 kx # Jan Hubicka 4/22/2001
5 kx # stolen from Sam Lantinga 9/21/99
5 kx # stolen from Manish Singh
5 kx # stolen back from Frank Belew
5 kx # stolen from Manish Singh
5 kx # Shamelessly stolen from Owen Taylor
5 kx
5 kx dnl AM_PATH_AALIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
5 kx dnl Test for AALIB, and define AALIB_CFLAGS and AALIB_LIBS
5 kx dnl
5 kx AC_DEFUN([AM_PATH_AALIB],
5 kx [dnl
5 kx dnl Get the cflags and libraries from the aalib-config script
5 kx dnl
5 kx AC_ARG_WITH(aalib-prefix,[ --with-aalib-prefix=PFX Prefix where AALIB is installed (optional)],
5 kx aalib_prefix="$withval", aalib_prefix="")
5 kx AC_ARG_WITH(aalib-exec-prefix,[ --with-aalib-exec-prefix=PFX Exec prefix where AALIB is installed (optional)],
5 kx aalib_exec_prefix="$withval", aalib_exec_prefix="")
5 kx AC_ARG_ENABLE(aalibtest, [ --disable-aalibtest Do not try to compile and run a test AALIB program],
5 kx , enable_aalibtest=yes)
5 kx
5 kx if test x$aalib_exec_prefix != x ; then
5 kx aalib_args="$aalib_args --exec-prefix=$aalib_exec_prefix"
5 kx if test x${AALIB_CONFIG+set} != xset ; then
5 kx AALIB_CONFIG=$aalib_exec_prefix/bin/aalib-config
5 kx fi
5 kx fi
5 kx if test x$aalib_prefix != x ; then
5 kx aalib_args="$aalib_args --prefix=$aalib_prefix"
5 kx if test x${AALIB_CONFIG+set} != xset ; then
5 kx AALIB_CONFIG=$aalib_prefix/bin/aalib-config
5 kx fi
5 kx fi
5 kx
5 kx AC_PATH_PROG(AALIB_CONFIG, aalib-config, no)
5 kx min_aalib_version=ifelse([$1], ,0.11.0,$1)
5 kx AC_MSG_CHECKING(for AALIB - version >= $min_aalib_version)
5 kx no_aalib=""
5 kx if test "$AALIB_CONFIG" = "no" ; then
5 kx no_aalib=yes
5 kx else
5 kx AALIB_CFLAGS=`$AALIB_CONFIG $aalibconf_args --cflags`
5 kx AALIB_LIBS=`$AALIB_CONFIG $aalibconf_args --libs`
5 kx
5 kx aalib_major_version=`$AALIB_CONFIG $aalib_args --version | \
5 kx sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
5 kx aalib_minor_version=`$AALIB_CONFIG $aalib_args --version | \
5 kx sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
5 kx aalib_micro_version=`$AALIB_CONFIG $aalib_config_args --version | \
5 kx sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
5 kx if test "x$enable_aalibtest" = "xyes" ; then
5 kx ac_save_CFLAGS="$CFLAGS"
5 kx ac_save_LIBS="$LIBS"
5 kx CFLAGS="$CFLAGS $AALIB_CFLAGS"
5 kx LIBS="$LIBS $AALIB_LIBS"
5 kx dnl
5 kx dnl Now check if the installed AALIB is sufficiently new. (Also sanity
5 kx dnl checks the results of aalib-config to some extent
5 kx dnl
5 kx rm -f conf.aalibtest
5 kx AC_TRY_RUN([
5 kx #include <stdio.h>
5 kx #include <stdlib.h>
5 kx #include <string.h>
5 kx #include "aalib.h"
5 kx
5 kx char*
5 kx my_strdup (char *str)
5 kx {
5 kx char *new_str;
5 kx
5 kx if (str)
5 kx {
5 kx new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
5 kx strcpy (new_str, str);
5 kx }
5 kx else
5 kx new_str = NULL;
5 kx
5 kx return new_str;
5 kx }
5 kx
5 kx int main (int argc, char *argv[])
5 kx {
5 kx int major, minor, micro;
5 kx char *tmp_version;
5 kx
5 kx /* This hangs on some systems (?)
5 kx system ("touch conf.aalibtest");
5 kx */
5 kx { FILE *fp = fopen("conf.aalibtest", "a"); if ( fp ) fclose(fp); }
5 kx
5 kx /* HP/UX 9 (%@#!) writes to sscanf strings */
5 kx tmp_version = my_strdup("$min_aalib_version");
5 kx if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
5 kx printf("%s, bad version string\n", "$min_aalib_version");
5 kx exit(1);
5 kx }
5 kx
5 kx if (($aalib_major_version > major) ||
5 kx (($aalib_major_version == major) && ($aalib_minor_version > minor)) ||
5 kx (($aalib_major_version == major) && ($aalib_minor_version == minor) && ($aalib_micro_version >= micro)))
5 kx {
5 kx return 0;
5 kx }
5 kx else
5 kx {
5 kx printf("\n*** 'aalib-config --version' returned %d.%d.%d, but the minimum version\n", $aalib_major_version, $aalib_minor_version, $aalib_micro_version);
5 kx printf("*** of AALIB required is %d.%d.%d. If aalib-config is correct, then it is\n", major, minor, micro);
5 kx printf("*** best to upgrade to the required version.\n");
5 kx printf("*** If aalib-config was wrong, set the environment variable AALIB_CONFIG\n");
5 kx printf("*** to point to the correct copy of aalib-config, and remove the file\n");
5 kx printf("*** config.cache before re-running configure\n");
5 kx return 1;
5 kx }
5 kx }
5 kx
5 kx ],, no_aalib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
5 kx CFLAGS="$ac_save_CFLAGS"
5 kx LIBS="$ac_save_LIBS"
5 kx fi
5 kx fi
5 kx if test "x$no_aalib" = x ; then
5 kx AC_MSG_RESULT(yes)
5 kx ifelse([$2], , :, [$2])
5 kx else
5 kx AC_MSG_RESULT(no)
5 kx if test "$AALIB_CONFIG" = "no" ; then
5 kx echo "*** The aalib-config script installed by AALIB could not be found"
5 kx echo "*** If AALIB was installed in PREFIX, make sure PREFIX/bin is in"
5 kx echo "*** your path, or set the AALIB_CONFIG environment variable to the"
5 kx echo "*** full path to aalib-config."
5 kx else
5 kx if test -f conf.aalibtest ; then
5 kx :
5 kx else
5 kx echo "*** Could not run AALIB test program, checking why..."
5 kx CFLAGS="$CFLAGS $AALIB_CFLAGS"
5 kx LIBS="$LIBS $AALIB_LIBS"
5 kx AC_TRY_LINK([
5 kx #include <stdio.h>
5 kx #include "AALIB.h"
5 kx ], [ return 0; ],
5 kx [ echo "*** The test program compiled, but did not run. This usually means"
5 kx echo "*** that the run-time linker is not finding AALIB or finding the wrong"
5 kx echo "*** version of AALIB. If it is not finding AALIB, you'll need to set your"
5 kx echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
5 kx echo "*** to the installed location Also, make sure you have run ldconfig if that"
5 kx echo "*** is required on your system"
5 kx echo "***"
5 kx echo "*** If you have an old version installed, it is best to remove it, although"
5 kx echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
5 kx [ echo "*** The test program failed to compile or link. See the file config.log for the"
5 kx echo "*** exact error that occured. This usually means AALIB was incorrectly installed"
5 kx echo "*** or that you have moved AALIB since it was installed. In the latter case, you"
5 kx echo "*** may want to edit the aalib-config script: $AALIB_CONFIG" ])
5 kx CFLAGS="$ac_save_CFLAGS"
5 kx LIBS="$ac_save_LIBS"
5 kx fi
5 kx fi
5 kx AALIB_CFLAGS=""
5 kx AALIB_LIBS=""
5 kx ifelse([$3], , :, [$3])
5 kx fi
5 kx AC_SUBST(AALIB_CFLAGS)
5 kx AC_SUBST(AALIB_LIBS)
5 kx rm -f conf.aalibtest
5 kx ])