allegro.m4
Upload User: wmy0603
Upload Date: 2022-05-02
Package Size: 1808k
Code Size: 8k
Development Platform:

Visual C++

  1. # Configure paths for Allegro
  2. # Shamelessly stolen from libxml.a4
  3. # Jon Rafkind 2004-06-06
  4. # Adapted from:
  5. # Configure paths for libXML
  6. # Toshio Kuratomi 2001-04-21
  7. # Adapted from:
  8. # Configure paths for GLIB
  9. # Owen Taylor     97-11-3
  10. dnl AM_PATH_allegro([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  11. dnl Test for allegro, and define allegro_CFLAGS and allegro_LIBS
  12. dnl
  13. AC_DEFUN([AM_PATH_ALLEGRO],[ 
  14. AC_ARG_WITH(allegro-prefix,
  15.             [  --with-allegro-prefix=PFX   Prefix where liballegro is installed (optional)],
  16.             ALLEGRO_CONFIG_prefix="$withval", ALLEGRO_CONFIG_prefix="")
  17. AC_ARG_WITH(allegro-exec-prefix,
  18.             [  --with-allegro-exec-prefix=PFX Exec prefix where liballegro is installed (optional)],
  19.             ALLEGRO_CONFIG_exec_prefix="$withval", ALLEGRO_CONFIG_exec_prefix="")
  20. AC_ARG_ENABLE(allegrotest,
  21.               [  --disable-allegrotest       Do not try to compile and run a test LIBallegro program],,
  22.               enable_allegrotest=yes)
  23.   if test x$ALLEGRO_CONFIG_exec_prefix != x ; then
  24.      ALLEGRO_CONFIG_args="$ALLEGRO_CONFIG_args --exec-prefix=$ALLEGRO_CONFIG_exec_prefix"
  25.      if test x${ALLEGRO_CONFIG+set} != xset ; then
  26.         ALLEGRO_CONFIG=$ALLEGRO_CONFIG_exec_prefix/bin/allegro-config
  27.      fi
  28.   fi
  29.   if test x$ALLEGRO_CONFIG_prefix != x ; then
  30.      ALLEGRO_CONFIG_args="$ALLEGRO_CONFIG_args --prefix=$ALLEGRO_CONFIG_prefix"
  31.      if test x${ALLEGRO_CONFIG+set} != xset ; then
  32.         ALLEGRO_CONFIG=$ALLEGRO_CONFIG_prefix/bin/allegro-config
  33.      fi
  34.   fi
  35.   AC_PATH_PROG(ALLEGRO_CONFIG, allegro-config, no)
  36.   min_allegro_version=ifelse([$1], ,4.0.0,[$1])
  37.   AC_MSG_CHECKING(for Allegro - version >= $min_allegro_version)
  38.   no_allegro=""
  39.   if test "$ALLEGRO_CONFIG" = "no" ; then
  40.     no_allegro=yes
  41.   else
  42.     allegro_CFLAGS=`$ALLEGRO_CONFIG $ALLEGRO_CONFIG_args --cflags`
  43.     allegro_LIBS=`$ALLEGRO_CONFIG $ALLEGRO_CONFIG_args --libs`
  44.     ALLEGRO_CONFIG_major_version=`$ALLEGRO_CONFIG $ALLEGRO_CONFIG_args --version | 
  45.            sed 's/([[0-9]]*).([[0-9]]*).([[0-9]]*)/1/'`
  46.     ALLEGRO_CONFIG_minor_version=`$ALLEGRO_CONFIG $ALLEGRO_CONFIG_args --version | 
  47.            sed 's/([[0-9]]*).([[0-9]]*).([[0-9]]*)/2/'`
  48.     ALLEGRO_CONFIG_micro_version=`$ALLEGRO_CONFIG $ALLEGRO_CONFIG_args --version | 
  49.            sed 's/([[0-9]]*).([[0-9]]*).([[0-9]]*)/3/'`
  50.     if test "x$enable_allegrotest" = "xyes" ; then
  51.       ac_save_CFLAGS="$CFLAGS"
  52.       ac_save_LIBS="$LIBS"
  53.       CFLAGS="$CFLAGS $allegro_CFLAGS"
  54.       LIBS="$allegro_LIBS $LIBS"
  55. dnl
  56. dnl Now check if the installed liballegro is sufficiently new.
  57. dnl (Also sanity checks the results of allegro-config to some extent)
  58. dnl
  59.       rm -f conf.allegrotest
  60.       AC_TRY_RUN([
  61. #include <stdlib.h>
  62. #include <stdio.h>
  63. #include <string.h>
  64. #include <allegro.h>
  65. int 
  66. main()
  67. {
  68.   int allegro_major_version, allegro_minor_version, allegro_micro_version;
  69.   int major, minor, micro;
  70.   char *tmp_version;
  71.   int tmp_int_version;
  72.   system("touch conf.allegrotest");
  73.   /* Capture allegro-config output via autoconf/configure variables */
  74.   /* HP/UX 9 (%@#!) writes to sscanf strings */
  75.   tmp_version = (char *)strdup("$min_allegro_version");
  76.   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  77.      printf("%s, bad version string from allegro-confign", "$min_allegro_version");
  78.      free(tmp_version);
  79.      exit(1);
  80.    }
  81.    free(tmp_version);
  82.    /* Capture the version information from the header files */
  83.    allegro_major_version = ALLEGRO_VERSION;
  84.    allegro_minor_version = ALLEGRO_SUB_VERSION;
  85.    allegro_micro_version = ALLEGRO_WIP_VERSION;
  86.  /* Compare allegro-config output to the Allegro headers */
  87.   if ((allegro_major_version != $ALLEGRO_CONFIG_major_version) ||
  88.       (allegro_minor_version != $ALLEGRO_CONFIG_minor_version))
  89.   
  90.     {
  91.       printf("*** Allegro header files (version %d.%d.%d) do not matchn",
  92.          allegro_major_version, allegro_minor_version, allegro_micro_version);
  93.       printf("*** allegro-config (version %d.%d.%d)n",
  94.          $ALLEGRO_CONFIG_major_version, $ALLEGRO_CONFIG_minor_version, $ALLEGRO_CONFIG_micro_version);
  95.       return 1;
  96.     } 
  97. /* Compare the headers to the library to make sure we match */
  98.   /* Less than ideal -- doesn't provide us with return value feedback, 
  99.    * only exits if there's a serious mismatch between header and library.
  100.    */
  101.     /* TODO:
  102.  * This doesnt work!
  103.  */
  104.     /* ALLEGRO_TEST_VERSION; */
  105.     /* Test that the library is greater than our minimum version */
  106.     if (($ALLEGRO_CONFIG_major_version > major) ||
  107.         (($ALLEGRO_CONFIG_major_version == major) && ($ALLEGRO_CONFIG_minor_version > minor)) ||
  108.         (($ALLEGRO_CONFIG_major_version == major) && ($ALLEGRO_CONFIG_minor_version == minor) &&
  109.         ($ALLEGRO_CONFIG_micro_version >= micro)))
  110.       {
  111.         return 0;
  112.        }
  113.      else
  114.       {
  115.         printf("n*** An old version of Allegro (%d.%d.%d) was found.n",
  116.                allegro_major_version, allegro_minor_version, allegro_micro_version);
  117.         printf("*** You need a version of Allegro newer than %d.%d.%d. The latest version ofn",
  118.            major, minor, micro);
  119.         printf("*** Allegro is always available from http://alleg.sf.net.n");
  120.         printf("***n");
  121.         printf("*** If you have already installed a sufficiently new version, this errorn");
  122.         printf("*** probably means that the wrong copy of the allegro-config shell script isn");
  123.         printf("*** being found. The easiest way to fix this is to remove the old versionn");
  124.         printf("*** of Allegro, but you can also set the ALLEGRO_CONFIG environment to point to then");
  125.         printf("*** correct copy of allegro-config. (In this case, you will have ton");
  126.         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.confn");
  127.         printf("*** so that the correct libraries are found at run-time))n");
  128.     }
  129.   return 1;
  130. } END_OF_MAIN()
  131. ],, no_allegro=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  132.        CFLAGS="$ac_save_CFLAGS"
  133.        LIBS="$ac_save_LIBS"
  134.      fi
  135.   fi
  136.   if test "x$no_allegro" = x ; then
  137.      AC_MSG_RESULT(yes (version $ALLEGRO_CONFIG_major_version.$ALLEGRO_CONFIG_minor_version.$ALLEGRO_CONFIG_micro_version))
  138.      ifelse([$2], , :, [$2])     
  139.   else
  140.      AC_MSG_RESULT(no)
  141.      if test "$ALLEGRO_CONFIG" = "no" ; then
  142.        echo "*** The allegro-config script installed by Allegro could not be found"
  143.        echo "*** If Allegro was installed in PREFIX, make sure PREFIX/bin is in"
  144.        echo "*** your path, or set the ALLEGRO_CONFIG environment variable to the"
  145.        echo "*** full path to allegro-config."
  146.      else
  147.        if test -f conf.allegrotest ; then
  148.         :
  149.        else
  150.           echo "*** Could not run Allegro test program, checking why..."
  151.           CFLAGS="$CFLAGS $allegro_CFLAGS"
  152.           LIBS="$LIBS $allegro_LIBS"
  153.           AC_TRY_LINK([
  154. #include <allegro.h>
  155. #include <stdio.h>
  156. ],      [ ALLEGRO_TEST_VERSION; return 0;],
  157.         [ echo "*** The test program compiled, but did not run. This usually means"
  158.           echo "*** that the run-time linker is not finding Allegro or finding the wrong"
  159.           echo "*** version of Allegro. If it is not finding Allegro, you'll need to set your"
  160.           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  161.           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
  162.           echo "*** is required on your system"
  163.           echo "***"
  164.           echo "*** If you have an old version installed, it is best to remove it, although"
  165.           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 Allegro was incorrectly installed"
  168.           echo "*** or that you have moved Allegro since it was installed. In the latter case, you"
  169.           echo "*** may want to edit the allegro-config script: $ALLEGRO_CONFIG" ])
  170.           CFLAGS="$ac_save_CFLAGS"
  171.           LIBS="$ac_save_LIBS"
  172.        fi
  173.      fi
  174.      allegro_CFLAGS=""
  175.      allegro_LIBS=""
  176.      ifelse([$3], , :, [$3])
  177.   fi
  178.   AC_SUBST(allegro_CFLAGS)
  179.   AC_SUBST(allegro_LIBS)
  180.   rm -f conf.allegrotest
  181. ])