1 | dnl AM_PATH_OAF([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) |
---|
2 | dnl Test for OAF, and define OAF_CFLAGS and OAF_LIBS |
---|
3 | dnl |
---|
4 | AC_DEFUN(AM_PATH_OAF, |
---|
5 | [dnl |
---|
6 | dnl Get the cflags and libraries from the oaf-config script |
---|
7 | dnl |
---|
8 | AC_ARG_WITH(oaf-prefix,[ --with-oaf-prefix=PFX Prefix where OAF is installed (optional)], |
---|
9 | oaf_config_prefix="$withval", oaf_config_prefix="") |
---|
10 | AC_ARG_WITH(oaf-exec-prefix,[ --with-oaf-exec-prefix=PFX Exec prefix where OAF is installed (optional)], |
---|
11 | oaf_config_exec_prefix="$withval", oaf_config_exec_prefix="") |
---|
12 | AC_ARG_ENABLE(oaftest, [ --disable-oaftest Do not try to compile and run a test OAF program], |
---|
13 | , enable_oaftest=yes) |
---|
14 | |
---|
15 | oaf_config_args="$oaf_config_args $4" |
---|
16 | |
---|
17 | if test x$oaf_config_exec_prefix != x ; then |
---|
18 | oaf_config_args="$oaf_config_args --exec-prefix=$oaf_config_exec_prefix" |
---|
19 | if test x${OAF_CONFIG+set} != xset ; then |
---|
20 | OAF_CONFIG=$oaf_config_exec_prefix/bin/oaf-config |
---|
21 | fi |
---|
22 | fi |
---|
23 | if test x$oaf_config_prefix != x ; then |
---|
24 | oaf_config_args="$oaf_config_args --prefix=$oaf_config_prefix" |
---|
25 | if test x${OAF_CONFIG+set} != xset ; then |
---|
26 | OAF_CONFIG=$oaf_config_prefix/bin/oaf-config |
---|
27 | fi |
---|
28 | fi |
---|
29 | |
---|
30 | AC_PATH_PROG(OAF_CONFIG, oaf-config, no) |
---|
31 | min_oaf_version=ifelse([$1], , 0.1, $1) |
---|
32 | AC_MSG_CHECKING(for OAF - version >= $min_oaf_version) |
---|
33 | no_oaf="" |
---|
34 | if test "$OAF_CONFIG" = "no" ; then |
---|
35 | no_oaf=yes |
---|
36 | else |
---|
37 | OAF_CFLAGS="`$OAF_CONFIG $oaf_config_args --cflags`" |
---|
38 | OAF_LIBS="`$OAF_CONFIG $oaf_config_args --libs`" |
---|
39 | oaf_config_major_version=`$OAF_CONFIG $oaf_config_args --version | \ |
---|
40 | sed -e 's,^[[^0-9.]]*,,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
---|
41 | oaf_config_minor_version=`$OAF_CONFIG $oaf_config_args --version | \ |
---|
42 | sed -e 's,^[[^0-9.]]*,,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
---|
43 | oaf_config_micro_version=`$OAF_CONFIG $oaf_config_args --version | \ |
---|
44 | sed -e 's,^[[^0-9\.]]*,,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
---|
45 | if test "x$enable_oaftest" = "xyes" ; then |
---|
46 | ac_save_CFLAGS="$CFLAGS" |
---|
47 | ac_save_LIBS="$LIBS" |
---|
48 | CFLAGS="$CFLAGS $OAF_CFLAGS" |
---|
49 | LIBS="$OAF_LIBS $LIBS" |
---|
50 | dnl |
---|
51 | dnl Now check if the installed OAF is sufficiently new. (Also sanity |
---|
52 | dnl checks the results of oaf-config to some extent |
---|
53 | dnl |
---|
54 | rm -f conf.oaftest |
---|
55 | AC_TRY_RUN([ |
---|
56 | #include <liboaf/liboaf.h> |
---|
57 | #include <stdio.h> |
---|
58 | #include <stdlib.h> |
---|
59 | |
---|
60 | int |
---|
61 | main () |
---|
62 | { |
---|
63 | int major, minor, micro; |
---|
64 | char *tmp_version; |
---|
65 | |
---|
66 | system ("touch conf.oaftest"); |
---|
67 | |
---|
68 | /* HP/UX 9 (%@#!) writes to sscanf strings */ |
---|
69 | tmp_version = g_strdup("$min_oaf_version"); |
---|
70 | if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { |
---|
71 | printf("%s, bad version string\n", "$min_oaf_version"); |
---|
72 | exit(1); |
---|
73 | } |
---|
74 | |
---|
75 | if ((liboaf_major_version != $oaf_config_major_version) || |
---|
76 | (liboaf_minor_version != $oaf_config_minor_version) || |
---|
77 | (liboaf_micro_version != $oaf_config_micro_version)) |
---|
78 | { |
---|
79 | printf("\n*** 'oaf-config --version' returned %d.%d.%d, but OAF (%d.%d.%d)\n", |
---|
80 | $oaf_config_major_version, $oaf_config_minor_version, $oaf_config_micro_version, |
---|
81 | liboaf_major_version, liboaf_minor_version, liboaf_micro_version); |
---|
82 | printf ("*** was found! If oaf-config was correct, then it is best\n"); |
---|
83 | printf ("*** to remove the old version of OAF. You may also be able to fix the error\n"); |
---|
84 | printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); |
---|
85 | printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); |
---|
86 | printf("*** required on your system.\n"); |
---|
87 | printf("*** If oaf-config was wrong, set the environment variable OAF_CONFIG\n"); |
---|
88 | printf("*** to point to the correct copy of oaf-config, and remove the file config.cache\n"); |
---|
89 | printf("*** before re-running configure\n"); |
---|
90 | } |
---|
91 | #if defined (OAF_MAJOR_VERSION) && defined (OAF_MINOR_VERSION) && defined (OAF_MICRO_VERSION) |
---|
92 | else if ((liboaf_major_version != OAF_MAJOR_VERSION) || |
---|
93 | (liboaf_minor_version != OAF_MINOR_VERSION) || |
---|
94 | (liboaf_micro_version != OAF_MICRO_VERSION)) |
---|
95 | { |
---|
96 | printf("*** OAF header files (version %d.%d.%d) do not match\n", |
---|
97 | OAF_MAJOR_VERSION, OAF_MINOR_VERSION, OAF_MICRO_VERSION); |
---|
98 | printf("*** library (version %d.%d.%d)\n", |
---|
99 | liboaf_major_version, liboaf_minor_version, liboaf_micro_version); |
---|
100 | } |
---|
101 | #endif /* defined (OAF_MAJOR_VERSION) ... */ |
---|
102 | else |
---|
103 | { |
---|
104 | if ((liboaf_major_version > major) || |
---|
105 | ((liboaf_major_version == major) && (liboaf_minor_version > minor)) || |
---|
106 | ((liboaf_major_version == major) && (liboaf_minor_version == minor) && (liboaf_micro_version >= micro))) |
---|
107 | { |
---|
108 | return 0; |
---|
109 | } |
---|
110 | else |
---|
111 | { |
---|
112 | printf("\n*** An old version of OAF (%d.%d.%d) was found.\n", |
---|
113 | liboaf_major_version, liboaf_minor_version, liboaf_micro_version); |
---|
114 | printf("*** You need a version of OAF newer than %d.%d.%d. The latest version of\n", |
---|
115 | major, minor, micro); |
---|
116 | printf("*** OAF is always available from ftp://ftp.gnome.org/pub/GNOME/sources/oaf/.\n"); |
---|
117 | printf("***\n"); |
---|
118 | printf("*** If you have already installed a sufficiently new version, this error\n"); |
---|
119 | printf("*** probably means that the wrong copy of the oaf-config shell script is\n"); |
---|
120 | printf("*** being found. The easiest way to fix this is to remove the old version\n"); |
---|
121 | printf("*** of OAF, but you can also set the OAF_CONFIG environment to point to the\n"); |
---|
122 | printf("*** correct copy of oaf-config. (In this case, you will have to\n"); |
---|
123 | printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); |
---|
124 | printf("*** so that the correct libraries are found at run-time))\n"); |
---|
125 | } |
---|
126 | } |
---|
127 | return 1; |
---|
128 | } |
---|
129 | ],, no_oaf=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
---|
130 | CFLAGS="$ac_save_CFLAGS" |
---|
131 | LIBS="$ac_save_LIBS" |
---|
132 | fi |
---|
133 | fi |
---|
134 | if test "x$no_oaf" = x ; then |
---|
135 | AC_MSG_RESULT(yes) |
---|
136 | ifelse([$2], , :, [$2]) |
---|
137 | else |
---|
138 | AC_MSG_RESULT(no) |
---|
139 | if test "$OAF_CONFIG" = "no" ; then |
---|
140 | echo "*** The oaf-config script installed by OAF could not be found" |
---|
141 | echo "*** If OAF was installed in PREFIX, make sure PREFIX/bin is in" |
---|
142 | echo "*** your path, or set the OAF_CONFIG environment variable to the" |
---|
143 | echo "*** full path to oaf-config." |
---|
144 | else |
---|
145 | if test -f conf.oaftest ; then |
---|
146 | : |
---|
147 | else |
---|
148 | echo "*** Could not run OAF test program, checking why..." |
---|
149 | CFLAGS="$CFLAGS $OAF_CFLAGS" |
---|
150 | LIBS="$LIBS $OAF_LIBS" |
---|
151 | AC_TRY_LINK([ |
---|
152 | #include <liboaf/liboaf.h> |
---|
153 | #include <stdio.h> |
---|
154 | ], [ return ((liboaf_major_version) || (liboaf_minor_version) || (liboaf_micro_version)); ], |
---|
155 | [ echo "*** The test program compiled, but did not run. This usually means" |
---|
156 | echo "*** that the run-time linker is not finding OAF or finding the wrong" |
---|
157 | echo "*** version of OAF. If it is not finding OAF, you'll need to set your" |
---|
158 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
---|
159 | echo "*** to the installed location Also, make sure you have run ldconfig if that" |
---|
160 | echo "*** is required on your system" |
---|
161 | echo "***" |
---|
162 | echo "*** If you have an old version installed, it is best to remove it, although" |
---|
163 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" |
---|
164 | echo "***" |
---|
165 | echo "*** If you have a RedHat 5.0 system, you should remove the OAF package that" |
---|
166 | echo "*** came with the system with the command" |
---|
167 | echo "***" |
---|
168 | echo "*** rpm --erase --nodeps oaf oaf-devel" ], |
---|
169 | [ echo "*** The test program failed to compile or link. See the file config.log for the" |
---|
170 | echo "*** exact error that occured. This usually means OAF was incorrectly installed" |
---|
171 | echo "*** or that you have moved OAF since it was installed. In the latter case, you" |
---|
172 | echo "*** may want to edit the oaf-config script: $OAF_CONFIG" ]) |
---|
173 | CFLAGS="$ac_save_CFLAGS" |
---|
174 | LIBS="$ac_save_LIBS" |
---|
175 | fi |
---|
176 | fi |
---|
177 | OAF_CFLAGS="" |
---|
178 | OAF_LIBS="" |
---|
179 | ifelse([$3], , :, [$3]) |
---|
180 | fi |
---|
181 | AC_SUBST(OAF_CFLAGS) |
---|
182 | AC_SUBST(OAF_LIBS) |
---|
183 | rm -f conf.oaftest |
---|
184 | ]) |
---|