1 # (this check is roughly 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.
14 # This macro #defines HAVE_URIPARSER if a working uriparser setup is
15 # found, and sets @URIPARSER@ and @URIPARSER_CPPFLAGS@ to the necessary
18 # Users may override the detected values by doing something like:
19 # URIPARSER="-luriparser" URIPARSER_CPPFLAGS="-I/usr/myinclude" ./configure
22 AC_DEFUN([URIPARSER_CHECK],
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])])
28 if test "$_uriparser_with" != "no" ; then
30 _uriparser_try_link=yes
32 AC_CHECK_PROG(PKGCONFIG,pkg-config,pkg-config,no)
34 if test "x$URIPARSER" != "x" || test "x$URIPARSER_CPPFLAGS" != "x"; then
36 elif test -d "$_uriparser_with" ; then
37 URIPARSER_CPPFLAGS="-I$withval/include"
38 _uriparser_ldflags="-L$withval/lib"
40 elif test x$PKGCONFIG != xno; then
42 AC_CACHE_CHECK([for the version of uriparser],
43 [uriparser_cv_uriparser_version],
44 [uriparser_cv_uriparser_version=`$PKGCONFIG liburiparser --modversion`])
48 _uriparser_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
50 _uriparser_version=`echo $uriparser_cv_uriparser_version | $_uriparser_version_parse`
51 _uriparser_wanted=`echo ifelse([$2],,[0],[$2]) | $_uriparser_version_parse`
53 if test $_uriparser_wanted -gt 0 ; then
54 AC_CACHE_CHECK([for uriparser >= version $2],
55 [uriparser_cv_lib_version_ok],
57 if test $_uriparser_version -ge $_uriparser_wanted ; then
58 uriparser_cv_lib_version_ok=yes
60 uriparser_cv_lib_version_ok=no
65 if test $_uriparser_wanted -eq 0 || test x$uriparser_cv_lib_version_ok = xyes ; then
66 if test x"$URIPARSER_CPPFLAGS" = "x" ; then
67 URIPARSER_CPPFLAGS=`$PKGCONFIG liburiparser --cflags`
69 if test x"$URIPARSER" = "x" ; then
70 URIPARSER=`$PKGCONFIG liburiparser --libs`
73 _uriparser_try_link=no
76 unset _uriparser_wanted
78 dnl no pkg-config, ok, do our best and set some defaults
79 URIPARSER_CPPFLAGS="-I/usr/include"
80 URIPARSER="-luriparser -L/usr/lib -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i686-linux-gnu"
83 if test $_uriparser_try_link = yes ; then
85 # let's see if the user-supplied
86 # link line (or failing that, "-luriparser") is enough.
87 URIPARSER=${URIPARSER-"$_uriparser_ldflags -luriparser"}
89 AC_CACHE_CHECK([whether uriparser is usable],
90 [uriparser_cv_lib_uriparser_usable],
92 _liburiparser_save_cppflags=$CPPFLAGS
93 CPPFLAGS="$URIPARSER_CPPFLAGS $CPPFLAGS"
94 _liburiparser_save_libs=$LIBS
95 LIBS="$URIPARSER $LIBS"
97 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <uriparser/Uri.h>]],[[
98 /* Try and use a few common options to force a failure if we are
99 missing symbols or cannot link. */
100 UriParserStateA state;
103 char *location = "http://test.dom/dir/file.ext";
104 int x = uriParseUriA (&state, location);
105 if (x == URI_SUCCESS) {;}
106 ]])],uriparser_cv_lib_uriparser_usable=yes,uriparser_cv_lib_uriparser_usable=no)
108 CPPFLAGS=$_liburiparser_save_cppflags
109 LIBS=$_liburiparser_save_libs
110 unset _liburiparser_save_cppflags
111 unset _liburiparser_save_libs
114 if test $uriparser_cv_lib_uriparser_usable = yes ; then
115 AC_DEFINE(HAVE_URIPARSER,1,
116 [Define to 1 if you have a functional uriparser library.])
117 AC_SUBST(URIPARSER_CPPFLAGS)
121 unset URIPARSER_CPPFLAGS
125 unset _uriparser_try_link
126 unset _uriparser_version_parse
127 unset _uriparser_version
128 unset _uriparser_ldflags
131 if test x$_uriparser_with = xno || test x$uriparser_cv_lib_uriparser_usable != xyes ; then
132 # This is the IF-NO path
135 # This is the IF-YES path
139 unset _uriparser_with