]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
autotools: fix `dllmain.c` in unity builds
authorViktor Szakats <commit@vsz.me>
Thu, 13 Mar 2025 22:53:40 +0000 (23:53 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 14 Mar 2025 09:38:28 +0000 (10:38 +0100)
Sync it with cmake to:
- exclude it from all builds except Windows and Cygwin.
- exclude it from unity builds for Cygwin to avoid the included
  `windows.h` header interfere with the rest of the code.

Also:
- fix to trim ending spaces from `CSOURCES` for the `tidy` target.
  The solution requires a non-POSIX `-E` `sed` option. Supported by BSD
  and GNU implementations.
  Follow-up to 37523c91bc418fc734ee54f329677dc7123eb465 #16480

Follow-up to 60c3d0446546332e1645541f2dc2c072cd019fe9 #14815
Follow-up to 7860f575fe9e527ced66b31ec076914bbadd64a4 #12408

Closes #16712

configure.ac
lib/CMakeLists.txt
lib/Makefile.am
lib/Makefile.inc

index 8dc4e12f343cb27c696dfc31416ef15df4d019dc..c8558c15cbb4da9cc1ef1e24b657355a897a46b4 100644 (file)
@@ -609,6 +609,7 @@ curl_cv_cygwin='no'
 case $host_os in
   cygwin*|msys*) curl_cv_cygwin='yes';;
 esac
+AM_CONDITIONAL(DOING_CYGWIN, test "x$curl_cv_cygwin" = xyes)
 
 AM_CONDITIONAL([HAVE_WINDRES],
   [test "$curl_cv_native_windows" = "yes" && test -n "${RC}"])
index 7200b0925d893b4a87f95d40ed28672f706a7878..32e4943d08ac6b5ec365a8941ddf677c0654184a 100644 (file)
@@ -31,9 +31,6 @@ configure_file("curl_config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h"
 curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
 include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
 
-# DllMain is added later for DLL builds only.
-list(REMOVE_ITEM CSOURCES "dllmain.c")
-
 list(APPEND HHEADERS "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h")
 
 # The rest of the build
index 3cba38fafb278f1354cfb1566ea64dacf6e774fb..7edbb9303c0015130f8a0d34d699762ff234a845 100644 (file)
@@ -68,6 +68,14 @@ AM_CFLAGS =
 # Makefile.inc provides the CSOURCES and HHEADERS defines
 include Makefile.inc
 
+if DOING_NATIVE_WINDOWS
+CSOURCES += dllmain.c
+else
+if DOING_CYGWIN
+CSOURCES += dllmain.c
+endif
+endif
+
 if USE_UNITY
 # Keep these separate to avoid duplicate definitions when linking libtests
 # in static mode.
@@ -77,6 +85,11 @@ if DEBUGBUILD
 # applying to them.
 curl_EXCLUDE += memdebug.c curl_multibyte.c
 endif
+# For Cygwin always compile dllmain.c as a separate unit since it
+# includes windows.h, which should not be included in other units.
+if DOING_CYGWIN
+curl_EXCLUDE += dllmain.c
+endif
 libcurl_unity.c: $(top_srcdir)/scripts/mk-unity.pl $(CSOURCES)
        @PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CSOURCES) --exclude $(curl_EXCLUDE) > libcurl_unity.c
 
@@ -162,7 +175,7 @@ endif
 TIDY := clang-tidy
 
 tidy:
-       (_csources=`echo ' $(CSOURCES)' | sed -e 's/ +/ /g' -e 's| | $(srcdir)/|g'`; \
+       (_csources=`echo ' $(CSOURCES)' | sed -E -e 's/ +$$//' -e 's/ +/ /g' -e 's| | $(srcdir)/|g'`; \
        $(TIDY) $$_csources $(TIDYFLAGS) $(CURL_CLANG_TIDYFLAGS) -- $(AM_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H)
 
 optiontable:
index cd11cad18f098d355bd37ce0b0640ea0f2626b02..a8e4da1cf9c0be955495a612becdd3dd6276f074 100644 (file)
@@ -146,7 +146,6 @@ LIB_CFILES =         \
   cw-out.c           \
   cw-pause.c         \
   dict.c             \
-  dllmain.c          \
   doh.c              \
   dynbuf.c           \
   dynhds.c           \