MakefileBuild.vc 18 KB

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