diff options
Diffstat (limited to 'm4')
-rw-r--r-- | m4/uriparser.m4 | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/m4/uriparser.m4 b/m4/uriparser.m4 new file mode 100644 index 0000000..7fb25d6 --- /dev/null +++ b/m4/uriparser.m4 | |||
@@ -0,0 +1,137 @@ | |||
1 | # (this check is rougly based on and inspired libcurl.m4) | ||
2 | # URIPARSER_CHECK ([DEFAULT-ACTION], [MINIMUM-VERSION], | ||
3 | # [ACTION-IF-YES], [ACTION-IF-NO]) | ||
4 | # Checks for uriparser library. DEFAULT-ACTION is the string yes or no to | ||
5 | # specify whether to default to --with-uriparser or --without-liburiparser. | ||
6 | # If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the | ||
7 | # minimum version of uriparser to accept. Pass the version as a regular | ||
8 | # version number like 0.8.5. If not supplied, any version is | ||
9 | # accepted. ACTION-IF-YES is a list of shell commands to run if | ||
10 | # uriparser was successfully found and passed the various tests. | ||
11 | # ACTION-IF-NO is a list of shell commands that are run otherwise. | ||
12 | # Note that using --without-uriparser does run ACTION-IF-NO. | ||
13 | # | ||
14 | # This macro #defines HAVE_URIPARSER if a working uriparser setup is | ||
15 | # found, and sets @URIPARSER@ and @URIPARSER_CPPFLAGS@ to the necessary | ||
16 | # values. | ||
17 | # | ||
18 | # Users may override the detected values by doing something like: | ||
19 | # URIPARSER="-luriparser" URIPARSER_CPPFLAGS="-I/usr/myinclude" ./configure | ||
20 | # | ||
21 | |||
22 | AC_DEFUN([URIPARSER_CHECK], | ||
23 | [ | ||
24 | AC_ARG_WITH(uriparser, | ||
25 | AS_HELP_STRING([--with-uriparser=PREFIX],[look for the uriparser library in PREFIX/lib and headers in PREFIX/include]), | ||
26 | [_uriparser_with=$withval],[_uriparser_with=ifelse([$1],,[yes],[$1])]) | ||
27 | |||
28 | if test "$_uriparser_with" != "no" ; then | ||
29 | |||
30 | _uriparser_try_link=yes | ||
31 | |||
32 | if test -d "$_uriparser_with" ; then | ||
33 | URIPARSER_CPPFLAGS="-I$withval/include" | ||
34 | _uriparser_ldflags="-L$withval/lib" | ||
35 | fi | ||
36 | |||
37 | AC_CHECK_PROG(PKGCONFIG,pkg-config,pkg-config,no) | ||
38 | |||
39 | if test x$PKGCONFIG != xno; then | ||
40 | |||
41 | AC_CACHE_CHECK([for the version of uriparser], | ||
42 | [uriparser_cv_uriparser_version], | ||
43 | [uriparser_cv_uriparser_version=`$PKGCONFIG liburiparser --modversion`]) | ||
44 | |||
45 | AC_PROG_AWK | ||
46 | |||
47 | _uriparser_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'" | ||
48 | |||
49 | _uriparser_version=`echo $uriparser_cv_uriparser_version | $_uriparser_version_parse` | ||
50 | _uriparser_wanted=`echo ifelse([$2],,[0],[$2]) | $_uriparser_version_parse` | ||
51 | |||
52 | if test $_uriparser_wanted -gt 0 ; then | ||
53 | AC_CACHE_CHECK([for uriparser >= version $2], | ||
54 | [uriparser_cv_lib_version_ok], | ||
55 | [ | ||
56 | if test $_uriparser_version -ge $_uriparser_wanted ; then | ||
57 | uriparser_cv_lib_version_ok=yes | ||
58 | else | ||
59 | uriparser_cv_lib_version_ok=no | ||
60 | fi | ||
61 | ]) | ||
62 | fi | ||
63 | |||
64 | if test $_uriparser_wanted -eq 0 || test x$uriparser_cv_lib_version_ok = xyes ; then | ||
65 | if test x"$URIPARSER_CPPFLAGS" = "x" ; then | ||
66 | URIPARSER_CPPFLAGS=`$PKGCONFIG liburiparser --cflags` | ||
67 | fi | ||
68 | if test x"$URIPARSER" = "x" ; then | ||
69 | URIPARSER=`$PKGCONFIG liburiparser --libs` | ||
70 | fi | ||
71 | else | ||
72 | _uriparser_try_link=no | ||
73 | fi | ||
74 | |||
75 | unset _uriparser_wanted | ||
76 | fi | ||
77 | |||
78 | if test $_uriparser_try_link = yes ; then | ||
79 | |||
80 | # we didn't find curl-config, so let's see if the user-supplied | ||
81 | # link line (or failing that, "-luriparser") is enough. | ||
82 | URIPARSERLIBS=${URIPARSERLIBS-"$_uriparser_ldflags -luriparser"} | ||
83 | |||
84 | AC_CACHE_CHECK([whether uriparser is usable], | ||
85 | [uriparser_cv_lib_uriparser_usable], | ||
86 | [ | ||
87 | _liburiparser_save_cppflags=$CPPFLAGS | ||
88 | CPPFLAGS="$URIPARSER_CPPFLAGS $CPPFLAGS" | ||
89 | _liburiparser_save_libs=$LIBS | ||
90 | LIBS="$URIPARSER $LIBS" | ||
91 | |||
92 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <uriparser/Uri.h>]],[[ | ||
93 | /* Try and use a few common options to force a failure if we are | ||
94 | missing symbols or cannot link. */ | ||
95 | UriParserStateA state; | ||
96 | UriUriA uri; | ||
97 | state.uri = &uri; | ||
98 | char *location = "http://test.dom/dir/file.ext"; | ||
99 | int x = uriParseUriA (&state, location); | ||
100 | if (x == URI_SUCCESS) {;} | ||
101 | ]])],uriparser_cv_lib_uriparser_usable=yes,uriparser_cv_lib_uriparser_usable=no) | ||
102 | |||
103 | CPPFLAGS=$_liburiparser_save_cppflags | ||
104 | LIBS=$_liburiparser_save_libs | ||
105 | unset _liburiparser_save_cppflags | ||
106 | unset _liburiparser_save_libs | ||
107 | ]) | ||
108 | |||
109 | if test $uriparser_cv_lib_uriparser_usable = yes ; then | ||
110 | AC_DEFINE(HAVE_URIPARSER,1, | ||
111 | [Define to 1 if you have a functional uriparser library.]) | ||
112 | AC_SUBST(URIPARSER_CPPFLAGS) | ||
113 | AC_SUBST(URIPARSER) | ||
114 | else | ||
115 | unset URIPARSER | ||
116 | unset URIPARSER_CPPFLAGS | ||
117 | fi | ||
118 | fi | ||
119 | |||
120 | unset _uriparser_try_link | ||
121 | unset _uriparser_version_parse | ||
122 | unset _uriparser_version | ||
123 | unset _uriparser_ldflags | ||
124 | fi | ||
125 | |||
126 | if test x$_uriparser_with = xno || test x$uriparser_cv_lib_uriparser_usable != xyes ; then | ||
127 | # This is the IF-NO path | ||
128 | ifelse([$4],,:,[$4]) | ||
129 | else | ||
130 | # This is the IF-YES path | ||
131 | ifelse([$3],,:,[$3]) | ||
132 | fi | ||
133 | |||
134 | unset _uriparser_with | ||
135 | ])dnl | ||
136 | |||
137 | |||