home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 January / maximum-cd-2009-01.iso / DiscContents / gimpshop_2.2.8_fix1_setup.exe / share / aclocal / gimp-2.0.m4
Encoding:
M4 Source File  |  2005-10-13  |  5.9 KB  |  181 lines

  1. # Configure paths for GIMP-2.0
  2. # Manish Singh, Sven Neumann
  3. # Large parts shamelessly stolen from Owen Taylor
  4.  
  5. dnl AM_PATH_GIMP_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  6. dnl Test for GIMP, and define GIMP_CFLAGS and GIMP_LIBS
  7. dnl
  8. AC_DEFUN([AM_PATH_GIMP_2_0],
  9. [dnl 
  10. dnl Get the cflags and libraries from pkg-config
  11. dnl
  12.  
  13. AC_ARG_ENABLE(gimptest, [  --disable-gimptest      do not try to compile and run a test GIMP program],, enable_gimptest=yes)
  14.  
  15.   pkg_name=gimp-2.0
  16.   pkg_config_args="$pkg_name gimpui-2.0"
  17.  
  18.   no_gimp=""
  19.  
  20.   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  21.  
  22.   if test x$PKG_CONFIG != xno ; then
  23.     if pkg-config --atleast-pkgconfig-version 0.7 ; then
  24.       :
  25.     else
  26.       echo *** pkg-config too old; version 0.7 or better required.
  27.       no_gimp=yes
  28.       PKG_CONFIG=no
  29.     fi
  30.   else
  31.     no_gimp=yes
  32.   fi
  33.  
  34.   min_gimp_version=ifelse([$1], ,2.0.0,$1)
  35.   AC_MSG_CHECKING(for GIMP - version >= $min_gimp_version)
  36.  
  37.   if test x$PKG_CONFIG != xno ; then
  38.     ## don't try to run the test against uninstalled libtool libs
  39.     if $PKG_CONFIG --uninstalled $pkg_config_args; then
  40.       echo "Will use uninstalled version of GIMP found in PKG_CONFIG_PATH"
  41.       enable_gimptest=no
  42.     fi
  43.  
  44.     if $PKG_CONFIG --atleast-version $min_gimp_version $pkg_config_args; then
  45.       :
  46.     else
  47.       no_gimp=yes
  48.     fi
  49.   fi
  50.  
  51.   if test x"$no_gimp" = x ; then
  52.     GIMP_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
  53.     GIMP_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
  54.     GIMP_CFLAGS_NOUI=`$PKG_CONFIG $pkg_name --cflags`
  55.     GIMP_LIBS_NOUI=`$PKG_CONFIG $pkg_name --libs`
  56.     GIMP_DATA_DIR=`$PKG_CONFIG $pkg_name --variable=gimpdatadir`
  57.     GIMP_PLUGIN_DIR=`$PKG_CONFIG $pkg_name --variable=gimplibdir`
  58.  
  59.     gimp_pkg_major_version=`$PKG_CONFIG --modversion $pkg_name | \
  60.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  61.     gimp_pkg_minor_version=`$PKG_CONFIG --modversion $pkg_name | \
  62.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  63.     gimp_pkg_micro_version=`$PKG_CONFIG --modversion $pkg_name | \
  64.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  65.     if test "x$enable_gimptest" = "xyes" ; then
  66.       ac_save_CFLAGS="$CFLAGS"
  67.       ac_save_LIBS="$LIBS"
  68.       CFLAGS="$CFLAGS $GIMP_CFLAGS"
  69.       LIBS="$GIMP_LIBS $LIBS"
  70.  
  71. dnl
  72. dnl Now check if the installed GIMP is sufficiently new. (Also sanity
  73. dnl checks the results of pkg-config to some extent
  74. dnl
  75.       rm -f conf.gimptest
  76.       AC_TRY_RUN([
  77. #include <stdio.h>
  78. #include <stdlib.h>
  79.  
  80. #include <libgimp/gimp.h>
  81.  
  82. GimpPlugInInfo PLUG_IN_INFO =
  83. {
  84.   NULL,  /* init_proc */
  85.   NULL,  /* quit_proc */
  86.   NULL,  /* query_proc */
  87.   NULL   /* run_proc */
  88. };
  89.  
  90. int main ()
  91. {
  92.   int major, minor, micro;
  93.   char *tmp_version;
  94.  
  95.   system ("touch conf.gimptest");
  96.  
  97.   /* HP/UX 9 (%@#!) writes to sscanf strings */
  98.   tmp_version = g_strdup("$min_gimp_version");
  99.   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
  100.      printf("%s, bad version string\n", "$min_gimp_version");
  101.      exit(1);
  102.    }
  103.  
  104.     if (($gimp_pkg_major_version > major) ||
  105.         (($gimp_pkg_major_version == major) && ($gimp_pkg_minor_version > minor)) ||
  106.         (($gimp_pkg_major_version == major) && ($gimp_pkg_minor_version == minor) && ($gimp_pkg_micro_version >= micro)))
  107.     {
  108.       return 0;
  109.     }
  110.   else
  111.     {
  112.       printf("\n*** 'pkg-config --modversion %s' returned %d.%d.%d, but the minimum version\n", "$pkg_name", $gimp_pkg_major_version, $gimp_pkg_minor_version, $gimp_pkg_micro_version);
  113.       printf("*** of GIMP required is %d.%d.%d. If pkg-config is correct, then it is\n", major, minor, micro);
  114.       printf("*** best to upgrade to the required version.\n");
  115.       printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
  116.       printf("*** to point to the correct the correct configuration files\n");
  117.       return 1;
  118.     }
  119. }
  120.  
  121. ],, no_gimp=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  122.        CFLAGS="$ac_save_CFLAGS"
  123.        LIBS="$ac_save_LIBS"
  124.      fi
  125.   fi
  126.   if test "x$no_gimp" = x ; then
  127.      AC_MSG_RESULT(yes (version $gimp_pkg_major_version.$gimp_pkg_minor_version.$gimp_pkg_micro_version))
  128.      ifelse([$2], , :, [$2])     
  129.   else
  130.      if test "$PKG_CONFIG" = "no" ; then
  131.        echo "*** A new enough version of pkg-config was not found."
  132.        echo "*** See http://www.freedesktop.org/software/pkgconfig/"
  133.      else
  134.        if test -f conf.gimptest ; then
  135.         :
  136.        else
  137.           echo "*** Could not run GIMP test program, checking why..."
  138.           CFLAGS="$CFLAGS $GIMP_CFLAGS"
  139.           LIBS="$LIBS $GIMP_LIBS"
  140.           AC_TRY_LINK([
  141. #include <stdio.h>
  142. #include <libgimp/gimp.h>
  143.  
  144. GimpPlugInInfo PLUG_IN_INFO =
  145. {
  146.   NULL,  /* init_proc */
  147.   NULL,  /* quit_proc */
  148.   NULL,  /* query_proc */
  149.   NULL   /* run_proc */
  150. };
  151. ],      [ return 0; ],
  152.         [ echo "*** The test program compiled, but did not run. This usually means"
  153.           echo "*** that the run-time linker is not finding GIMP or finding the wrong"
  154.           echo "*** version of GIMP. If it is not finding GIMP, you'll need to set your"
  155.           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  156.           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
  157.           echo "*** is required on your system"
  158.       echo "***"
  159.           echo "*** If you have an old version installed, it is best to remove it, although"
  160.           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  161.         [ echo "*** The test program failed to compile or link. See the file config.log for the"
  162.           echo "*** exact error that occured. This usually means GIMP is incorrectly installed."])
  163.           CFLAGS="$ac_save_CFLAGS"
  164.           LIBS="$ac_save_LIBS"
  165.        fi
  166.      fi
  167.      GIMP_CFLAGS=""
  168.      GIMP_LIBS=""
  169.      GIMP_CFLAGS_NOUI=""
  170.      GIMP_LIBS_NOUI=""
  171.      ifelse([$3], , :, [$3])
  172.   fi
  173.   AC_SUBST(GIMP_CFLAGS)
  174.   AC_SUBST(GIMP_LIBS)
  175.   AC_SUBST(GIMP_CFLAGS_NOUI)
  176.   AC_SUBST(GIMP_LIBS_NOUI)
  177.   AC_SUBST(GIMP_DATA_DIR)
  178.   AC_SUBST(GIMP_PLUGIN_DIR)
  179.   rm -f conf.gimptest
  180. ])
  181.