#*************************************************************************** # _ _ ____ _ # Project ___| | | | _ \| | # / __| | | | |_) | | # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # # Copyright (C) 1999 - 2022, Daniel Stenberg, , 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 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 # # Set component roots via envvar _PATH. CPPFLAGS, LDFLAGS, LIBS, # CFLAGS, RCFLAGS (and more) are also available for customization. PROOT := ../.. CPPFLAGS += -I. -I$(PROOT)/include RCFLAGS += -I$(PROOT)/include -DCURL_EMBED_MANIFEST LDFLAGS += -L$(PROOT)/lib LIBS += -lcurl ifneq ($(ARCH),custom) # Set environment var ARCH to your architecture to override autodetection. 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 -dyn,$(CFG)),) curl_DEPENDENCIES := $(PROOT)/lib/libcurl$(CURL_DLL_SUFFIX).dll curl_DEPENDENCIES += $(PROOT)/lib/libcurl.dll.a else curl_DEPENDENCIES := $(PROOT)/lib/libcurl.a CPPFLAGS += -DCURL_STATICLIB LDFLAGS += -static endif ifneq ($(findstring -unicode,$(CFG)),) CPPFLAGS += -DUNICODE -D_UNICODE LDFLAGS += -municode endif ifneq ($(findstring -sync,$(CFG)),) else ifneq ($(findstring -ares,$(CFG)),) LIBCARES_PATH ?= $(PROOT)/../c-ares LDFLAGS += -L"$(LIBCARES_PATH)/lib" LIBS += -lcares endif endif ifneq ($(findstring -rtmp,$(CFG)),) LIBRTMP_PATH ?= $(PROOT)/../librtmp LDFLAGS += -L"$(LIBRTMP_PATH)/librtmp" LIBS += -lrtmp -lwinmm ZLIB := 1 endif ifneq ($(findstring -ssh2,$(CFG)),) LIBSSH2_PATH ?= $(PROOT)/../libssh2 LDFLAGS += -L"$(LIBSSH2_PATH)/lib" LDFLAGS += -L"$(LIBSSH2_PATH)/win32" LIBS += -lssh2 endif ifneq ($(findstring -nghttp2,$(CFG)),) NGHTTP2_PATH ?= $(PROOT)/../nghttp2 LDFLAGS += -L"$(NGHTTP2_PATH)/lib" LIBS += -lnghttp2 endif ifneq ($(findstring -nghttp3,$(CFG)),) ifneq ($(findstring -ngtcp2,$(CFG)),) NGHTTP3_PATH ?= $(PROOT)/../nghttp3 LDFLAGS += -L"$(NGHTTP3_PATH)/lib" LIBS += -lnghttp3 NGTCP2_PATH ?= $(PROOT)/../ngtcp2 LDFLAGS += -L"$(NGTCP2_PATH)/lib" NGTCP2_LIBS ?= -lngtcp2 -lngtcp2_crypto_openssl LIBS += $(NGTCP2_LIBS) endif endif ifneq ($(findstring -ssl,$(CFG)),) OPENSSL_PATH ?= $(PROOT)/../openssl OPENSSL_LIBPATH ?= $(OPENSSL_PATH)/lib LDFLAGS += -L"$(OPENSSL_LIBPATH)" OPENSSL_LIBS ?= -lssl -lcrypto LIBS += $(OPENSSL_LIBS) endif ifneq ($(findstring -zlib,$(CFG))$(ZLIB),) ZLIB_PATH ?= $(PROOT)/../zlib LDFLAGS += -L"$(ZLIB_PATH)" LIBS += -lz endif ifneq ($(findstring -zstd,$(CFG)),) ZSTD_PATH ?= $(PROOT)/../zstd LDFLAGS += -L"$(ZSTD_PATH)/lib" ZSTD_LIBS ?= -lzstd LIBS += $(ZSTD_LIBS) endif ifneq ($(findstring -brotli,$(CFG)),) BROTLI_PATH ?= $(PROOT)/../brotli LDFLAGS += -L"$(BROTLI_PATH)/lib" BROTLI_LIBS ?= -lbrotlidec -lbrotlicommon LIBS += $(BROTLI_LIBS) endif ifneq ($(findstring -gsasl,$(CFG)),) LIBGSASL_PATH ?= $(PROOT)/../gsasl LDFLAGS += -L"$(LIBGSASL_PATH)/lib" LIBS += -lgsasl endif ifneq ($(findstring -idn2,$(CFG)),) LIBIDN2_PATH ?= $(PROOT)/../libidn2 LDFLAGS += -L"$(LIBIDN2_PATH)/lib" LIBS += -lidn2 else ifneq ($(findstring -winidn,$(CFG)),) LIBS += -lnormaliz endif endif ifeq ($(findstring -lldap,$(LIBS)),) LIBS += -lwldap32 endif LIBS += -lws2_32 -lcrypt32 -lbcrypt ### Sources and targets # Provides check_PROGRAMS include Makefile.inc TARGETS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS))) TARGETS += synctime.exe RESOURCE := $(PROOT)/src/curl.res .PRECIOUS: %.o ### Rules CC ?= $(CROSSPREFIX)gcc RC ?= $(CROSSPREFIX)windres ifneq ($(findstring /sh,$(SHELL)),) DEL = rm -f $1 else DEL = -del 2>NUL /q /f $(subst /,\,$1) endif all: $(TARGETS) %.exe: %.o $(RESOURCE) $(curl_DEPENDENCIES) $(CC) $(LDFLAGS) -o $@ $< $(RESOURCE) $(LIBS) %.o: %.c $(CC) $(CFLAGS) $(CPPFLAGS) -c $< %.res: %.rc $(RC) -O coff $(RCFLAGS) -i $< -o $@ clean: @$(call DEL, $(TARGETS:.exe=.o) $(RESOURCE)) distclean vclean: clean @$(call DEL, $(TARGETS))