]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Makefile.m32: cleanups and fixes [ci skip]
authorViktor Szakats <commit@vsz.me>
Sat, 1 Oct 2022 10:07:34 +0000 (10:07 +0000)
committerViktor Szakats <commit@vsz.me>
Sat, 1 Oct 2022 10:14:18 +0000 (10:14 +0000)
- Add `-lcrypt32` once, and add it always for simplicity.
- Delete broken link and reference to the pre-Vista WinIDN add-on.
  MS no longer distribute it.
- Delete related `WINIDN_PATH` option. IDN is a system lib since Vista.
- Sync `LIBCARES_PATH` default with the rest of dependencies.
- Delete version numbers from dependency path defaults.
- `libgsasl` package is now called `gsasl`.
- Delete `libexpat` and `libxml2` references. No longer used by curl.
- Delete `Edit the path below...` comments. We recommend to predefine
  those envvars instead.
- `libcares.a` is not an internal dependency anymore. Stop using it as
  such.
- `windres` `--include-dir` -> `-I`, `-F` -> `--target=` for readability.
- Delete `STRIP`, `CURL_STRIP`, `AR` references from `src/Makefile.m32`.
  They were never used.
- Stop to `clean` some objects twice in `src/Makefile.m32`.
- Delete cvs-specific leftovers.
- Finish resource support in examples make file.
- Delete `-I<root>/lib` from examples make file.
- Fix copyright start year in examples make file.
- Delete duplicate `ftpuploadresume` input in examples make file.
- Sync OpenSSL lib order, `SYNC` support, `PROOT` use, dependency path
  defaults, variables names and other internal bits between the three
  make files.
- `lib/Makefile.m32` accepted custom options via `DLL_LIBS` envvar. This
  was lib-specific and possibly accidental. Use `CURL_LDFLAG_EXTRAS_DLL`
  envvar for the same effect.
- Fix linking `curl.exe` and examples to wrong static libs with
  auto-detected OpenSSL 1.0.2 or earlier.
- Add `-lgdi32` for OpenSSL 1.0.2 and earlier only.
- Add link to Novell LDAP SDK and use a relative default path. Latest
  version is from 2016, linked to an outdated OpenSSL 1.0.1.
- Whitespace and comment cleanups.

TODO in a next commit:

Delete built-in detection/logic for OpenSSL 1.0.2 and earlier, the Novell
LDAP SDK and the other LDAP SDK (which is _not_ OpenLDAP). Write up the
necessary custom envvars to configure them.

Closes #9616

docs/examples/Makefile.m32
lib/Makefile.m32
src/Makefile.m32

index 3d393e9b271997859cb72c7a1df15ff3b3942a46..188504702b74056e9595bc6ab37bac9ad7c755c9 100644 (file)
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1999 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
 
 ###########################################################################
 #
-## Makefile for building curl examples with MinGW (GCC-3.2 or later)
-## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4),
-## brotli (1.0.1), zstd (1.4.5)
-##
-## Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
-## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
-##
-## Hint: you can also set environment vars to control the build, e.g.:
-## set ZLIB_PATH=c:/zlib-1.2.8
-## set ZLIB=1
+# Makefile for building curl examples with MinGW and optional features.
+#
+# Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
+# Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
+#
+# Hint: you can also set environment vars to control the build, e.g.:
+# set ZLIB_PATH=C:/zlib
+# set ZLIB=1
 #
 ###########################################################################
 
-# Edit the path below to point to the base of your Zlib sources.
+PROOT = ../..
+
 ifndef ZLIB_PATH
-ZLIB_PATH = ../../../zlib-1.2.8
+ZLIB_PATH = $(PROOT)/../zlib
 endif
-# Edit the path below to point to the base of your Zstandard sources.
 ifndef ZSTD_PATH
-ZSTD_PATH = ../../../zstd-1.4.5
+ZSTD_PATH = $(PROOT)/../zstd
 endif
-# Edit the path below to point to the base of your Brotli sources.
 ifndef BROTLI_PATH
-BROTLI_PATH = ../../../brotli-1.0.1
+BROTLI_PATH = $(PROOT)/../brotli
 endif
-# Edit the path below to point to the base of your OpenSSL package.
 ifndef OPENSSL_PATH
-OPENSSL_PATH = ../../../openssl-1.0.2a
+OPENSSL_PATH = $(PROOT)/../openssl
 endif
-# Edit the path below to point to the base of your LibSSH2 package.
 ifndef LIBSSH2_PATH
-LIBSSH2_PATH = ../../../libssh2-1.5.0
+LIBSSH2_PATH = $(PROOT)/../libssh2
 endif
-# Edit the path below to point to the base of your librtmp package.
 ifndef LIBRTMP_PATH
