source: trunk/third/ORBit/libIDL/libIDL.m4.in @ 15271

Revision 15271, 8.1 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15270, which included commits to RCS files with non-trunk default branches.
Line 
1# Configure paths for LIBIDL
2
3dnl AM_PATH_LIBIDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
4dnl Test for LIBIDL, and define LIBIDL_CFLAGS and LIBIDL_LIBS
5dnl
6AC_DEFUN(AM_PATH_LIBIDL,
7[dnl
8dnl Get the cflags and libraries from the libIDL-config script
9dnl
10AC_ARG_WITH(libIDL-prefix,[  --with-libIDL-prefix=PFX   Prefix where libIDL is installed (optional)],
11            libIDL_config_prefix="$withval", libIDL_config_prefix="")
12AC_ARG_WITH(libIDL-exec-prefix,[  --with-libIDL-exec-prefix=PFX Exec prefix where libIDL is installed (optional)],
13            libIDL_config_exec_prefix="$withval", libIDL_config_exec_prefix="")
14AC_ARG_ENABLE(libIDLtest, [  --disable-libIDLtest       Do not try to compile and run a test libIDL program],
15                    , enable_libIDLtest=yes)
16
17  if test x$libIDL_config_exec_prefix != x ; then
18     libIDL_config_args="$libIDL_config_args --exec-prefix=$libIDL_config_exec_prefix"
19     if test x${LIBIDL_CONFIG+set} != xset ; then
20        LIBIDL_CONFIG=$libIDL_config_exec_prefix/bin/libIDL-config
21     fi
22  fi
23  if test x$libIDL_config_prefix != x ; then
24     libIDL_config_args="$libIDL_config_args --prefix=$libIDL_config_prefix"
25     if test x${LIBIDL_CONFIG+set} != xset ; then
26        LIBIDL_CONFIG=$libIDL_config_prefix/bin/libIDL-config
27     fi
28  fi
29
30  AM_PATH_GLIB(@GLIB_VERSION_REQUIRED@)
31
32  AC_PATH_PROG(LIBIDL_CONFIG, libIDL-config, no)
33  min_libIDL_version=ifelse([$1], ,0.6.0,$1)
34  AC_MSG_CHECKING(for libIDL - version >= $min_libIDL_version)
35  no_libIDL=""
36  if test "$LIBIDL_CONFIG" = "no" ; then
37    no_libIDL=yes
38  else
39    LIBIDL_CFLAGS=`$LIBIDL_CONFIG $libIDL_config_args --cflags`
40    LIBIDL_LIBS=`$LIBIDL_CONFIG $libIDL_config_args --libs`
41    libIDL_config_major_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
42           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
43    libIDL_config_minor_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
44           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
45    libIDL_config_micro_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
46           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
47    if test "x$enable_libIDLtest" = "xyes" ; then
48      ac_save_CFLAGS="$CFLAGS"
49      ac_save_LIBS="$LIBS"
50      CFLAGS="$CFLAGS $LIBIDL_CFLAGS"
51      LIBS="$LIBIDL_LIBS $LIBS"
52dnl
53dnl Now check if the installed LIBIDL is sufficiently new.
54dnl
55      rm -f conf.libIDLtest
56      AC_TRY_RUN([
57#include <stdio.h>
58#include <stdlib.h>
59#include <libIDL/IDL.h>
60
61int
62main ()
63{
64  int major, minor, micro;
65  int libIDL_major_version;
66  int libIDL_minor_version;
67  int libIDL_micro_version;
68  char *tmp_version;
69
70  system ("touch conf.libIDLtest");
71
72  /* HP/UX 9 (%@#!) writes to sscanf strings */
73  tmp_version = g_strdup ("$min_libIDL_version");
74  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
75     printf("%s, bad version string\n", "$min_libIDL_version");
76     exit(1);
77  }
78  tmp_version = g_strdup (IDL_get_libver_string ());
79  if (sscanf(tmp_version, "%d.%d.%d",
80             &libIDL_major_version,
81             &libIDL_minor_version,
82             &libIDL_micro_version) != 3) {
83     printf("%s, bad version string\n", tmp_version);
84     exit(1);
85  }
86
87  if ((libIDL_major_version != $libIDL_config_major_version) ||
88      (libIDL_minor_version != $libIDL_config_minor_version) ||
89      (libIDL_micro_version != $libIDL_config_micro_version))
90    {
91      printf("\n*** 'libIDL-config --version' returned %d.%d.%d, but libIDL (%d.%d.%d)\n",
92             $libIDL_config_major_version, $libIDL_config_minor_version, $libIDL_config_micro_version,
93             libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
94      printf ("*** was found! If libIDL-config was correct, then it is best\n");
95      printf ("*** to remove the old version of LIBIDL. You may also be able to fix the error\n");
96      printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
97      printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
98      printf("*** required on your system.\n");
99      printf("*** If libIDL-config was wrong, set the environment variable LIBIDL_CONFIG\n");
100      printf("*** to point to the correct copy of libIDL-config, and remove the file config.cache\n");
101      printf("*** before re-running configure\n");
102    }
103  else if ((libIDL_major_version != LIBIDL_MAJOR_VERSION) ||
104           (libIDL_minor_version != LIBIDL_MINOR_VERSION) ||
105           (libIDL_micro_version != LIBIDL_MICRO_VERSION))
106    {
107      printf("\n*** libIDL header files (version %d.%d.%d) do not match\n",
108             LIBIDL_MAJOR_VERSION, LIBIDL_MINOR_VERSION, LIBIDL_MICRO_VERSION);
109      printf("*** library (version %d.%d.%d)\n",
110             libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
111    }
112  else
113    {
114      if ((libIDL_major_version > major) ||
115        ((libIDL_major_version == major) && (libIDL_minor_version > minor)) ||
116        ((libIDL_major_version == major) && (libIDL_minor_version == minor) && (libIDL_micro_version >= micro)))
117      {
118        return 0;
119       }
120     else
121      {
122        printf("\n*** An old version of libIDL (%d.%d.%d) was found.\n",
123               libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
124        printf("*** You need at least libIDL version %d.%d.%d.\n",
125               major, minor, micro);
126        printf("***\n");
127        printf("*** If you have already installed a sufficiently new version, this error\n");
128        printf("*** probably means that the wrong copy of the libIDL-config shell script is\n");
129        printf("*** being found. The easiest way to fix this is to remove the old version\n");
130        printf("*** of libIDL, but you can also set the LIBIDL_CONFIG environment to point to the\n");
131        printf("*** correct copy of libIDL-config. (In this case, you will have to\n");
132        printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
133        printf("*** so that the correct libraries are found at run-time))\n");
134      }
135    }
136  return 1;
137}
138],, no_libIDL=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
139       CFLAGS="$ac_save_CFLAGS"
140       LIBS="$ac_save_LIBS"
141     fi
142  fi
143  if test "x$no_libIDL" = x ; then
144     AC_MSG_RESULT(yes)
145     ifelse([$2], , :, [$2])     
146  else
147     AC_MSG_RESULT(no)
148     if test "$LIBIDL_CONFIG" = "no" ; then
149       echo "*** The libIDL-config script installed by libIDL could not be found"
150       echo "*** If libIDL was installed in PREFIX, make sure PREFIX/bin is in"
151       echo "*** your path, or set the LIBIDL_CONFIG environment variable to the"
152       echo "*** full path to libIDL-config."
153     else
154       if test -f conf.libIDLtest ; then
155        :
156       else
157          echo "*** Could not run libIDL test program, checking why..."
158          CFLAGS="$CFLAGS $LIBIDL_CFLAGS"
159          LIBS="$LIBS $LIBIDL_LIBS"
160          AC_TRY_LINK([
161#include <stdio.h>
162#include <stdlib.h>
163#include <libIDL/IDL.h>
164],      [ return IDL_get_libver_string ? 1 : 0; ],
165        [ echo "*** The test program compiled, but did not run. This usually means"
166          echo "*** that the run-time linker is not finding libIDL or finding the wrong"
167          echo "*** version of LIBIDL. If it is not finding libIDL, you'll need to set your"
168          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
169          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
170          echo "*** is required on your system"
171          echo "***"
172          echo "*** If you have an old version installed, it is best to remove it, although"
173          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
174        [ echo "*** The test program failed to compile or link. See the file config.log for the"
175          echo "*** exact error that occured. This usually means libIDL was incorrectly installed"
176          echo "*** or that you have moved libIDL since it was installed. In the latter case, you"
177          echo "*** may want to edit the libIDL-config script: $LIBIDL_CONFIG" ])
178          CFLAGS="$ac_save_CFLAGS"
179          LIBS="$ac_save_LIBS"
180       fi
181     fi
182     LIBIDL_CFLAGS=""
183     LIBIDL_LIBS=""
184     ifelse([$3], , :, [$3])
185  fi
186  AC_SUBST(LIBIDL_CFLAGS)
187  AC_SUBST(LIBIDL_LIBS)
188  rm -f conf.libIDLtest
189])
Note: See TracBrowser for help on using the repository browser.