root/trunk/acinclude.m4

Revision 187, 6.9 kB (checked in by azrael, 2 years ago)

Pulled in several upstream patches

Line 
1 dnl AM_PATH_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
2 dnl Test for check, and define WBXML_CFLAGS and WBXML_LIBS
3 dnl
4
5 AC_DEFUN([AM_PATH_WBXML],
6 [
7   AC_ARG_WITH(wbxml,
8   [  --with-wbxml=PATH       prefix where wbxml is installed [default=auto]])
9  
10   min_check_version=ifelse([$1], ,0.9.0,$1)
11
12   AC_MSG_CHECKING(for wbxml - version >= $min_check_version)
13
14   if test x$with_wbxml = xno; then
15     AC_MSG_RESULT(disabled)
16   else
17     if test "x$with_wbxml" != x -a "x$with_wbxml" != "xyes"; then
18       WBXML_CFLAGS="-I$with_wbxml/include"
19       WBXML_LIBS="-L$with_wbxml/lib -lwbxml2"
20     else
21       WBXML_CFLAGS="-I/usr/include/wbxml2"
22       WBXML_LIBS="-L${libdir} -lwbxml2"
23     fi
24
25     ac_save_CFLAGS="$CFLAGS"
26     ac_save_LIBS="$LIBS"
27
28     CFLAGS="$WBXML_CFLAGS $CFLAGS"
29     LIBS="$WBXML_LIBS $LIBS"
30
31         AC_TRY_COMPILE([#include <wbxml.h>],[WBXMLConvXML2WBXMLParams w; w.wbxml_version = WBXML_VERSION_11 ],AC_MSG_RESULT(yes);LIBWBXML=yes,AC_MSG_RESULT(no);LIBWBXML=no)
32        
33         if test "x${LIBWBXML}" = "xno"; then
34            echo "To enable WBXML communication (for e.g. cell phones) you must have version 0.8.1 or later of libwbxml2."
35         else
36                 AC_DEFINE_UNQUOTED(ENABLE_WBXML, 1, Defined if the correct libwbxml2 version exists.)
37                 AC_DEFINE_UNQUOTED(WBXML_LIBS, " -lwbxml",[wbxml])
38                 AC_SUBST(WBXML_LIBS)
39         fi
40        
41         AM_CONDITIONAL(ENABLE_WBXML, test x$LIBWBXML = xyes)
42        
43     CFLAGS="$ac_save_CFLAGS"
44     LIBS="$ac_save_LIBS"
45
46     AC_SUBST(WBXML_CFLAGS)
47     AC_SUBST(WBXML_LIBS)
48
49         echo "checking WBXML_CFLAGS... $WBXML_CFLAGS"
50         echo "checking WBXML_LIBS... $WBXML_LIBS"
51
52   fi
53 ])
54
55 dnl AM_PATH_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
56 dnl Test for check, and define CHECK_CFLAGS and CHECK_LIBS
57 dnl
58
59 AC_DEFUN([AM_PATH_CHECK],
60 [
61   AC_ARG_WITH(check,
62   [  --with-check=PATH       prefix where check is installed [default=auto]])
63  
64   min_check_version=ifelse([$1], ,0.8.2,$1)
65
66   AC_MSG_CHECKING(for check - version >= $min_check_version)
67
68   if test x$with_check = xno; then
69     AC_MSG_RESULT(disabled)
70     ifelse([$3], , AC_MSG_ERROR([disabling check is not supported]), [$3])
71   else
72     if test "x$with_check" != x; then
73       CHECK_CFLAGS="-I$with_check/include"
74       CHECK_LIBS="-L$with_check/lib -lcheck"
75     else
76       CHECK_CFLAGS=""
77       CHECK_LIBS="-lcheck"
78     fi
79
80     ac_save_CFLAGS="$CFLAGS"
81     ac_save_LIBS="$LIBS"
82
83     CFLAGS="$CFLAGS $CHECK_CFLAGS"
84     LIBS="$CHECK_LIBS $LIBS"
85
86     rm -f conf.check-test
87     AC_TRY_RUN([
88 #include <stdio.h>
89 #include <stdlib.h>
90
91 #include <check.h>
92
93 int main ()
94 {
95   int major, minor, micro;
96   char *tmp_version;
97
98   system ("touch conf.check-test");
99
100   /* HP/UX 9 (%@#!) writes to sscanf strings */
101   tmp_version = strdup("$min_check_version");
102   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
103      printf("%s, bad version string\n", "$min_check_version");
104      return 1;
105    }
106    
107   if ((CHECK_MAJOR_VERSION != check_major_version) ||
108       (CHECK_MINOR_VERSION != check_minor_version) ||
109       (CHECK_MICRO_VERSION != check_micro_version))
110     {
111       printf("\n*** The check header file (version %d.%d.%d) does not match\n",
112              CHECK_MAJOR_VERSION, CHECK_MINOR_VERSION, CHECK_MICRO_VERSION);
113       printf("*** the check library (version %d.%d.%d).\n",
114              check_major_version, check_minor_version, check_micro_version);
115       return 1;
116     }
117
118   if ((check_major_version > major) ||
119       ((check_major_version == major) && (check_minor_version > minor)) ||
120       ((check_major_version == major) && (check_minor_version == minor) && (check_micro_version >= micro)))
121     {
122       return 0;
123     }
124   else
125     {
126       printf("\n*** An old version of check (%d.%d.%d) was found.\n",
127              check_major_version, check_minor_version, check_micro_version);
128       printf("*** You need a version of check being at least %d.%d.%d.\n", major, minor, micro);
129       printf("***\n");
130       printf("*** If you have already installed a sufficiently new version, this error\n");
131       printf("*** probably means that the wrong copy of the check library and header\n");
132       printf("*** file is being found. Rerun configure with the --with-check=PATH option\n");
133       printf("*** to specify the prefix where the correct version was installed.\n");
134     }
135
136   return 1;
137 }
138 ],, no_check=yes, [echo $ac_n "cross compiling; assumed OK... $ac_c"])
139
140     CFLAGS="$ac_save_CFLAGS"
141     LIBS="$ac_save_LIBS"
142
143     if test "x$no_check" = x ; then
144       AC_MSG_RESULT(yes)
145       ifelse([$2], , :, [$2])
146     else
147       AC_MSG_RESULT(no)
148       if test -f conf.check-test ; then
149         :
150       else
151         echo "*** Could not run check test program, checking why..."
152         CFLAGS="$CFLAGS $CHECK_CFLAGS"
153         LIBS="$CHECK_LIBS $LIBS"
154         AC_TRY_LINK([
155 #include <stdio.h>
156 #include <stdlib.h>
157
158 #include <check.h>
159 ], ,  [ echo "*** The test program compiled, but did not run. This usually means"
160         echo "*** that the run-time linker is not finding check. You'll need to set your"
161         echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
162         echo "*** to the installed location  Also, make sure you have run ldconfig if that"
163         echo "*** is required on your system"
164         echo "***"
165         echo "*** If you have an old version installed, it is best to remove it, although"
166         echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
167       [ echo "*** The test program failed to compile or link. See the file config.log for"
168         echo "*** the exact error that occured." ])
169      
170         CFLAGS="$ac_save_CFLAGS"
171         LIBS="$ac_save_LIBS"
172       fi
173
174       CHECK_CFLAGS=""
175       CHECK_LIBS=""
176
177       rm -f conf.check-test
178       ifelse([$3], , AC_MSG_ERROR([check not found]), [$3])
179     fi
180
181     AC_SUBST(CHECK_CFLAGS)
182     AC_SUBST(CHECK_LIBS)
183
184     rm -f conf.check-test
185
186   fi
187 ])
188
189 AC_DEFUN([AM_PATH_OPENOBEX], [
190         if (test "${prefix}" = "NONE"); then
191                 openobex_prefix=${ac_default_prefix}
192         else
193                 openobex_prefix=${prefix}
194         fi
195
196         AC_ARG_WITH(openobex, AC_HELP_STRING([--with-openobex=DIR], [OpenOBEX library is installed in DIR]), [
197                 if (test "${withval}" != "yes"); then
198                         openobex_prefix=${withval}
199                 fi
200         ])
201
202         ac_save_CPPFLAGS=$CPPFLAGS
203         ac_save_LDFLAGS=$LDFLAGS
204
205         OPENOBEX_CFLAGS=""
206         test -d "${openobex_prefix}/include" && OPENOBEX_CFLAGS="$OPENOBEX_CFLAGS -I${openobex_prefix}/include"
207
208         CPPFLAGS="$CPPFLAGS $OPENOBEX_CFLAGS"
209         AC_CHECK_HEADER(openobex/obex.h,, AC_MSG_ERROR(OpenOBEX header files not found))
210
211         OPENOBEX_LIBS=""
212         if (test "${ac_default_prefix}" = "${openobex_prefix}"); then
213                 test -d "${libdir}" && OPENOBEX_LIBS="$OPENOBEX_LIBS -L${libdir}"
214         else
215                 test -d "${openobex_prefix}/lib64" && OPENOBEX_LIBS="$OPENOBEX_LIBS -L${openobex_prefix}/lib64"
216                 test -d "${openobex_prefix}/lib" && OPENOBEX_LIBS="$OPENOBEX_LIBS -L${openobex_prefix}/lib"
217         fi
218
219         LDFLAGS="$LDFLAGS $OPENOBEX_LIBS"
220         AC_CHECK_LIB(openobex, OBEX_Init, OPENOBEX_LIBS="$OPENOBEX_LIBS -lopenobex", AC_MSG_ERROR(OpenOBEX library not found))
221
222         CPPFLAGS=$ac_save_CPPFLAGS
223         LDFLAGS=$ac_save_LDFLAGS
224
225         AC_SUBST(OPENOBEX_CFLAGS)
226         AC_SUBST(OPENOBEX_LIBS)
227 ])
Note: See TracBrowser for help on using the browser.