MakefileBuild.vc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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 /DWIN32 /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 /DWIN32 /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 /DWIN32 /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. !IFDEF NGHTTP2_PATH
  125. NGHTTP2_INC_DIR = $(NGHTTP2_PATH)\include
  126. NGHTTP2_LIB_DIR = $(NGHTTP2_PATH)\lib
  127. NGHTTP2_LFLAGS = $(NGHTTP2_LFLAGS) "/LIBPATH:$(NGHTTP2_LIB_DIR)"
  128. !ELSE
  129. NGHTTP2_INC_DIR = $(DEVEL_INCLUDE)
  130. NGHTTP2_LIB_DIR = $(DEVEL_LIB)
  131. !ENDIF
  132. !IF "$(WITH_NGHTTP2)"=="dll"
  133. NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /I"$(NGHTTP2_INC_DIR)"
  134. NGHTTP2_LIBS = nghttp2.lib
  135. !ELSEIF "$(WITH_NGHTTP2)"=="static"
  136. NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /DNGHTTP2_STATICLIB /I"$(NGHTTP2_INC_DIR)"
  137. !IF EXISTS("$(NGHTTP2_LIB_DIR)\nghttp2_static.lib")
  138. NGHTTP2_LIBS = nghttp2_static.lib
  139. !ELSE
  140. NGHTTP2_LIBS = nghttp2.lib
  141. !ENDIF
  142. !ENDIF
  143. !IFDEF MSH3_PATH
  144. MSH3_INC_DIR = $(MSH3_PATH)\include
  145. MSH3_LIB_DIR = $(MSH3_PATH)\lib
  146. MSH3_LFLAGS = $(MSH3_LFLAGS) "/LIBPATH:$(MSH3_LIB_DIR)"
  147. !ELSE
  148. MSH3_INC_DIR = $(DEVEL_INCLUDE)
  149. MSH3_LIB_DIR = $(DEVEL_LIB)
  150. !ENDIF
  151. !IF "$(WITH_MSH3)"=="dll"
  152. MSH3_CFLAGS = /DUSE_MSH3 /I"$(MSH3_INC_DIR)"
  153. MSH3_LIBS = msh3.lib
  154. !ELSEIF "$(WITH_MSH3)"=="static"
  155. MSH3_CFLAGS = /DUSE_MSH3 /DMSH3_STATICLIB /I"$(MSH3_INC_DIR)"
  156. !IF EXISTS("$(NGHTTP2_LIB_DIR)\msh3_static.lib")
  157. MSH3_LIBS = msh3_static.lib
  158. !ELSE
  159. MSH3_LIBS = msh3.lib
  160. !ENDIF
  161. !ENDIF
  162. !IFDEF MBEDTLS_PATH
  163. MBEDTLS_INC_DIR = $(MBEDTLS_PATH)\include
  164. MBEDTLS_LIB_DIR = $(MBEDTLS_PATH)\lib
  165. MBEDTLS_LFLAGS = $(MBEDTLS_LFLAGS) "/LIBPATH:$(MBEDTLS_LIB_DIR)"
  166. !ELSE
  167. MBEDTLS_INC_DIR = $(DEVEL_INCLUDE)
  168. MBEDTLS_LIB_DIR = $(DEVEL_LIB)
  169. !ENDIF
  170. !IF "$(WITH_MBEDTLS)"=="dll" || "$(WITH_MBEDTLS)"=="static"
  171. USE_MBEDTLS = true
  172. MBEDTLS = $(WITH_MBEDTLS)
  173. MBEDTLS_CFLAGS = /DUSE_MBEDTLS /I"$(MBEDTLS_INC_DIR)"
  174. MBEDTLS_LIBS = mbedtls.lib mbedcrypto.lib mbedx509.lib
  175. !ENDIF
  176. !IFDEF CARES_PATH
  177. CARES_INC_DIR = $(CARES_PATH)\include
  178. CARES_LIB_DIR = $(CARES_PATH)\lib
  179. CARES_LFLAGS = $(CARES_LFLAGS) "/LIBPATH:$(CARES_LIB_DIR)"
  180. !ELSE
  181. CARES_INC_DIR = $(DEVEL_INCLUDE)/cares
  182. CARES_LIB_DIR = $(DEVEL_LIB)
  183. !ENDIF
  184. !IF "$(WITH_CARES)"=="dll"
  185. !IF "$(DEBUG)"=="yes"
  186. CARES_LIBS = caresd.lib
  187. !ELSE
  188. CARES_LIBS = cares.lib
  189. !ENDIF
  190. USE_CARES = true
  191. CARES = dll
  192. !ELSEIF "$(WITH_CARES)"=="static"
  193. !IF "$(DEBUG)"=="yes"
  194. CARES_LIBS = libcaresd.lib
  195. !ELSE
  196. CARES_LIBS = libcares.lib
  197. !ENDIF
  198. USE_CARES = true
  199. CARES = static
  200. !ENDIF
  201. !IFDEF USE_CARES
  202. CARES_CFLAGS = /DUSE_ARES /I"$(CARES_INC_DIR)"
  203. !IF "$(CARES)"=="static"
  204. CARES_CFLAGS = $(CARES_CFLAGS) /DCARES_STATICLIB
  205. !ENDIF
  206. !ENDIF
  207. !IFDEF ZLIB_PATH
  208. ZLIB_INC_DIR = $(ZLIB_PATH)\include
  209. ZLIB_LIB_DIR = $(ZLIB_PATH)\lib
  210. ZLIB_LFLAGS = $(ZLIB_LFLAGS) "/LIBPATH:$(ZLIB_LIB_DIR)"
  211. !ELSE
  212. ZLIB_INC_DIR = $(DEVEL_INCLUDE)
  213. ZLIB_LIB_DIR = $(DEVEL_LIB)
  214. !ENDIF
  215. # Depending on how zlib is built the libraries have different names, we
  216. # try to handle them all.
  217. !IF "$(WITH_ZLIB)"=="dll"
  218. !IF EXISTS("$(ZLIB_LIB_DIR)\zlibwapi.lib")
  219. ZLIB_LIBS = zlibwapi.lib
  220. ADDITIONAL_ZLIB_CFLAGS = /DZLIB_WINAPI
  221. !ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zdll.lib")
  222. ZLIB_LIBS = zdll.lib
  223. !ELSE
  224. ZLIB_LIBS = zlib.lib
  225. !ENDIF
  226. USE_ZLIB = true
  227. ZLIB = dll
  228. !ELSEIF "$(WITH_ZLIB)"=="static"
  229. !IF EXISTS("$(ZLIB_LIB_DIR)\zlibstat.lib")
  230. ZLIB_LIBS = zlibstat.lib
  231. ADDITIONAL_ZLIB_CFLAGS = /DZLIB_WINAPI
  232. !ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zlibstatic.lib")
  233. ZLIB_LIBS = zlibstatic.lib
  234. !ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zlib.lib")
  235. ZLIB_LIBS = zlib.lib
  236. !ELSE
  237. ZLIB_LIBS = zlib_a.lib
  238. !ENDIF
  239. USE_ZLIB = true
  240. ZLIB = static
  241. !ENDIF
  242. !IFDEF USE_ZLIB
  243. ZLIB_CFLAGS = /DHAVE_LIBZ $(ADDITIONAL_ZLIB_CFLAGS) /I"$(ZLIB_INC_DIR)"
  244. !ENDIF
  245. !IFDEF SSH2_PATH
  246. SSH2_INC_DIR= $(SSH2_PATH)\include
  247. SSH2_LIB_DIR= $(SSH2_PATH)\lib
  248. SSH2_LFLAGS = $(SSH2_LFLAGS) "/LIBPATH:$(SSH2_LIB_DIR)"
  249. !ELSE
  250. SSH2_LIB_DIR= $(DEVEL_LIB)
  251. SSH2_INC_DIR= $(DEVEL_INCLUDE)/libssh2
  252. !ENDIF
  253. !IF "$(WITH_SSH2)"=="dll"
  254. SSH2_LIBS = libssh2.lib
  255. USE_SSH2 = true
  256. SSH2 = dll
  257. !ELSEIF "$(WITH_SSH2)"=="static"
  258. # libssh2 NMakefile on Windows at default creates a static library without _a suffix
  259. !IF EXISTS("$(SSH2_LIB_DIR)\libssh2.lib")
  260. SSH2_LIBS = libssh2.lib
  261. !ELSE
  262. SSH2_LIBS = libssh2_a.lib
  263. !ENDIF
  264. WIN_LIBS = $(WIN_LIBS) user32.lib
  265. USE_SSH2 = true
  266. SSH2 = static
  267. !ENDIF
  268. !IFDEF USE_SSH2
  269. SSH2_CFLAGS = /DUSE_LIBSSH2
  270. SSH2_CFLAGS = $(SSH2_CFLAGS) /I"$(SSH2_INC_DIR)"
  271. !ENDIF
  272. !IFDEF SSH_PATH
  273. SSH_INC_DIR= $(SSH_PATH)\include
  274. SSH_LIB_DIR= $(SSH_PATH)\lib
  275. SSH_LFLAGS = $(SSH_LFLAGS) "/LIBPATH:$(SSH_LIB_DIR)"
  276. !ELSE
  277. SSH_LIB_DIR= $(DEVEL_LIB)
  278. SSH_INC_DIR= $(DEVEL_INCLUDE)
  279. !ENDIF
  280. !IF "$(WITH_SSH)"=="dll" || "$(WITH_SSH)"=="static"
  281. SSH_LIBS = ssh.lib
  282. USE_SSH = true
  283. SSH = $(WITH_SSH)
  284. !ENDIF
  285. !IFDEF USE_SSH
  286. SSH_CFLAGS = /DUSE_LIBSSH
  287. SSH_CFLAGS = $(SSH_CFLAGS) /I"$(SSH_INC_DIR)"
  288. !ENDIF
  289. !IFNDEF USE_IDN
  290. USE_IDN = true
  291. !ELSEIF "$(USE_IDN)"=="yes"
  292. USE_IDN = true
  293. !ENDIF
  294. !IF "$(USE_IDN)"=="true"
  295. IDN_CFLAGS = $(IDN_CFLAGS) /DUSE_WIN32_IDN
  296. WIN_LIBS = $(WIN_LIBS) Normaliz.lib
  297. !ENDIF
  298. !IFNDEF USE_IPV6
  299. USE_IPV6 = true
  300. !ELSEIF "$(USE_IPV6)"=="yes"
  301. USE_IPV6 = true
  302. !ENDIF
  303. !IF "$(USE_IPV6)"=="true"
  304. IPV6_CFLAGS = $(IPV6_CFLAGS) /DUSE_IPV6
  305. !ENDIF
  306. !IFNDEF USE_SSPI
  307. USE_SSPI = true
  308. !ELSEIF "$(USE_SSPI)"=="yes"
  309. USE_SSPI = true
  310. !ENDIF
  311. !IF "$(USE_SSPI)"=="true"
  312. SSPI_CFLAGS = $(SSPI_CFLAGS) /DUSE_WINDOWS_SSPI
  313. !ENDIF
  314. !IFNDEF USE_SCHANNEL
  315. !IF "$(USE_SSL)"=="true"
  316. USE_SCHANNEL = false
  317. !ELSE
  318. USE_SCHANNEL = $(USE_SSPI)
  319. !ENDIF
  320. !ELSEIF "$(USE_SCHANNEL)"=="yes"
  321. USE_SCHANNEL = true
  322. !ENDIF
  323. !IF "$(USE_SCHANNEL)"=="true"
  324. !IF "$(USE_SSPI)"!="true"
  325. !ERROR cannot build with Schannel without SSPI
  326. !ENDIF
  327. SSPI_CFLAGS = $(SSPI_CFLAGS) /DUSE_SCHANNEL
  328. WIN_LIBS = $(WIN_LIBS) Crypt32.lib
  329. !ENDIF
  330. !IF "$(GEN_PDB)"=="yes"
  331. GEN_PDB = true
  332. !ENDIF
  333. !IFDEF EMBED_MANIFEST
  334. MANIFESTTOOL = $(MT) -manifest $(DIRDIST)\bin\$(PROGRAM_NAME).manifest -outputresource:$(DIRDIST)\bin\$(PROGRAM_NAME);1
  335. !ELSE
  336. CURL_RC_FLAGS = $(CURL_RC_FLAGS) /dCURL_EMBED_MANIFEST
  337. !ENDIF
  338. # Runtime library configuration
  339. !IF "$(RTLIBCFG)"=="static"
  340. RTLIB = /MT
  341. RTLIB_DEBUG = /MTd
  342. !ELSE
  343. RTLIB = /MD
  344. RTLIB_DEBUG = /MDd
  345. !ENDIF
  346. !IF "$(MODE)"=="static"
  347. TARGET = $(LIB_NAME_STATIC)
  348. CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC)
  349. AS_DLL = false
  350. CFGSET = true
  351. !ELSEIF "$(MODE)"=="dll"
  352. TARGET = $(LIB_NAME_DLL)
  353. CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP)
  354. AS_DLL = true
  355. CFGSET = true
  356. !ENDIF
  357. !IF "$(CFGSET)" == "FALSE"
  358. !ERROR please choose a valid mode
  359. !ENDIF
  360. # CURL_XX macros are for the curl.exe command
  361. !IF "$(DEBUG)"=="yes"
  362. RC_FLAGS = /dDEBUGBUILD=1 /Fo $@ $(LIBCURL_SRC_DIR)\libcurl.rc
  363. CURL_CC = $(CC_DEBUG) $(RTLIB_DEBUG)
  364. CURL_RC_FLAGS = $(CURL_RC_FLAGS) /i../include /dDEBUGBUILD=1 /Fo $@ $(CURL_SRC_DIR)\curl.rc
  365. !ELSE
  366. RC_FLAGS = /dDEBUGBUILD=0 /Fo $@ $(LIBCURL_SRC_DIR)\libcurl.rc
  367. CURL_CC = $(CC_NODEBUG) $(RTLIB)
  368. CURL_RC_FLAGS = $(CURL_RC_FLAGS) /i../include /dDEBUGBUILD=0 /Fo $@ $(CURL_SRC_DIR)\curl.rc
  369. !ENDIF
  370. !IF "$(AS_DLL)" == "true"
  371. LNK = $(LNKDLL) $(LFLAGS) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET)
  372. !IF "$(DEBUG)"=="yes"
  373. TARGET = $(LIB_NAME_DLL_DEBUG)
  374. LNK = $(LNK) /DEBUG /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG)
  375. PDB = $(PDB_NAME_DLL_DEBUG)
  376. CURL_LIBS = /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG)
  377. !ELSE
  378. TARGET = $(LIB_NAME_DLL)
  379. LNK = $(LNK) /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP)
  380. PDB = $(PDB_NAME_DLL)
  381. CURL_LIBS = /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP)
  382. !ENDIF
  383. RESOURCE = $(LIB_DIROBJ)\libcurl.res
  384. # AS_DLL
  385. !ELSE
  386. !IF "$(DEBUG)"=="yes"
  387. TARGET = $(LIB_NAME_STATIC_DEBUG)
  388. PDB = $(PDB_NAME_STATIC_DEBUG)
  389. !ELSE
  390. TARGET = $(LIB_NAME_STATIC)
  391. PDB = $(PDB_NAME_STATIC)
  392. !ENDIF
  393. LNK = $(LNKLIB) /out:$(LIB_DIROBJ)\$(TARGET)
  394. CURL_CC = $(CURL_CC) $(CFLAGS_LIBCURL_STATIC)
  395. # AS_DLL
  396. !ENDIF
  397. !IF "$(USE_SSL)"=="true"
  398. CFLAGS = $(CFLAGS) $(SSL_CFLAGS)
  399. LFLAGS = $(LFLAGS) $(SSL_LFLAGS) $(SSL_LIBS)
  400. !ENDIF
  401. !IF "$(USE_MBEDTLS)"=="true"
  402. CFLAGS = $(CFLAGS) $(MBEDTLS_CFLAGS)
  403. LFLAGS = $(LFLAGS) $(MBEDTLS_LFLAGS) $(MBEDTLS_LIBS)
  404. !ENDIF
  405. !IF "$(USE_CARES)"=="true"
  406. CFLAGS = $(CFLAGS) $(CARES_CFLAGS)
  407. LFLAGS = $(LFLAGS) $(CARES_LFLAGS) $(CARES_LIBS)
  408. !ENDIF
  409. !IF "$(USE_ZLIB)"=="true"
  410. CFLAGS = $(CFLAGS) $(ZLIB_CFLAGS)
  411. LFLAGS = $(LFLAGS) $(ZLIB_LFLAGS) $(ZLIB_LIBS)
  412. !ENDIF
  413. !IF "$(USE_SSH2)"=="true"
  414. CFLAGS = $(CFLAGS) $(SSH2_CFLAGS)
  415. LFLAGS = $(LFLAGS) $(SSH2_LFLAGS) $(SSH2_LIBS)
  416. !ENDIF
  417. !IF "$(USE_SSH)"=="true"
  418. CFLAGS = $(CFLAGS) $(SSH_CFLAGS)
  419. LFLAGS = $(LFLAGS) $(SSH_LFLAGS) $(SSH_LIBS)
  420. !ENDIF
  421. !IF "$(USE_IDN)"=="true"
  422. CFLAGS = $(CFLAGS) $(IDN_CFLAGS)
  423. !ENDIF
  424. !IF "$(USE_IPV6)"=="true"
  425. CFLAGS = $(CFLAGS) $(IPV6_CFLAGS)
  426. !ENDIF
  427. !IF "$(USE_SSPI)"=="true"
  428. CFLAGS = $(CFLAGS) $(SSPI_CFLAGS)
  429. !ENDIF
  430. !IF "$(USE_NGHTTP2)"=="true"
  431. CFLAGS = $(CFLAGS) $(NGHTTP2_CFLAGS)
  432. LFLAGS = $(LFLAGS) $(NGHTTP2_LFLAGS) $(NGHTTP2_LIBS)
  433. !ENDIF
  434. !IF "$(USE_MSH3)"=="true"
  435. CFLAGS = $(CFLAGS) $(MSH3_CFLAGS)
  436. LFLAGS = $(LFLAGS) $(MSH3_LFLAGS) $(MSH3_LIBS)
  437. !ENDIF
  438. !IF "$(GEN_PDB)"=="true"
  439. CFLAGS = $(CFLAGS) $(CFLAGS_PDB) /Fd"$(LIB_DIROBJ)\$(PDB)"
  440. LFLAGS = $(LFLAGS) $(LFLAGS_PDB)
  441. !ENDIF
  442. !IF ( "$(USE_SSL)"=="true" && "$(USE_SCHANNEL)"=="true" ) \
  443. || ( "$(USE_SSL)"=="true" && "$(USE_MBEDTLS)"=="true" ) \
  444. || ( "$(USE_MBEDTLS)"=="true" && "$(USE_SCHANNEL)"=="true" )
  445. CFLAGS = $(CFLAGS) /DCURL_WITH_MULTI_SSL
  446. !ENDIF
  447. !IF "$(USE_UNICODE)"=="true"
  448. CFLAGS = $(CFLAGS) /DUNICODE /D_UNICODE
  449. !ENDIF
  450. LIB_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-lib
  451. CURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-curl
  452. !IFDEF WITH_PREFIX
  453. DIRDIST = $(WITH_PREFIX)
  454. !ELSE
  455. DIRDIST = ..\builds\$(CONFIG_NAME_LIB)\
  456. !ENDIF
  457. #
  458. # curl.exe
  459. #
  460. CURL_LINK = link.exe /incremental:no /libpath:"$(DIRDIST)\lib"
  461. !IF "$(CFGSET)" != "FALSE"
  462. # A mode was provided, so the library can be built.
  463. #
  464. !include CURL_OBJS.inc
  465. !include LIBCURL_OBJS.inc
  466. !IF "$(AS_DLL)" == "true"
  467. LIB_OBJS = $(LIBCURL_OBJS) $(RESOURCE)
  468. !ELSE
  469. LIB_OBJS = $(LIBCURL_OBJS)
  470. !ENDIF
  471. EXE_OBJS = $(CURL_OBJS) $(CURL_DIROBJ)\curl.res
  472. all : $(TARGET) $(PROGRAM_NAME)
  473. package: $(TARGET)
  474. @cd $(DIRDIST)
  475. @-$(ZIP) -9 -q -r ..\$(CONFIG_NAME_LIB).zip .>nul 2<&1
  476. @cd $(MAKEDIR)
  477. $(TARGET): $(LIB_OBJS) $(LIB_DIROBJ) $(DIRDIST)
  478. @echo Using SSL: $(USE_SSL)
  479. @echo Using NGHTTP2: $(USE_NGHTTP2)
  480. @echo Using MSH3: $(USE_MSH3)
  481. @echo Using c-ares: $(USE_CARES)
  482. @echo Using SSH2: $(USE_SSH2)
  483. @echo Using SSH: $(USE_SSH)
  484. @echo Using ZLIB: $(USE_ZLIB)
  485. @echo Using IDN: $(USE_IDN)
  486. @echo Using IPv6: $(USE_IPV6)
  487. @echo Using SSPI: $(USE_SSPI)
  488. @echo Using Schannel: $(USE_SCHANNEL)
  489. @echo CFLAGS: $(CFLAGS)
  490. @echo LFLAGS: $(LFLAGS)
  491. @echo GenPDB: $(GEN_PDB)
  492. @echo Debug: $(DEBUG)
  493. @echo Machine: $(MACHINE)
  494. $(LNK) $(LIB_OBJS)
  495. @echo Copying libs...
  496. @if exist $(LIB_DIROBJ)\$(LIB_NAME_DLL) copy $(LIB_DIROBJ)\$(LIB_NAME_DLL) $(DIRDIST)\bin\ /y >nul 2<&1
  497. @if exist $(LIB_DIROBJ)\$(LIB_NAME_STATIC) copy $(LIB_DIROBJ)\$(LIB_NAME_STATIC) $(DIRDIST)\lib\ /y >nul 2<&1
  498. @if exist $(LIB_DIROBJ)\$(LIB_NAME_DLL_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_DLL_DEBUG) $(DIRDIST)\bin\ /y >nul 2<&1
  499. @if exist $(LIB_DIROBJ)\$(LIB_NAME_STATIC_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_STATIC_DEBUG) $(DIRDIST)\lib\ /y >nul 2<&1
  500. @if exist $(LIB_DIROBJ)\$(LIB_NAME_IMP) copy $(LIB_DIROBJ)\$(LIB_NAME_IMP) $(DIRDIST)\lib\ /y >nul 2<&1
  501. @if exist $(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG) $(DIRDIST)\lib >nul 2<&1
  502. @-copy $(LIB_DIROBJ)\*.exp $(DIRDIST)\lib /y >nul 2<&1
  503. @-copy $(LIB_DIROBJ)\*.pdb $(DIRDIST)\lib /y >nul 2<&1
  504. @-copy ..\include\curl\*.h $(DIRDIST)\include\curl\ /y >nul 2<&1
  505. $(LIB_OBJS): $(LIB_DIROBJ) $(DIRDIST)
  506. $(DIRDIST):
  507. @if not exist "$(DIRDIST)\bin" mkdir $(DIRDIST)\bin
  508. @if not exist "$(DIRDIST)\include" mkdir $(DIRDIST)\include
  509. @if not exist "$(DIRDIST)\include\curl" mkdir $(DIRDIST)\include\curl
  510. @if not exist "$(DIRDIST)\lib" mkdir $(DIRDIST)\lib
  511. $(LIB_DIROBJ):
  512. @if not exist "$(LIB_DIROBJ)" mkdir $(LIB_DIROBJ)
  513. @if not exist "$(LIB_DIROBJ)\vauth" mkdir $(LIB_DIROBJ)\vauth
  514. @if not exist "$(LIB_DIROBJ)\vtls" mkdir $(LIB_DIROBJ)\vtls
  515. @if not exist "$(LIB_DIROBJ)\vssh" mkdir $(LIB_DIROBJ)\vssh
  516. @if not exist "$(LIB_DIROBJ)\vquic" mkdir $(LIB_DIROBJ)\vquic
  517. $(CURL_DIROBJ):
  518. @if not exist "$(CURL_DIROBJ)" mkdir $(CURL_DIROBJ)
  519. # we need a lib dir for the portability functions from libcurl
  520. # we use the .c directly here
  521. @if not exist "$(CURL_DIROBJ)" mkdir $(CURL_DIROBJ)\lib
  522. .SUFFIXES: .c .obj .res
  523. {$(LIBCURL_SRC_DIR)\}.c{$(LIB_DIROBJ)\}.obj::
  524. $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\\" $<
  525. {$(LIBCURL_SRC_DIR)\vauth\}.c{$(LIB_DIROBJ)\vauth\}.obj::
  526. $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\vauth\\" $<
  527. {$(LIBCURL_SRC_DIR)\vtls\}.c{$(LIB_DIROBJ)\vtls\}.obj::
  528. $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\vtls\\" $<
  529. {$(LIBCURL_SRC_DIR)\vssh\}.c{$(LIB_DIROBJ)\vssh\}.obj::
  530. $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\vssh\\" $<
  531. {$(LIBCURL_SRC_DIR)\vquic\}.c{$(LIB_DIROBJ)\vquic\}.obj::
  532. $(CURL_CC) $(CFLAGS) /Fo"$(LIB_DIROBJ)\vquic\\" $<
  533. $(LIB_DIROBJ)\libcurl.res: $(LIBCURL_SRC_DIR)\libcurl.rc
  534. $(RC) $(RC_FLAGS)
  535. #
  536. # curl.exe
  537. #
  538. !IF "$(MODE)"=="static"
  539. !IF "$(DEBUG)"=="yes"
  540. CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC_DEBUG)
  541. !ELSE
  542. CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC)
  543. !ENDIF
  544. !ELSEIF "$(MODE)"=="dll"
  545. !IF "$(DEBUG)"=="yes"
  546. CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP_DEBUG)
  547. !ELSE
  548. CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP)
  549. !ENDIF
  550. !ENDIF
  551. CURL_FROM_LIBCURL=$(CURL_DIROBJ)\tool_hugehelp.obj \
  552. $(CURL_DIROBJ)\nonblock.obj \
  553. $(CURL_DIROBJ)\strtoofft.obj \
  554. $(CURL_DIROBJ)\warnless.obj \
  555. $(CURL_DIROBJ)\curl_multibyte.obj \
  556. $(CURL_DIROBJ)\version_win32.obj \
  557. $(CURL_DIROBJ)\dynbuf.obj \
  558. $(CURL_DIROBJ)\base64.obj
  559. $(PROGRAM_NAME): $(CURL_DIROBJ) $(CURL_FROM_LIBCURL) $(EXE_OBJS)
  560. $(CURL_LINK) $(CURL_LFLAGS) $(CURL_LIBCURL_LIBNAME) $(WIN_LIBS) $(CURL_FROM_LIBCURL) $(EXE_OBJS)
  561. $(MANIFESTTOOL)
  562. {$(CURL_SRC_DIR)\}.c{$(CURL_DIROBJ)\}.obj::
  563. $(CURL_CC) $(CURL_CFLAGS) /Fo"$(CURL_DIROBJ)\\" $<
  564. $(CURL_DIROBJ)\tool_hugehelp.obj: $(CURL_SRC_DIR)\tool_hugehelp.c
  565. $(CURL_CC) $(CURL_CFLAGS) /Zm200 /Fo"$@" $(CURL_SRC_DIR)\tool_hugehelp.c
  566. $(CURL_DIROBJ)\nonblock.obj: ../lib/nonblock.c
  567. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/nonblock.c
  568. $(CURL_DIROBJ)\strtoofft.obj: ../lib/strtoofft.c
  569. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/strtoofft.c
  570. $(CURL_DIROBJ)\warnless.obj: ../lib/warnless.c
  571. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/warnless.c
  572. $(CURL_DIROBJ)\curl_multibyte.obj: ../lib/curl_multibyte.c
  573. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/curl_multibyte.c
  574. $(CURL_DIROBJ)\version_win32.obj: ../lib/version_win32.c
  575. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/version_win32.c
  576. $(CURL_DIROBJ)\dynbuf.obj: ../lib/dynbuf.c
  577. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/dynbuf.c
  578. $(CURL_DIROBJ)\base64.obj: ../lib/base64.c
  579. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/base64.c
  580. $(CURL_DIROBJ)\curl.res: $(CURL_SRC_DIR)\curl.rc
  581. rc $(CURL_RC_FLAGS)
  582. !ENDIF # End of case where a config was provided.
  583. # Makefile.vc's clean removes (LIB)CURL_DIROBJ and DIRDIST dirs then calls
  584. # this clean. Note those are the original directories we control and not the
  585. # directories possibly modified by this makefile to point to user-specified
  586. # directories.
  587. # For example, don't remove DIRDIST here since it may contain user files if it
  588. # has been changed by WITH_PREFIX to a different output dir (eg C:\usr\local).
  589. clean:
  590. @-erase /s *.dll 2> NUL
  591. @-erase /s *.exp 2> NUL
  592. @-erase /s *.idb 2> NUL
  593. @-erase /s *.lib 2> NUL
  594. @-erase /s *.obj 2> NUL
  595. @-erase /s *.pch 2> NUL
  596. @-erase /s *.pdb 2> NUL
  597. @-erase /s *.res 2> NUL