$NetBSD: patch-configure,v 1.1 2014/01/10 09:50:42 wiz Exp $ Fix libotr>=4 detection. --- configure.orig 2012-12-02 13:30:10.000000000 +0000 +++ configure @@ -15502,7 +15502,7 @@ else fi if test "x$enable_otr" = "xyes"; then - # Look for libgcrypt and libotr + # Look for libgcrypt and libotr # Check whether --with-libgcrypt-prefix was given. if test "${with_libgcrypt_prefix+set}" = set; then : @@ -15687,7 +15687,182 @@ $as_echo "does not match. want=$req_libg LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` - libotr_save_CFLAGS="$CFLAGS" + libotr_save_CFLAGS="$CFLAGS" +libotr_save_LDFLAGS="$LDFLAGS" +libotr_save_LIBS="$LIBS" +libotr_found=yes + + +# Check whether --with-libotr-prefix was given. +if test "${with_libotr_prefix+set}" = set; then : + withval=$with_libotr_prefix; libotr_prefix="$withval" +else + libotr_prefix="" +fi + + + +# Check whether --with-libotr-inc-prefix was given. +if test "${with_libotr_inc_prefix+set}" = set; then : + withval=$with_libotr_inc_prefix; libotr_inc_prefix="$withval" +else + libotr_inc_prefix="" +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libotr CFLAGS" >&5 +$as_echo_n "checking for libotr CFLAGS... " >&6; } +if test "$libotr_inc_prefix" != "" ; then + LIBOTR_CFLAGS="$LIBOTR_CFLAGS -I$libotr_inc_prefix" + CFLAGS="$CFLAGS $LIBOTR_CFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBOTR_CFLAGS" >&5 +$as_echo "$LIBOTR_CFLAGS" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libotr LIBS" >&5 +$as_echo_n "checking for libotr LIBS... " >&6; } +if test "$libotr_prefix" != "" ; then + LIBOTR_LIBS="$LIBOTR_LIBS -L$libotr_prefix" + LDFLAGS="$LDFLAGS $LIBOTR_LIBS" +fi + +LIBOTR_LIBS="$LIBOTR_LIBS -lotr" +LIBS="$LIBOTR_LIBS $LIBS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBOTR_LIBS" >&5 +$as_echo "$LIBOTR_LIBS" >&6; } + +min_libotr_version=4.0.0 +no_libotr="" + libotr_min_major_version=`echo $min_libotr_version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + libotr_min_minor_version=`echo $min_libotr_version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + libotr_min_sub_version=`echo $min_libotr_version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libotr headers version $libotr_min_major_version.x >= $min_libotr_version" >&5 +$as_echo_n "checking for libotr headers version $libotr_min_major_version.x >= $min_libotr_version... " >&6; } + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ + +# if(OTRL_VERSION_MAJOR != $libotr_min_major_version) +# error not present +# else + +# if(OTRL_VERSION_MINOR > $libotr_min_minor_version) + exit(0); +# else +# if(OTRL_VERSION_MINOR < $libotr_min_minor_version) +# error not present +# endif + +# if(OTRL_VERSION_SUB < $libotr_min_sub_version) +# error not present +# endif +# endif +# endif +exit(0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found." >&5 +$as_echo "found." >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not present." >&5 +$as_echo "not present." >&6; } + + libotr_found=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for otrl_message_receiving in -lotr" >&5 +$as_echo_n "checking for otrl_message_receiving in -lotr... " >&6; } +if ${ac_cv_lib_otr_otrl_message_receiving+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lotr $LIBGCRYPT_LIBS + $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char otrl_message_receiving (); +int +main () +{ +return otrl_message_receiving (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_otr_otrl_message_receiving=yes +else + ac_cv_lib_otr_otrl_message_receiving=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_otr_otrl_message_receiving" >&5 +$as_echo "$ac_cv_lib_otr_otrl_message_receiving" >&6; } +if test "x$ac_cv_lib_otr_otrl_message_receiving" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBOTR 1 +_ACEOF + + LIBS="-lotr $LIBS" + +else + + libotr_found=no +fi + + +LDFLAGS="$libotr_save_LDFLAGS" +LIBS="$libotr_save_LIBS" + +if test "x$libotr_found" = "xyes" ; then + + +$as_echo "#define HAVE_LIBOTR 1" >>confdefs.h + + +else + LIBOTR_CFLAGS="" + LIBOTR_LIBS="" + + libotr_save_CFLAGS="$CFLAGS" libotr_save_LDFLAGS="$LDFLAGS" libotr_save_LIBS="$LIBS" libotr_found=yes @@ -15853,11 +16028,26 @@ LDFLAGS="$libotr_save_LDFLAGS" LIBS="$libotr_save_LIBS" if test "x$libotr_found" = "xyes" ; then - : + + +$as_echo "#define HAVE_LIBOTR 1" >>confdefs.h + + +$as_echo "#define HAVE_LIBOTR3 1" >>confdefs.h + + else LIBOTR_CFLAGS="" LIBOTR_LIBS="" - as_fn_error $? "libotr 3.1.0 or newer is required." "$LINENO" 5 + + as_fn_error $? "libotr 3.1.0 or newer is required." "$LINENO" 5 + +fi + + + + + fi @@ -15890,7 +16080,8 @@ $as_echo "$as_me: WARNING: else LIBGCRYPT_CFLAGS="" LIBGCRYPT_LIBS="" - as_fn_error $? "libgcrypt 1.2.2 or newer is required." "$LINENO" 5 + + as_fn_error $? "libgcrypt 1.2.2 or newer is required." "$LINENO" 5 fi