-LIBRTMP_PATH = ../../../librtmp-2.4
-endif
-# Edit the path below to point to the base of your libexpat package.
-ifndef LIBEXPAT_PATH
-LIBEXPAT_PATH = ../../../expat-2.1.0
+LIBRTMP_PATH = $(PROOT)/../librtmp
 endif
-# Edit the path below to point to the base of your libxml2 package.
-ifndef LIBXML2_PATH
-LIBXML2_PATH = ../../../libxml2-2.9.2
-endif
-# Edit the path below to point to the base of your libgsasl package.
 ifndef LIBGSASL_PATH
-LIBGSASL_PATH = ../../../libgsasl-1.10.0
+LIBGSASL_PATH = $(PROOT)/../gsasl
 endif
-# Edit the path below to point to the base of your libidn2 package.
 ifndef LIBIDN2_PATH
-LIBIDN2_PATH = ../../../libidn2-2.0.3
-endif
-# Edit the path below to point to the base of your MS IDN package.
-# Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
-# https://www.microsoft.com/en-us/download/details.aspx?id=734
-ifndef WINIDN_PATH
-WINIDN_PATH = ../../../Microsoft IDN Mitigation APIs
+LIBIDN2_PATH = $(PROOT)/../libidn2
 endif
-# Edit the path below to point to the base of your Novell LDAP NDK.
+# https://www.novell.com/developer/ndk/ldap_libraries_for_c.html
 ifndef LDAP_SDK
-LDAP_SDK = c:/novell/ndk/cldapsdk/win32
+LDAP_SDK = $(PROOT)/../openldapsdk
 endif
-# Edit the path below to point to the base of your nghttp2 package.
 ifndef NGHTTP2_PATH
-NGHTTP2_PATH = ../../../nghttp2-1.0.0
+NGHTTP2_PATH = $(PROOT)/../nghttp2
 endif
-# Edit the path below to point to the base of your nghttp3 package.
 ifndef NGHTTP3_PATH
-NGHTTP3_PATH = ../../../nghttp3-1.0.0
+NGHTTP3_PATH = $(PROOT)/../nghttp3
 endif
-# Edit the path below to point to the base of your ngtcp2 package.
 ifndef NGTCP2_PATH
-NGTCP2_PATH = ../../../ngtcp2-1.0.0
+NGTCP2_PATH = $(PROOT)/../ngtcp2
 endif
-
-PROOT = ../..
-
-# Edit the path below to point to the base of your c-ares package.
 ifndef LIBCARES_PATH
-LIBCARES_PATH = $(PROOT)/ares
+LIBCARES_PATH = $(PROOT)/../c-ares
 endif
 
 ifeq ($(CURL_CC),)
@@ -121,7 +92,7 @@ CC = $(CURL_CC)
 CFLAGS = -O3 $(CURL_CFLAG_EXTRAS) -W -Wall
 LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_EXE)
 RC = $(CURL_RC)
-RCFLAGS = --include-dir=$(PROOT)/include -O coff $(CURL_RCFLAG_EXTRAS)
+RCFLAGS = -I$(PROOT)/include -O coff -DCURL_EMBED_MANIFEST $(CURL_RCFLAG_EXTRAS)
 
 # Set environment var ARCH to your architecture to override autodetection.
 ifndef ARCH
@@ -136,11 +107,11 @@ ifneq ($(ARCH),custom)
 ifeq ($(ARCH),w64)
 CFLAGS  += -m64
 LDFLAGS += -m64
-RCFLAGS += -pe-x86-64
+RCFLAGS += --target=pe-x86-64
 else
 CFLAGS  += -m32
 LDFLAGS += -m32
-RCFLAGS += -pe-i386
+RCFLAGS += --target=pe-i386
 endif
 endif
 
@@ -150,7 +121,6 @@ DEL     = rm -f $1
 RMDIR   = rm -fr $1
 MKDIR   = mkdir -p $1
 COPY    = -cp -afv $1 $2
