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