gimp-3.0.m4 5.92 KB
Newer Older
1
# Configure paths for GIMP-3.0
2 3
# Manish Singh, Sven Neumann
# Large parts shamelessly stolen from Owen Taylor
4

5
dnl AM_PATH_GIMP_3_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
6 7
dnl Test for GIMP, and define GIMP_CFLAGS and GIMP_LIBS
dnl
8
AC_DEFUN([AM_PATH_GIMP_3_0],
9
[dnl 
10
dnl Get the cflags and libraries from pkg-config
11 12
dnl

13 14
AC_ARG_ENABLE(gimptest, [  --disable-gimptest      do not try to compile and run a test GIMP program],, enable_gimptest=yes)

15 16
  pkg_name=gimp-3.0
  pkg_config_args="$pkg_name gimpui-3.0"
17

18
  no_gimp=""
19 20 21 22 23 24

  AC_PATH_PROG(PKG_CONFIG, pkg-config, no)

  if test x$PKG_CONFIG != xno ; then
    if pkg-config --atleast-pkgconfig-version 0.7 ; then
      :
25
    else
26 27 28
      echo *** pkg-config too old; version 0.7 or better required.
      no_gimp=yes
      PKG_CONFIG=no
29
    fi
30 31 32
  else
    no_gimp=yes
  fi
33

34
  min_gimp_version=ifelse([$1], ,3.0.0,$1)
35 36 37 38 39 40 41
  AC_MSG_CHECKING(for GIMP - version >= $min_gimp_version)

  if test x$PKG_CONFIG != xno ; then
    ## don't try to run the test against uninstalled libtool libs
    if $PKG_CONFIG --uninstalled $pkg_config_args; then
	  echo "Will use uninstalled version of GIMP found in PKG_CONFIG_PATH"
	  enable_gimptest=no
Marc Lehmann's avatar
Marc Lehmann committed
42
    fi
43

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    if $PKG_CONFIG --atleast-version $min_gimp_version $pkg_config_args; then
	  :
    else
	  no_gimp=yes
    fi
  fi

  if test x"$no_gimp" = x ; then
    GIMP_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
    GIMP_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
    GIMP_CFLAGS_NOUI=`$PKG_CONFIG $pkg_name --cflags`
    GIMP_LIBS_NOUI=`$PKG_CONFIG $pkg_name --libs`
    GIMP_DATA_DIR=`$PKG_CONFIG $pkg_name --variable=gimpdatadir`
    GIMP_PLUGIN_DIR=`$PKG_CONFIG $pkg_name --variable=gimplibdir`

    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 65 66 67 68
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
    if test "x$enable_gimptest" = "xyes" ; then
      ac_save_CFLAGS="$CFLAGS"
      ac_save_LIBS="$LIBS"
      CFLAGS="$CFLAGS $GIMP_CFLAGS"
69 70
      LIBS="$GIMP_LIBS $LIBS"

71 72
dnl
dnl Now check if the installed GIMP is sufficiently new. (Also sanity
73
dnl checks the results of pkg-config to some extent
74 75 76 77 78
dnl
      rm -f conf.gimptest
      AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
Marc Lehmann's avatar
Marc Lehmann committed
79

80 81
#include <libgimp/gimp.h>

Michael Natterer's avatar
Michael Natterer committed
82
GimpPlugInInfo PLUG_IN_INFO =
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
{
  NULL,  /* init_proc */
  NULL,  /* quit_proc */
  NULL,  /* query_proc */
  NULL   /* run_proc */
};

int main ()
{
  int major, minor, micro;
  char *tmp_version;

  system ("touch conf.gimptest");

  /* HP/UX 9 (%@#!) writes to sscanf strings */
  tmp_version = g_strdup("$min_gimp_version");
  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
     printf("%s, bad version string\n", "$min_gimp_version");
     exit(1);
   }

104 105 106
    if (($gimp_pkg_major_version > major) ||
        (($gimp_pkg_major_version == major) && ($gimp_pkg_minor_version > minor)) ||
        (($gimp_pkg_major_version == major) && ($gimp_pkg_minor_version == minor) && ($gimp_pkg_micro_version >= micro)))
107 108 109 110 111
    {
      return 0;
    }
  else
    {
112 113
      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);
      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 116
      printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
      printf("*** to point to the correct the correct configuration files\n");
117 118 119 120 121 122 123 124 125 126
      return 1;
    }
}

],, no_gimp=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
       CFLAGS="$ac_save_CFLAGS"
       LIBS="$ac_save_LIBS"
     fi
  fi
  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 129
     ifelse([$2], , :, [$2])     
  else
130 131 132
     if test "$PKG_CONFIG" = "no" ; then
       echo "*** A new enough version of pkg-config was not found."
       echo "*** See http://www.freedesktop.org/software/pkgconfig/"
133 134 135 136 137 138 139 140 141 142
     else
       if test -f conf.gimptest ; then
        :
       else
          echo "*** Could not run GIMP test program, checking why..."
          CFLAGS="$CFLAGS $GIMP_CFLAGS"
          LIBS="$LIBS $GIMP_LIBS"
          AC_TRY_LINK([
#include <stdio.h>
#include <libgimp/gimp.h>
143

Michael Natterer's avatar
Michael Natterer committed
144
GimpPlugInInfo PLUG_IN_INFO =
145 146 147 148 149 150
{
  NULL,  /* init_proc */
  NULL,  /* quit_proc */
  NULL,  /* query_proc */
  NULL   /* run_proc */
};
151 152 153 154 155 156 157 158 159 160 161
],      [ return 0; ],
        [ echo "*** The test program compiled, but did not run. This usually means"
          echo "*** that the run-time linker is not finding GIMP or finding the wrong"
          echo "*** version of GIMP. If it is not finding GIMP, you'll need to set your"
          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
          echo "*** is required on your system"
	  echo "***"
          echo "*** If you have an old version installed, it is best to remove it, although"
          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
        [ echo "*** The test program failed to compile or link. See the file config.log for the"
162
          echo "*** exact error that occurred. This usually means GIMP is incorrectly installed."])
163 164 165 166 167 168
          CFLAGS="$ac_save_CFLAGS"
          LIBS="$ac_save_LIBS"
       fi
     fi
     GIMP_CFLAGS=""
     GIMP_LIBS=""
169 170
     GIMP_CFLAGS_NOUI=""
     GIMP_LIBS_NOUI=""
171 172 173 174
     ifelse([$3], , :, [$3])
  fi
  AC_SUBST(GIMP_CFLAGS)
  AC_SUBST(GIMP_LIBS)
175 176
  AC_SUBST(GIMP_CFLAGS_NOUI)
  AC_SUBST(GIMP_LIBS_NOUI)
177 178
  AC_SUBST(GIMP_DATA_DIR)
  AC_SUBST(GIMP_PLUGIN_DIR)
179 180
  rm -f conf.gimptest
])