blob: 727ef085075f786218dce1125709494e4fc53b5f [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1999 - 2022, 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.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# SPDX-License-Identifier: curl
22#
23#***************************************************************************
24
25###########################################################################
26#
27# Makefile for building libcurl with MSVC
28#
29# Usage: see README.md
30#
31##############################################################
32
33CFGSET=FALSE
34WINBUILD_DIR=`cd`
35
36# Utilities.
37# If a path is required that contains characters such as space, quote the path.
38MT = mt.exe
39RC = rc.exe
40ZIP = zip.exe
41
42# Allow changing C compiler via environment variable CC (default cl.exe)
43# This command macro is not set by default: https://msdn.microsoft.com/en-us/library/ms933742.aspx
44!If "$(CC)" == ""
45CC = cl.exe
46!Endif
47
48!IF "$(VC)"=="6"
49CC_NODEBUG = $(CC) /O2 /DNDEBUG
50CC_DEBUG = $(CC) /Od /Gm /Zi /D_DEBUG /GZ
51CFLAGS = /I. /I../lib /I../include /nologo /W4 /GX /DWIN32 /YX /FD /c /DBUILDING_LIBCURL
52!ELSE
53CC_NODEBUG = $(CC) /O2 /DNDEBUG
54CC_DEBUG = $(CC) /Od /D_DEBUG /RTC1 /Z7 /LDd
55CFLAGS = /I. /I ../lib /I../include /nologo /W4 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL
56!ENDIF
57
58LFLAGS = /nologo /machine:$(MACHINE)
59LNKDLL = link.exe /DLL
60# Use lib.exe instead of link.exe as link.exe /lib has the following bad habits:
61# - optimizing options like /opt:ref raises warnings (at least in Visual Studio 2015)
62# - all (including Windows) dependencies are aggregated (as static parts)
63# - link.exe /lib is not documented (anymore) at MSDN
64# Instead of id: just create an archive, that contains all objects
65LNKLIB = lib.exe
66
67CFLAGS_PDB = /Zi
68LFLAGS_PDB = /incremental:no /opt:ref,icf /DEBUG
69
70CFLAGS_LIBCURL_STATIC = /DCURL_STATICLIB
71
72WIN_LIBS = ws2_32.lib wldap32.lib advapi32.lib crypt32.lib
73
74BASE_NAME = libcurl
75BASE_NAME_DEBUG = $(BASE_NAME)_debug
76BASE_NAME_STATIC = $(BASE_NAME)_a
77BASE_NAME_STATIC_DEBUG = $(BASE_NAME_STATIC)_debug
78
79LIB_NAME_STATIC = $(BASE_NAME_STATIC).lib
80LIB_NAME_STATIC_DEBUG = $(BASE_NAME_STATIC_DEBUG).lib
81LIB_NAME_DLL = $(BASE_NAME).dll
82LIB_NAME_IMP = $(BASE_NAME).lib
83LIB_NAME_DLL_DEBUG = $(BASE_NAME_DEBUG).dll
84LIB_NAME_IMP_DEBUG = $(BASE_NAME_DEBUG).lib
85
86PDB_NAME_STATIC = $(BASE_NAME_STATIC).pdb
87PDB_NAME_STATIC_DEBUG = $(BASE_NAME_STATIC_DEBUG).pdb
88PDB_NAME_DLL = $(BASE_NAME).pdb
89PDB_NAME_DLL_DEBUG = $(BASE_NAME_DEBUG).pdb
90
91# CURL Command section
92PROGRAM_NAME = curl.exe
93CURL_CFLAGS = /I../lib /I../include /nologo /W4 /EHsc /DWIN32 /FD /c
94CURL_LFLAGS = /out:$(DIRDIST)\bin\$(PROGRAM_NAME) /subsystem:console $(LFLAGS)
95CURL_RESFLAGS = /i../include
96
97#############################################################
98## Nothing more to do below this line!
99LIBCURL_SRC_DIR = ..\lib
100CURL_SRC_DIR = ..\src
101
102!IFNDEF WITH_DEVEL
103WITH_DEVEL = ../../deps
104!ENDIF
105DEVEL_INCLUDE= $(WITH_DEVEL)/include
106DEVEL_LIB = $(WITH_DEVEL)/lib
107
108!IF EXISTS("$(DEVEL_INCLUDE)")
109CFLAGS = $(CFLAGS) /I"$(DEVEL_INCLUDE)"
110!ENDIF
111!IF EXISTS("$(DEVEL_LIB)")
112LFLAGS = $(LFLAGS) "/LIBPATH:$(DEVEL_LIB)"
113!ENDIF
114
115!IFDEF SSL_PATH
116SSL_INC_DIR = $(SSL_PATH)\include
117SSL_LIB_DIR = $(SSL_PATH)\lib
118SSL_LFLAGS = $(SSL_LFLAGS) "/LIBPATH:$(SSL_LIB_DIR)"
119!ELSE
120SSL_INC_DIR=$(DEVEL_INCLUDE)\openssl
121SSL_LIB_DIR=$(DEVEL_LIB)
122!ENDIF
123
124!IF "$(WITH_SSL)"=="dll" || "$(WITH_SSL)"=="static"
125!IF EXISTS("$(SSL_LIB_DIR)\libssl.lib")
126SSL_LIBS = libssl.lib libcrypto.lib
127!ELSE
128SSL_LIBS = libeay32.lib ssleay32.lib
129!ENDIF
130USE_SSL = true
131SSL = $(WITH_SSL)
132!IF "$(WITH_SSL)"=="static"
133WIN_LIBS = $(WIN_LIBS) gdi32.lib user32.lib crypt32.lib
134!ENDIF
135!ENDIF
136
137!IFDEF USE_SSL
138SSL_CFLAGS = /DUSE_OPENSSL /I"$(SSL_INC_DIR)"
139!IF EXISTS("$(SSL_INC_DIR)\is_boringssl.h")
140SSL_CFLAGS = $(SSL_CFLAGS) /DHAVE_BORINGSSL
141!ENDIF
142!IF "$(ENABLE_OPENSSL_AUTO_LOAD_CONFIG)"=="false"
143SSL_CFLAGS = $(SSL_CFLAGS) /DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
144!ENDIF
145!ENDIF
146
147
148!IFDEF NGHTTP2_PATH
149NGHTTP2_INC_DIR = $(NGHTTP2_PATH)\include
150NGHTTP2_LIB_DIR = $(NGHTTP2_PATH)\lib
151NGHTTP2_LFLAGS = $(NGHTTP2_LFLAGS) "/LIBPATH:$(NGHTTP2_LIB_DIR)"
152!ELSE
153NGHTTP2_INC_DIR = $(DEVEL_INCLUDE)
154NGHTTP2_LIB_DIR = $(DEVEL_LIB)
155!ENDIF
156
157!IF "$(WITH_NGHTTP2)"=="dll"
158NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /I"$(NGHTTP2_INC_DIR)"
159NGHTTP2_LIBS = nghttp2.lib
160!ELSEIF "$(WITH_NGHTTP2)"=="static"
161NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /DNGHTTP2_STATICLIB /I"$(NGHTTP2_INC_DIR)"
162!IF EXISTS("$(NGHTTP2_LIB_DIR)\nghttp2_static.lib")
163NGHTTP2_LIBS = nghttp2_static.lib
164!ELSE
165NGHTTP2_LIBS = nghttp2.lib
166!ENDIF
167!ENDIF
168
169!IFDEF MSH3_PATH
170MSH3_INC_DIR = $(MSH3_PATH)\include
171MSH3_LIB_DIR = $(MSH3_PATH)\lib
172MSH3_LFLAGS = $(MSH3_LFLAGS) "/LIBPATH:$(MSH3_LIB_DIR)"
173!ELSE
174MSH3_INC_DIR = $(DEVEL_INCLUDE)
175MSH3_LIB_DIR = $(DEVEL_LIB)
176!ENDIF
177
178!IF "$(WITH_MSH3)"=="dll"
179MSH3_CFLAGS = /DUSE_MSH3 /I"$(MSH3_INC_DIR)"
180MSH3_LIBS = msh3.lib
181!ELSEIF "$(WITH_MSH3)"=="static"
182MSH3_CFLAGS = /DUSE_MSH3 /DMSH3_STATICLIB /I"$(MSH3_INC_DIR)"
183!IF EXISTS("$(NGHTTP2_LIB_DIR)\msh3_static.lib")
184MSH3_LIBS = msh3_static.lib
185!ELSE
186MSH3_LIBS = msh3.lib
187!ENDIF
188!ENDIF
189
190!IFDEF MBEDTLS_PATH
191MBEDTLS_INC_DIR = $(MBEDTLS_PATH)\include
192MBEDTLS_LIB_DIR = $(MBEDTLS_PATH)\lib
193MBEDTLS_LFLAGS = $(MBEDTLS_LFLAGS) "/LIBPATH:$(MBEDTLS_LIB_DIR)"
194!ELSE
195MBEDTLS_INC_DIR = $(DEVEL_INCLUDE)
196MBEDTLS_LIB_DIR = $(DEVEL_LIB)
197!ENDIF
198
199!IF "$(WITH_MBEDTLS)"=="dll" || "$(WITH_MBEDTLS)"=="static"
200USE_MBEDTLS = true
201MBEDTLS = $(WITH_MBEDTLS)
202MBEDTLS_CFLAGS = /DUSE_MBEDTLS /I"$(MBEDTLS_INC_DIR)"
203MBEDTLS_LIBS = mbedtls.lib mbedcrypto.lib mbedx509.lib
204!ENDIF
205
206
207!IFDEF CARES_PATH
208CARES_INC_DIR = $(CARES_PATH)\include
209CARES_LIB_DIR = $(CARES_PATH)\lib
210CARES_LFLAGS = $(CARES_LFLAGS) "/LIBPATH:$(CARES_LIB_DIR)"
211!ELSE
212CARES_INC_DIR = $(DEVEL_INCLUDE)/cares
213CARES_LIB_DIR = $(DEVEL_LIB)
214!ENDIF
215
216!IF "$(WITH_CARES)"=="dll"
217!IF "$(DEBUG)"=="yes"
218CARES_LIBS = caresd.lib
219!ELSE
220CARES_LIBS = cares.lib
221!ENDIF
222USE_CARES = true
223CARES = dll
224!ELSEIF "$(WITH_CARES)"=="static"
225!IF "$(DEBUG)"=="yes"
226CARES_LIBS = libcaresd.lib
227!ELSE
228CARES_LIBS = libcares.lib
229!ENDIF
230USE_CARES = true
231CARES = static
232!ENDIF
233
234!IFDEF USE_CARES
235CARES_CFLAGS = /DUSE_ARES /I"$(CARES_INC_DIR)"
236!IF "$(CARES)"=="static"
237CARES_CFLAGS = $(CARES_CFLAGS) /DCARES_STATICLIB
238!ENDIF
239!ENDIF
240
241
242!IFDEF ZLIB_PATH
243ZLIB_INC_DIR = $(ZLIB_PATH)\include
244ZLIB_LIB_DIR = $(ZLIB_PATH)\lib
245ZLIB_LFLAGS = $(ZLIB_LFLAGS) "/LIBPATH:$(ZLIB_LIB_DIR)"
246!ELSE
247ZLIB_INC_DIR = $(DEVEL_INCLUDE)
248ZLIB_LIB_DIR = $(DEVEL_LIB)
249!ENDIF
250
251# Depending on how zlib is built the libraries have different names, we
252# try to handle them all.
253!IF "$(WITH_ZLIB)"=="dll"
254!IF EXISTS("$(ZLIB_LIB_DIR)\zlibwapi.lib")
255ZLIB_LIBS = zlibwapi.lib
256ADDITIONAL_ZLIB_CFLAGS = /DZLIB_WINAPI
257!ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zdll.lib")
258ZLIB_LIBS = zdll.lib
259!ELSE
260ZLIB_LIBS = zlib.lib
261!ENDIF
262USE_ZLIB = true
263ZLIB = dll
264!ELSEIF "$(WITH_ZLIB)"=="static"
265!IF EXISTS("$(ZLIB_LIB_DIR)\zlibstat.lib")
266ZLIB_LIBS = zlibstat.lib
267ADDITIONAL_ZLIB_CFLAGS = /DZLIB_WINAPI
268!ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zlib.lib")
269ZLIB_LIBS = zlib.lib
270!ELSE
271ZLIB_LIBS = zlib_a.lib
272!ENDIF
273USE_ZLIB = true
274ZLIB = static
275!ENDIF
276
277!IFDEF USE_ZLIB
278ZLIB_CFLAGS = /DHAVE_LIBZ $(ADDITIONAL_ZLIB_CFLAGS) /I"$(ZLIB_INC_DIR)"
279!ENDIF
280
281
282!IFDEF SSH2_PATH
283SSH2_INC_DIR= $(SSH2_PATH)\include
284SSH2_LIB_DIR= $(SSH2_PATH)\lib
285SSH2_LFLAGS = $(SSH2_LFLAGS) "/LIBPATH:$(SSH2_LIB_DIR)"
286!ELSE
287SSH2_LIB_DIR= $(DEVEL_LIB)
288SSH2_INC_DIR= $(DEVEL_INCLUDE)/libssh2
289!ENDIF
290
291!IF "$(WITH_SSH2)"=="dll"
292SSH2_LIBS = libssh2.lib
293USE_SSH2 = true
294SSH2 = dll
295!ELSEIF "$(WITH_SSH2)"=="static"
296# libssh2 NMakefile on Windows at default creates a static library without _a suffix
297!IF EXISTS("$(SSH2_LIB_DIR)\libssh2.lib")
298SSH2_LIBS = libssh2.lib
299!ELSE
300SSH2_LIBS = libssh2_a.lib
301!ENDIF
302WIN_LIBS = $(WIN_LIBS) user32.lib
303USE_SSH2 = true
304SSH2 = static
305!ENDIF
306
307!IFDEF USE_SSH2
308SSH2_CFLAGS = /DUSE_LIBSSH2
309SSH2_CFLAGS = $(SSH2_CFLAGS) /I"$(SSH2_INC_DIR)"
310!ENDIF
311
312
313!IFDEF SSH_PATH
314SSH_INC_DIR= $(SSH_PATH)\include
315SSH_LIB_DIR= $(SSH_PATH)\lib
316SSH_LFLAGS = $(SSH_LFLAGS) "/LIBPATH:$(SSH_LIB_DIR)"
317!ELSE
318SSH_LIB_DIR= $(DEVEL_LIB)
319SSH_INC_DIR= $(DEVEL_INCLUDE)
320!ENDIF
321
322!IF "$(WITH_SSH)"=="dll" || "$(WITH_SSH)"=="static"
323SSH_LIBS = ssh.lib
324USE_SSH = true
325SSH = $(WITH_SSH)
326!ENDIF
327
328!IFDEF USE_SSH
329SSH_CFLAGS = /DUSE_LIBSSH
330SSH_CFLAGS = $(SSH_CFLAGS) /I"$(SSH_INC_DIR)"
331!ENDIF
332
333
334!IFNDEF USE_IDN
335USE_IDN = true
336!ELSEIF "$(USE_IDN)"=="yes"
337USE_IDN = true
338!ENDIF
339
340!IF "$(USE_IDN)"=="true"
341IDN_CFLAGS = $(IDN_CFLAGS) /DUSE_WIN32_IDN /DWANT_IDN_PROTOTYPES
342WIN_LIBS = $(WIN_LIBS) Normaliz.lib
343!ENDIF
344
345
346!IFNDEF USE_IPV6
347USE_IPV6 = true
348!ELSEIF "$(USE_IPV6)"=="yes"
349USE_IPV6 = true
350!ENDIF
351
352!IF "$(USE_IPV6)"=="true"
353IPV6_CFLAGS = $(IPV6_CFLAGS) /DUSE_IPV6
354!ENDIF
355
356
357!IFNDEF USE_SSPI
358USE_SSPI = true
359!ELSEIF "$(USE_SSPI)"=="yes"
360USE_SSPI = true
361!ENDIF
362
363!IF "$(USE_SSPI)"=="true"
364SSPI_CFLAGS = $(SSPI_CFLAGS) /DUSE_WINDOWS_SSPI
365!ENDIF
366
367
368!IFNDEF USE_SCHANNEL
369!IF "$(USE_SSL)"=="true"
370USE_SCHANNEL = false
371!ELSE
372USE_SCHANNEL = $(USE_SSPI)
373!ENDIF
374!ELSEIF "$(USE_SCHANNEL)"=="yes"
375USE_SCHANNEL = true
376!ENDIF
377
378
379!IF "$(USE_SCHANNEL)"=="true"
380!IF "$(USE_SSPI)"!="true"
381!ERROR cannot build with Schannel without SSPI
382!ENDIF
383SSPI_CFLAGS = $(SSPI_CFLAGS) /DUSE_SCHANNEL
384WIN_LIBS = $(WIN_LIBS) Crypt32.lib
385!ENDIF
386
387
388!IF "$(GEN_PDB)"=="yes"
389GEN_PDB = true
390!ENDIF
391
392
393!IFDEF EMBED_MANIFEST
394MANIFESTTOOL = $(MT) -manifest $(DIRDIST)\bin\$(PROGRAM_NAME).manifest -outputresource:$(DIRDIST)\bin\$(PROGRAM_NAME);1
395!ELSE
396CURL_RC_FLAGS = $(CURL_RC_FLAGS) /dCURL_EMBED_MANIFEST
397!ENDIF
398
399# Runtime library configuration
400!IF "$(RTLIBCFG)"=="static"
401RTLIB = /MT
402RTLIB_DEBUG = /MTd
403!ELSE
404RTLIB = /MD
405RTLIB_DEBUG = /MDd
406!ENDIF
407
408!IF "$(MODE)"=="static"
409TARGET = $(LIB_NAME_STATIC)
410CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC)
411AS_DLL = false
412CFGSET = true
413!ELSEIF "$(MODE)"=="dll"
414TARGET = $(LIB_NAME_DLL)
415CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP)
416AS_DLL = true
417CFGSET = true
418!ENDIF
419
420!IF "$(CFGSET)" == "FALSE"
421!ERROR please choose a valid mode
422!ENDIF
423
424
425
426# CURL_XX macros are for the curl.exe command
427
428!IF "$(DEBUG)"=="yes"
429RC_FLAGS = /dDEBUGBUILD=1 /Fo $@ $(LIBCURL_SRC_DIR)\libcurl.rc
430CURL_CC = $(CC_DEBUG) $(RTLIB_DEBUG)
431CURL_RC_FLAGS = $(CURL_RC_FLAGS) /i../include /dDEBUGBUILD=1 /Fo $@ $(CURL_SRC_DIR)\curl.rc
432!ELSE
433RC_FLAGS = /dDEBUGBUILD=0 /Fo $@ $(LIBCURL_SRC_DIR)\libcurl.rc
434CURL_CC = $(CC_NODEBUG) $(RTLIB)
435CURL_RC_FLAGS = $(CURL_RC_FLAGS) /i../include /dDEBUGBUILD=0 /Fo $@ $(CURL_SRC_DIR)\curl.rc
436!ENDIF
437
438!IF "$(AS_DLL)" == "true"
439
440LNK = $(LNKDLL) $(LFLAGS) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET)
441!IF "$(DEBUG)"=="yes"
442TARGET = $(LIB_NAME_DLL_DEBUG)
443LNK = $(LNK) /DEBUG /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG)
444PDB = $(PDB_NAME_DLL_DEBUG)
445CURL_LIBS = /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG)
446!ELSE
447TARGET = $(LIB_NAME_DLL)
448LNK = $(LNK) /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP)
449PDB = $(PDB_NAME_DLL)
450CURL_LIBS = /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP)
451!ENDIF
452RESOURCE = $(LIB_DIROBJ)\libcurl.res
453
454# AS_DLL
455!ELSE
456
457!IF "$(DEBUG)"=="yes"
458TARGET = $(LIB_NAME_STATIC_DEBUG)
459PDB = $(PDB_NAME_STATIC_DEBUG)
460!ELSE
461TARGET = $(LIB_NAME_STATIC)
462PDB = $(PDB_NAME_STATIC)
463!ENDIF
464LNK = $(LNKLIB) /out:$(LIB_DIROBJ)\$(TARGET)
465CURL_CC = $(CURL_CC) $(CFLAGS_LIBCURL_STATIC)
466
467# AS_DLL
468!ENDIF
469
470!IF "$(USE_SSL)"=="true"
471CFLAGS = $(CFLAGS) $(SSL_CFLAGS)
472LFLAGS = $(LFLAGS) $(SSL_LFLAGS) $(SSL_LIBS)
473!ENDIF
474
475!IF "$(USE_MBEDTLS)"=="true"
476CFLAGS = $(CFLAGS) $(MBEDTLS_CFLAGS)
477LFLAGS = $(LFLAGS) $(MBEDTLS_LFLAGS) $(MBEDTLS_LIBS)
478!ENDIF
479
480!IF "$(USE_CARES)"=="true"
481CFLAGS = $(CFLAGS) $(CARES_CFLAGS)
482LFLAGS = $(LFLAGS) $(CARES_LFLAGS) $(CARES_LIBS)
483!ENDIF
484
485!IF "$(USE_ZLIB)"=="true"
486CFLAGS = $(CFLAGS) $(ZLIB_CFLAGS)
487LFLAGS = $(LFLAGS) $(ZLIB_LFLAGS) $(ZLIB_LIBS)
488!ENDIF
489
490!IF "$(USE_SSH2)"=="true"
491CFLAGS = $(CFLAGS) $(SSH2_CFLAGS)
492LFLAGS = $(LFLAGS) $(SSH2_LFLAGS) $(SSH2_LIBS)
493!ENDIF
494
495!IF "$(USE_SSH)"=="true"
496CFLAGS = $(CFLAGS) $(SSH_CFLAGS)
497LFLAGS = $(LFLAGS) $(SSH_LFLAGS) $(SSH_LIBS)
498!ENDIF
499
500!IF "$(USE_IDN)"=="true"
501CFLAGS = $(CFLAGS) $(IDN_CFLAGS)
502!ENDIF
503
504!IF "$(USE_IPV6)"=="true"
505CFLAGS = $(CFLAGS) $(IPV6_CFLAGS)
506!ENDIF
507
508!IF "$(USE_SSPI)"=="true"
509CFLAGS = $(CFLAGS) $(SSPI_CFLAGS)
510!ENDIF
511
512!IF "$(USE_NGHTTP2)"=="true"
513CFLAGS = $(CFLAGS) $(NGHTTP2_CFLAGS)
514LFLAGS = $(LFLAGS) $(NGHTTP2_LFLAGS) $(NGHTTP2_LIBS)
515!ENDIF
516
517!IF "$(USE_MSH3)"=="true"
518CFLAGS = $(CFLAGS) $(MSH3_CFLAGS)
519LFLAGS = $(LFLAGS) $(MSH3_LFLAGS) $(MSH3_LIBS)
520!ENDIF
521
522!IF "$(GEN_PDB)"=="true"
523CFLAGS = $(CFLAGS) $(CFLAGS_PDB) /Fd"$(LIB_DIROBJ)\$(PDB)"
524LFLAGS = $(LFLAGS) $(LFLAGS_PDB)
525!ENDIF
526
527!IF ( "$(USE_SSL)"=="true" && "$(USE_SCHANNEL)"=="true" ) \
528 || ( "$(USE_SSL)"=="true" && "$(USE_MBEDTLS)"=="true" ) \
529 || ( "$(USE_MBEDTLS)"=="true" && "$(USE_SCHANNEL)"=="true" )
530CFLAGS = $(CFLAGS) /DCURL_WITH_MULTI_SSL
531!ENDIF
532
533!IF "$(USE_UNICODE)"=="true"
534CFLAGS = $(CFLAGS) /DUNICODE /D_UNICODE
535!ENDIF
536
537LIB_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-lib
538CURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-curl
539
540!IFDEF WITH_PREFIX
541DIRDIST = $(WITH_PREFIX)
542!ELSE
543DIRDIST = ..\builds\$(CONFIG_NAME_LIB)\
544!ENDIF
545
546#
547# curl.exe
548#
549CURL_LINK = link.exe /incremental:no /libpath:"$(DIRDIST)\lib"
550
551!IF "$(CFGSET)" != "FALSE"
552# A mode was provided, so the library can be built.
553#
554!include CURL_OBJS.inc
555!include LIBCURL_OBJS.inc
556
557!IF "$(AS_DLL)" == "true"
558LIB_OBJS = $(LIBCURL_OBJS) $(RESOURCE)
559!ELSE
560LIB_OBJS = $(LIBCURL_OBJS)
561!ENDIF
562
563EXE_OBJS = $(CURL_OBJS) $(CURL_DIROBJ)\curl.res
564
565all : $(TARGET) $(PROGRAM_NAME)
566
567package: $(TARGET)
568 @cd $(DIRDIST)
569 @-$(ZIP) -9 -q -r ..\$(CONFIG_NAME_LIB).zip .>nul 2<&1
570 @cd $(MAKEDIR)
571
572$(TARGET): $(LIB_OBJS) $(LIB_DIROBJ) $(DIRDIST)
573 @echo Using SSL: $(USE_SSL)
574 @echo Using NGHTTP2: $(USE_NGHTTP2)
575 @echo Using MSH3: $(USE_MSH3)
576 @echo Using c-ares: $(USE_CARES)
577 @echo Using SSH2: $(USE_SSH2)
578 @echo Using SSH: $(USE_SSH)
579 @echo Using ZLIB: $(USE_ZLIB)
580 @echo Using IDN: $(USE_IDN)
581 @echo Using IPv6: $(USE_IPV6)
582 @echo Using SSPI: $(USE_SSPI)
583 @echo Using Schannel: $(USE_SCHANNEL)
584 @echo CFLAGS: $(CFLAGS)
585 @echo LFLAGS: $(LFLAGS)
586 @echo GenPDB: $(GEN_PDB)
587 @echo Debug: $(DEBUG)
588 @echo Machine: $(MACHINE)
589 $(LNK) $(LIB_OBJS)
590 @echo Copying libs...
591 @if exist $(LIB_DIROBJ)\$(LIB_NAME_DLL) copy $(LIB_DIROBJ)\$(LIB_NAME_DLL) $(DIRDIST)\bin\ /y >nul 2<&1
592 @if exist $(LIB_DIROBJ)\$(LIB_NAME_STATIC) copy $(LIB_DIROBJ)\$(LIB_NAME_STATIC) $(DIRDIST)\lib\ /y >nul 2<&1
593 @if exist $(LIB_DIROBJ)\$(LIB_NAME_DLL_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_DLL_DEBUG) $(DIRDIST)\bin\ /y >nul 2<&1
594 @if exist $(LIB_DIROBJ)\$(LIB_NAME_STATIC_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_STATIC_DEBUG) $(DIRDIST)\lib\ /y >nul 2<&1
595 @if exist $(LIB_DIROBJ)\$(LIB_NAME_IMP) copy $(LIB_DIROBJ)\$(LIB_NAME_IMP) $(DIRDIST)\lib\ /y >nul 2<&1
596 @if exist $(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG) $(DIRDIST)\lib >nul 2<&1
597 @-copy $(LIB_DIROBJ)\*.exp $(DIRDIST)\lib /y >nul 2<&1
598 @-copy $(LIB_DIROBJ)\*.pdb $(DIRDIST)\lib /y >nul 2<&1
599 @-copy ..\include\curl\*.h $(DIRDIST)\include\curl\ /y >nul 2<&1
600
601$(LIB_OBJS): $(LIB_DIROBJ) $(DIRDIST)
602
603$(DIRDIST):
604 @if not exist "$(DIRDIST)\bin" mkdir $(DIRDIST)\bin
605 @if not exist "$(DIRDIST)\include" mkdir $(DIRDIST)\include
606 @if not exist "$(DIRDIST)\include\curl" mkdir $(DIRDIST)\include\curl
607 @if not exist "$(DIRDIST)\lib" mkdir $(DIRDIST)\lib
608
609$(LIB_DIROBJ):
610 @if not exist "$(LIB_DIROBJ)" mkdir $(LIB_DIROBJ)
611 @if not exist "$(LIB_DIROBJ)\vauth" mkdir $(LIB_DIROBJ)\vauth
612 @if not exist "$(LIB_DIROBJ)\vtls" mkdir $(LIB_DIROBJ)\vtls
613 @if not exist "$(LIB_DIROBJ)\vssh" mkdir $(LIB_DIROBJ)\vssh
614 @if not exist "$(LIB_DIROBJ)\vquic" mkdir $(LIB_DIROBJ)\vquic
615
616$(CURL_DIROBJ):
617 @if not exist "$(CURL_DIROBJ)" mkdir $(CURL_DIROBJ)
618# we need a lib dir for the portability functions from libcurl
619# we use the .c directly here
620 @if not exist "$(CURL_DIROBJ)" mkdir $(CURL_DIROBJ)\lib
621
622.SUFFIXES: .c .obj .res
623
624{$(LIBCURL_SRC_DIR)\}.c{$(LIB_DIROBJ)\}.obj::
625 $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\\" $<
626
627{$(LIBCURL_SRC_DIR)\vauth\}.c{$(LIB_DIROBJ)\vauth\}.obj::
628 $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\vauth\\" $<
629
630{$(LIBCURL_SRC_DIR)\vtls\}.c{$(LIB_DIROBJ)\vtls\}.obj::
631 $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\vtls\\" $<
632
633{$(LIBCURL_SRC_DIR)\vssh\}.c{$(LIB_DIROBJ)\vssh\}.obj::
634 $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\vssh\\" $<
635
636{$(LIBCURL_SRC_DIR)\vquic\}.c{$(LIB_DIROBJ)\vquic\}.obj::
637 $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\vquic\\" $<
638
639$(LIB_DIROBJ)\libcurl.res: $(LIBCURL_SRC_DIR)\libcurl.rc
640 $(RC) $(RC_FLAGS)
641
642#
643# curl.exe
644#
645
646
647!IF "$(MODE)"=="static"
648!IF "$(DEBUG)"=="yes"
649CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC_DEBUG)
650!ELSE
651CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC)
652!ENDIF
653!ELSEIF "$(MODE)"=="dll"
654!IF "$(DEBUG)"=="yes"
655CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP_DEBUG)
656!ELSE
657CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP)
658!ENDIF
659!ENDIF
660
661CURL_FROM_LIBCURL=$(CURL_DIROBJ)\tool_hugehelp.obj \
662 $(CURL_DIROBJ)\nonblock.obj \
663 $(CURL_DIROBJ)\strtoofft.obj \
664 $(CURL_DIROBJ)\warnless.obj \
665 $(CURL_DIROBJ)\curl_multibyte.obj \
666 $(CURL_DIROBJ)\version_win32.obj \
667 $(CURL_DIROBJ)\dynbuf.obj
668
669$(PROGRAM_NAME): $(CURL_DIROBJ) $(CURL_FROM_LIBCURL) $(EXE_OBJS)
670 $(CURL_LINK) $(CURL_LFLAGS) $(CURL_LIBCURL_LIBNAME) $(WIN_LIBS) $(CURL_FROM_LIBCURL) $(EXE_OBJS)
671 $(MANIFESTTOOL)
672
673{$(CURL_SRC_DIR)\}.c{$(CURL_DIROBJ)\}.obj::
674 $(CURL_CC) $(CURL_CFLAGS) /Fo"$(CURL_DIROBJ)\\" $<
675
676$(CURL_DIROBJ)\tool_hugehelp.obj: $(CURL_SRC_DIR)\tool_hugehelp.c
677 $(CURL_CC) $(CURL_CFLAGS) /Zm200 /Fo"$@" $(CURL_SRC_DIR)\tool_hugehelp.c
678$(CURL_DIROBJ)\nonblock.obj: ../lib/nonblock.c
679 $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/nonblock.c
680$(CURL_DIROBJ)\strtoofft.obj: ../lib/strtoofft.c
681 $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/strtoofft.c
682$(CURL_DIROBJ)\warnless.obj: ../lib/warnless.c
683 $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/warnless.c
684$(CURL_DIROBJ)\curl_multibyte.obj: ../lib/curl_multibyte.c
685 $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/curl_multibyte.c
686$(CURL_DIROBJ)\version_win32.obj: ../lib/version_win32.c
687 $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/version_win32.c
688$(CURL_DIROBJ)\dynbuf.obj: ../lib/dynbuf.c
689 $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/dynbuf.c
690$(CURL_DIROBJ)\curl.res: $(CURL_SRC_DIR)\curl.rc
691 rc $(CURL_RC_FLAGS)
692
693!ENDIF # End of case where a config was provided.
694
695clean:
696 @-erase /s *.dll 2> NUL
697 @-erase /s *.exp 2> NUL
698 @-erase /s *.idb 2> NUL
699 @-erase /s *.lib 2> NUL
700 @-erase /s *.obj 2> NUL
701 @-erase /s *.pch 2> NUL
702 @-erase /s *.pdb 2> NUL
703 @-erase /s *.res 2> NUL
704 @if exist $(LIB_DIROBJ) rd /s/q $(LIB_DIROBJ)
705 @if exist $(CURL_DIROBJ)rd /s/q $(CURL_DIROBJ)
706 @if exist $(DIRDIST) rd /s/q $(DIRDIST)