From d6491ba403d37abf54e56c96fb5c7b808943b5d3 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 1 Jun 2018 11:14:05 +0200 Subject: removed embedded uriparser library, added --with-uriparser configure option to use uriparser library from the system --- m4/uriparser.m4 | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 m4/uriparser.m4 (limited to 'm4/uriparser.m4') diff --git a/m4/uriparser.m4 b/m4/uriparser.m4 new file mode 100644 index 00000000..7fb25d65 --- /dev/null +++ b/m4/uriparser.m4 @@ -0,0 +1,137 @@ +# (this check is rougly based on and inspired libcurl.m4) +# URIPARSER_CHECK ([DEFAULT-ACTION], [MINIMUM-VERSION], +# [ACTION-IF-YES], [ACTION-IF-NO]) +# Checks for uriparser library. DEFAULT-ACTION is the string yes or no to +# specify whether to default to --with-uriparser or --without-liburiparser. +# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the +# minimum version of uriparser to accept. Pass the version as a regular +# version number like 0.8.5. If not supplied, any version is +# accepted. ACTION-IF-YES is a list of shell commands to run if +# uriparser was successfully found and passed the various tests. +# ACTION-IF-NO is a list of shell commands that are run otherwise. +# Note that using --without-uriparser does run ACTION-IF-NO. +# +# This macro #defines HAVE_URIPARSER if a working uriparser setup is +# found, and sets @URIPARSER@ and @URIPARSER_CPPFLAGS@ to the necessary +# values. +# +# Users may override the detected values by doing something like: +# URIPARSER="-luriparser" URIPARSER_CPPFLAGS="-I/usr/myinclude" ./configure +# + +AC_DEFUN([URIPARSER_CHECK], +[ + AC_ARG_WITH(uriparser, + AS_HELP_STRING([--with-uriparser=PREFIX],[look for the uriparser library in PREFIX/lib and headers in PREFIX/include]), + [_uriparser_with=$withval],[_uriparser_with=ifelse([$1],,[yes],[$1])]) + + if test "$_uriparser_with" != "no" ; then + + _uriparser_try_link=yes + + if test -d "$_uriparser_with" ; then + URIPARSER_CPPFLAGS="-I$withval/include" + _uriparser_ldflags="-L$withval/lib" + fi + + AC_CHECK_PROG(PKGCONFIG,pkg-config,pkg-config,no) + + if test x$PKGCONFIG != xno; then + + AC_CACHE_CHECK([for the version of uriparser], + [uriparser_cv_uriparser_version], + [uriparser_cv_uriparser_version=`$PKGCONFIG liburiparser --modversion`]) + + AC_PROG_AWK + + _uriparser_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'" + + _uriparser_version=`echo $uriparser_cv_uriparser_version | $_uriparser_version_parse` + _uriparser_wanted=`echo ifelse([$2],,[0],[$2]) | $_uriparser_version_parse` + + if test $_uriparser_wanted -gt 0 ; then + AC_CACHE_CHECK([for uriparser >= version $2], + [uriparser_cv_lib_version_ok], + [ + if test $_uriparser_version -ge $_uriparser_wanted ; then + uriparser_cv_lib_version_ok=yes + else + uriparser_cv_lib_version_ok=no + fi + ]) + fi + + if test $_uriparser_wanted -eq 0 || test x$uriparser_cv_lib_version_ok = xyes ; then + if test x"$URIPARSER_CPPFLAGS" = "x" ; then + URIPARSER_CPPFLAGS=`$PKGCONFIG liburiparser --cflags` + fi + if test x"$URIPARSER" = "x" ; then + URIPARSER=`$PKGCONFIG liburiparser --libs` + fi + else + _uriparser_try_link=no + fi + + unset _uriparser_wanted + fi + + if test $_uriparser_try_link = yes ; then + + # we didn't find curl-config, so let's see if the user-supplied + # link line (or failing that, "-luriparser") is enough. + URIPARSERLIBS=${URIPARSERLIBS-"$_uriparser_ldflags -luriparser"} + + AC_CACHE_CHECK([whether uriparser is usable], + [uriparser_cv_lib_uriparser_usable], + [ + _liburiparser_save_cppflags=$CPPFLAGS + CPPFLAGS="$URIPARSER_CPPFLAGS $CPPFLAGS" + _liburiparser_save_libs=$LIBS + LIBS="$URIPARSER $LIBS" + + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]],[[ +/* Try and use a few common options to force a failure if we are + missing symbols or cannot link. */ +UriParserStateA state; +UriUriA uri; +state.uri = &uri; +char *location = "http://test.dom/dir/file.ext"; +int x = uriParseUriA (&state, location); +if (x == URI_SUCCESS) {;} +]])],uriparser_cv_lib_uriparser_usable=yes,uriparser_cv_lib_uriparser_usable=no) + + CPPFLAGS=$_liburiparser_save_cppflags + LIBS=$_liburiparser_save_libs + unset _liburiparser_save_cppflags + unset _liburiparser_save_libs + ]) + + if test $uriparser_cv_lib_uriparser_usable = yes ; then + AC_DEFINE(HAVE_URIPARSER,1, + [Define to 1 if you have a functional uriparser library.]) + AC_SUBST(URIPARSER_CPPFLAGS) + AC_SUBST(URIPARSER) + else + unset URIPARSER + unset URIPARSER_CPPFLAGS + fi + fi + + unset _uriparser_try_link + unset _uriparser_version_parse + unset _uriparser_version + unset _uriparser_ldflags + fi + + if test x$_uriparser_with = xno || test x$uriparser_cv_lib_uriparser_usable != xyes ; then + # This is the IF-NO path + ifelse([$4],,:,[$4]) + else + # This is the IF-YES path + ifelse([$3],,:,[$3]) + fi + + unset _uriparser_with +])dnl + + -- cgit v1.2.3-74-g34f1 From df5be47f84c06d2fd481439793dc86494fdc0d7a Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 1 Jun 2018 18:35:02 +0200 Subject: check-curl: have some fallbacks ready if pkg-config is missing for uriparser tests --- m4/uriparser.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'm4/uriparser.m4') diff --git a/m4/uriparser.m4 b/m4/uriparser.m4 index 7fb25d65..dc404738 100644 --- a/m4/uriparser.m4 +++ b/m4/uriparser.m4 @@ -73,6 +73,10 @@ AC_DEFUN([URIPARSER_CHECK], fi unset _uriparser_wanted + else + dnl no pkg-config, ok, to our best and set some defaults + URIPARSER_CPPFLAGS="-I/usr/include" + URIPARSER="-luriparser -L/usr/lib -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i686-linux-gnu" fi if test $_uriparser_try_link = yes ; then -- cgit v1.2.3-74-g34f1 From 70888d0f880362a8c8671df93d55428b144dbce1 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Tue, 23 Oct 2018 10:56:05 +0200 Subject: check_curl: do not use pkg-config if --with-uriparser was supplied by commandline if we run configure with --with-uriparser=... it should use that path or fail. --- m4/uriparser.m4 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'm4/uriparser.m4') diff --git a/m4/uriparser.m4 b/m4/uriparser.m4 index dc404738..c77f7649 100644 --- a/m4/uriparser.m4 +++ b/m4/uriparser.m4 @@ -29,14 +29,13 @@ AC_DEFUN([URIPARSER_CHECK], _uriparser_try_link=yes + AC_CHECK_PROG(PKGCONFIG,pkg-config,pkg-config,no) + if test -d "$_uriparser_with" ; then URIPARSER_CPPFLAGS="-I$withval/include" _uriparser_ldflags="-L$withval/lib" - fi - AC_CHECK_PROG(PKGCONFIG,pkg-config,pkg-config,no) - - if test x$PKGCONFIG != xno; then + elif test x$PKGCONFIG != xno; then AC_CACHE_CHECK([for the version of uriparser], [uriparser_cv_uriparser_version], @@ -83,7 +82,7 @@ AC_DEFUN([URIPARSER_CHECK], # we didn't find curl-config, so let's see if the user-supplied # link line (or failing that, "-luriparser") is enough. - URIPARSERLIBS=${URIPARSERLIBS-"$_uriparser_ldflags -luriparser"} + URIPARSER=${URIPARSER-"$_uriparser_ldflags -luriparser"} AC_CACHE_CHECK([whether uriparser is usable], [uriparser_cv_lib_uriparser_usable], @@ -137,5 +136,3 @@ if (x == URI_SUCCESS) {;} unset _uriparser_with ])dnl - - -- cgit v1.2.3-74-g34f1 From 7501ba9f8a34413147281bed0b32b89da1ce2cb7 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Tue, 23 Oct 2018 17:01:44 +0200 Subject: uriparser: do not reset flags if already set --- m4/uriparser.m4 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'm4/uriparser.m4') diff --git a/m4/uriparser.m4 b/m4/uriparser.m4 index c77f7649..dbb8a551 100644 --- a/m4/uriparser.m4 +++ b/m4/uriparser.m4 @@ -31,7 +31,9 @@ AC_DEFUN([URIPARSER_CHECK], AC_CHECK_PROG(PKGCONFIG,pkg-config,pkg-config,no) - if test -d "$_uriparser_with" ; then + if test "x$URIPARSER" != "x" || test "x$URIPARSER_CPPFLAGS" != "x"; then + : + elif test -d "$_uriparser_with" ; then URIPARSER_CPPFLAGS="-I$withval/include" _uriparser_ldflags="-L$withval/lib" @@ -73,14 +75,14 @@ AC_DEFUN([URIPARSER_CHECK], unset _uriparser_wanted else - dnl no pkg-config, ok, to our best and set some defaults + dnl no pkg-config, ok, do our best and set some defaults URIPARSER_CPPFLAGS="-I/usr/include" URIPARSER="-luriparser -L/usr/lib -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i686-linux-gnu" fi if test $_uriparser_try_link = yes ; then - # we didn't find curl-config, so let's see if the user-supplied + # let's see if the user-supplied # link line (or failing that, "-luriparser") is enough. URIPARSER=${URIPARSER-"$_uriparser_ldflags -luriparser"} -- cgit v1.2.3-74-g34f1