1 # Configure paths for LIBIDL
3 dnl AM_PATH_LIBIDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
4 dnl Test for LIBIDL, and define LIBIDL_CFLAGS and LIBIDL_LIBS
6 AC_DEFUN([AM_PATH_LIBIDL_2],
8 dnl Get the cflags and libraries from the libIDL-config-2 script
10 AC_ARG_WITH(libIDL-prefix,[ --with-libIDL-prefix=PFX
11 Prefix where libIDL is installed (optional)],
12 libIDL_config_prefix="$withval", libIDL_config_prefix="")
13 AC_ARG_WITH(libIDL-exec-prefix,[ --with-libIDL-exec-prefix=PFX
14 Exec prefix where libIDL is installed (optional)],
15 libIDL_config_exec_prefix="$withval", libIDL_config_exec_prefix="")
16 AC_ARG_ENABLE(libIDLtest, [ --disable-libIDLtest Do not try to compile and run a test libIDL program],
17 , enable_libIDLtest=yes)
19 if test x$libIDL_config_exec_prefix != x ; then
20 libIDL_config_args="$libIDL_config_args --exec-prefix=$libIDL_config_exec_prefix"
21 if test x${LIBIDL_CONFIG+set} != xset ; then
22 LIBIDL_CONFIG=$libIDL_config_exec_prefix/bin/libIDL-config-2
25 if test x$libIDL_config_prefix != x ; then
26 libIDL_config_args="$libIDL_config_args --prefix=$libIDL_config_prefix"
27 if test x${LIBIDL_CONFIG+set} != xset ; then
28 LIBIDL_CONFIG=$libIDL_config_prefix/bin/libIDL-config-2
32 dnl Force a version check to keep upgraded versions from being overridden by the cached value.
33 unset ac_cv_path_LIBIDL_CONFIG
35 AC_PATH_PROG(LIBIDL_CONFIG, libIDL-config-2, no)
36 min_libIDL_version=ifelse([$1], ,0.6.0,$1)
37 AC_MSG_CHECKING(for libIDL - version >= $min_libIDL_version)
39 if test "$LIBIDL_CONFIG" = "no" ; then
42 LIBIDL_CFLAGS=`$LIBIDL_CONFIG $libIDL_config_args --cflags`
43 LIBIDL_LIBS=`$LIBIDL_CONFIG $libIDL_config_args --libs`
44 # hack to allow us to keep using libIDL 0.6.3-0.6.7. Anyone may remove
45 # this after we start requiring libIDL 0.6.8 or anything higher
46 LIBIDL_CFLAGS="$GLIB_CFLAGS $LIBIDL_CFLAGS"
47 LIBIDL_LIBS="$GLIB_LIBS $LIBIDL_LIBS"
48 libIDL_config_major_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
49 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
50 libIDL_config_minor_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
51 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
52 libIDL_config_micro_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
53 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
54 if test "x$enable_libIDLtest" = "xyes" ; then
55 ac_save_CFLAGS="$CFLAGS"
57 CFLAGS="$CFLAGS $LIBIDL_CFLAGS"
58 LIBS="$LIBIDL_LIBS $LIBS"
60 dnl Now check if the installed LIBIDL is sufficiently new.
66 #include <libIDL/IDL.h>
71 int major, minor, micro;
72 int libIDL_major_version;
73 int libIDL_minor_version;
74 int libIDL_micro_version;
77 system ("touch conf.libIDLtest");
79 /* HP/UX 9 (%@#!) writes to sscanf strings */
80 tmp_version = g_strdup ("$min_libIDL_version");
81 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
82 printf("%s, bad version string\n", "$min_libIDL_version");
85 tmp_version = g_strdup (IDL_get_libver_string ());
86 if (sscanf(tmp_version, "%d.%d.%d",
87 &libIDL_major_version,
88 &libIDL_minor_version,
89 &libIDL_micro_version) != 3) {
90 printf("%s, bad version string\n", tmp_version);
94 if ((libIDL_major_version != $libIDL_config_major_version) ||
95 (libIDL_minor_version != $libIDL_config_minor_version) ||
96 (libIDL_micro_version != $libIDL_config_micro_version))
98 printf("\n*** 'libIDL-config-2 --version' returned %d.%d.%d, but libIDL (%d.%d.%d)\n",
99 $libIDL_config_major_version, $libIDL_config_minor_version, $libIDL_config_micro_version,
100 libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
101 printf ("*** was found! If libIDL-config-2 was correct, then it is best\n");
102 printf ("*** to remove the old version of LIBIDL. You may also be able to fix the error\n");
103 printf("*** by modifying your LD_LIBRARY_PATH environment variable, or by editing\n");
104 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
105 printf("*** required on your system.\n");
106 printf("*** If libIDL-config-2 was wrong, set the environment variable LIBIDL_CONFIG\n");
107 printf("*** to point to the correct copy of libIDL-config-2, and remove the file config.cache\n");
108 printf("*** before re-running configure\n");
110 else if ((libIDL_major_version != LIBIDL_MAJOR_VERSION) ||
111 (libIDL_minor_version != LIBIDL_MINOR_VERSION) ||
112 (libIDL_micro_version != LIBIDL_MICRO_VERSION))
114 printf("\n*** libIDL header files (version %d.%d.%d) do not match\n",
115 LIBIDL_MAJOR_VERSION, LIBIDL_MINOR_VERSION, LIBIDL_MICRO_VERSION);
116 printf("*** library (version %d.%d.%d)\n",
117 libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
121 if ((libIDL_major_version > major) ||
122 ((libIDL_major_version == major) && (libIDL_minor_version > minor)) ||
123 ((libIDL_major_version == major) && (libIDL_minor_version == minor) && (libIDL_micro_version >= micro)))
129 printf("\n*** An old version of libIDL (%d.%d.%d) was found.\n",
130 libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
131 printf("*** You need at least libIDL version %d.%d.%d.\n",
132 major, minor, micro);
134 printf("*** If you have already installed a sufficiently new version, this error\n");
135 printf("*** probably means that the wrong copy of the libIDL-config-2 shell script is\n");
136 printf("*** being found. The easiest way to fix this is to remove the old version\n");
137 printf("*** of libIDL, but you can also set the LIBIDL_CONFIG environment to point to the\n");
138 printf("*** correct copy of libIDL-config-2. (In this case, you will have to\n");
139 printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n");
140 printf("*** so that the correct libraries are found at run-time))\n");
145 ],, no_libIDL=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
146 CFLAGS="$ac_save_CFLAGS"
150 if test "x$no_libIDL" = x ; then
152 ifelse([$2], , :, [$2])
155 if test "$LIBIDL_CONFIG" = "no" ; then
156 echo "*** The libIDL-config-2 script installed by libIDL could not be found"
157 echo "*** If libIDL was installed in PREFIX, make sure PREFIX/bin is in"
158 echo "*** your path, or set the LIBIDL_CONFIG environment variable to the"
159 echo "*** full path to libIDL-config-2."
161 if test -f conf.libIDLtest ; then
164 echo "*** Could not run libIDL test program, checking why..."
165 CFLAGS="$CFLAGS $LIBIDL_CFLAGS"
166 LIBS="$LIBS $LIBIDL_LIBS"
170 #include <libIDL/IDL.h>
171 ], [ return IDL_get_libver_string ? 1 : 0; ],
172 [ echo "*** The test program compiled, but did not run. This usually means"
173 echo "*** that the run-time linker is not finding libIDL or finding the wrong"
174 echo "*** version of LIBIDL. If it is not finding libIDL, you'll need to set your"
175 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
176 echo "*** to the installed location Also, make sure you have run ldconfig if that"
177 echo "*** is required on your system"
179 echo "*** If you have an old version installed, it is best to remove it, although"
180 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
181 [ echo "*** The test program failed to compile or link. See the file config.log for the"
182 echo "*** exact error that occured. This usually means libIDL was incorrectly installed"
183 echo "*** or that you have moved libIDL since it was installed. In the latter case, you"
184 echo "*** may want to edit the libIDL-config-2 script: $LIBIDL_CONFIG" ])
185 CFLAGS="$ac_save_CFLAGS"
191 ifelse([$3], , :, [$3])
193 AC_SUBST(LIBIDL_CFLAGS)
194 AC_SUBST(LIBIDL_LIBS)
195 rm -f conf.libIDLtest