]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix to link with libssp for libcrypto and getaddrinfo check for
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 Jan 2024 15:40:14 +0000 (16:40 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 Jan 2024 15:40:14 +0000 (16:40 +0100)
  only header. Also update crosscompile to remove ssp for 32bit.

acx_nlnetlabs.m4
configure
configure.ac
doc/Changelog
makedist.sh

index 579e7099151b14a5891949db2f1e7ca9c583e69a..6a01dc5a4769f845a4e75be7f0cbbc97373f5699 100644 (file)
@@ -2,7 +2,9 @@
 # Copyright 2009, Wouter Wijngaards, NLnet Labs.   
 # BSD licensed.
 #
-# Version 47
+# Version 48
+# 2024-01-16 fix to add -l:libssp.a to -lcrypto link check.
+#           and check for getaddrinfo with only header.
 # 2024-01-15 fix to add crypt32 to -lcrypto link check when checking for gdi32.
 # 2023-05-04 fix to remove unused whitespace.
 # 2023-01-26 fix -Wstrict-prototypes.
@@ -754,9 +756,9 @@ AC_DEFUN([ACX_SSL_CHECKS], [
                        LIBS="$BAKLIBS"
                        LIBSSL_LIBS="$BAKSSLLIBS"
 
-                       LIBS="$LIBS -ldl"
-                       LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
-                       AC_MSG_CHECKING([if -lcrypto needs -ldl])
+                       LIBS="$LIBS -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a"
+                       LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a"
+                       AC_MSG_CHECKING([if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a])
                        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
                            int EVP_sha256(void);
                            (void)EVP_sha256();
@@ -768,9 +770,10 @@ AC_DEFUN([ACX_SSL_CHECKS], [
                            AC_MSG_RESULT(no)
                            LIBS="$BAKLIBS"
                            LIBSSL_LIBS="$BAKSSLLIBS"
-                           LIBS="$LIBS -ldl -pthread"
-                           LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread"
-                           AC_MSG_CHECKING([if -lcrypto needs -ldl -pthread])
+
+                           LIBS="$LIBS -ldl"
+                           LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
+                           AC_MSG_CHECKING([if -lcrypto needs -ldl])
                            AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
                                int EVP_sha256(void);
                                (void)EVP_sha256();
@@ -780,10 +783,25 @@ AC_DEFUN([ACX_SSL_CHECKS], [
                                AC_MSG_RESULT(yes)
                              ],[
                                AC_MSG_RESULT(no)
-                               AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
+                               LIBS="$BAKLIBS"
+                               LIBSSL_LIBS="$BAKSSLLIBS"
+                               LIBS="$LIBS -ldl -pthread"
+                               LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread"
+                               AC_MSG_CHECKING([if -lcrypto needs -ldl -pthread])
+                               AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
+                                   int EVP_sha256(void);
+                                   (void)EVP_sha256();
+                                 ]])],[
+                                   AC_DEFINE([HAVE_EVP_SHA256], 1,
+                                       [If you have EVP_sha256])
+                                   AC_MSG_RESULT(yes)
+                                 ],[
+                                   AC_MSG_RESULT(no)
+                                   AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
+                               ])
                            ])
                        ])
-                    ])
+                   ])
                 ])
             ])
         fi
@@ -890,7 +908,7 @@ dnl see if on windows
 if test "$ac_cv_header_windows_h" = "yes"; then
        AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
        USE_WINSOCK="1"
-       if echo $LIBS | grep 'lws2_32' >/dev/null; then
+       if echo "$LIBS" | grep 'lws2_32' >/dev/null; then
                :
        else
                LIBS="$LIBS -lws2_32"
@@ -898,6 +916,24 @@ if test "$ac_cv_header_windows_h" = "yes"; then
 fi
 ],
 dnl no quick getaddrinfo, try mingw32 and winsock2 library.
+dnl perhaps getaddrinfo needs only the include
+AC_LINK_IFELSE(
+[AC_LANG_PROGRAM(
+[
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+],
+[
+        (void)getaddrinfo(NULL, NULL, NULL, NULL);
+]
+)],
+[
+ac_cv_func_getaddrinfo="yes"
+AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
+USE_WINSOCK="1"
+],
+
 ORIGLIBS="$LIBS"
 LIBS="$LIBS -lws2_32"
 AC_LINK_IFELSE(
@@ -922,6 +958,7 @@ ac_cv_func_getaddrinfo="no"
 LIBS="$ORIGLIBS"
 ])
 )
+)
 
 AC_MSG_RESULT($ac_cv_func_getaddrinfo)
 if test $ac_cv_func_getaddrinfo = yes; then
