2
0

MakefileBuild.vc 20 KB

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