MakefileBuild.vc 19 KB

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