index 2b100b613cb4afb76d7bef3db8f03d6d5f4c82bb..1f07417ecbe5afd66f517ca226b3705688c2c4d0 100755 (executable)
--- a/configure
+++ b/configure
@@ -18138,10 +18138,10 @@ $as_echo "no" >&6; }
                        LIBS="$BAKLIBS"
                        LIBSSL_LIBS="$BAKSSLLIBS"
 
-                       LIBS="$LIBS -ldl"
-                       LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl" >&5
-$as_echo_n "checking if -lcrypto needs -ldl... " >&6; }
+                       LIBS="$LIBS -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a"
+                       LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a"
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a" >&5
+$as_echo_n "checking if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a... " >&6; }
                        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -18170,10 +18170,11 @@ else
 $as_echo "no" >&6; }
                            LIBS="$BAKLIBS"
                            LIBSSL_LIBS="$BAKSSLLIBS"
-                           LIBS="$LIBS -ldl -pthread"
-                           LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread"
-                           { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl -pthread" >&5
-$as_echo_n "checking if -lcrypto needs -ldl -pthread... " >&6; }
+
+                           LIBS="$LIBS -ldl"
+                           LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
+                           { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl" >&5
+$as_echo_n "checking if -lcrypto needs -ldl... " >&6; }
                            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -18200,7 +18201,43 @@ else
 
                                { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-                               as_fn_error $? "OpenSSL found in $ssldir, but version 0.9.7 or higher is required" "$LINENO" 5
+                               LIBS="$BAKLIBS"
+                               LIBSSL_LIBS="$BAKSSLLIBS"
+                               LIBS="$LIBS -ldl -pthread"
+                               LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread"
+                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl -pthread" >&5
+$as_echo_n "checking if -lcrypto needs -ldl -pthread... " >&6; }
+                               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+                                   int EVP_sha256(void);
+                                   (void)EVP_sha256();
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+
+$as_echo "#define HAVE_EVP_SHA256 1" >>confdefs.h
+
+                                   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+else
+
+                                   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+                                   as_fn_error $? "OpenSSL found in $ssldir, but version 0.9.7 or higher is required" "$LINENO" 5
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 
 fi
 rm -f core conftest.err conftest.$ac_objext \
@@ -19885,7 +19922,7 @@ if test x_$enable_static_exe = x_yes; then
        if test "$on_mingw" = yes; then
                staticexe="-all-static"
                # for static compile, include gdi32 and zlib here.
-               if echo $LIBS | grep 'lgdi32' >/dev/null; then
+               if echo "$LIBS" | grep 'lgdi32' >/dev/null; then
                        :
                else
                        LIBS="$LIBS -lgdi32"
@@ -19930,7 +19967,11 @@ if test "x$ac_cv_lib_z_compress" = xyes; then :
    LIBS="$LIBS -lz"
 fi
 
-               LIBS="$LIBS -l:libssp.a"
+               if echo "$LIBS" | grep -e "libssp.a" -e "lssp" >/dev/null; then
+                       :
+               else
+                       LIBS="$LIBS -l:libssp.a"
+               fi
        fi
 fi
 
@@ -19989,7 +20030,11 @@ if test "x$ac_cv_lib_z_compress" = xyes; then :
    LIBS="$LIBS -lz"
 fi
 
-               LIBS="$LIBS -l:libssp.a"
+               if echo "$LIBS" | grep -e "libssp.a" -e "lssp" >/dev/null; then
+                       :
+               else
+                       LIBS="$LIBS -l:libssp.a"
+               fi
        fi
 fi
 
@@ -20036,13 +20081,40 @@ if test "$ac_cv_header_windows_h" = "yes"; then
 $as_echo "#define USE_WINSOCK 1" >>confdefs.h
 
        USE_WINSOCK="1"
-       if echo $LIBS | grep 'lws2_32' >/dev/null; then
+       if echo "$LIBS" | grep 'lws2_32' >/dev/null; then
                :
        else
                LIBS="$LIBS -lws2_32"
        fi
 fi
 
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+
+int
+main ()
+{
+
+        (void)getaddrinfo(NULL, NULL, NULL, NULL);
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ac_cv_func_getaddrinfo="yes"
+
+$as_echo "#define USE_WINSOCK 1" >>confdefs.h
+
+USE_WINSOCK="1"
+
 else
   ORIGLIBS="$LIBS"
 LIBS="$LIBS -lws2_32"
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getaddrinfo" >&5
 $as_echo "$ac_cv_func_getaddrinfo" >&6; }
 if test $ac_cv_func_getaddrinfo = yes; then
index 04d4e00ed0e2797c1751b57dc869e8706102f0e2..d4a13e6d62231b926d53aac7607826e3e527f03f 100644 (file)
@@ -1526,13 +1526,17 @@ if test x_$enable_static_exe = x_yes; then
        if test "$on_mingw" = yes; then
                staticexe="-all-static"
                # for static compile, include gdi32 and zlib here.
