libidn: Autoconf tests

1 
1 2.5 Autoconf tests
1 ==================
1 
1 If your project uses Autoconf (⇒GNU Autoconf (autoconf)top.) to
1 check for installed libraries, you might find the following snippet
1 illustrative.  It add a new ‘configure’ parameter ‘--with-libidn’, and
1 check for ‘idna.h’ and ‘-lidn’ (possibly below the directory specified
1 as the optional argument to ‘--with-libidn’), and define the CPP symbol
1 ‘LIBIDN’ if the library is found.  The default behaviour is to search
1 for the library and enable the functionality (that is, define the
1 symbol) when the library is found, but if you wish to make the default
1 behaviour of your package be that Libidn is not used (even if it is
1 installed on the system), change ‘libidn=yes’ to ‘libidn=no’ on the
1 third line.
1 
1      AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]],
1                                      [Support IDN (needs GNU Libidn)]),
1        libidn=$withval, libidn=yes)
1      if test "$libidn" != "no"; then
1        if test "$libidn" != "yes"; then
1          LDFLAGS="${LDFLAGS} -L$libidn/lib"
1          CPPFLAGS="${CPPFLAGS} -I$libidn/include"
1        fi
1        AC_CHECK_HEADER(idna.h,
1          AC_CHECK_LIB(idn, stringprep_check_version,
1            [libidn=yes LIBS="${LIBS} -lidn"], libidn=no),
1          libidn=no)
1      fi
1      if test "$libidn" != "no" ; then
1        AC_DEFINE(LIBIDN, 1, [Define to 1 if you want IDN support.])
1      else
1        AC_MSG_WARN([Libidn not found])
1      fi
1      AC_MSG_CHECKING([if Libidn should be used])
1      AC_MSG_RESULT($libidn)
1 
1    If you require that your users have installed ‘pkg-config’ (which I
1 cannot recommend generally), the above can be done more easily as
1 follows.
1 
1      AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]],
1                                      [Support IDN (needs GNU Libidn)]),
1        libidn=$withval, libidn=yes)
1      if test "$libidn" != "no" ; then
1        PKG_CHECK_MODULES(LIBIDN, libidn >= 0.0.0, [libidn=yes], [libidn=no])
1        if test "$libidn" != "yes" ; then
1          libidn=no
1          AC_MSG_WARN([Libidn not found])
1        else
1          libidn=yes
1          AC_DEFINE(LIBIDN, 1, [Define to 1 if you want Libidn.])
1        fi
1      fi
1      AC_MSG_CHECKING([if Libidn should be used])
1      AC_MSG_RESULT($libidn)
1