$NetBSD: patch-configure,v 1.1 2025/07/16 10:58:03 sborrill Exp $

* More support for OpenSSL 1.1; not only check SSL_Library_init() but
  also check OPENSSL_init_ssl().
* Fix syntax error by accidental new line.
* Utilize <stdlib.h> on BSD.
* Do not override CFLAGS/CXXFLAGS except linux.
* Prevent WRKDIR reference.

--- configure.orig	2025-07-10 13:45:26.000000000 +0100
+++ configure	2025-07-15 11:57:43.052095332 +0100
@@ -1133,9 +1133,6 @@
 CCC
 BUILDCXX
 CPP
-PKG_CONFIG
-PKG_CONFIG_PATH
-PKG_CONFIG_LIBDIR
 LT_SYS_LIBRARY_PATH
 CXXCPP
 EXT_LIBECAP_CFLAGS
@@ -29115,10 +29112,13 @@
 done
 
   # GLIBC 2.30 deprecates sysctl.h. Test with the same flags that (may) break includes later.
-  CFLAGS=$SQUID_CFLAGS
-  CXXFLAGS=$SQUID_CXXFLAGS
   case "$squid_host_os" in #(
-  linux|solaris|freebsd|openbsd|netbsd|cygwin) :
+  linux) :
+    CFLAGS=$SQUID_CFLAGS
+    CXXFLAGS=$SQUID_CXXFLAGS
+    : ;; #(
+  solaris|freebsd|openbsd|netbsd|cygwin) :
+    ${TRUE}
     : ;; #(
   mingw) :
     EUILIB="-liphlpapi" ;; #(
@@ -29166,6 +29166,7 @@
 fi
 
   ac_fn_cxx_check_header_compile "$LINENO" "net/if_arp.h" "ac_cv_header_net_if_arp_h" "
+#include <stdio.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 
@@ -29176,6 +29177,7 @@
 
 fi
 ac_fn_cxx_check_header_compile "$LINENO" "net/route.h" "ac_cv_header_net_route_h" "
+#include <stdio.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 
@@ -30169,6 +30171,49 @@
 else $as_nop
 
       as_fn_error $? "library 'ssl' is required for OpenSSL" "$LINENO" 5
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL_init_ssl in -lssl" >&5
+$as_echo_n "checking for OPENSSL_init_ssl in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_OPENSSL_init_ssl+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lssl $LIBOPENSSL_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 OPENSSL_init_ssl ();
+int
+main ()
+{
+return OPENSSL_init_ssl ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_ssl_OPENSSL_init_ssl=yes
+else
+  ac_cv_lib_ssl_OPENSSL_init_ssl=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_ssl_OPENSSL_init_ssl" >&5
+$as_echo "$ac_cv_lib_ssl_OPENSSL_init_ssl" >&6; }
+if test "x$ac_cv_lib_ssl_OPENSSL_init_ssl" = xyes; then :
+  LIBOPENSSL_LIBS="-lssl $LIBOPENSSL_LIBS"
+else
+
+	as_fn_error $? "library 'ssl' is required for OpenSSL" "$LINENO" 5
+
+fi
 
 fi
 
@@ -30272,7 +30317,51 @@
   LIBOPENSSL_LIBS="-lssl $LIBOPENSSL_LIBS"
 else $as_nop
 
-      as_fn_error $? "library 'ssl' is required for OpenSSL" "$LINENO" 5
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL_init_ssl in -lssl" >&5
+$as_echo_n "checking for OPENSSL_init_ssl in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_OPENSSL_init_ssl+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lssl $LIBOPENSSL_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 OPENSSL_init_ssl ();
+int
+main ()
+{
+return OPENSSL_init_ssl ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_ssl_OPENSSL_init_ssl=yes
+else
+  ac_cv_lib_ssl_OPENSSL_init_ssl=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_ssl_OPENSSL_init_ssl" >&5
+$as_echo "$ac_cv_lib_ssl_OPENSSL_init_ssl" >&6; }
+if test "x$ac_cv_lib_ssl_OPENSSL_init_ssl" = xyes; then :
+  LIBOPENSSL_LIBS="-lssl $LIBOPENSSL_LIBS"
+else
+
+	as_fn_error $? "library 'ssl' is required for OpenSSL" "$LINENO" 5
+
+fi
+
+
 
 fi
 
@@ -47322,6 +47411,8 @@
 # elif defined _MSC_VER
 #  include <malloc.h>
 #  define alloca _alloca
+# elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
+#   include <stdlib.h>
 # else
 #  ifdef  __cplusplus
 extern "C"
@@ -50163,6 +50254,9 @@
 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
 #define minor_t fubar
 #endif
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
 #if HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