-               if echo $LIBS | grep 'lgdi32' >/dev/null; then
+               if echo "$LIBS" | grep 'lgdi32' >/dev/null; then
                        :
                else
                        LIBS="$LIBS -lgdi32"
                fi
                AC_CHECK_LIB([z], [compress], [ LIBS="$LIBS -lz" ])
-               LIBS="$LIBS -l:libssp.a"
+               if echo "$LIBS" | grep -e "libssp.a" -e "lssp" >/dev/null; then
+                       :
+               else
+                       LIBS="$LIBS -l:libssp.a"
+               fi
        fi
 fi
 
@@ -1549,7 +1553,11 @@ if test x_$enable_fully_static = x_yes; then
                        LIBS="$LIBS -lgdi32"
                fi
                AC_CHECK_LIB([z], [compress], [ LIBS="$LIBS -lz" ])
-               LIBS="$LIBS -l:libssp.a"
+               if echo "$LIBS" | grep -e "libssp.a" -e "lssp" >/dev/null; then
+                       :
+               else
+                       LIBS="$LIBS -l:libssp.a"
+               fi
        fi
 fi
 
index 733ba123ec48df15e44c3c9cc90e282e66616543..78ad7c1548d89ea3172b447f416db87fd5051e89 100644 (file)
@@ -1,3 +1,7 @@
+16 January 2024: Wouter
+       - Fix to link with libssp for libcrypto and getaddrinfo check for
+         only header. Also update crosscompile to remove ssp for 32bit.
+
 15 January 2024: Wouter
        - Fix to link with -lcrypt32 for OpenSSL 3.2.0 on Windows.
 
index 84f16d4ea7348e7ea43838b96d743844fc7850a9..c86b3b6551d22fa7f6bb9b549d0bb2bfbb786b4a 100755 (executable)
@@ -267,10 +267,10 @@ if [ "$DOWIN" = "yes" ]; then
                # cross-compilation and it is not used anyway
                # before 1.0.1i need --cross-compile-prefix=i686-w64-mingw32-
                if test "$mw64" = "mingw64"; then
-                       sslflags="no-asm -DOPENSSL_NO_CAPIENG mingw64"
+                       sslflags="no-asm no-tests -DOPENSSL_NO_CAPIENG mingw64"
                        sspdll="/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libssp-0.dll"
                else
-                       sslflags="no-asm -DOPENSSL_NO_CAPIENG mingw"
+                       sslflags="no-asm no-tests -DOPENSSL_NO_CAPIENG mingw"
                        sspdll="/usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll"
                fi
                if test -f "$sspdll"; then
@@ -282,9 +282,18 @@ if [ "$DOWIN" = "yes" ]; then
                        SSPLIB=""
                fi
                info "winssl: Configure no-shared $sslflags"
-               set -x # echo the configure command
-               __CNF_LDLIBS=$SSPLIB CC=${warch}-w64-mingw32-gcc AR=${warch}-w64-mingw32-ar RANLIB=${warch}-w64-mingw32-ranlib WINDRES=${warch}-w64-mingw32-windres ./Configure --prefix="$sslinstall" no-shared $sslflags || error_cleanup "OpenSSL Configure failed"
-               set +x
+               if test "$W64" = "no"; then
+                       # Disable stack-protector for 32-bit windows builds.
+                       # mingw passes an LDFLAGS, so there is something
+                       # passed in the LDFLAGS to stop -lssp passed in it.
+                       set -x # echo the configure command
+                       __CNF_LDLIBS=$SSPLIB __CNF_LDFLAGS="-fno-stack-protector" CC=${warch}-w64-mingw32-gcc AR=${warch}-w64-mingw32-ar RANLIB=${warch}-w64-mingw32-ranlib WINDRES=${warch}-w64-mingw32-windres ./Configure --prefix="$sslinstall" no-shared $sslflags || error_cleanup "OpenSSL Configure failed"
+                       set +x
+               else
+                       set -x # echo the configure command
+                       __CNF_LDLIBS=$SSPLIB CC=${warch}-w64-mingw32-gcc AR=${warch}-w64-mingw32-ar RANLIB=${warch}-w64-mingw32-ranlib WINDRES=${warch}-w64-mingw32-windres ./Configure --prefix="$sslinstall" no-shared $sslflags || error_cleanup "OpenSSL Configure failed"
+                       set +x
+               fi
                info "winssl: make"
                make $MINJ || error_cleanup "OpenSSL crosscompile failed"
                # only install sw not docs, which take a long time.
@@ -297,9 +306,15 @@ if [ "$DOWIN" = "yes" ]; then
                sslsharedinstall="`pwd`/sslsharedinstall"
                cd openssl_shared
                info "winssl: Configure shared $sslflags"