-#COPYR  = -cp -afr $1/* $2
 COPYR   = -rsync -aC $1/* $2
 TOUCH   = touch $1
 CAT     = cat
@@ -181,6 +151,9 @@ endif
 ifneq ($(findstring -ares,$(CFG)),)
 ARES = 1
 endif
+ifneq ($(findstring -sync,$(CFG)),)
+SYNC = 1
+endif
 ifneq ($(findstring -rtmp,$(CFG)),)
 RTMP = 1
 ZLIB = 1
@@ -232,6 +205,9 @@ endif
 ifneq ($(findstring -ngtcp2,$(CFG)),)
 NGTCP2 = 1
 endif
+ifneq ($(findstring -unicode,$(CFG)),)
+UNICODE = 1
+endif
 
 # SSH2 and RTMP require an SSL library; assume OpenSSL if none specified
 ifneq ($(SSH2)$(RTMP),)
@@ -240,7 +216,11 @@ ifneq ($(SSH2)$(RTMP),)
   endif
 endif
 
-INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
+INCLUDES = -I. -I$(PROOT)/include
+ifdef UNICODE
+  CFLAGS += -DUNICODE -D_UNICODE
+  LDFLAGS += -municode
+endif
 
 ifdef DYN
   curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
@@ -251,12 +231,13 @@ else
   CFLAGS += -DCURL_STATICLIB
   LDFLAGS += -static
 endif
-ifdef ARES
-  ifndef DYN
-    curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
+ifdef SYNC
+  CFLAGS += -DUSE_SYNC_DNS
+else
+  ifdef ARES
+    CFLAGS += -DUSE_ARES -DCARES_STATICLIB
+    curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
   endif
-  CFLAGS += -DUSE_ARES
-  curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
 endif
 ifdef RTMP
   CFLAGS += -DUSE_LIBRTMP
@@ -269,11 +250,6 @@ endif
 ifdef SSH2
   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
   curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
-  ifdef SCHANNEL
-    ifndef DYN
-      curl_LDADD += -lcrypt32
-    endif
-  endif
 endif
 ifdef NGHTTP3
   CFLAGS += -DUSE_NGHTTP3
@@ -294,6 +270,7 @@ endif
 ifdef SSL
   ifndef OPENSSL_INCLUDE
     ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
+      # OpenSSL 1.0.2 and earlier
       OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
     endif
     ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
@@ -306,25 +283,23 @@ ifdef SSL
   ifndef OPENSSL_LIBPATH
     OPENSSL_LIBS = -lssl -lcrypto
     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
+      # OpenSSL 1.0.2 and earlier
       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
-      ifdef DYN
-        OPENSSL_LIBS = -lssl32 -leay32
+      OPENSSL_LIBS = -lssl32 -leay32
+      ifndef DYN
+        OPENSSL_LIBS += -lgdi32
       endif
     endif
     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
     endif
   endif
-  ifndef DYN
-    OPENSSL_LIBS += -lgdi32 -lcrypt32
-  endif
   INCLUDES += -I"$(OPENSSL_INCLUDE)"
   CFLAGS += -DUSE_OPENSSL
   curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
 endif
 ifdef SCHANNEL
   CFLAGS += -DUSE_SCHANNEL
-  curl_LDADD += -lcrypt32
 endif
 ifdef ZLIB
   INCLUDES += -I"$(ZLIB_PATH)"
@@ -361,7 +336,7 @@ ifdef IDN2
 else
 ifdef WINIDN
   CFLAGS += -DUSE_WIN32_IDN
-  curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
+  curl_LDADD += -lnormaliz
 endif
 endif
 ifdef SSPI
@@ -386,21 +361,23 @@ ifndef USE_LDAP_OPENLDAP
   curl_LDADD += -lwldap32
 endif
 endif
-curl_LDADD += -lws2_32 -lbcrypt
+curl_LDADD += -lws2_32 -lcrypt32 -lbcrypt
 
-# Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
+# Makefile.inc provides the check_PROGRAMS define
 include Makefile.inc
 
-check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
-check_PROGRAMS += ftpuploadresume.exe synctime.exe
+TARGETS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
+TARGETS += synctime.exe
+
+RESOURCE = $(PROOT)/src/curl.res
 
 .PRECIOUS: %.o
 
 
-all: $(check_PROGRAMS)
+all: $(TARGETS)
 
-%.exe: %.o $(curl_DEPENDENCIES)
-       $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD)
+%.exe: %.o $(RESOURCE) $(curl_DEPENDENCIES)
+       $(CC) $(LDFLAGS) -o $@ $< $(RESOURCE) $(curl_LDADD)
 
 %.o: %.c
        $(CC) $(INCLUDES) $(CFLAGS) -c $<
@@ -409,7 +386,7 @@ all: $(check_PROGRAMS)
        $(RC) $(RCFLAGS) -i $< -o $@
 
 clean:
-       @$(call DEL, $(check_PROGRAMS:.exe=.o))
+       @$(call DEL, $(TARGETS:.exe=.o) $(RESOURCE))
 
 distclean vclean: clean
-       @$(call DEL, $(check_PROGRAMS))
+       @$(call DEL, $(TARGETS))
index 698d02861e42ba5d54cfd7c08612a6de23276aff..7097ebf0080820d0eb64b4e11adbb22dee31ca49 100644 (file)
 
 ###########################################################################
 #
-## Makefile for building libcurl.a with MinGW (GCC-3.2 or later or LLVM/Clang)
-## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4),
-## brotli (1.0.1), zstd (1.4.5)
-##
-## Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
-## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
-##
-## Hint: you can also set environment vars to control the build, e.g.:
-## set ZLIB_PATH=c:/zlib-1.2.8
-## set ZLIB=1
+# Makefile for building libcurl.a with MinGW and optional features.
+#
+# Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
+# Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
+#
+# Hint: you can also set environment vars to control the build, e.g.:
+# set ZLIB_PATH=C:/zlib
+# set ZLIB=1
 #
 ###########################################################################
 
-# Edit the path below to point to the base of your Zlib sources.
+PROOT = ..
+
 ifndef ZLIB_PATH
-ZLIB_PATH = ../../zlib-1.2.8
+ZLIB_PATH = $(PROOT)/../zlib
 endif
-# Edit the path below to point to the base of your Zstandard sources.
 ifndef ZSTD_PATH
-ZSTD_PATH = ../../zstd-1.4.5
+ZSTD_PATH = $(PROOT)/../zstd
 endif
-# Edit the path below to point to the base of your Brotli sources.
 ifndef BROTLI_PATH
-BROTLI_PATH = ../../brotli-1.0.1
+BROTLI_PATH = $(PROOT)/../brotli
 endif
-# Edit the path below to point to the base of your OpenSSL package.
 ifndef OPENSSL_PATH
-OPENSSL_PATH = ../../openssl-1.0.2a
+OPENSSL_PATH = $(PROOT)/../openssl
 endif
-# Edit the path below to point to the base of your LibSSH2 package.
 ifndef LIBSSH2_PATH
-LIBSSH2_PATH = ../../libssh2-1.5.0
+LIBSSH2_PATH = $(PROOT)/../libssh2
 endif
-# Edit the path below to point to the base of your librtmp package.
 ifndef LIBRTMP_PATH
-LIBRTMP_PATH = ../../librtmp-2.4
+LIBRTMP_PATH = $(PROOT)/../librtmp
 endif
-# Edit the path below to point to the base of your libgsasl package.
 ifndef LIBGSASL_PATH
-LIBGSASL_PATH = ../../libgsasl-1.10.0
+LIBGSASL_PATH = $(PROOT)/../gsasl
 endif
-# Edit the path below to point to the base of your libidn2 package.
 ifndef LIBIDN2_PATH
-LIBIDN2_PATH = ../../libidn2-2.0.3
+LIBIDN2_PATH = $(PROOT)/../libidn2
 endif
-# Edit the path below to point to the base of your MS IDN package.
-# Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
-# https://www.microsoft.com/en-us/download/details.aspx?id=734
-ifndef WINIDN_PATH
-WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
-endif
-# Edit the path below to point to the base of your Novell LDAP NDK.
+# https://www.novell.com/developer/ndk/ldap_libraries_for_c.html
 ifndef LDAP_SDK
-LDAP_SDK = c:/novell/ndk/cldapsdk/win32
+LDAP_SDK = $(PROOT)/../openldapsdk
 endif
-# Edit the path below to point to the base of your nghttp2 package.
 ifndef NGHTTP2_PATH
-NGHTTP2_PATH = ../../nghttp2-1.0.0
+NGHTTP2_PATH = $(PROOT)/../nghttp2
 endif
-# Edit the path below to point to the base of your nghttp3 package.
 ifndef NGHTTP3_PATH
-NGHTTP3_PATH = ../../nghttp3-1.0.0
+NGHTTP3_PATH = $(PROOT)/../nghttp3
 endif
-# Edit the path below to point to the base of your ngtcp2 package.
 ifndef NGTCP2_PATH
-NGTCP2_PATH = ../../ngtcp2-1.0.0
+NGTCP2_PATH = $(PROOT)/../ngtcp2
 endif
-
-PROOT = ..
-
-# Edit the path below to point to the base of your c-ares package.
 ifndef LIBCARES_PATH
-LIBCARES_PATH = $(PROOT)/ares
+LIBCARES_PATH = $(PROOT)/../c-ares
 endif
 
 ifeq ($(CURL_CC),)
@@ -121,7 +100,7 @@ LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_DLL)
 AR = $(CURL_AR)
 RANLIB = $(CURL_RANLIB)
 RC = $(CURL_RC)
-RCFLAGS = --include-dir=$(PROOT)/include -O coff $(CURL_RCFLAG_EXTRAS)
+RCFLAGS = -I$(PROOT)/include -O coff $(CURL_RCFLAG_EXTRAS)
 STRIP   = $(CURL_STRIP) -g
 
 # Set environment var ARCH to your architecture to override autodetection.
@@ -137,11 +116,11 @@ ifneq ($(ARCH),custom)
 ifeq ($(ARCH),w64)
 CFLAGS  += -m64
 LDFLAGS += -m64
-RCFLAGS += -pe-x86-64
+RCFLAGS += --target=pe-x86-64
 else
 CFLAGS  += -m32
 LDFLAGS += -m32
-RCFLAGS += -pe-i386
+RCFLAGS += --target=pe-i386
 endif
 endif
 
@@ -151,7 +130,6 @@ DEL     = rm -f $1
 RMDIR   = rm -fr $1
 MKDIR   = mkdir -p $1
 COPY    = -cp -afv $1 $2
-#COPYR  = -cp -afr $1/* $2
 COPYR   = -rsync -aC $1/* $2
 TOUCH   = touch $1
 CAT     = cat
@@ -250,7 +228,7 @@ ifneq ($(SSH2)$(RTMP),)
   endif
 endif
 
-INCLUDES = -I. -I../include
+INCLUDES = -I. -I$(PROOT)/include
 CFLAGS += -DBUILDING_LIBCURL
 ifdef SSL
   ifdef SCHANNEL
@@ -267,44 +245,38 @@ else
   ifdef ARES
     INCLUDES += -I"$(LIBCARES_PATH)"
     CFLAGS += -DUSE_ARES -DCARES_STATICLIB
-    DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
-    libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
+    curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
   endif
 endif
 ifdef RTMP
   INCLUDES += -I"$(LIBRTMP_PATH)"
   CFLAGS += -DUSE_LIBRTMP
-  DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
+  curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
 endif
 ifdef NGHTTP2
   INCLUDES += -I"$(NGHTTP2_PATH)/include"
   CFLAGS += -DUSE_NGHTTP2
-  DLL_LIBS += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
+  curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
 endif
 ifdef SSH2
   INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
-  DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
-  ifdef SCHANNEL
-    ifndef DYN
-      DLL_LIBS += -lcrypt32
-    endif
-  endif
+  curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
 endif
 ifdef NGHTTP3
   INCLUDES += -I"$(NGHTTP3_PATH)/include"
   CFLAGS += -DUSE_NGHTTP3
-  DLL_LIBS += -L"$(NGHTTP3_PATH)/lib" -lnghttp3
+  curl_LDADD += -L"$(NGHTTP3_PATH)/lib" -lnghttp3
   ifdef NGTCP2
     INCLUDES += -I"$(NGTCP2_PATH)/include"
     CFLAGS += -DUSE_NGTCP2
-    DLL_LIBS += -L"$(NGTCP2_PATH)/lib"
+    curl_LDADD += -L"$(NGTCP2_PATH)/lib"
     ifdef NGTCP2_LIBS
-      DLL_LIBS += $(NGTCP2_LIBS)
+      curl_LDADD += $(NGTCP2_LIBS)
     else
-      DLL_LIBS += -lngtcp2
+      curl_LDADD += -lngtcp2
       ifdef SSL
-        DLL_LIBS += -lngtcp2_crypto_openssl
+        curl_LDADD += -lngtcp2_crypto_openssl
       endif
     endif
   endif
@@ -312,6 +284,7 @@ endif
 ifdef SSL
   ifndef OPENSSL_INCLUDE
     ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
+      # OpenSSL 1.0.2 and earlier
       OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
     endif
     ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
@@ -322,70 +295,71 @@ ifdef SSL
     $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
   endif
   ifndef OPENSSL_LIBPATH
+    OPENSSL_LIBS = -lssl -lcrypto
     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
+      # OpenSSL 1.0.2 and earlier
       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
-      OPENSSL_LIBS = -leay32 -lssl32
+      OPENSSL_LIBS = -lssl32 -leay32
+      ifndef DYN
+        OPENSSL_LIBS += -lgdi32
+      endif
     endif
     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
-      OPENSSL_LIBS = -lcrypto -lssl
     endif
   endif
-  ifndef DYN
-    OPENSSL_LIBS += -lgdi32 -lcrypt32
-  endif
   INCLUDES += -I"$(OPENSSL_INCLUDE)"
   CFLAGS += -DUSE_OPENSSL
-  DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
+  curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
   ifdef SRP
     ifeq "$(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h)" "$(OPENSSL_INCLUDE)/openssl/srp.h"
+      # OpenSSL 1.0.1 and later
       CFLAGS += -DHAVE_OPENSSL_SRP -DUSE_TLS_SRP
     endif
   endif
 endif
 ifdef SCHANNEL
   CFLAGS += -DUSE_SCHANNEL
-  DLL_LIBS += -lcrypt32
 endif
 ifdef ZLIB
   INCLUDES += -I"$(ZLIB_PATH)"
   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
-  DLL_LIBS += -L"$(ZLIB_PATH)" -lz
+  curl_LDADD += -L"$(ZLIB_PATH)" -lz
 endif
 ifdef ZSTD
   INCLUDES += -I"$(ZSTD_PATH)/include"
   CFLAGS += -DHAVE_ZSTD
-  DLL_LIBS += -L"$(ZSTD_PATH)/lib"
+  curl_LDADD += -L"$(ZSTD_PATH)/lib"
   ifdef ZSTD_LIBS
-    DLL_LIBS += $(ZSTD_LIBS)
+    curl_LDADD += $(ZSTD_LIBS)
   else
-    DLL_LIBS += -lzstd
+    curl_LDADD += -lzstd
   endif
 endif
 ifdef BROTLI
   INCLUDES += -I"$(BROTLI_PATH)/include"
   CFLAGS += -DHAVE_BROTLI
-  DLL_LIBS += -L"$(BROTLI_PATH)/lib"
+  curl_LDADD += -L"$(BROTLI_PATH)/lib"
   ifdef BROTLI_LIBS
-    DLL_LIBS += $(BROTLI_LIBS)
+    curl_LDADD += $(BROTLI_LIBS)
   else
-    DLL_LIBS += -lbrotlidec
+    curl_LDADD += -lbrotlidec
   endif
 endif
 ifdef GSASL
   INCLUDES += -I"$(LIBGSASL_PATH)/include"
   CFLAGS += -DUSE_GSASL
-  DLL_LIBS += -L"$(LIBGSASL_PATH)/lib" -lgsasl
+  curl_LDADD += -L"$(LIBGSASL_PATH)/lib" -lgsasl
 endif
 ifdef IDN2
   INCLUDES += -I"$(LIBIDN2_PATH)/include"
   CFLAGS += -DUSE_LIBIDN2
-  DLL_LIBS += -L"$(LIBIDN2_PATH)/lib" -lidn2
+  curl_LDADD += -L"$(LIBIDN2_PATH)/lib" -lidn2
 else
 ifdef WINIDN
   CFLAGS += -DUSE_WIN32_IDN
   CFLAGS += -DWANT_IDN_PROTOTYPES
-  DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
+  curl_LDADD += -lnormaliz
 endif
 endif
 ifdef SSPI
@@ -403,19 +377,19 @@ endif
 ifdef USE_LDAP_NOVELL
   INCLUDES += -I"$(LDAP_SDK)/inc"
   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
-  DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
+  curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
 endif
 ifdef USE_LDAP_OPENLDAP
   INCLUDES += -I"$(LDAP_SDK)/include"
   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
-  DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
+  curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
 endif
 ifndef USE_LDAP_NOVELL
 ifndef USE_LDAP_OPENLDAP
-  DLL_LIBS += -lwldap32
+  curl_LDADD += -lwldap32
 endif
 endif
-DLL_LIBS += -lws2_32 -lbcrypt
+curl_LDADD += -lws2_32 -lcrypt32 -lbcrypt
 
 # Makefile.inc provides the CSOURCES and HHEADERS defines
 include Makefile.inc
@@ -444,11 +418,10 @@ $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
 
 # remove the last line above to keep debug info
 
-$(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
+$(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE)
        @$(call DEL, $@)
-       $(CC) $(LDFLAGS) -shared -o $@ \
-         -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) \
-         $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
+       $(CC) $(LDFLAGS) -shared -o $@ $(libcurl_a_OBJECTS) $(RESOURCE) $(curl_LDADD) \
+         -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY)
 
 %.o: %.c
        $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
index 7bc09e739dd7accc104eae5241bab62f0531c85e..1736682809731f4f99fcb4aadb537c5df01f9345 100644 (file)
 
 ###########################################################################
 #
-## Makefile for building curl.exe with MinGW (GCC-3.2 or later or LLVM/Clang)
-## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4),
-## brotli (1.0.1), zstd (1.4.5)
-##
-## Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
-## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
-##
-## Hint: you can also set environment vars to control the build, e.g.:
-## set ZLIB_PATH=c:/zlib-1.2.8
-## set ZLIB=1
+# Makefile for building curl.exe with MinGW and optional features.
+#
+# Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
+# Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
+#
+# Hint: you can also set environment vars to control the build, e.g.:
+# set ZLIB_PATH=C:/zlib
+# set ZLIB=1
 #
 ###########################################################################
 
-# Edit the path below to point to the base of your Zlib sources.
+PROOT = ..
+
 ifndef ZLIB_PATH
-ZLIB_PATH = ../../zlib-1.2.8
+ZLIB_PATH = $(PROOT)/../zlib
 endif
-# Edit the path below to point to the base of your Zstandard sources.
 ifndef ZSTD_PATH
-ZSTD_PATH = ../../zstd-1.4.5
+ZSTD_PATH = $(PROOT)/../zstd
 endif
-# Edit the path below to point to the base of your Brotli sources.
 ifndef BROTLI_PATH
-BROTLI_PATH = ../../brotli-1.0.1
+BROTLI_PATH = $(PROOT)/../brotli
 endif
-# Edit the path below to point to the base of your OpenSSL package.
 ifndef OPENSSL_PATH
-OPENSSL_PATH = ../../openssl-1.0.2a
+OPENSSL_PATH = $(PROOT)/../openssl
 endif
-# Edit the path below to point to the base of your LibSSH2 package.
 ifndef LIBSSH2_PATH
-LIBSSH2_PATH = ../../libssh2-1.5.0
+LIBSSH2_PATH = $(PROOT)/../libssh2
 endif
-# Edit the path below to point to the base of your librtmp package.
 ifndef LIBRTMP_PATH
-LIBRTMP_PATH = ../../librtmp-2.4
-endif
-# Edit the path below to point to the base of your libexpat package.
-ifndef LIBEXPAT_PATH
-LIBEXPAT_PATH = ../../expat-2.1.0
+LIBRTMP_PATH = $(PROOT)/../librtmp
 endif
-# Edit the path below to point to the base of your libxml2 package.
-ifndef LIBXML2_PATH
-LIBXML2_PATH = ../../libxml2-2.9.2
-endif
-# Edit the path below to point to the base of your libgsasl package.
 ifndef LIBGSASL_PATH
-LIBGSASL_PATH = ../../libgsasl-1.10.0
+LIBGSASL_PATH = $(PROOT)/../gsasl
 endif
-# Edit the path below to point to the base of your libidn2 package.
 ifndef LIBIDN2_PATH
-LIBIDN2_PATH = ../../libidn2-2.0.3
-endif
-# Edit the path below to point to the base of your MS IDN package.
-# Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
-# https://www.microsoft.com/en-us/download/details.aspx?id=734
-ifndef WINIDN_PATH
-WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
+LIBIDN2_PATH = $(PROOT)/../libidn2
 endif
-# Edit the path below to point to the base of your Novell LDAP NDK.
+# https://www.novell.com/developer/ndk/ldap_libraries_for_c.html
 ifndef LDAP_SDK
-LDAP_SDK = c:/novell/ndk/cldapsdk/win32
+LDAP_SDK = $(PROOT)/../openldapsdk
 endif
-# Edit the path below to point to the base of your nghttp2 package.
 ifndef NGHTTP2_PATH
-NGHTTP2_PATH = ../../nghttp2-1.0.0
+NGHTTP2_PATH = $(PROOT)/../nghttp2
 endif
-# Edit the path below to point to the base of your nghttp3 package.
 ifndef NGHTTP3_PATH
-NGHTTP3_PATH = ../../nghttp3-1.0.0
+NGHTTP3_PATH = $(PROOT)/../nghttp3
 endif
-# Edit the path below to point to the base of your ngtcp2 package.
 ifndef NGTCP2_PATH
-NGTCP2_PATH = ../../ngtcp2-1.0.0
+NGTCP2_PATH = $(PROOT)/../ngtcp2
 endif
-
-PROOT = ..
-
-# Edit the path below to point to the base of your c-ares package.
 ifndef LIBCARES_PATH
-LIBCARES_PATH = $(PROOT)/ares
+LIBCARES_PATH = $(PROOT)/../c-ares
 endif
 
 ifeq ($(CURL_CC),)
@@ -116,21 +87,12 @@ endif
 ifeq ($(CURL_RC),)
 CURL_RC := $(CROSSPREFIX)windres
 endif
-ifeq ($(CURL_STRIP),)
-CURL_STRIP := $(CROSSPREFIX)strip
-endif
 
 CC = $(CURL_CC)
 CFLAGS = -O3 $(CURL_CFLAG_EXTRAS) -W -Wall
 LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_EXE)
-AR = $(CURL_AR)
 RC = $(CURL_RC)
-RCFLAGS = --include-dir=$(PROOT)/include -O coff -DCURL_EMBED_MANIFEST $(CURL_RCFLAG_EXTRAS)
-STRIP   = $(CURL_STRIP) -g
-
-# We may need these someday
-# PERL = perl
-# NROFF = nroff
+RCFLAGS = -I$(PROOT)/include -O coff -DCURL_EMBED_MANIFEST $(CURL_RCFLAG_EXTRAS)
 
 # Set environment var ARCH to your architecture to override autodetection.
 ifndef ARCH
@@ -145,11 +107,11 @@ ifneq ($(ARCH),custom)
 ifeq ($(ARCH),w64)
 CFLAGS  += -m64
 LDFLAGS += -m64
-RCFLAGS += -pe-x86-64
+RCFLAGS += --target=pe-x86-64
 else
 CFLAGS  += -m32
 LDFLAGS += -m32
-RCFLAGS += -pe-i386
+RCFLAGS += --target=pe-i386
 endif
 endif
 
@@ -159,7 +121,6 @@ DEL     = rm -f $1
 RMDIR   = rm -fr $1
 MKDIR   = mkdir -p $1
 COPY    = -cp -afv $1 $2
-#COPYR  = -cp -afr $1/* $2
 COPYR   = -rsync -aC $1/* $2
 TOUCH   = touch $1
 CAT     = cat
@@ -255,7 +216,7 @@ ifneq ($(SSH2)$(RTMP),)
   endif
 endif
 
-INCLUDES = -I. -I../include -I../lib
+INCLUDES = -I. -I$(PROOT)/include -I$(PROOT)/lib
 ifdef SSL
   ifdef SCHANNEL
     CFLAGS += -DCURL_WITH_MULTI_SSL
@@ -279,9 +240,6 @@ ifdef SYNC
   CFLAGS += -DUSE_SYNC_DNS
 else
   ifdef ARES
-    ifndef DYN
-      curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
-    endif
     CFLAGS += -DUSE_ARES -DCARES_STATICLIB
     curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
   endif
@@ -297,11 +255,6 @@ endif
 ifdef SSH2
   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
   curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
-  ifdef SCHANNEL
-    ifndef DYN
-      curl_LDADD += -lcrypt32
-    endif
-  endif
 endif
 ifdef NGHTTP3
   CFLAGS += -DUSE_NGHTTP3
@@ -322,6 +275,7 @@ endif
 ifdef SSL
   ifndef OPENSSL_INCLUDE
     ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
+      # OpenSSL 1.0.2 and earlier
       OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
     endif
     ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
@@ -334,25 +288,23 @@ ifdef SSL
   ifndef OPENSSL_LIBPATH
     OPENSSL_LIBS = -lssl -lcrypto
     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
+      # OpenSSL 1.0.2 and earlier
       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
-      ifdef DYN
-        OPENSSL_LIBS = -lssl32 -leay32
+      OPENSSL_LIBS = -lssl32 -leay32
+      ifndef DYN
+        OPENSSL_LIBS += -lgdi32
       endif
     endif
     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
     endif
   endif
-  ifndef DYN
-    OPENSSL_LIBS += -lgdi32 -lcrypt32
-  endif
   INCLUDES += -I"$(OPENSSL_INCLUDE)"
   CFLAGS += -DUSE_OPENSSL
   curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
 endif
 ifdef SCHANNEL
   CFLAGS += -DUSE_SCHANNEL
-  curl_LDADD += -lcrypt32
 endif
 ifdef ZLIB
   INCLUDES += -I"$(ZLIB_PATH)"
@@ -389,7 +341,7 @@ ifdef IDN2
 else
 ifdef WINIDN
   CFLAGS += -DUSE_WIN32_IDN
-  curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
+  curl_LDADD += -lnormaliz
 endif
 endif
 ifdef SSPI
@@ -411,37 +363,27 @@ ifdef USE_LDAP_OPENLDAP
 endif
 ifndef USE_LDAP_NOVELL
 ifndef USE_LDAP_OPENLDAP
-curl_LDADD += -lwldap32
+  curl_LDADD += -lwldap32
 endif
 endif
-curl_LDADD += -lws2_32 -lbcrypt
+curl_LDADD += -lws2_32 -lcrypt32 -lbcrypt
 
-# Makefile.inc provides the CSOURCES and HHEADERS defines
+# Makefile.inc provides the CURL_CFILES and CURLX_CFILES defines
 include Makefile.inc
 
-curl_PROGRAMS = curl.exe
+TARGETS = curl.exe
 curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
-curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
-curl_OBJECTS += $(curlx_OBJECTS)
+curl_OBJECTS += $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
 vpath %.c $(PROOT)/lib
 
 RESOURCE = curl.res
 
 
-all: $(curl_PROGRAMS)
-
-curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
-       $(call DEL, $@)
-       $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
+all: $(TARGETS)
 
-# We don't have nroff normally under win32
-# tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl
-#      @$(call DEL, tool_hugehelp.c)
-#      $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c
-
-tool_hugehelp.c:
-       @echo Creating $@
-       @$(call COPY, $@.cvs, $@)
+curl.exe: $(curl_OBJECTS) $(RESOURCE) $(curl_DEPENDENCIES)
+       @$(call DEL, $@)
+       $(CC) $(LDFLAGS) -o $@ $(curl_OBJECTS) $(RESOURCE) $(curl_LDADD)
 
 %.o: %.c
        $(CC) $(INCLUDES) $(CFLAGS) -c $<
@@ -450,10 +392,7 @@ tool_hugehelp.c:
        $(RC) $(RCFLAGS) -i $< -o $@
 
 clean:
-ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs"
-       @$(call DEL, tool_hugehelp.c)
-endif
-       @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
+       @$(call DEL, $(curl_OBJECTS) $(RESOURCE))
 
 distclean vclean: clean
-       @$(call DEL, $(curl_PROGRAMS))
+       @$(call DEL, $(TARGETS))