MakefileBuild.vc 20 KB

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