| 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 | # 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 |
|
|---|
| 34 | ifndef PROOT
|
|---|
| 35 | PROOT := ..
|
|---|
| 36 | LOCAL := 1
|
|---|
| 37 | endif
|
|---|
| 38 |
|
|---|
| 39 | ### Common
|
|---|
| 40 |
|
|---|
| 41 | CFLAGS ?=
|
|---|
| 42 | CPPFLAGS ?=
|
|---|
| 43 | RCFLAGS ?=
|
|---|
| 44 | LDFLAGS ?=
|
|---|
| 45 | CURL_LDFLAGS_BIN ?=
|
|---|
| 46 | CURL_LDFLAGS_LIB ?=
|
|---|
| 47 | LIBS ?=
|
|---|
| 48 |
|
|---|
| 49 | CROSSPREFIX ?=
|
|---|
| 50 |
|
|---|
| 51 | ifeq ($(CC),cc)
|
|---|
| 52 | CC := gcc
|
|---|
| 53 | endif
|
|---|
| 54 | CC := $(CROSSPREFIX)$(CC)
|
|---|
| 55 | AR := $(CROSSPREFIX)$(AR)
|
|---|
| 56 | RC ?= $(CROSSPREFIX)windres
|
|---|
| 57 |
|
|---|
| 58 | # For compatibility
|
|---|
| 59 | ARCH ?=
|
|---|
| 60 | ifeq ($(ARCH),w64)
|
|---|
| 61 | TRIPLET := x86_64-w64-mingw32
|
|---|
| 62 | CFLAGS += -m64
|
|---|
| 63 | LDFLAGS += -m64
|
|---|
| 64 | RCFLAGS += --target=pe-x86-64
|
|---|
| 65 | else ifdef ARCH
|
|---|
| 66 | TRIPLET := i686-w64-mingw32
|
|---|
| 67 | CFLAGS += -m32
|
|---|
| 68 | LDFLAGS += -m32
|
|---|
| 69 | RCFLAGS += --target=pe-i386
|
|---|
| 70 | else
|
|---|
| 71 | TRIPLET ?= $(shell $(CC) -dumpmachine)
|
|---|
| 72 | endif
|
|---|
| 73 |
|
|---|
| 74 | BIN_EXT := .exe
|
|---|
| 75 |
|
|---|
| 76 | ifneq ($(findstring -w,$(TRIPLET)),)
|
|---|
| 77 | WIN32 := 1
|
|---|
| 78 | else ifneq ($(findstring msdos,$(TRIPLET)),)
|
|---|
| 79 | # Cross-tools: https://github.com/andrewwutw/build-djgpp
|
|---|
| 80 | MSDOS := 1
|
|---|
| 81 | else ifneq ($(findstring amigaos,$(TRIPLET)),)
|
|---|
| 82 | # Cross-tools: https://github.com/bebbo/amiga-gcc
|
|---|
| 83 | AMIGA := 1
|
|---|
| 84 | endif
|
|---|
| 85 |
|
|---|
| 86 | CPPFLAGS += -I. -I$(PROOT)/include
|
|---|
| 87 | RCFLAGS += -I$(PROOT)/include
|
|---|
| 88 |
|
|---|
| 89 | ifndef WIN32
|
|---|
| 90 | DYN :=
|
|---|
| 91 | endif
|
|---|
| 92 |
|
|---|
| 93 | ifdef AMIGA
|
|---|
| 94 | BIN_EXT :=
|
|---|
| 95 | endif
|
|---|
| 96 |
|
|---|
| 97 | ### Deprecated settings. For compatibility.
|
|---|
| 98 |
|
|---|
| 99 | ifdef WATT_ROOT
|
|---|
| 100 | WATT_PATH := $(realpath $(WATT_ROOT))
|
|---|
| 101 | endif
|
|---|
| 102 |
|
|---|
| 103 | ### Optional features
|
|---|
| 104 |
|
|---|
| 105 | ifneq ($(findstring -debug,$(CFG)),)
|
|---|
| 106 | CPPFLAGS += -DDEBUGBUILD
|
|---|
| 107 | LDFLAGS += -g
|
|---|
| 108 | else
|
|---|
| 109 | CPPFLAGS += -DNDEBUG
|
|---|
| 110 | endif
|
|---|
| 111 | ifneq ($(findstring -trackmem,$(CFG)),)
|
|---|
| 112 | CPPFLAGS += -DCURLDEBUG
|
|---|
| 113 | endif
|
|---|
| 114 | ifneq ($(findstring -map,$(CFG)),)
|
|---|
| 115 | MAP := 1
|
|---|
| 116 | endif
|
|---|
| 117 |
|
|---|
| 118 | ifdef WIN32
|
|---|
| 119 | ifneq ($(findstring -unicode,$(CFG)),)
|
|---|
| 120 | CPPFLAGS += -DUNICODE -D_UNICODE
|
|---|
| 121 | CURL_LDFLAGS_BIN += -municode
|
|---|
| 122 | endif
|
|---|
| 123 | endif
|
|---|
| 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 |
|
|---|
| 133 | ifneq ($(findstring -sync,$(CFG)),)
|
|---|
| 134 | CPPFLAGS += -DUSE_SYNC_DNS
|
|---|
| 135 | else 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
|
|---|
| 141 | endif
|
|---|
| 142 |
|
|---|
| 143 | ifneq ($(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
|
|---|
| 150 | endif
|
|---|
| 151 |
|
|---|
| 152 | ifneq ($(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
|
|---|
| 161 | else 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
|
|---|
| 167 | else 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
|
|---|
| 173 | endif
|
|---|
| 174 |
|
|---|
| 175 | ifneq ($(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
|
|---|
| 200 | else 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
|
|---|
| 209 | endif
|
|---|
| 210 | ifneq ($(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
|
|---|
| 217 | endif
|
|---|
| 218 | ifneq ($(findstring -schannel,$(CFG)),)
|
|---|
| 219 | CPPFLAGS += -DUSE_SCHANNEL
|
|---|
| 220 | SSLLIBS += 1
|
|---|
| 221 | endif
|
|---|
| 222 |
|
|---|
| 223 | ifneq ($(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
|
|---|
| 229 | endif
|
|---|
| 230 |
|
|---|
| 231 | ifeq ($(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)
|
|---|
| 246 | endif
|
|---|
| 247 |
|
|---|
| 248 | ifneq ($(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
|
|---|
| 257 | endif
|
|---|
| 258 | ifneq ($(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)
|
|---|
| 265 | endif
|
|---|
| 266 | ifneq ($(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)
|
|---|
| 273 | endif
|
|---|
| 274 | ifneq ($(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
|
|---|
| 280 | endif
|
|---|
| 281 |
|
|---|
| 282 | ifneq ($(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 |
|
|---|
| 289 | ifneq ($(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
|
|---|
| 295 | endif
|
|---|
| 296 | else ifneq ($(findstring -winidn,$(CFG)),)
|
|---|
| 297 | CPPFLAGS += -DUSE_WIN32_IDN
|
|---|
| 298 | _LIBS += -lnormaliz
|
|---|
| 299 | endif
|
|---|
| 300 |
|
|---|
| 301 | ifneq ($(findstring -sspi,$(CFG)),)
|
|---|
| 302 | ifdef WIN32
|
|---|
| 303 | CPPFLAGS += -DUSE_WINDOWS_SSPI
|
|---|
| 304 | endif
|
|---|
| 305 | endif
|
|---|
| 306 | ifneq ($(findstring -ipv6,$(CFG)),)
|
|---|
| 307 | CPPFLAGS += -DENABLE_IPV6
|
|---|
| 308 | endif
|
|---|
| 309 | ifneq ($(findstring -ldaps,$(CFG)),)
|
|---|
| 310 | CPPFLAGS += -DHAVE_LDAP_SSL
|
|---|
| 311 | endif
|
|---|
| 312 |
|
|---|
| 313 | ifneq ($(findstring -watt,$(CFG))$(MSDOS),)
|
|---|
| 314 | WATT_PATH ?= $(PROOT)/../watt
|
|---|
| 315 | CPPFLAGS += -I"$(WATT_PATH)/inc"
|
|---|
| 316 | _LDFLAGS += -L"$(WATT_PATH)/lib"
|
|---|
| 317 | _LIBS += -lwatt
|
|---|
| 318 | endif
|
|---|
| 319 |
|
|---|
| 320 | ifdef WIN32
|
|---|
| 321 | ifeq ($(findstring -lldap,$(LIBS)),)
|
|---|
| 322 | _LIBS += -lwldap32
|
|---|
| 323 | endif
|
|---|
| 324 | _LIBS += -lws2_32 -lcrypt32 -lbcrypt
|
|---|
| 325 | endif
|
|---|
| 326 |
|
|---|
| 327 | ifneq ($(findstring 11,$(subst $(subst ,, ),,$(SSLLIBS))),)
|
|---|
| 328 | CPPFLAGS += -DCURL_WITH_MULTI_SSL
|
|---|
| 329 | endif
|
|---|
| 330 |
|
|---|
| 331 | ifndef DYN
|
|---|
| 332 | LDFLAGS += $(_LDFLAGS)
|
|---|
| 333 | LIBS += $(_LIBS)
|
|---|
| 334 | endif
|
|---|
| 335 |
|
|---|
| 336 | ### Common rules
|
|---|
| 337 |
|
|---|
| 338 | OBJ_DIR := $(TRIPLET)
|
|---|
| 339 |
|
|---|
| 340 | ifneq ($(findstring /sh,$(SHELL)),)
|
|---|
| 341 | DEL = rm -f $1
|
|---|
| 342 | COPY = -cp -afv $1 $2
|
|---|
| 343 | MKDIR = mkdir -p $1
|
|---|
| 344 | RMDIR = rm -fr $1
|
|---|
| 345 | WHICH = $(SHELL) -c "command -v $1"
|
|---|
| 346 | else
|
|---|
| 347 | DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
|---|
| 348 | COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
|
|---|
| 349 | MKDIR = -md 2>NUL $(subst /,\,$1)
|
|---|
| 350 | RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
|
|---|
| 351 | WHICH = where $1
|
|---|
| 352 | endif
|
|---|
| 353 |
|
|---|
| 354 | all: $(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 |
|
|---|
| 365 | clean:
|
|---|
| 366 | @$(call DEL, $(TOCLEAN))
|
|---|
| 367 | @$(RMDIR) $(OBJ_DIR)
|
|---|
| 368 |
|
|---|
| 369 | distclean vclean: clean
|
|---|
| 370 | @$(call DEL, $(TARGETS) $(TOVCLEAN))
|
|---|
| 371 |
|
|---|
| 372 | ### Local
|
|---|
| 373 |
|
|---|
| 374 | ifdef LOCAL
|
|---|
| 375 |
|
|---|
| 376 | CPPFLAGS += -DBUILDING_LIBCURL
|
|---|
| 377 |
|
|---|
| 378 | ### Sources and targets
|
|---|
| 379 |
|
|---|
| 380 | # Provides CSOURCES, HHEADERS, LIB_RCFILES
|
|---|
| 381 | include Makefile.inc
|
|---|
| 382 |
|
|---|
| 383 | vpath %.c vauth vquic vssh vtls
|
|---|
| 384 |
|
|---|
| 385 | libcurl_a_LIBRARY := libcurl.a
|
|---|
| 386 | ifdef WIN32
|
|---|
| 387 | CURL_DLL_SUFFIX ?=
|
|---|
| 388 | libcurl_dll_LIBRARY := libcurl$(CURL_DLL_SUFFIX).dll
|
|---|
| 389 | libcurl_dll_a_LIBRARY := libcurl.dll.a
|
|---|
| 390 | ifdef MAP
|
|---|
| 391 | libcurl_map_LIBRARY := libcurl$(CURL_DLL_SUFFIX).map
|
|---|
| 392 | CURL_LDFLAGS_LIB += -Wl,-Map,$(libcurl_map_LIBRARY)
|
|---|
| 393 | endif
|
|---|
| 394 | endif
|
|---|
| 395 |
|
|---|
| 396 | TARGETS := $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
|
|---|
| 397 |
|
|---|
| 398 | libcurl_a_OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(notdir $(strip $(CSOURCES))))
|
|---|
| 399 | libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
|
|---|
| 400 | ifdef WIN32
|
|---|
| 401 | libcurl_dll_OBJECTS := $(libcurl_a_OBJECTS)
|
|---|
| 402 | libcurl_dll_OBJECTS += $(patsubst %.rc,$(OBJ_DIR)/%.res,$(strip $(LIB_RCFILES)))
|
|---|
| 403 | endif
|
|---|
| 404 |
|
|---|
| 405 | TOCLEAN := $(libcurl_dll_OBJECTS)
|
|---|
| 406 | TOVCLEAN := $(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 |
|
|---|
| 418 | all: $(OBJ_DIR) $(TARGETS)
|
|---|
| 419 | endif
|
|---|