123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- #***************************************************************************
- # _ _ ____ _
- # Project ___| | | | _ \| |
- # / __| | | | |_) | |
- # | (__| |_| | _ <| |___
- # \___|\___/|_| \_\_____|
- #
- # 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
- # are also available at https://curl.se/docs/copyright.html.
- #
- # You may opt to use, copy, modify, merge, publish, distribute and/or sell
- # copies of the Software, and permit persons to whom the Software is
- # furnished to do so, under the terms of the COPYING file.
- #
- # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- # KIND, either express or implied.
- #
- # SPDX-License-Identifier: curl
- #
- #***************************************************************************
- # Makefile for building curl parts 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
- #
- # Set component roots via envvar <feature>_PATH. Also available for
- # customization: CC, RC, AR, CPPFLAGS, LDFLAGS, LIBS, CFLAGS, RCFLAGS,
- # ARCH[=custom], CROSSPREFIX, CURL_LDFLAGS_BIN, CURL_LDFLAGS_LIB, CURL_DLL_SUFFIX,
- # and more for individual components (see below).
- # This script is reused by 'src' and 'docs/examples' Makefile.m32 scripts.
- # Skip lib-specific parts when called through them.
- ifndef PROOT
- PROOT := ..
- CPPFLAGS += -DBUILDING_LIBCURL
- ### Sources and targets
- # Provides CSOURCES, HHEADERS, LIB_RCFILES
- include Makefile.inc
- libcurl_dll_LIBRARY := libcurl$(CURL_DLL_SUFFIX).dll
- libcurl_dll_a_LIBRARY := libcurl.dll.a
- libcurl_a_LIBRARY := libcurl.a
- TARGETS := $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
- libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CSOURCES))))
- libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
- libcurl_dll_OBJECTS := $(libcurl_a_OBJECTS)
- libcurl_dll_OBJECTS += $(patsubst %.rc,%.res,$(strip $(LIB_RCFILES)))
- vpath %.c vauth vquic vssh vtls
- TOCLEAN := $(libcurl_dll_OBJECTS)
- TOVCLEAN := $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY)
- ### Local rules
- # Keep this at the top to act as the default target.
- all: $(TARGETS)
- $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
- @$(call DEL, $@)
- $(AR) rcs $@ $(libcurl_a_OBJECTS)
- $(libcurl_dll_LIBRARY): $(libcurl_dll_OBJECTS)
- $(CC) $(LDFLAGS) -shared $(CURL_LDFLAGS_LIB) -o $@ $(libcurl_dll_OBJECTS) $(LIBS) \
- -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY)
- endif
- CPPFLAGS += -I. -I$(PROOT)/include
- RCFLAGS += -I$(PROOT)/include
- CC := $(CROSSPREFIX)$(CC)
- AR := $(CROSSPREFIX)$(AR)
- RC ?= $(CROSSPREFIX)windres
- ifneq ($(ARCH),custom)
- # Set environment var ARCH to your architecture to override auto-detection.
- ifndef ARCH
- ifneq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),)
- ARCH := w64
- else
- ARCH := w32
- endif
- endif
- ifeq ($(ARCH),w64)
- CFLAGS += -m64
- LDFLAGS += -m64
- RCFLAGS += --target=pe-x86-64
- else
- CFLAGS += -m32
- LDFLAGS += -m32
- RCFLAGS += --target=pe-i386
- endif
- endif
- ### Optional features
- ifneq ($(findstring -unicode,$(CFG)),)
- CPPFLAGS += -DUNICODE -D_UNICODE
- CURL_LDFLAGS_BIN += -municode
- endif
- # CPPFLAGS below are only necessary when building libcurl via 'lib' (see
- # comments below about exceptions). Always include them anyway to match
- # behavior of other build systems.
- # Linker options to exclude for shared mode executables.
- _LDFLAGS :=
- _LIBS :=
- ifneq ($(findstring -sync,$(CFG)),)
- CPPFLAGS += -DUSE_SYNC_DNS
- else ifneq ($(findstring -ares,$(CFG)),)
- LIBCARES_PATH ?= $(PROOT)/../c-ares
- CPPFLAGS += -DUSE_ARES
- CPPFLAGS += -I"$(LIBCARES_PATH)/include"
- _LDFLAGS += -L"$(LIBCARES_PATH)/lib"
- _LIBS += -lcares
- endif
- ifneq ($(findstring -rtmp,$(CFG)),)
- LIBRTMP_PATH ?= $(PROOT)/../librtmp
- CPPFLAGS += -DUSE_LIBRTMP
- CPPFLAGS += -I"$(LIBRTMP_PATH)"
- _LDFLAGS += -L"$(LIBRTMP_PATH)/librtmp"
- _LIBS += -lrtmp -lwinmm
- ZLIB := 1
- endif
- ifneq ($(findstring -ssh2,$(CFG)),)
- LIBSSH2_PATH ?= $(PROOT)/../libssh2
- CPPFLAGS += -DUSE_LIBSSH2
- CPPFLAGS += -I"$(LIBSSH2_PATH)/include"
- _LDFLAGS += -L"$(LIBSSH2_PATH)/lib"
- _LDFLAGS += -L"$(LIBSSH2_PATH)/win32"
- _LIBS += -lssh2
- else ifneq ($(findstring -libssh,$(CFG)),)
- LIBSSH_PATH ?= $(PROOT)/../libssh
- CPPFLAGS += -DUSE_LIBSSH
- CPPFLAGS += -I"$(LIBSSH_PATH)/include"
- _LDFLAGS += -L"$(LIBSSH_PATH)/lib"
- _LIBS += -lssh
- else ifneq ($(findstring -wolfssh,$(CFG)),)
- WOLFSSH_PATH ?= $(PROOT)/../wolfssh
- CPPFLAGS += -DUSE_WOLFSSH
- CPPFLAGS += -I"$(WOLFSSH_PATH)/include"
- _LDFLAGS += -L"$(WOLFSSH_PATH)/lib"
- _LIBS += -lwolfssh
- endif
- ifneq ($(findstring -ssl,$(CFG)),)
- OPENSSL_PATH ?= $(PROOT)/../openssl
- CPPFLAGS += -DUSE_OPENSSL
- CPPFLAGS += -DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
- OPENSSL_INCLUDE ?= $(OPENSSL_PATH)/include
- OPENSSL_LIBPATH ?= $(OPENSSL_PATH)/lib
- CPPFLAGS += -I"$(OPENSSL_INCLUDE)"
- _LDFLAGS += -L"$(OPENSSL_LIBPATH)"
- OPENSSL_LIBS ?= -lssl -lcrypto
- _LIBS += $(OPENSSL_LIBS)
- ifneq ($(wildcard $(OPENSSL_INCLUDE)/openssl/aead.h),)
- OPENSSL := boringssl
- else
- # including libressl
- OPENSSL := openssl
- endif
- ifneq ($(findstring -srp,$(CFG)),)
- ifneq ($(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h),)
- # OpenSSL 1.0.1 and later.
- CPPFLAGS += -DHAVE_OPENSSL_SRP -DUSE_TLS_SRP
- endif
- endif
- SSLLIBS += 1
- else ifneq ($(findstring -wolfssl,$(CFG)),)
- WOLFSSL_PATH ?= $(PROOT)/../zlib
- CPPFLAGS += -DUSE_WOLFSSL
- CPPFLAGS += -DSIZEOF_LONG_LONG=8
- CPPFLAGS += -I"$(WOLFSSL_PATH)/include"
- _LDFLAGS += -L"$(WOLFSSL_PATH)/lib"
- _LIBS += -lwolfssl
- OPENSSL := wolfssl
- SSLLIBS += 1
- endif
- ifneq ($(findstring -mbedtls,$(CFG)),)
- MBEDTLS_PATH ?= $(PROOT)/../zlib
- CPPFLAGS += -DUSE_MBEDTLS
- CPPFLAGS += -I"$(MBEDTLS_PATH)/include"
- _LDFLAGS += -L"$(MBEDTLS_PATH)/lib"
- _LIBS += -lmbedtls -lmbedx509 -lmbedcrypto
- SSLLIBS += 1
- endif
- ifneq ($(findstring -schannel,$(CFG)),)
- CPPFLAGS += -DUSE_SCHANNEL
- SSLLIBS += 1
- endif
- ifneq ($(findstring -nghttp2,$(CFG)),)
- NGHTTP2_PATH ?= $(PROOT)/../nghttp2
- CPPFLAGS += -DUSE_NGHTTP2
- CPPFLAGS += -I"$(NGHTTP2_PATH)/include"
- _LDFLAGS += -L"$(NGHTTP2_PATH)/lib"
- _LIBS += -lnghttp2
- endif
- ifeq ($(findstring -nghttp3,$(CFG))$(findstring -ngtcp2,$(CFG)),-nghttp3-ngtcp2)
- NGHTTP3_PATH ?= $(PROOT)/../nghttp3
- CPPFLAGS += -DUSE_NGHTTP3
- CPPFLAGS += -I"$(NGHTTP3_PATH)/include"
- _LDFLAGS += -L"$(NGHTTP3_PATH)/lib"
- _LIBS += -lnghttp3
- NGTCP2_PATH ?= $(PROOT)/../ngtcp2
- CPPFLAGS += -DUSE_NGTCP2
- CPPFLAGS += -I"$(NGTCP2_PATH)/include"
- _LDFLAGS += -L"$(NGTCP2_PATH)/lib"
- ifneq ($(OPENSSL),)
- NGTCP2_LIBS ?= -lngtcp2_crypto_$(OPENSSL)
- endif
- _LIBS += -lngtcp2 $(NGTCP2_LIBS)
- endif
- ifneq ($(findstring -zlib,$(CFG))$(ZLIB),)
- ZLIB_PATH ?= $(PROOT)/../zlib
- # These CPPFLAGS are also required when compiling the curl tool via 'src'.
- CPPFLAGS += -DHAVE_LIBZ
- CPPFLAGS += -I"$(ZLIB_PATH)"
- _LDFLAGS += -L"$(ZLIB_PATH)"
- _LIBS += -lz
- endif
- ifneq ($(findstring -zstd,$(CFG)),)
- ZSTD_PATH ?= $(PROOT)/../zstd
- CPPFLAGS += -DHAVE_ZSTD
- CPPFLAGS += -I"$(ZSTD_PATH)/include"
- _LDFLAGS += -L"$(ZSTD_PATH)/lib"
- ZSTD_LIBS ?= -lzstd
- _LIBS += $(ZSTD_LIBS)
- endif
- ifneq ($(findstring -brotli,$(CFG)),)
- BROTLI_PATH ?= $(PROOT)/../brotli
- CPPFLAGS += -DHAVE_BROTLI
- CPPFLAGS += -I"$(BROTLI_PATH)/include"
- _LDFLAGS += -L"$(BROTLI_PATH)/lib"
- BROTLI_LIBS ?= -lbrotlidec -lbrotlicommon
- _LIBS += $(BROTLI_LIBS)
- endif
- ifneq ($(findstring -gsasl,$(CFG)),)
- LIBGSASL_PATH ?= $(PROOT)/../gsasl
- CPPFLAGS += -DUSE_GSASL
- CPPFLAGS += -I"$(LIBGSASL_PATH)/include"
- _LDFLAGS += -L"$(LIBGSASL_PATH)/lib"
- _LIBS += -lgsasl
- endif
- ifneq ($(findstring -idn2,$(CFG)),)
- LIBIDN2_PATH ?= $(PROOT)/../libidn2
- CPPFLAGS += -DUSE_LIBIDN2
- CPPFLAGS += -I"$(LIBIDN2_PATH)/include"
- _LDFLAGS += -L"$(LIBIDN2_PATH)/lib"
- _LIBS += -lidn2
- ifneq ($(findstring -psl,$(CFG)),)
- LIBPSL_PATH ?= $(PROOT)/../libpsl
- CPPFLAGS += -DUSE_LIBPSL
- CPPFLAGS += -I"$(LIBPSL_PATH)/include"
- _LDFLAGS += -L"$(LIBPSL_PATH)/lib"
- _LIBS += -lpsl
- endif
- else ifneq ($(findstring -winidn,$(CFG)),)
- CPPFLAGS += -DUSE_WIN32_IDN
- _LIBS += -lnormaliz
- endif
- ifneq ($(findstring -sspi,$(CFG)),)
- CPPFLAGS += -DUSE_WINDOWS_SSPI
- endif
- ifneq ($(findstring -ipv6,$(CFG)),)
- CPPFLAGS += -DENABLE_IPV6
- endif
- ifneq ($(findstring -ldaps,$(CFG)),)
- CPPFLAGS += -DHAVE_LDAP_SSL
- endif
- ifeq ($(findstring -lldap,$(LIBS)),)
- _LIBS += -lwldap32
- endif
- _LIBS += -lws2_32 -lcrypt32 -lbcrypt
- ifneq ($(findstring 11,$(subst $() ,,$(SSLLIBS))),)
- CPPFLAGS += -DCURL_WITH_MULTI_SSL
- endif
- ifndef DYN
- LDFLAGS += $(_LDFLAGS)
- LIBS += $(_LIBS)
- endif
- ### Global rules
- ifneq ($(findstring /sh,$(SHELL)),)
- DEL = rm -f $1
- COPY = -cp -afv $1 $2
- else
- DEL = -del 2>NUL /q /f $(subst /,\,$1)
- COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
- endif
- all: $(TARGETS)
- %.o: %.c
- $(CC) -W -Wall $(CFLAGS) $(CPPFLAGS) -c $<
- %.res: %.rc
- $(RC) -O coff $(RCFLAGS) -i $< -o $@
- clean:
- @$(call DEL, $(TOCLEAN))
- distclean vclean: clean
- @$(call DEL, $(TARGETS) $(TOVCLEAN))
|