MakefileBuild.vc 19 KB

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