2
0

MakefileBuild.vc 19 KB

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