MakefileBuild.vc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1999 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. # SPDX-License-Identifier: curl
  22. #
  23. #***************************************************************************
  24. ###########################################################################
  25. #
  26. # 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 EXISTS("$(SSL_INC_DIR)\is_boringssl.h")
  121. SSL_CFLAGS = $(SSL_CFLAGS) /DHAVE_BORINGSSL
  122. !ENDIF
  123. !IF "$(ENABLE_OPENSSL_AUTO_LOAD_CONFIG)"=="false"
  124. SSL_CFLAGS = $(SSL_CFLAGS) /DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
  125. !ENDIF
  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)\zlib.lib")
  236. ZLIB_LIBS = zlib.lib
  237. !ELSE
  238. ZLIB_LIBS = zlib_a.lib
  239. !ENDIF
  240. USE_ZLIB = true
  241. ZLIB = static
  242. !ENDIF
  243. !IFDEF USE_ZLIB
  244. ZLIB_CFLAGS = /DHAVE_ZLIB_H /DHAVE_ZLIB /DHAVE_LIBZ $(ADDITIONAL_ZLIB_CFLAGS) /I"$(ZLIB_INC_DIR)"
  245. !ENDIF
  246. !IFDEF SSH2_PATH
  247. SSH2_INC_DIR= $(SSH2_PATH)\include
  248. SSH2_LIB_DIR= $(SSH2_PATH)\lib
  249. SSH2_LFLAGS = $(SSH2_LFLAGS) "/LIBPATH:$(SSH2_LIB_DIR)"
  250. !ELSE
  251. SSH2_LIB_DIR= $(DEVEL_LIB)
  252. SSH2_INC_DIR= $(DEVEL_INCLUDE)/libssh2
  253. !ENDIF
  254. !IF "$(WITH_SSH2)"=="dll"
  255. SSH2_LIBS = libssh2.lib
  256. USE_SSH2 = true
  257. SSH2 = dll
  258. !ELSEIF "$(WITH_SSH2)"=="static"
  259. # libssh2 NMakefile on Windows at default creates a static library without _a suffix
  260. !IF EXISTS("$(SSH2_LIB_DIR)\libssh2.lib")
  261. SSH2_LIBS = libssh2.lib
  262. !ELSE
  263. SSH2_LIBS = libssh2_a.lib
  264. !ENDIF
  265. WIN_LIBS = $(WIN_LIBS) user32.lib
  266. USE_SSH2 = true
  267. SSH2 = static
  268. !ENDIF
  269. !IFDEF USE_SSH2
  270. SSH2_CFLAGS = /DHAVE_LIBSSH2 /DHAVE_LIBSSH2_H /DLIBSSH2_WIN32 /DLIBSSH2_LIBRARY /DUSE_LIBSSH2
  271. SSH2_CFLAGS = $(SSH2_CFLAGS) /I$(SSH2_INC_DIR)
  272. !ENDIF
  273. !IFDEF SSH_PATH
  274. SSH_INC_DIR= $(SSH_PATH)\include
  275. SSH_LIB_DIR= $(SSH_PATH)\lib
  276. SSH_LFLAGS = $(SSH_LFLAGS) "/LIBPATH:$(SSH_LIB_DIR)"
  277. !ELSE
  278. SSH_LIB_DIR= $(DEVEL_LIB)
  279. SSH_INC_DIR= $(DEVEL_INCLUDE)
  280. !ENDIF
  281. !IF "$(WITH_SSH)"=="dll" || "$(WITH_SSH)"=="static"
  282. SSH_LIBS = ssh.lib
  283. USE_SSH = true
  284. SSH = $(WITH_SSH)
  285. !ENDIF
  286. !IFDEF USE_SSH
  287. SSH_CFLAGS = /DHAVE_LIBSSH /DHAVE_LIBSSH_LIBSSH_H /DLIBSSH_WIN32 /DLIBSSH_LIBRARY /DUSE_LIBSSH /DCURL_USE_LIBSSH
  288. SSH_CFLAGS = $(SSH_CFLAGS) /I$(SSH_INC_DIR)
  289. !ENDIF
  290. !IFNDEF USE_IDN
  291. USE_IDN = true
  292. !ELSEIF "$(USE_IDN)"=="yes"
  293. USE_IDN = true
  294. !ENDIF
  295. !IF "$(USE_IDN)"=="true"
  296. IDN_CFLAGS = $(IDN_CFLAGS) /DUSE_WIN32_IDN /DWANT_IDN_PROTOTYPES
  297. WIN_LIBS = $(WIN_LIBS) Normaliz.lib
  298. !ENDIF
  299. !IFNDEF USE_IPV6
  300. USE_IPV6 = true
  301. !ELSEIF "$(USE_IPV6)"=="yes"
  302. USE_IPV6 = true
  303. !ENDIF
  304. !IF "$(USE_IPV6)"=="true"
  305. IPV6_CFLAGS = $(IPV6_CFLAGS) /DUSE_IPV6
  306. !ENDIF
  307. !IFNDEF USE_SSPI
  308. USE_SSPI = true
  309. !ELSEIF "$(USE_SSPI)"=="yes"
  310. USE_SSPI = true
  311. !ENDIF
  312. !IF "$(USE_SSPI)"=="true"
  313. SSPI_CFLAGS = $(SSPI_CFLAGS) /DUSE_WINDOWS_SSPI
  314. !ENDIF
  315. !IFNDEF USE_SCHANNEL
  316. !IF "$(USE_SSL)"=="true"
  317. USE_SCHANNEL = false
  318. !ELSE
  319. USE_SCHANNEL = $(USE_SSPI)
  320. !ENDIF
  321. !ELSEIF "$(USE_SCHANNEL)"=="yes"
  322. USE_SCHANNEL = true
  323. !ENDIF
  324. !IF "$(USE_SCHANNEL)"=="true"
  325. !IF "$(USE_SSPI)"!="true"
  326. !ERROR cannot build with Schannel without SSPI
  327. !ENDIF
  328. SSPI_CFLAGS = $(SSPI_CFLAGS) /DUSE_SCHANNEL
  329. WIN_LIBS = $(WIN_LIBS) Crypt32.lib
  330. !ENDIF
  331. !IF "$(GEN_PDB)"=="yes"
  332. GEN_PDB = true
  333. !ENDIF
  334. !IFDEF EMBED_MANIFEST
  335. MANIFESTTOOL = $(MT) -manifest $(DIRDIST)\bin\$(PROGRAM_NAME).manifest -outputresource:$(DIRDIST)\bin\$(PROGRAM_NAME);1
  336. !ELSE
  337. CURL_RC_FLAGS = $(CURL_RC_FLAGS) /dCURL_EMBED_MANIFEST
  338. !ENDIF
  339. # Runtime library configuration
  340. !IF "$(RTLIBCFG)"=="static"
  341. RTLIB = /MT
  342. RTLIB_DEBUG = /MTd
  343. !ELSE
  344. RTLIB = /MD
  345. RTLIB_DEBUG = /MDd
  346. !ENDIF
  347. !IF "$(MODE)"=="static"
  348. TARGET = $(LIB_NAME_STATIC)
  349. CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC)
  350. AS_DLL = false
  351. CFGSET = true
  352. !ELSEIF "$(MODE)"=="dll"
  353. TARGET = $(LIB_NAME_DLL)
  354. CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP)
  355. AS_DLL = true
  356. CFGSET = true
  357. !ENDIF
  358. !IF "$(CFGSET)" == "FALSE"
  359. !ERROR please choose a valid mode
  360. !ENDIF
  361. # CURL_XX macros are for the curl.exe command
  362. !IF "$(DEBUG)"=="yes"
  363. RC_FLAGS = /dDEBUGBUILD=1 /Fo $@ $(LIBCURL_SRC_DIR)\libcurl.rc
  364. CURL_CC = $(CC_DEBUG) $(RTLIB_DEBUG)
  365. CURL_RC_FLAGS = $(CURL_RC_FLAGS) /i../include /dDEBUGBUILD=1 /Fo $@ $(CURL_SRC_DIR)\curl.rc
  366. !ELSE
  367. RC_FLAGS = /dDEBUGBUILD=0 /Fo $@ $(LIBCURL_SRC_DIR)\libcurl.rc
  368. CURL_CC = $(CC_NODEBUG) $(RTLIB)
  369. CURL_RC_FLAGS = $(CURL_RC_FLAGS) /i../include /dDEBUGBUILD=0 /Fo $@ $(CURL_SRC_DIR)\curl.rc
  370. !ENDIF
  371. !IF "$(AS_DLL)" == "true"
  372. LNK = $(LNKDLL) $(LFLAGS) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET)
  373. !IF "$(DEBUG)"=="yes"
  374. TARGET = $(LIB_NAME_DLL_DEBUG)
  375. LNK = $(LNK) /DEBUG /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG)
  376. PDB = $(PDB_NAME_DLL_DEBUG)
  377. CURL_LIBS = /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG)
  378. !ELSE
  379. TARGET = $(LIB_NAME_DLL)
  380. LNK = $(LNK) /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP)
  381. PDB = $(PDB_NAME_DLL)
  382. CURL_LIBS = /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP)
  383. !ENDIF
  384. RESOURCE = $(LIB_DIROBJ)\libcurl.res
  385. # AS_DLL
  386. !ELSE
  387. !IF "$(DEBUG)"=="yes"
  388. TARGET = $(LIB_NAME_STATIC_DEBUG)
  389. PDB = $(PDB_NAME_STATIC_DEBUG)
  390. !ELSE
  391. TARGET = $(LIB_NAME_STATIC)
  392. PDB = $(PDB_NAME_STATIC)
  393. !ENDIF
  394. LNK = $(LNKLIB) /out:$(LIB_DIROBJ)\$(TARGET)
  395. CURL_CC = $(CURL_CC) $(CFLAGS_LIBCURL_STATIC)
  396. # AS_DLL
  397. !ENDIF
  398. !IF "$(USE_SSL)"=="true"
  399. CFLAGS = $(CFLAGS) $(SSL_CFLAGS)
  400. LFLAGS = $(LFLAGS) $(SSL_LFLAGS) $(SSL_LIBS)
  401. !ENDIF
  402. !IF "$(USE_MBEDTLS)"=="true"
  403. CFLAGS = $(CFLAGS) $(MBEDTLS_CFLAGS)
  404. LFLAGS = $(LFLAGS) $(MBEDTLS_LFLAGS) $(MBEDTLS_LIBS)
  405. !ENDIF
  406. !IF "$(USE_CARES)"=="true"
  407. CFLAGS = $(CFLAGS) $(CARES_CFLAGS)
  408. LFLAGS = $(LFLAGS) $(CARES_LFLAGS) $(CARES_LIBS)
  409. !ENDIF
  410. !IF "$(USE_ZLIB)"=="true"
  411. CFLAGS = $(CFLAGS) $(ZLIB_CFLAGS)
  412. LFLAGS = $(LFLAGS) $(ZLIB_LFLAGS) $(ZLIB_LIBS)
  413. !ENDIF
  414. !IF "$(USE_SSH2)"=="true"
  415. CFLAGS = $(CFLAGS) $(SSH2_CFLAGS)
  416. LFLAGS = $(LFLAGS) $(SSH2_LFLAGS) $(SSH2_LIBS)
  417. !ENDIF
  418. !IF "$(USE_SSH)"=="true"
  419. CFLAGS = $(CFLAGS) $(SSH_CFLAGS)
  420. LFLAGS = $(LFLAGS) $(SSH_LFLAGS) $(SSH_LIBS)
  421. !ENDIF
  422. !IF "$(USE_IDN)"=="true"
  423. CFLAGS = $(CFLAGS) $(IDN_CFLAGS)
  424. !ENDIF
  425. !IF "$(USE_IPV6)"=="true"
  426. CFLAGS = $(CFLAGS) $(IPV6_CFLAGS)
  427. !ENDIF
  428. !IF "$(USE_SSPI)"=="true"
  429. CFLAGS = $(CFLAGS) $(SSPI_CFLAGS)
  430. !ENDIF
  431. !IF "$(USE_NGHTTP2)"=="true"
  432. CFLAGS = $(CFLAGS) $(NGHTTP2_CFLAGS)
  433. LFLAGS = $(LFLAGS) $(NGHTTP2_LFLAGS) $(NGHTTP2_LIBS)
  434. !ENDIF
  435. !IF "$(USE_MSH3)"=="true"
  436. CFLAGS = $(CFLAGS) $(MSH3_CFLAGS)
  437. LFLAGS = $(LFLAGS) $(MSH3_LFLAGS) $(MSH3_LIBS)
  438. !ENDIF
  439. !IF "$(GEN_PDB)"=="true"
  440. CFLAGS = $(CFLAGS) $(CFLAGS_PDB) /Fd"$(LIB_DIROBJ)\$(PDB)"
  441. LFLAGS = $(LFLAGS) $(LFLAGS_PDB)
  442. !ENDIF
  443. !IF ( "$(USE_SSL)"=="true" && "$(USE_SCHANNEL)"=="true" ) \
  444. || ( "$(USE_SSL)"=="true" && "$(USE_MBEDTLS)"=="true" ) \
  445. || ( "$(USE_MBEDTLS)"=="true" && "$(USE_SCHANNEL)"=="true" )
  446. CFLAGS = $(CFLAGS) /DCURL_WITH_MULTI_SSL
  447. !ENDIF
  448. !IF "$(USE_UNICODE)"=="true"
  449. CFLAGS = $(CFLAGS) /DUNICODE /D_UNICODE
  450. !ENDIF
  451. LIB_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-lib
  452. CURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-curl
  453. !IFDEF WITH_PREFIX
  454. DIRDIST = $(WITH_PREFIX)
  455. !ELSE
  456. DIRDIST = ..\builds\$(CONFIG_NAME_LIB)\
  457. !ENDIF
  458. #
  459. # curl.exe
  460. #
  461. CURL_LINK = link.exe /incremental:no /libpath:"$(DIRDIST)\lib"
  462. !IF "$(CFGSET)" != "FALSE"
  463. # A mode was provided, so the library can be built.
  464. #
  465. !include CURL_OBJS.inc
  466. !include LIBCURL_OBJS.inc
  467. !IF "$(AS_DLL)" == "true"
  468. LIB_OBJS = $(LIBCURL_OBJS) $(RESOURCE)
  469. !ELSE
  470. LIB_OBJS = $(LIBCURL_OBJS)
  471. !ENDIF
  472. EXE_OBJS = $(CURL_OBJS) $(CURL_DIROBJ)\curl.res
  473. all : $(TARGET) $(PROGRAM_NAME)
  474. package: $(TARGET)
  475. @cd $(DIRDIST)
  476. @-$(ZIP) -9 -q -r ..\$(CONFIG_NAME_LIB).zip .>nul 2<&1
  477. @cd $(MAKEDIR)
  478. $(TARGET): $(LIB_OBJS) $(LIB_DIROBJ) $(DIRDIST)
  479. @echo Using SSL: $(USE_SSL)
  480. @echo Using NGHTTP2: $(USE_NGHTTP2)
  481. @echo Using MSH3: $(USE_MSH3)
  482. @echo Using c-ares: $(USE_CARES)
  483. @echo Using SSH2: $(USE_SSH2)
  484. @echo Using SSH: $(USE_SSH)
  485. @echo Using ZLIB: $(USE_ZLIB)
  486. @echo Using IDN: $(USE_IDN)
  487. @echo Using IPv6: $(USE_IPV6)
  488. @echo Using SSPI: $(USE_SSPI)
  489. @echo Using Schannel: $(USE_SCHANNEL)
  490. @echo CFLAGS: $(CFLAGS)
  491. @echo LFLAGS: $(LFLAGS)
  492. @echo GenPDB: $(GEN_PDB)
  493. @echo Debug: $(DEBUG)
  494. @echo Machine: $(MACHINE)
  495. $(LNK) $(LIB_OBJS)
  496. @echo Copying libs...
  497. @if exist $(LIB_DIROBJ)\$(LIB_NAME_DLL) copy $(LIB_DIROBJ)\$(LIB_NAME_DLL) $(DIRDIST)\bin\ /y >nul 2<&1
  498. @if exist $(LIB_DIROBJ)\$(LIB_NAME_STATIC) copy $(LIB_DIROBJ)\$(LIB_NAME_STATIC) $(DIRDIST)\lib\ /y >nul 2<&1
  499. @if exist $(LIB_DIROBJ)\$(LIB_NAME_DLL_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_DLL_DEBUG) $(DIRDIST)\bin\ /y >nul 2<&1
  500. @if exist $(LIB_DIROBJ)\$(LIB_NAME_STATIC_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_STATIC_DEBUG) $(DIRDIST)\lib\ /y >nul 2<&1
  501. @if exist $(LIB_DIROBJ)\$(LIB_NAME_IMP) copy $(LIB_DIROBJ)\$(LIB_NAME_IMP) $(DIRDIST)\lib\ /y >nul 2<&1
  502. @if exist $(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG) copy $(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG) $(DIRDIST)\lib >nul 2<&1
  503. @-copy $(LIB_DIROBJ)\*.exp $(DIRDIST)\lib /y >nul 2<&1
  504. @-copy $(LIB_DIROBJ)\*.pdb $(DIRDIST)\lib /y >nul 2<&1
  505. @-copy ..\include\curl\*.h $(DIRDIST)\include\curl\ /y >nul 2<&1
  506. $(LIB_OBJS): $(LIB_DIROBJ) $(DIRDIST)
  507. $(DIRDIST):
  508. @if not exist "$(DIRDIST)\bin" mkdir $(DIRDIST)\bin
  509. @if not exist "$(DIRDIST)\include" mkdir $(DIRDIST)\include
  510. @if not exist "$(DIRDIST)\include\curl" mkdir $(DIRDIST)\include\curl
  511. @if not exist "$(DIRDIST)\lib" mkdir $(DIRDIST)\lib
  512. $(LIB_DIROBJ):
  513. @if not exist "$(LIB_DIROBJ)" mkdir $(LIB_DIROBJ)
  514. @if not exist "$(LIB_DIROBJ)\vauth" mkdir $(LIB_DIROBJ)\vauth
  515. @if not exist "$(LIB_DIROBJ)\vtls" mkdir $(LIB_DIROBJ)\vtls
  516. @if not exist "$(LIB_DIROBJ)\vssh" mkdir $(LIB_DIROBJ)\vssh
  517. @if not exist "$(LIB_DIROBJ)\vquic" mkdir $(LIB_DIROBJ)\vquic
  518. $(CURL_DIROBJ):
  519. @if not exist "$(CURL_DIROBJ)" mkdir $(CURL_DIROBJ)
  520. # we need a lib dir for the portability functions from libcurl
  521. # we use the .c directly here
  522. @if not exist "$(CURL_DIROBJ)" mkdir $(CURL_DIROBJ)\lib
  523. .SUFFIXES: .c .obj .res
  524. {$(LIBCURL_SRC_DIR)\}.c{$(LIB_DIROBJ)\}.obj:
  525. $(CURL_CC) $(CFLAGS) /Fo"$@" $<
  526. {$(LIBCURL_SRC_DIR)\vauth\}.c{$(LIB_DIROBJ)\vauth\}.obj:
  527. $(CURL_CC) $(CFLAGS) /Fo"$@" $<
  528. {$(LIBCURL_SRC_DIR)\vtls\}.c{$(LIB_DIROBJ)\vtls\}.obj:
  529. $(CURL_CC) $(CFLAGS) /Fo"$@" $<
  530. {$(LIBCURL_SRC_DIR)\vssh\}.c{$(LIB_DIROBJ)\vssh\}.obj:
  531. $(CURL_CC) $(CFLAGS) /Fo"$@" $<
  532. {$(LIBCURL_SRC_DIR)\vquic\}.c{$(LIB_DIROBJ)\vquic\}.obj:
  533. $(CURL_CC) $(CFLAGS) /Fo"$@" $<
  534. $(LIB_DIROBJ)\libcurl.res: $(LIBCURL_SRC_DIR)\libcurl.rc
  535. $(RC) $(RC_FLAGS)
  536. #
  537. # curl.exe
  538. #
  539. !IF "$(MODE)"=="static"
  540. !IF "$(DEBUG)"=="yes"
  541. CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC_DEBUG)
  542. !ELSE
  543. CURL_LIBCURL_LIBNAME=$(LIB_NAME_STATIC)
  544. !ENDIF
  545. !ELSEIF "$(MODE)"=="dll"
  546. !IF "$(DEBUG)"=="yes"
  547. CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP_DEBUG)
  548. !ELSE
  549. CURL_LIBCURL_LIBNAME=$(LIB_NAME_IMP)
  550. !ENDIF
  551. !ENDIF
  552. CURL_FROM_LIBCURL=$(CURL_DIROBJ)\tool_hugehelp.obj \
  553. $(CURL_DIROBJ)\nonblock.obj \
  554. $(CURL_DIROBJ)\strtoofft.obj \
  555. $(CURL_DIROBJ)\warnless.obj \
  556. $(CURL_DIROBJ)\curl_ctype.obj \
  557. $(CURL_DIROBJ)\curl_multibyte.obj \
  558. $(CURL_DIROBJ)\version_win32.obj \
  559. $(CURL_DIROBJ)\dynbuf.obj
  560. $(PROGRAM_NAME): $(CURL_DIROBJ) $(CURL_FROM_LIBCURL) $(EXE_OBJS)
  561. $(CURL_LINK) $(CURL_LFLAGS) $(CURL_LIBCURL_LIBNAME) $(WIN_LIBS) $(CURL_FROM_LIBCURL) $(EXE_OBJS)
  562. $(MANIFESTTOOL)
  563. {$(CURL_SRC_DIR)\}.c{$(CURL_DIROBJ)\}.obj:
  564. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" $<
  565. $(CURL_DIROBJ)\tool_hugehelp.obj: $(CURL_SRC_DIR)\tool_hugehelp.c
  566. $(CURL_CC) $(CURL_CFLAGS) /Zm200 /Fo"$@" $(CURL_SRC_DIR)\tool_hugehelp.c
  567. $(CURL_DIROBJ)\nonblock.obj: ../lib/nonblock.c
  568. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/nonblock.c
  569. $(CURL_DIROBJ)\strtoofft.obj: ../lib/strtoofft.c
  570. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/strtoofft.c
  571. $(CURL_DIROBJ)\warnless.obj: ../lib/warnless.c
  572. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/warnless.c
  573. $(CURL_DIROBJ)\curl_ctype.obj: ../lib/curl_ctype.c
  574. $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/curl_ctype.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)\curl.res: $(CURL_SRC_DIR)\curl.rc
  582. rc $(CURL_RC_FLAGS)
  583. !ENDIF # End of case where a config was provided.
  584. clean:
  585. @-erase /s *.dll 2> NUL
  586. @-erase /s *.exp 2> NUL
  587. @-erase /s *.idb 2> NUL
  588. @-erase /s *.lib 2> NUL
  589. @-erase /s *.obj 2> NUL
  590. @-erase /s *.pch 2> NUL
  591. @-erase /s *.pdb 2> NUL
  592. @-erase /s *.res 2> NUL
  593. @if exist $(LIB_DIROBJ) rd /s/q $(LIB_DIROBJ)
  594. @if exist $(CURL_DIROBJ)rd /s/q $(CURL_DIROBJ)
  595. @if exist $(DIRDIST) rd /s/q $(DIRDIST)