-               set -x # echo the configure command
-               __CNF_LDLIBS=$SSPLIB CC=${warch}-w64-mingw32-gcc AR=${warch}-w64-mingw32-ar RANLIB=${warch}-w64-mingw32-ranlib WINDRES=${warch}-w64-mingw32-windres ./Configure --prefix="$sslsharedinstall" shared $sslflags || error_cleanup "OpenSSL Configure failed"
-               set +x
+               if test "$W64" = "no"; then
+                       set -x # echo the configure command
+                       __CNF_LDLIBS=$SSPLIB __CNF_LDFLAGS="-fno-stack-protector" CC=${warch}-w64-mingw32-gcc AR=${warch}-w64-mingw32-ar RANLIB=${warch}-w64-mingw32-ranlib WINDRES=${warch}-w64-mingw32-windres ./Configure --prefix="$sslsharedinstall" shared $sslflags || error_cleanup "OpenSSL Configure failed"
+                       set +x
+               else
+                       set -x # echo the configure command
+                       __CNF_LDLIBS=$SSPLIB CC=${warch}-w64-mingw32-gcc AR=${warch}-w64-mingw32-ar RANLIB=${warch}-w64-mingw32-ranlib WINDRES=${warch}-w64-mingw32-windres ./Configure --prefix="$sslsharedinstall" shared $sslflags || error_cleanup "OpenSSL Configure failed"
+                       set +x
+               fi
                info "winssl: make"
                make $MINJ || error_cleanup "OpenSSL crosscompile failed"
                info "winssl: make install_sw"
@@ -315,7 +330,16 @@ if [ "$DOWIN" = "yes" ]; then
                wxpinstall="`pwd`/wxpinstall"
                cd expat-* || error_cleanup "no expat-X dir in tarball"
                info "wxp: configure"
-               $configure --prefix="$wxpinstall" --exec-prefix="$wxpinstall" --bindir="$wxpinstall/bin" --includedir="$wxpinstall/include" --mandir="$wxpinstall/man" --libdir="$wxpinstall/lib"  || error_cleanup "libexpat configure failed"
+               if test "$W64" = "no"; then
+                       # Disable stack-protector for 32-bit windows builds.
+                       set -x # echo the configure command
+                       $configure --prefix="$wxpinstall" --exec-prefix="$wxpinstall" --bindir="$wxpinstall/bin" --includedir="$wxpinstall/include" --mandir="$wxpinstall/man" --libdir="$wxpinstall/lib" LDFLAGS="-fno-stack-protector" || error_cleanup "libexpat configure failed"
+                       set +x
+               else
+                       set -x # echo the configure command
+                       $configure --prefix="$wxpinstall" --exec-prefix="$wxpinstall" --bindir="$wxpinstall/bin" --includedir="$wxpinstall/include" --mandir="$wxpinstall/man" --libdir="$wxpinstall/lib"  || error_cleanup "libexpat configure failed"
+                       set +x
+               fi
                info "wxp: make"
                make $MINJ || error_cleanup "libexpat crosscompile failed"
                info "wxp: make install"
@@ -379,8 +403,8 @@ if [ "$DOWIN" = "yes" ]; then
     fi
     if test "$W64" = "no"; then
                # Disable stack-protector for 32-bit windows builds.
-               echo "$configure"' --enable-debug --enable-static-exe --disable-flto --disable-gost '"$* $cross_flag" "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector'
-               $configure --enable-debug --enable-static-exe --disable-flto --disable-gost $* $cross_flag "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector'\
+               echo "$configure"' --enable-debug --enable-static-exe --disable-flto --disable-gost '"$* $cross_flag" "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector' LDFLAGS="-fno-stack-protector"
+               $configure --enable-debug --enable-static-exe --disable-flto --disable-gost $* $cross_flag "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector' LDFLAGS="-fno-stack-protector" \
                || error_cleanup "Could not configure"
     else
                echo "$configure"' --enable-debug --enable-static-exe --disable-flto --disable-gost '"$* $cross_flag"
@@ -396,8 +420,8 @@ if [ "$DOWIN" = "yes" ]; then
     cd ../unbound_shared
     if test "$W64" = "no"; then
        # Disable stack-protector for 32-bit windows builds.
-               echo "$configure"' --enable-debug --disable-flto --disable-gost '"$* $shared_cross_flag" "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector'
-               $configure --enable-debug --disable-flto --disable-gost $* $shared_cross_flag "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector'\
+               echo "$configure"' --enable-debug --disable-flto --disable-gost '"$* $shared_cross_flag" "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector' LDFLAGS="-fno-stack-protector"
+               $configure --enable-debug --disable-flto --disable-gost $* $shared_cross_flag "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector' LDFLAGS="-fno-stack-protector" \
                || error_cleanup "Could not configure"
     else
                echo "$configure"' --enable-debug --disable-flto --disable-gost '"$* $shared_cross_flag"