MakefileBuild.vc 19 KB

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