forked from apache/apr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml.m4
224 lines (190 loc) · 6.73 KB
/
xml.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
dnl -------------------------------------------------------- -*- autoconf -*-
dnl Licensed to the Apache Software Foundation (ASF) under one or more
dnl contributor license agreements. See the NOTICE file distributed with
dnl this work for additional information regarding copyright ownership.
dnl The ASF licenses this file to You under the Apache License, Version 2.0
dnl (the "License"); you may not use this file except in compliance with
dnl the License. You may obtain a copy of the License at
dnl
dnl http://www.apache.org/licenses/LICENSE-2.0
dnl
dnl Unless required by applicable law or agreed to in writing, software
dnl distributed under the License is distributed on an "AS IS" BASIS,
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dnl See the License for the specific language governing permissions and
dnl limitations under the License.
dnl
dnl APU_TRY_EXPAT_LINK(
dnl test-message, cache-var-name, hdrs, libs,
dnl [actions-on-success], [actions-on-failure])
dnl
dnl Tests linking against expat with libraries 'libs' and includes
dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
dnl On success, sets $expat_libs to libs, sets $apu_has_expat to 1,
dnl and runs actions-on-success; on failure runs actions-on-failure.
dnl
AC_DEFUN([APU_TRY_EXPAT_LINK], [
AC_CACHE_CHECK([$1], [$2], [
apu_expat_LIBS=$LIBS
apu_expat_CPPFLAGS=$CPPFLAGS
LIBS="$LIBS $4"
CPPFLAGS="$CPPFLAGS $INCLUDES"
AC_TRY_LINK([#include <stdlib.h>
#include <$3>], [XML_ParserCreate(NULL);],
[$2=yes], [$2=no])
LIBS=$apu_expat_LIBS
CPPFLAGS=$apu_expat_CPPFLAGS
])
if test $[$2] = yes; then
AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
[Define if $3 is available])
apu_expat_libs="$4"
apu_has_expat=1
$5
AC_SUBST(apu_has_expat)
else
apu_has_expat=0
$6
fi
])
dnl
dnl APU_SYSTEM_EXPAT: tests for a system expat installation
dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
dnl appropriately. This is mostly for compatibility with existing
dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
dnl be dropped later.
dnl
AC_DEFUN([APU_SYSTEM_EXPAT], [
APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system,
[expat.h], [-lexpat])
if test $apu_has_expat = 0; then
APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
[xmltok/xmlparse.h], [-lxmlparse -lxmltok])
fi
if test $apu_has_expat = 0; then
APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
[xml/xmlparse.h], [-lexpat])
fi
if test $apu_has_expat = 0; then
APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
[xmlparse/xmlparse.h], [-lexpat])
fi
if test $apu_has_expat = 0; then
APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
APR_ADDTO(INCLUDES, [-I/usr/local/include])
APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local],
apu_cv_expat_usrlocal, [expat.h], [-lexpat], [
APR_ADDTO(APRUTIL_INCLUDES, [-I/usr/local/include])
APR_ADDTO(APRUTIL_LDFLAGS, [-L/usr/local/lib])],[
], [
APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
APR_REMOVEFROM(INCLUDES, [-I/usr/local/include])
])
fi
])
dnl
dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled)
dnl
AC_DEFUN([APU_FIND_EXPAT], [
apu_has_expat=0
old_libs="$LIBS"
old_cppflags="$CPPFLAGS"
old_ldflags="$LDFLAGS"
AC_ARG_WITH([expat],
[ --with-expat=DIR specify Expat location], [
if test "$withval" = "yes"; then
AC_MSG_ERROR([a directory must be specified for --with-expat])
elif test "$withval" = "no"; then
if test "$apu_has_libxml2" != "1"; then
AC_MSG_ERROR([An XML parser is required! If you disable expat, you must select --with-libxml2])
fi
else
# Add given path to standard search paths if appropriate:
if test "$apu_has_libxml2" = "1"; then
AC_MSG_ERROR(Cannot build with both expat and libxml2 - please select one)
fi
if test "$withval" != "/usr"; then
APR_ADDTO(INCLUDES, [-I$withval/include])
APR_ADDTO(LDFLAGS, [-L$withval/lib])
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
fi
fi
])
if test "$apu_has_libxml2" != "1"; then
APU_SYSTEM_EXPAT
APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
APR_ADDTO(APRUTIL_LIBS, [$apu_expat_libs])
APR_XML_DIR=$bundled_subdir
AC_SUBST(APR_XML_DIR)
fi
LIBS="$old_libs"
CPPFLAGS="$old_cppflags"
LDFLAGS="$old_ldflags"
])
dnl
dnl APU_FIND_LIBXML2: figure out where LIBXML2 is located (or use bundled)
dnl
AC_DEFUN([APU_FIND_LIBXML2], [
apu_has_libxml2=0
apu_try_libxml2=0
old_libs="$LIBS"
old_cppflags="$CPPFLAGS"
old_ldflags="$LDFLAGS"
AC_ARG_WITH([libxml2],
[ --with-libxml2=DIR specify libxml2 location], [
if test "$withval" = "yes"; then
AC_PATH_TOOL([XML2_CONFIG],[xml2-config])
if test "x$XML2_CONFIG" != 'x'; then
xml2_CPPFLAGS="`$XML2_CONFIG --cflags`"
xml2_LIBS="`$XML2_CONFIG --libs`"
APR_ADDTO(CPPFLAGS, [$xml2_CPPFLAGS])
APR_ADDTO(LIBS, [$xml2_LIBS])
fi
AC_CHECK_HEADERS(libxml/parser.h, AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1]))
elif test "$withval" != "no"; then
AC_PATH_TOOL([XML2_CONFIG],[xml2-config],,[$withval/bin])
if test "x$XML2_CONFIG" != 'x'; then
xml2_CPPFLAGS="`$XML2_CONFIG --cflags`"
xml2_LIBS="`$XML2_CONFIG --libs`"
else
xml2_CPPFLAGS="-I$withval/include/libxml2"
xml2_LDFLAGS="-L$withval/lib64 -L$withval/lib"
xml2_LIBS="-lxml2"
fi
APR_ADDTO(CPPFLAGS, [$xml2_CPPFLAGS])
APR_ADDTO(LIBS, [$xml2_LIBS])
AC_MSG_NOTICE(checking for libxml2 in $withval)
AC_CHECK_HEADERS(libxml/parser.h, AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1]))
fi
], [
xml2_LIBS="-lxml2"
AC_CHECK_HEADERS(libxml/parser.h, AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1]))
])
AC_SUBST(apu_has_libxml2)
if test ${apu_has_libxml2} = "1" ; then
APR_ADDTO(APRUTIL_CPPFLAGS, [$xml2_CPPFLAGS])
APR_ADDTO(APRUTIL_PRIV_INCLUDES, [$xml2_CPPFLAGS])
APR_ADDTO(APRUTIL_LIBS, [$xml2_LIBS])
fi
LIBS="$old_libs"
CPPFLAGS="$old_cppflags"
LDFLAGS="$old_ldflags"
])
dnl
dnl APU_FIND_XML: Find an XML library
dnl
dnl Logic: we need exactly one but not both XML libraries
dnl Make expat the default for back-compatibility.
dnl Use libxml2 if a --with-libxml2 is specified (and works),
dnl otherwise expat.
dnl
AC_DEFUN([APU_FIND_XML], [
APU_FIND_LIBXML2
APU_FIND_EXPAT
if test ${apu_has_expat} = "1" && test ${apu_has_libxml2} = "1" ; then
AC_MSG_ERROR(Cannot build with both expat and libxml2 - please select one)
elif test ${apu_has_expat} != "1" && test ${apu_has_libxml2} != "1" ; then
AC_MSG_ERROR(No XML parser found! Please specify --with-expat or --with-libxml2)
fi
])