autotools: fix dllmain.c in unity builds

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 37523c91bc #16480

Follow-up to 60c3d04465 #14815
Follow-up to 7860f575fe #12408

Closes #16712
This commit is contained in:
Viktor Szakats 2025-03-13 23:53:40 +01:00
parent 63cf464793
commit c799f608f2
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
4 changed files with 15 additions and 5 deletions

View 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}"])

View 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

View 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:

View file

@ -146,7 +146,6 @@ LIB_CFILES = \
cw-out.c \
cw-pause.c \
dict.c \
dllmain.c \
doh.c \
dynbuf.c \
dynhds.c \