@@ -4,43 +4,14 @@ dnl Sets:
4
4
dnl LIBXML2_CFLAGS
5
5
dnl LIBXML2_LIBS
6
6
7
- AC_DEFUN ( [ CHECK_XML2CONFIG] , [
8
-
9
- AC_MSG_CHECKING ( [ for libxml2 config script] )
10
-
11
- for x in ${test_paths}; do
12
- dnl # Determine if the script was specified and use it directly
13
- if test ! -d "$x" -a -e "$x"; then
14
- LIBXML2_CONFIG=$x
15
- libxml2_path="no"
16
- break
17
- fi
18
-
19
- dnl # Try known config script names/locations
20
- for LIBXML2_CONFIG in xml2-config xml-2-config xml-config; do
21
- if test -e "${x}/bin/${LIBXML2_CONFIG}"; then
22
- libxml2_path="${x}/bin"
23
- break
24
- elif test -e "${x}/${LIBXML2_CONFIG}"; then
25
- libxml2_path="${x}"
26
- break
27
- else
28
- libxml2_path=""
29
- fi
30
- done
31
- if test -n "$libxml2_path"; then
32
- break
33
- fi
34
- done
35
-
36
- if test -n "${libxml2_path}"; then
37
- if test "${libxml2_path}" != "no"; then
38
- LIBXML2_CONFIG="${libxml2_path}/${LIBXML2_CONFIG}"
39
- fi
7
+ AC_DEFUN ( [ CHECK_FOR_LIBXML2_AT] , [
8
+ libxml2_path=$1
9
+ if test "${libxml2_path}" != "no"; then
10
+ LIBXML2_CONFIG="${libxml2_path}/${LIBXML2_CONFIG}"
40
11
AC_MSG_RESULT ( [ ${LIBXML2_CONFIG}] )
41
12
LIBXML2_VERSION=`${LIBXML2_CONFIG} --version | sed 's/^[ [ ^0-9] ] [ [ ^[ :space:] ] ] [ [ ^[ :space:] ] ] *[ [ [ :space:] ] ] *//'`
42
13
if test ! -z "${LIBXML2_VERSION}"; then AC_MSG_NOTICE ( xml VERSION: $LIBXML2_VERSION ) ; fi
43
- LIBXML2_CFLAGS="`${LIBXML2_CONFIG} --cflags` -DWITH_LIBXML2 "
14
+ LIBXML2_CFLAGS="`${LIBXML2_CONFIG} --cflags`"
44
15
if test ! -z "${LIBXML2_CFLAGS}"; then AC_MSG_NOTICE ( xml CFLAGS: $LIBXML2_CFLAGS ) ; fi
45
16
LIBXML2_LDADD="`${LIBXML2_CONFIG} --libs`"
46
17
if test ! -z "${LIBXML2_LDADD}"; then AC_MSG_NOTICE ( xml LDADD: $LIBXML2_LDADD ) ; fi
@@ -54,11 +25,8 @@ if test -n "${libxml2_path}"; then
54
25
AC_MSG_RESULT ( [ no, $LIBXML2_VERSION] )
55
26
AC_MSG_ERROR ( [ NOTE: libxml2 library must be at least ${LIBXML2_MIN_VERSION}] )
56
27
fi
57
-
58
- else
59
- AC_MSG_RESULT ( [ no] )
60
28
fi
61
- ] )
29
+ ] ) # AC_DEFUN [CHECK_FOR_LIBXML2_AT]
62
30
63
31
AC_DEFUN ( [ CHECK_LIBXML2] , [
64
32
@@ -73,16 +41,19 @@ LIBXML2_PKG_NAME="libxml-2.0"
73
41
LIBXML2_CONFIG=""
74
42
LIBXML2_VERSION=""
75
43
LIBXML2_CFLAGS=""
76
- LIBXML2_CPPFLAGS=""
77
44
LIBXML2_LDADD=""
78
45
LIBXML2_LDFLAGS=""
79
46
80
- if test "x${with_libxml}" != "xno"; then
47
+ LIBXML2_MANDATORY=yes
48
+ AC_MSG_NOTICE ( [ libxml2 is mandatory] )
49
+
50
+ if test "x${with_libxml}" == "x" || test "x${with_libxml}" == "xyes"; then
51
+ # Nothing about libxml was informed, using the pkg-config to figure things out.
81
52
if test -n "${PKG_CONFIG}"; then
82
53
AC_MSG_CHECKING ( [ for libxml2 >= ${LIBXML2_MIN_VERSION} via pkg-config] )
83
54
if `${PKG_CONFIG} --exists "${LIBXML2_PKG_NAME} >= ${LIBXML2_MIN_VERSION}"`; then
84
55
LIBXML2_VERSION="`${PKG_CONFIG} --modversion ${LIBXML2_PKG_NAME}`"
85
- LIBXML2_CFLAGS="`${PKG_CONFIG} --cflags ${LIBXML2_PKG_NAME}` -DWITH_LIBXML2 "
56
+ LIBXML2_CFLAGS="`${PKG_CONFIG} --cflags ${LIBXML2_PKG_NAME}`"
86
57
LIBXML2_LDADD="`${PKG_CONFIG} --libs-only-l ${LIBXML2_PKG_NAME}`"
87
58
LIBXML2_LDFLAGS="`${PKG_CONFIG} --libs-only-L --libs-only-other ${LIBXML2_PKG_NAME}`"
88
59
AC_MSG_RESULT ( [ found version ${LIBXML2_VERSION}] )
@@ -92,44 +63,48 @@ if test "x${with_libxml}" != "xno"; then
92
63
fi
93
64
94
65
if test -z "${LIBXML2_VERSION}"; then
95
- CHECK_XML2CONFIG
96
- fi
97
- fi
98
-
99
- AC_SUBST ( LIBXML2_CONFIG )
100
- AC_SUBST ( LIBXML2_VERSION )
101
- AC_SUBST ( LIBXML2_CFLAGS )
102
- AC_SUBST ( LIBXML2_CPPFLAGS )
103
- AC_SUBST ( LIBXML2_LDADD )
104
- AC_SUBST ( LIBXML2_LDFLAGS )
105
-
106
-
107
- if test "x${with_libxml}" == "xno"; then
108
- LIBXML2_DISABLED=yes
109
- else
110
- if test "x${with_libxml}" != "x"; then
111
- LIBXML2_MANDATORY=yes
66
+ # If pkg-config did not find anything useful, go over file lookup.
67
+ AC_MSG_CHECKING ( [ for libxml2 config script] )
68
+
69
+ for x in ${test_paths}; do
70
+ dnl # Try known config script names/locations
71
+ for LIBXML2_CONFIG in xml2-config xml-2-config xml-config; do
72
+ if test -e "${x}/bin/${LIBXML2_CONFIG}"; then
73
+ libxml2_path="${x}/bin"
74
+ break
75
+ elif test -e "${x}/${LIBXML2_CONFIG}"; then
76
+ libxml2_path="${x}"
77
+ break
78
+ else
79
+ libxml2_path=""
80
+ fi
81
+ done
82
+ if test -n "$libxml2_path"; then
83
+ CHECK_FOR_LIBXML2_AT(${libxml2_path})
84
+ if test -n "${LIBXML2_VERSION}"; then
85
+ break
86
+ fi
87
+ fi
88
+ done
112
89
fi
90
+ elif test "x${with_libxml}" != "x"; then
91
+ # A specific path was informed, let's check.
92
+ CHECK_FOR_LIBXML2_AT(${with_libxml})
113
93
fi
114
94
115
95
if test -z "${LIBXML2_VERSION}"; then
116
- AC_MSG_NOTICE ( [ *** libxml2 library not found.] )
117
- if test -z "${LIBXML2_MANDATORY}"; then
118
- if test -z "${LIBXML2_DISABLED}"; then
119
- LIBXML2_FOUND=0
120
- else
121
- LIBXML2_FOUND=2
122
- fi
123
- else
124
- AC_MSG_ERROR ( [ Libxml2 was explicitly referenced but it was not found] )
125
- LIBXML2_FOUND=-1
126
- fi
96
+ AC_MSG_ERROR ( [ libxml2 is mandatory but it was not found] )
97
+ LIBXML2_FOUND=-1
127
98
else
128
99
LIBXML2_FOUND=1
129
100
AC_MSG_NOTICE ( [ using libxml2 v${LIBXML2_VERSION}] )
101
+ AC_SUBST ( LIBXML2_VERSION )
102
+ AC_SUBST ( LIBXML2_CFLAGS )
103
+ AC_SUBST ( LIBXML2_LDADD )
104
+ AC_SUBST ( LIBXML2_LDFLAGS )
130
105
LIBXML2_DISPLAY="${LIBXML2_LDADD}, ${LIBXML2_CFLAGS}"
106
+ AC_SUBST ( LIBXML2_DISPLAY )
131
107
fi
132
108
133
109
AC_SUBST ( LIBXML2_FOUND )
134
- AC_SUBST ( LIBXML2_DISPLAY )
135
110
] )
0 commit comments