VirtualBox

source: vbox/trunk/src/libs/curl-7.87.0/lib/Makefile.mk@ 98339

Last change on this file since 98339 was 98339, checked in by vboxsync, 2 years ago

curl-7.87.0: EOL style fixing, bit more irrelevant export fixing

  • Property svn:eol-style set to native
File size: 10.4 KB
Line 
1#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1999 - 2022, Daniel Stenberg, <[email protected]>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21# SPDX-License-Identifier: curl
22#
23#***************************************************************************
24
25# Makefile to build curl parts with GCC-like toolchains and optional features.
26#
27# Usage: [mingw32-]make -f Makefile.mk CFG=-feat1[-feat2][-feat3][...]
28# Example: [mingw32-]make -f Makefile.mk CFG=-zlib-ssl-libssh2-ipv6
29#
30# Look for ' ?=' to find all accepted customization variables.
31
32# This script is reused by 'src' and 'docs/examples' Makefile.mk scripts.
33
34ifndef PROOT
35 PROOT := ..
36 LOCAL := 1
37endif
38
39### Common
40
41CFLAGS ?=
42CPPFLAGS ?=
43RCFLAGS ?=
44LDFLAGS ?=
45CURL_LDFLAGS_BIN ?=
46CURL_LDFLAGS_LIB ?=
47LIBS ?=
48
49CROSSPREFIX ?=
50
51ifeq ($(CC),cc)
52 CC := gcc
53endif
54CC := $(CROSSPREFIX)$(CC)
55AR := $(CROSSPREFIX)$(AR)
56RC ?= $(CROSSPREFIX)windres
57
58# For compatibility
59ARCH ?=
60ifeq ($(ARCH),w64)
61 TRIPLET := x86_64-w64-mingw32
62 CFLAGS += -m64
63 LDFLAGS += -m64
64 RCFLAGS += --target=pe-x86-64
65else ifdef ARCH
66 TRIPLET := i686-w64-mingw32
67 CFLAGS += -m32
68 LDFLAGS += -m32
69 RCFLAGS += --target=pe-i386
70else
71 TRIPLET ?= $(shell $(CC) -dumpmachine)
72endif
73
74BIN_EXT := .exe
75
76ifneq ($(findstring -w,$(TRIPLET)),)
77 WIN32 := 1
78else ifneq ($(findstring msdos,$(TRIPLET)),)
79 # Cross-tools: https://github.com/andrewwutw/build-djgpp
80 MSDOS := 1
81else ifneq ($(findstring amigaos,$(TRIPLET)),)
82 # Cross-tools: https://github.com/bebbo/amiga-gcc
83 AMIGA := 1
84endif
85
86CPPFLAGS += -I. -I$(PROOT)/include
87RCFLAGS += -I$(PROOT)/include
88
89ifndef WIN32
90 DYN :=
91endif
92
93ifdef AMIGA
94 BIN_EXT :=
95endif
96
97### Deprecated settings. For compatibility.
98
99ifdef WATT_ROOT
100 WATT_PATH := $(realpath $(WATT_ROOT))
101endif
102
103### Optional features
104
105ifneq ($(findstring -debug,$(CFG)),)
106 CPPFLAGS += -DDEBUGBUILD
107 LDFLAGS += -g
108else
109 CPPFLAGS += -DNDEBUG
110endif
111ifneq ($(findstring -trackmem,$(CFG)),)
112 CPPFLAGS += -DCURLDEBUG
113endif
114ifneq ($(findstring -map,$(CFG)),)
115 MAP := 1
116endif
117
118ifdef WIN32
119 ifneq ($(findstring -unicode,$(CFG)),)
120 CPPFLAGS += -DUNICODE -D_UNICODE
121 CURL_LDFLAGS_BIN += -municode
122 endif
123endif
124
125# CPPFLAGS below are only necessary when building libcurl via 'lib' (see
126# comments below about exceptions). Always include them anyway to match
127# behavior of other build systems.
128
129# Linker options to exclude for shared mode executables.
130_LDFLAGS :=
131_LIBS :=
132
133ifneq ($(findstring -sync,$(CFG)),)
134 CPPFLAGS += -DUSE_SYNC_DNS
135else ifneq ($(findstring -ares,$(CFG)),)
136 LIBCARES_PATH ?= $(PROOT)/../c-ares
137 CPPFLAGS += -DUSE_ARES
138 CPPFLAGS += -I"$(LIBCARES_PATH)/include"
139 _LDFLAGS += -L"$(LIBCARES_PATH)/lib"
140 _LIBS += -lcares
141endif
142
143ifneq ($(findstring -rtmp,$(CFG)),)
144 LIBRTMP_PATH ?= $(PROOT)/../librtmp
145 CPPFLAGS += -DUSE_LIBRTMP
146 CPPFLAGS += -I"$(LIBRTMP_PATH)"
147 _LDFLAGS += -L"$(LIBRTMP_PATH)/librtmp"
148 _LIBS += -lrtmp -lwinmm
149 ZLIB := 1
150endif
151
152ifneq ($(findstring -ssh2,$(CFG)),)
153 LIBSSH2_PATH ?= $(PROOT)/../libssh2
154 CPPFLAGS += -DUSE_LIBSSH2
155 CPPFLAGS += -I"$(LIBSSH2_PATH)/include"
156 _LDFLAGS += -L"$(LIBSSH2_PATH)/lib"
157 ifdef WIN32
158 _LDFLAGS += -L"$(LIBSSH2_PATH)/win32"
159 endif
160 _LIBS += -lssh2
161else ifneq ($(findstring -libssh,$(CFG)),)
162 LIBSSH_PATH ?= $(PROOT)/../libssh
163 CPPFLAGS += -DUSE_LIBSSH
164 CPPFLAGS += -I"$(LIBSSH_PATH)/include"
165 _LDFLAGS += -L"$(LIBSSH_PATH)/lib"
166 _LIBS += -lssh
167else ifneq ($(findstring -wolfssh,$(CFG)),)
168 WOLFSSH_PATH ?= $(PROOT)/../wolfssh
169 CPPFLAGS += -DUSE_WOLFSSH
170 CPPFLAGS += -I"$(WOLFSSH_PATH)/include"
171 _LDFLAGS += -L"$(WOLFSSH_PATH)/lib"
172 _LIBS += -lwolfssh
173endif
174
175ifneq ($(findstring -ssl,$(CFG)),)
176 OPENSSL_PATH ?= $(PROOT)/../openssl
177 CPPFLAGS += -DUSE_OPENSSL
178 CPPFLAGS += -DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
179 OPENSSL_INCLUDE ?= $(OPENSSL_PATH)/include
180 OPENSSL_LIBPATH ?= $(OPENSSL_PATH)/lib
181 CPPFLAGS += -I"$(OPENSSL_INCLUDE)"
182 _LDFLAGS += -L"$(OPENSSL_LIBPATH)"
183 OPENSSL_LIBS ?= -lssl -lcrypto
184 _LIBS += $(OPENSSL_LIBS)
185
186 ifneq ($(wildcard $(OPENSSL_INCLUDE)/openssl/aead.h),)
187 OPENSSL := boringssl
188 else
189 # including libressl
190 OPENSSL := openssl
191 endif
192
193 ifneq ($(findstring -srp,$(CFG)),)
194 ifneq ($(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h),)
195 # OpenSSL 1.0.1 and later.
196 CPPFLAGS += -DHAVE_OPENSSL_SRP -DUSE_TLS_SRP
197 endif
198 endif
199 SSLLIBS += 1
200else ifneq ($(findstring -wolfssl,$(CFG)),)
201 WOLFSSL_PATH ?= $(PROOT)/../zlib
202 CPPFLAGS += -DUSE_WOLFSSL
203 CPPFLAGS += -DSIZEOF_LONG_LONG=8
204 CPPFLAGS += -I"$(WOLFSSL_PATH)/include"
205 _LDFLAGS += -L"$(WOLFSSL_PATH)/lib"
206 _LIBS += -lwolfssl
207 OPENSSL := wolfssl
208 SSLLIBS += 1
209endif
210ifneq ($(findstring -mbedtls,$(CFG)),)
211 MBEDTLS_PATH ?= $(PROOT)/../zlib
212 CPPFLAGS += -DUSE_MBEDTLS
213 CPPFLAGS += -I"$(MBEDTLS_PATH)/include"
214 _LDFLAGS += -L"$(MBEDTLS_PATH)/lib"
215 _LIBS += -lmbedtls -lmbedx509 -lmbedcrypto
216 SSLLIBS += 1
217endif
218ifneq ($(findstring -schannel,$(CFG)),)
219 CPPFLAGS += -DUSE_SCHANNEL
220 SSLLIBS += 1
221endif
222
223ifneq ($(findstring -nghttp2,$(CFG)),)
224 NGHTTP2_PATH ?= $(PROOT)/../nghttp2
225 CPPFLAGS += -DUSE_NGHTTP2
226 CPPFLAGS += -I"$(NGHTTP2_PATH)/include"
227 _LDFLAGS += -L"$(NGHTTP2_PATH)/lib"
228 _LIBS += -lnghttp2
229endif
230
231ifeq ($(findstring -nghttp3,$(CFG))$(findstring -ngtcp2,$(CFG)),-nghttp3-ngtcp2)
232 NGHTTP3_PATH ?= $(PROOT)/../nghttp3
233 CPPFLAGS += -DUSE_NGHTTP3
234 CPPFLAGS += -I"$(NGHTTP3_PATH)/include"
235 _LDFLAGS += -L"$(NGHTTP3_PATH)/lib"
236 _LIBS += -lnghttp3
237
238 NGTCP2_PATH ?= $(PROOT)/../ngtcp2
239 CPPFLAGS += -DUSE_NGTCP2
240 CPPFLAGS += -I"$(NGTCP2_PATH)/include"
241 _LDFLAGS += -L"$(NGTCP2_PATH)/lib"
242 ifneq ($(OPENSSL),)
243 NGTCP2_LIBS ?= -lngtcp2_crypto_$(OPENSSL)
244 endif
245 _LIBS += -lngtcp2 $(NGTCP2_LIBS)
246endif
247
248ifneq ($(findstring -zlib,$(CFG))$(ZLIB),)
249 ZLIB_PATH ?= $(PROOT)/../zlib
250 # These CPPFLAGS are also required when compiling the curl tool via 'src'.
251 CPPFLAGS += -DHAVE_LIBZ
252 CPPFLAGS += -I"$(ZLIB_PATH)/include"
253 _LDFLAGS += -L"$(ZLIB_PATH)/lib"
254 ZLIB_LIBS ?= -lz
255 _LIBS += $(ZLIB_LIBS)
256 ZLIB := 1
257endif
258ifneq ($(findstring -zstd,$(CFG)),)
259 ZSTD_PATH ?= $(PROOT)/../zstd
260 CPPFLAGS += -DHAVE_ZSTD
261 CPPFLAGS += -I"$(ZSTD_PATH)/include"
262 _LDFLAGS += -L"$(ZSTD_PATH)/lib"
263 ZSTD_LIBS ?= -lzstd
264 _LIBS += $(ZSTD_LIBS)
265endif
266ifneq ($(findstring -brotli,$(CFG)),)
267 BROTLI_PATH ?= $(PROOT)/../brotli
268 CPPFLAGS += -DHAVE_BROTLI
269 CPPFLAGS += -I"$(BROTLI_PATH)/include"
270 _LDFLAGS += -L"$(BROTLI_PATH)/lib"
271 BROTLI_LIBS ?= -lbrotlidec -lbrotlicommon
272 _LIBS += $(BROTLI_LIBS)
273endif
274ifneq ($(findstring -gsasl,$(CFG)),)
275 LIBGSASL_PATH ?= $(PROOT)/../gsasl
276 CPPFLAGS += -DUSE_GSASL
277 CPPFLAGS += -I"$(LIBGSASL_PATH)/include"
278 _LDFLAGS += -L"$(LIBGSASL_PATH)/lib"
279 _LIBS += -lgsasl
280endif
281
282ifneq ($(findstring -idn2,$(CFG)),)
283 LIBIDN2_PATH ?= $(PROOT)/../libidn2
284 CPPFLAGS += -DUSE_LIBIDN2
285 CPPFLAGS += -I"$(LIBIDN2_PATH)/include"
286 _LDFLAGS += -L"$(LIBIDN2_PATH)/lib"
287 _LIBS += -lidn2
288
289ifneq ($(findstring -psl,$(CFG)),)
290 LIBPSL_PATH ?= $(PROOT)/../libpsl
291 CPPFLAGS += -DUSE_LIBPSL
292 CPPFLAGS += -I"$(LIBPSL_PATH)/include"
293 _LDFLAGS += -L"$(LIBPSL_PATH)/lib"
294 _LIBS += -lpsl
295endif
296else ifneq ($(findstring -winidn,$(CFG)),)
297 CPPFLAGS += -DUSE_WIN32_IDN
298 _LIBS += -lnormaliz
299endif
300
301ifneq ($(findstring -sspi,$(CFG)),)
302 ifdef WIN32
303 CPPFLAGS += -DUSE_WINDOWS_SSPI
304 endif
305endif
306ifneq ($(findstring -ipv6,$(CFG)),)
307 CPPFLAGS += -DENABLE_IPV6
308endif
309ifneq ($(findstring -ldaps,$(CFG)),)
310 CPPFLAGS += -DHAVE_LDAP_SSL
311endif
312
313ifneq ($(findstring -watt,$(CFG))$(MSDOS),)
314 WATT_PATH ?= $(PROOT)/../watt
315 CPPFLAGS += -I"$(WATT_PATH)/inc"
316 _LDFLAGS += -L"$(WATT_PATH)/lib"
317 _LIBS += -lwatt
318endif
319
320ifdef WIN32
321 ifeq ($(findstring -lldap,$(LIBS)),)
322 _LIBS += -lwldap32
323 endif
324 _LIBS += -lws2_32 -lcrypt32 -lbcrypt
325endif
326
327ifneq ($(findstring 11,$(subst $(subst ,, ),,$(SSLLIBS))),)
328 CPPFLAGS += -DCURL_WITH_MULTI_SSL
329endif
330
331ifndef DYN
332 LDFLAGS += $(_LDFLAGS)
333 LIBS += $(_LIBS)
334endif
335
336### Common rules
337
338OBJ_DIR := $(TRIPLET)
339
340ifneq ($(findstring /sh,$(SHELL)),)
341DEL = rm -f $1
342COPY = -cp -afv $1 $2
343MKDIR = mkdir -p $1
344RMDIR = rm -fr $1
345WHICH = $(SHELL) -c "command -v $1"
346else
347DEL = -del 2>NUL /q /f $(subst /,\,$1)
348COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
349MKDIR = -md 2>NUL $(subst /,\,$1)
350RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
351WHICH = where $1
352endif
353
354all: $(TARGETS)
355
356$(OBJ_DIR):
357 -$(call MKDIR, $(OBJ_DIR))
358
359$(OBJ_DIR)/%.o: %.c
360 $(CC) -W -Wall $(CFLAGS) $(CPPFLAGS) -c $< -o $@
361
362$(OBJ_DIR)/%.res: %.rc
363 $(RC) -O coff $(RCFLAGS) -i $< -o $@
364
365clean:
366 @$(call DEL, $(TOCLEAN))
367 @$(RMDIR) $(OBJ_DIR)
368
369distclean vclean: clean
370 @$(call DEL, $(TARGETS) $(TOVCLEAN))
371
372### Local
373
374ifdef LOCAL
375
376CPPFLAGS += -DBUILDING_LIBCURL
377
378### Sources and targets
379
380# Provides CSOURCES, HHEADERS, LIB_RCFILES
381include Makefile.inc
382
383vpath %.c vauth vquic vssh vtls
384
385libcurl_a_LIBRARY := libcurl.a
386ifdef WIN32
387CURL_DLL_SUFFIX ?=
388libcurl_dll_LIBRARY := libcurl$(CURL_DLL_SUFFIX).dll
389libcurl_dll_a_LIBRARY := libcurl.dll.a
390ifdef MAP
391libcurl_map_LIBRARY := libcurl$(CURL_DLL_SUFFIX).map
392CURL_LDFLAGS_LIB += -Wl,-Map,$(libcurl_map_LIBRARY)
393endif
394endif
395
396TARGETS := $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
397
398libcurl_a_OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(notdir $(strip $(CSOURCES))))
399libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
400ifdef WIN32
401libcurl_dll_OBJECTS := $(libcurl_a_OBJECTS)
402libcurl_dll_OBJECTS += $(patsubst %.rc,$(OBJ_DIR)/%.res,$(strip $(LIB_RCFILES)))
403endif
404
405TOCLEAN := $(libcurl_dll_OBJECTS)
406TOVCLEAN := $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY) $(libcurl_map_LIBRARY)
407
408### Rules
409
410$(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
411 @$(call DEL, $@)
412 $(AR) rcs $@ $(libcurl_a_OBJECTS)
413
414$(libcurl_dll_LIBRARY): $(libcurl_dll_OBJECTS)
415 $(CC) $(LDFLAGS) -shared $(CURL_LDFLAGS_LIB) -o $@ $(libcurl_dll_OBJECTS) $(LIBS) \
416 -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY)
417
418all: $(OBJ_DIR) $(TARGETS)
419endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette