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