1#*************************************************************************** 2# _ _ ____ _ 3# Project ___| | | | _ \| | 4# / __| | | | |_) | | 5# | (__| |_| | _ <| |___ 6# \___|\___/|_| \_\_____| 7# 8# Copyright (C) 1999 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. 9# 10# This software is licensed as described in the file COPYING, which 11# you should have received as part of this distribution. The terms 12# are also available at https://curl.haxx.se/docs/copyright.html. 13# 14# You may opt to use, copy, modify, merge, publish, distribute and/or sell 15# copies of the Software, and permit persons to whom the Software is 16# furnished to do so, under the terms of the COPYING file. 17# 18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19# KIND, either express or implied. 20# 21#*************************************************************************** 22 23########################################################################### 24# 25## Makefile for building curl.exe with MingW (GCC-3.2 or later or LLVM/Clang) 26## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4), 27## brotli (1.0.1), zstd (1.4.5) 28## 29## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...] 30## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn 31## 32## Hint: you can also set environment vars to control the build, f.e.: 33## set ZLIB_PATH=c:/zlib-1.2.8 34## set ZLIB=1 35# 36########################################################################### 37 38# Edit the path below to point to the base of your Zlib sources. 39ifndef ZLIB_PATH 40ZLIB_PATH = ../../zlib-1.2.8 41endif 42# Edit the path below to point to the base of your Zstandard sources. 43ifndef ZSTD_PATH 44ZSTD_PATH = ../../zstd-1.4.5 45endif 46# Edit the path below to point to the base of your Brotli sources. 47ifndef BROTLI_PATH 48BROTLI_PATH = ../../brotli-1.0.1 49endif 50# Edit the path below to point to the base of your OpenSSL package. 51ifndef OPENSSL_PATH 52OPENSSL_PATH = ../../openssl-1.0.2a 53endif 54# Edit the path below to point to the base of your LibSSH2 package. 55ifndef LIBSSH2_PATH 56LIBSSH2_PATH = ../../libssh2-1.5.0 57endif 58# Edit the path below to point to the base of your librtmp package. 59ifndef LIBRTMP_PATH 60LIBRTMP_PATH = ../../librtmp-2.4 61endif 62# Edit the path below to point to the base of your libmetalink package. 63ifndef LIBMETALINK_PATH 64LIBMETALINK_PATH = ../../libmetalink-0.1.3 65endif 66# Edit the path below to point to the base of your libexpat package. 67ifndef LIBEXPAT_PATH 68LIBEXPAT_PATH = ../../expat-2.1.0 69endif 70# Edit the path below to point to the base of your libxml2 package. 71ifndef LIBXML2_PATH 72LIBXML2_PATH = ../../libxml2-2.9.2 73endif 74# Edit the path below to point to the base of your libidn2 package. 75ifndef LIBIDN2_PATH 76LIBIDN2_PATH = ../../libidn2-2.0.3 77endif 78# Edit the path below to point to the base of your MS IDN package. 79# Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1 80# https://www.microsoft.com/en-us/download/details.aspx?id=734 81ifndef WINIDN_PATH 82WINIDN_PATH = ../../Microsoft IDN Mitigation APIs 83endif 84# Edit the path below to point to the base of your Novell LDAP NDK. 85ifndef LDAP_SDK 86LDAP_SDK = c:/novell/ndk/cldapsdk/win32 87endif 88# Edit the path below to point to the base of your nghttp2 package. 89ifndef NGHTTP2_PATH 90NGHTTP2_PATH = ../../nghttp2-1.0.0 91endif 92 93PROOT = .. 94 95# Edit the path below to point to the base of your c-ares package. 96ifndef LIBCARES_PATH 97LIBCARES_PATH = $(PROOT)/ares 98endif 99 100ifeq ($(CURL_CC),) 101CURL_CC := $(CROSSPREFIX)gcc 102endif 103ifeq ($(CURL_AR),) 104CURL_AR := $(CROSSPREFIX)ar 105endif 106 107CC = $(CURL_CC) 108CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall -W 109CFLAGS += -fno-strict-aliasing 110# comment LDFLAGS below to keep debug info 111LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_EXE) -s 112AR = $(CURL_AR) 113RC = $(CROSSPREFIX)windres 114RCFLAGS = --include-dir=$(PROOT)/include -O coff -DCURL_EMBED_MANIFEST 115STRIP = $(CROSSPREFIX)strip -g 116 117# We may need these someday 118# PERL = perl 119# NROFF = nroff 120 121# Set environment var ARCH to your architecture to override autodetection. 122ifndef ARCH 123ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64) 124ARCH = w64 125else 126ARCH = w32 127endif 128endif 129 130ifeq ($(ARCH),w64) 131CFLAGS += -m64 -D_AMD64_ 132LDFLAGS += -m64 133RCFLAGS += -F pe-x86-64 134else 135CFLAGS += -m32 136LDFLAGS += -m32 137RCFLAGS += -F pe-i386 138endif 139 140# Platform-dependent helper tool macros 141ifeq ($(findstring /sh,$(SHELL)),/sh) 142DEL = rm -f $1 143RMDIR = rm -fr $1 144MKDIR = mkdir -p $1 145COPY = -cp -afv $1 $2 146#COPYR = -cp -afr $1/* $2 147COPYR = -rsync -aC $1/* $2 148TOUCH = touch $1 149CAT = cat 150ECHONL = echo "" 151DL = ' 152else 153ifeq "$(OS)" "Windows_NT" 154DEL = -del 2>NUL /q /f $(subst /,\,$1) 155RMDIR = -rd 2>NUL /q /s $(subst /,\,$1) 156else 157DEL = -del 2>NUL $(subst /,\,$1) 158RMDIR = -deltree 2>NUL /y $(subst /,\,$1) 159endif 160MKDIR = -md 2>NUL $(subst /,\,$1) 161COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2) 162COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2) 163TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,, 164CAT = type 165ECHONL = $(ComSpec) /c echo. 166endif 167 168######################################################## 169## Nothing more to do below this line! 170 171ifeq ($(findstring -dyn,$(CFG)),-dyn) 172DYN = 1 173endif 174ifeq ($(findstring -ares,$(CFG)),-ares) 175ARES = 1 176endif 177ifeq ($(findstring -sync,$(CFG)),-sync) 178SYNC = 1 179endif 180ifeq ($(findstring -rtmp,$(CFG)),-rtmp) 181RTMP = 1 182SSL = 1 183ZLIB = 1 184endif 185ifeq ($(findstring -ssh2,$(CFG)),-ssh2) 186SSH2 = 1 187SSL = 1 188ZLIB = 1 189endif 190ifeq ($(findstring -ssl,$(CFG)),-ssl) 191SSL = 1 192endif 193ifeq ($(findstring -zlib,$(CFG)),-zlib) 194ZLIB = 1 195endif 196ifeq ($(findstring -zstd,$(CFG)),-zstd) 197ZSTD = 1 198endif 199ifeq ($(findstring -brotli,$(CFG)),-brotli) 200BROTLI = 1 201endif 202ifeq ($(findstring -idn2,$(CFG)),-idn2) 203IDN2 = 1 204endif 205ifeq ($(findstring -winidn,$(CFG)),-winidn) 206WINIDN = 1 207endif 208ifeq ($(findstring -sspi,$(CFG)),-sspi) 209SSPI = 1 210endif 211ifeq ($(findstring -ldaps,$(CFG)),-ldaps) 212LDAPS = 1 213endif 214ifeq ($(findstring -ipv6,$(CFG)),-ipv6) 215IPV6 = 1 216endif 217ifeq ($(findstring -metalink,$(CFG)),-metalink) 218METALINK = 1 219endif 220ifeq ($(findstring -winssl,$(CFG)),-winssl) 221WINSSL = 1 222SSPI = 1 223endif 224ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2) 225NGHTTP2 = 1 226endif 227 228INCLUDES = -I. -I../include -I../lib 229ifdef SSL 230 ifdef WINSSL 231 CFLAGS += -DCURL_WITH_MULTI_SSL 232 endif 233endif 234 235ifdef DYN 236 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll 237 curl_LDADD = -L$(PROOT)/lib -lcurldll 238else 239 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a 240 curl_LDADD = -L$(PROOT)/lib -lcurl 241 CFLAGS += -DCURL_STATICLIB 242 LDFLAGS += -static 243endif 244ifdef SYNC 245 CFLAGS += -DUSE_SYNC_DNS 246else 247 ifdef ARES 248 ifndef DYN 249 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a 250 endif 251 CFLAGS += -DUSE_ARES -DCARES_STATICLIB 252 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares 253 endif 254endif 255ifdef RTMP 256 CFLAGS += -DUSE_LIBRTMP 257 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm 258endif 259ifdef NGHTTP2 260 CFLAGS += -DUSE_NGHTTP2 261 curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2 262endif 263ifdef SSH2 264 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H 265 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2 266 ifdef WINSSL 267 ifndef DYN 268 curl_LDADD += -lbcrypt -lcrypt32 269 endif 270 endif 271endif 272ifdef SSL 273 ifndef OPENSSL_INCLUDE 274 ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc" 275 OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc 276 endif 277 ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include" 278 OPENSSL_INCLUDE = $(OPENSSL_PATH)/include 279 endif 280 endif 281 ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h" 282 $(error Invalid path to OpenSSL package: $(OPENSSL_PATH)) 283 endif 284 ifndef OPENSSL_LIBPATH 285 OPENSSL_LIBS = -lssl -lcrypto 286 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out" 287 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out 288 ifdef DYN 289 OPENSSL_LIBS = -lssl32 -leay32 290 endif 291 endif 292 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib" 293 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib 294 endif 295 endif 296 ifndef DYN 297 OPENSSL_LIBS += -lgdi32 -lcrypt32 298 endif 299 INCLUDES += -I"$(OPENSSL_INCLUDE)" 300 CFLAGS += -DUSE_OPENSSL 301 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS) 302endif 303ifdef WINSSL 304 CFLAGS += -DUSE_SCHANNEL 305 curl_LDADD += -lcrypt32 306endif 307ifdef ZLIB 308 INCLUDES += -I"$(ZLIB_PATH)" 309 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H 310 curl_LDADD += -L"$(ZLIB_PATH)" -lz 311endif 312ifdef ZSTD 313 INCLUDES += -I"$(ZSTD_PATH)/include" 314 CFLAGS += -DHAVE_ZSTD 315 curl_LDADD += -L"$(ZSTD_PATH)/lib" 316 ifdef ZSTD_LIBS 317 curl_LDADD += $(ZSTD_LIBS) 318 else 319 curl_LDADD += -lzstd 320 endif 321endif 322ifdef BROTLI 323 INCLUDES += -I"$(BROTLI_PATH)/include" 324 CFLAGS += -DHAVE_BROTLI 325 curl_LDADD += -L"$(BROTLI_PATH)/lib" 326 ifdef BROTLI_LIBS 327 curl_LDADD += $(BROTLI_LIBS) 328 else 329 curl_LDADD += -lbrotlidec 330 endif 331endif 332ifdef IDN2 333 CFLAGS += -DUSE_LIBIDN2 334 curl_LDADD += -L"$(LIBIDN2_PATH)/lib" -lidn2 335else 336ifdef WINIDN 337 CFLAGS += -DUSE_WIN32_IDN 338 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz 339endif 340endif 341ifdef METALINK 342 INCLUDES += -I"$(LIBMETALINK_PATH)/include" 343 CFLAGS += -DUSE_METALINK 344 curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink 345 ifndef DYN 346 ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o) 347 curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat 348 else 349 curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2 350 endif 351 endif 352endif 353ifdef SSPI 354 CFLAGS += -DUSE_WINDOWS_SSPI 355endif 356ifdef IPV6 357 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501 358endif 359ifdef LDAPS 360 CFLAGS += -DHAVE_LDAP_SSL 361endif 362ifdef USE_LDAP_NOVELL 363 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK 364 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx 365endif 366ifdef USE_LDAP_OPENLDAP 367 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK 368 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber 369endif 370ifndef USE_LDAP_NOVELL 371ifndef USE_LDAP_OPENLDAP 372curl_LDADD += -lwldap32 373endif 374endif 375curl_LDADD += -lws2_32 376 377# Makefile.inc provides the CSOURCES and HHEADERS defines 378include Makefile.inc 379 380curl_PROGRAMS = curl.exe 381curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES))) 382curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES)))) 383curl_OBJECTS += $(curlx_OBJECTS) 384vpath %.c $(PROOT)/lib 385 386RESOURCE = curl.res 387 388 389all: $(curl_PROGRAMS) 390 391curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES) 392 $(call DEL, $@) 393 $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD) 394 395# We don't have nroff normally under win32 396# tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl 397# @$(call DEL, tool_hugehelp.c) 398# $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c 399 400tool_hugehelp.c: 401 @echo Creating $@ 402 @$(call COPY, $@.cvs, $@) 403 404%.o: %.c 405 $(CC) $(INCLUDES) $(CFLAGS) -c $< 406 407%.res: %.rc 408 $(RC) $(RCFLAGS) -i $< -o $@ 409 410clean: 411ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs" 412 @$(call DEL, tool_hugehelp.c) 413endif 414 @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE)) 415 416distclean vclean: clean 417 @$(call DEL, $(curl_PROGRAMS)) 418