Makefile.m32: deduplicate build rules [ci skip]
After this patch, we reduce the three copies of most `Makefile.m32` logic to one. This now resides in `lib/Makefile.m32`. It makes future updates easier, the code shorter, with a small amount of added complexity. `Makefile.m32` reduction: | | bytes | LOC total | blank | comment | code | |-------------------|-------:|----------:|-------:|---------:|------:| | 7.85.0 | 34772 | 1337 | 79 | 192 | 1066 | | before this patch | 17601 | 625 | 62 | 106 | 457 | | after this patch | 11680 | 392 | 52 | 104 | 236 | Details: - Change rules to create objects for the `v*` subdirs in the `lib` dir. This allows to use a shared compile rule and assumes that filenames are not (and will not be) colliding across these directories. `Makefile.m32` now also stores a list of these subdirs. They are changing rarely though. - Sync as much as possible between the three `Makefile.m32` scripts' rules and their source/target sections. - After this patch `CPPFLAGS` are all applied to the `src` sources once again. This matches the behaviour of cmake/autotools. Only zlib ones are actually required there. - Use `.rc` names from `Makefile.inc` instead of keeping a duplicate. - Change examples to link `libcurl.dll` by default. This makes building trivial, even as a cross-build: `CC=x86_64-w64-mingw32-gcc make -f Makefile.m32` To run them, you need to move/copy or add-to-path `libcurl.dll`. You can select static mode via `CFG=-static`. - List more of the `Makefile.m32` config variables. - Drop `.rc` support from examples. It made it fragile without much benefit. - Include a necessary system lib for the `externalsocket.c` example. - Exclude unnecessary systems libs when building in `-dyn` mode. Closes #9642
This commit is contained in:
Родитель
a2d0154e93
Коммит
784400806c
|
@ -22,171 +22,37 @@
|
|||
#
|
||||
#***************************************************************************
|
||||
|
||||
# Makefile for building curl examples with MinGW and optional features.
|
||||
#
|
||||
# Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
|
||||
# Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
|
||||
#
|
||||
# Set component roots via envvar <feature>_PATH. CPPFLAGS, LDFLAGS, LIBS,
|
||||
# CFLAGS, RCFLAGS (and more) are also available for customization.
|
||||
# Build libcurl via lib/Makefile.m32 first.
|
||||
|
||||
PROOT := ../..
|
||||
|
||||
CPPFLAGS += -I. -I$(PROOT)/include
|
||||
RCFLAGS += -I$(PROOT)/include -DCURL_EMBED_MANIFEST
|
||||
LDFLAGS += -L$(PROOT)/lib
|
||||
LIBS += -lcurl
|
||||
|
||||
ifneq ($(ARCH),custom)
|
||||
# Set environment var ARCH to your architecture to override autodetection.
|
||||
ifndef ARCH
|
||||
ifneq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),)
|
||||
ARCH := w64
|
||||
else
|
||||
ARCH := w32
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -m64
|
||||
LDFLAGS += -m64
|
||||
RCFLAGS += --target=pe-x86-64
|
||||
else
|
||||
CFLAGS += -m32
|
||||
LDFLAGS += -m32
|
||||
RCFLAGS += --target=pe-i386
|
||||
endif
|
||||
endif
|
||||
|
||||
### Optional features
|
||||
|
||||
ifneq ($(findstring -dyn,$(CFG)),)
|
||||
curl_DEPENDENCIES := $(PROOT)/lib/libcurl$(CURL_DLL_SUFFIX).dll
|
||||
ifeq ($(findstring -static,$(CFG)),)
|
||||
curl_DEPENDENCIES += $(PROOT)/lib/libcurl.dll.a
|
||||
DYN := 1
|
||||
else
|
||||
curl_DEPENDENCIES := $(PROOT)/lib/libcurl.a
|
||||
CPPFLAGS += -DCURL_STATICLIB
|
||||
LDFLAGS += -static
|
||||
endif
|
||||
|
||||
ifneq ($(findstring -unicode,$(CFG)),)
|
||||
CPPFLAGS += -DUNICODE -D_UNICODE
|
||||
LDFLAGS += -municode
|
||||
endif
|
||||
ifneq ($(findstring -sync,$(CFG)),)
|
||||
else
|
||||
ifneq ($(findstring -ares,$(CFG)),)
|
||||
LIBCARES_PATH ?= $(PROOT)/../c-ares
|
||||
LDFLAGS += -L"$(LIBCARES_PATH)/lib"
|
||||
LIBS += -lcares
|
||||
endif
|
||||
endif
|
||||
ifneq ($(findstring -rtmp,$(CFG)),)
|
||||
LIBRTMP_PATH ?= $(PROOT)/../librtmp
|
||||
LDFLAGS += -L"$(LIBRTMP_PATH)/librtmp"
|
||||
LIBS += -lrtmp -lwinmm
|
||||
ZLIB := 1
|
||||
endif
|
||||
ifneq ($(findstring -ssh2,$(CFG)),)
|
||||
LIBSSH2_PATH ?= $(PROOT)/../libssh2
|
||||
LDFLAGS += -L"$(LIBSSH2_PATH)/lib"
|
||||
LDFLAGS += -L"$(LIBSSH2_PATH)/win32"
|
||||
LIBS += -lssh2
|
||||
endif
|
||||
ifneq ($(findstring -nghttp2,$(CFG)),)
|
||||
NGHTTP2_PATH ?= $(PROOT)/../nghttp2
|
||||
LDFLAGS += -L"$(NGHTTP2_PATH)/lib"
|
||||
LIBS += -lnghttp2
|
||||
endif
|
||||
ifneq ($(findstring -nghttp3,$(CFG)),)
|
||||
ifneq ($(findstring -ngtcp2,$(CFG)),)
|
||||
NGHTTP3_PATH ?= $(PROOT)/../nghttp3
|
||||
LDFLAGS += -L"$(NGHTTP3_PATH)/lib"
|
||||
LIBS += -lnghttp3
|
||||
NGTCP2_PATH ?= $(PROOT)/../ngtcp2
|
||||
LDFLAGS += -L"$(NGTCP2_PATH)/lib"
|
||||
NGTCP2_LIBS ?= -lngtcp2 -lngtcp2_crypto_openssl
|
||||
LIBS += $(NGTCP2_LIBS)
|
||||
endif
|
||||
endif
|
||||
ifneq ($(findstring -ssl,$(CFG)),)
|
||||
OPENSSL_PATH ?= $(PROOT)/../openssl
|
||||
OPENSSL_LIBPATH ?= $(OPENSSL_PATH)/lib
|
||||
LDFLAGS += -L"$(OPENSSL_LIBPATH)"
|
||||
OPENSSL_LIBS ?= -lssl -lcrypto
|
||||
LIBS += $(OPENSSL_LIBS)
|
||||
endif
|
||||
ifneq ($(findstring -zlib,$(CFG))$(ZLIB),)
|
||||
ZLIB_PATH ?= $(PROOT)/../zlib
|
||||
LDFLAGS += -L"$(ZLIB_PATH)"
|
||||
LIBS += -lz
|
||||
endif
|
||||
ifneq ($(findstring -zstd,$(CFG)),)
|
||||
ZSTD_PATH ?= $(PROOT)/../zstd
|
||||
LDFLAGS += -L"$(ZSTD_PATH)/lib"
|
||||
ZSTD_LIBS ?= -lzstd
|
||||
LIBS += $(ZSTD_LIBS)
|
||||
endif
|
||||
ifneq ($(findstring -brotli,$(CFG)),)
|
||||
BROTLI_PATH ?= $(PROOT)/../brotli
|
||||
LDFLAGS += -L"$(BROTLI_PATH)/lib"
|
||||
BROTLI_LIBS ?= -lbrotlidec -lbrotlicommon
|
||||
LIBS += $(BROTLI_LIBS)
|
||||
endif
|
||||
ifneq ($(findstring -gsasl,$(CFG)),)
|
||||
LIBGSASL_PATH ?= $(PROOT)/../gsasl
|
||||
LDFLAGS += -L"$(LIBGSASL_PATH)/lib"
|
||||
LIBS += -lgsasl
|
||||
endif
|
||||
ifneq ($(findstring -idn2,$(CFG)),)
|
||||
LIBIDN2_PATH ?= $(PROOT)/../libidn2
|
||||
LDFLAGS += -L"$(LIBIDN2_PATH)/lib"
|
||||
LIBS += -lidn2
|
||||
else
|
||||
ifneq ($(findstring -winidn,$(CFG)),)
|
||||
LIBS += -lnormaliz
|
||||
endif
|
||||
endif
|
||||
ifeq ($(findstring -lldap,$(LIBS)),)
|
||||
LIBS += -lwldap32
|
||||
endif
|
||||
LIBS += -lws2_32 -lcrypt32 -lbcrypt
|
||||
LIBS += -lws2_32
|
||||
|
||||
### Sources and targets
|
||||
|
||||
# Provides check_PROGRAMS
|
||||
include Makefile.inc
|
||||
|
||||
TARGETS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
|
||||
TARGETS += synctime.exe
|
||||
TARGETS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS) synctime))
|
||||
TOCLEAN := $(TARGETS:.exe=.o)
|
||||
|
||||
RESOURCE := $(PROOT)/src/curl.res
|
||||
### Local rules
|
||||
|
||||
.PRECIOUS: %.o
|
||||
%.exe: %.o $(curl_DEPENDENCIES)
|
||||
$(CC) $(LDFLAGS) $(CURL_LDFLAGS_BIN) -o $@ $< $(LIBS)
|
||||
|
||||
### Rules
|
||||
### Global script
|
||||
|
||||
CC ?= $(CROSSPREFIX)gcc
|
||||
RC ?= $(CROSSPREFIX)windres
|
||||
|
||||
ifneq ($(findstring /sh,$(SHELL)),)
|
||||
DEL = rm -f $1
|
||||
else
|
||||
DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
||||
endif
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
%.exe: %.o $(RESOURCE) $(curl_DEPENDENCIES)
|
||||
$(CC) $(LDFLAGS) -o $@ $< $(RESOURCE) $(LIBS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
||||
|
||||
%.res: %.rc
|
||||
$(RC) -O coff $(RCFLAGS) -i $< -o $@
|
||||
|
||||
clean:
|
||||
@$(call DEL, $(TARGETS:.exe=.o) $(RESOURCE))
|
||||
|
||||
distclean vclean: clean
|
||||
@$(call DEL, $(TARGETS))
|
||||
include $(PROOT)/lib/Makefile.m32
|
||||
|
|
|
@ -22,17 +22,58 @@
|
|||
#
|
||||
#***************************************************************************
|
||||
|
||||
# Makefile for building libcurl with MinGW and optional features.
|
||||
# Makefile for building curl parts with MinGW and optional features.
|
||||
#
|
||||
# Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
|
||||
# Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
|
||||
#
|
||||
# Set component roots via envvar <feature>_PATH. CPPFLAGS, LDFLAGS, LIBS,
|
||||
# CFLAGS, RCFLAGS (and more) are also available for customization.
|
||||
# Set component roots via envvar <feature>_PATH. Also available for
|
||||
# customization: CPPFLAGS, LDFLAGS, LIBS, CFLAGS, RCFLAGS, ARCH[=custom],
|
||||
# CURL_LDFLAGS_BIN, CURL_LDFLAGS_LIB, CURL_DLL_SUFFIX, and more for individual
|
||||
# components.
|
||||
|
||||
# This script is reused by 'src' and 'docs/examples' Makefile.m32 scripts.
|
||||
# Skip lib-specific parts when called through them.
|
||||
ifndef PROOT
|
||||
PROOT := ..
|
||||
|
||||
CPPFLAGS += -I. -I$(PROOT)/include -DBUILDING_LIBCURL
|
||||
CPPFLAGS += -DBUILDING_LIBCURL
|
||||
|
||||
### Sources and targets
|
||||
|
||||
# Provides CSOURCES, HHEADERS, LIB_RCFILES
|
||||
include Makefile.inc
|
||||
|
||||
libcurl_dll_LIBRARY := libcurl$(CURL_DLL_SUFFIX).dll
|
||||
libcurl_dll_a_LIBRARY := libcurl.dll.a
|
||||
libcurl_a_LIBRARY := libcurl.a
|
||||
|
||||
TARGETS := $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
|
||||
|
||||
libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CSOURCES))))
|
||||
libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
|
||||
libcurl_dll_OBJECTS := $(libcurl_a_OBJECTS)
|
||||
libcurl_dll_OBJECTS += $(patsubst %.rc,%.res,$(strip $(LIB_RCFILES)))
|
||||
vpath %.c vauth vquic vssh vtls
|
||||
|
||||
TOCLEAN := $(libcurl_dll_OBJECTS)
|
||||
TOVCLEAN := $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY)
|
||||
|
||||
### Local rules
|
||||
|
||||
# Keep this at the top to act as the default target.
|
||||
all: $(TARGETS)
|
||||
|
||||
$(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
|
||||
@$(call DEL, $@)
|
||||
$(AR) rcs $@ $(libcurl_a_OBJECTS)
|
||||
|
||||
$(libcurl_dll_LIBRARY): $(libcurl_dll_OBJECTS)
|
||||
$(CC) $(LDFLAGS) -shared $(CURL_LDFLAGS_LIB) -o $@ $(libcurl_dll_OBJECTS) $(LIBS) \
|
||||
-Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY)
|
||||
endif
|
||||
|
||||
CPPFLAGS += -I. -I$(PROOT)/include
|
||||
RCFLAGS += -I$(PROOT)/include
|
||||
|
||||
ifneq ($(ARCH),custom)
|
||||
|
@ -57,8 +98,16 @@ endif
|
|||
|
||||
### Optional features
|
||||
|
||||
# Most CPPFLAGS are only necessary when building libcurl via 'lib'. We include
|
||||
# them always for simplicity and for being in sync with other build systems.
|
||||
# See comment below about the exception.
|
||||
|
||||
# LDFLAGS and LIBS below are not required when building 'src' and
|
||||
# 'docs/examples' in DYN mode.
|
||||
|
||||
ifneq ($(findstring -unicode,$(CFG)),)
|
||||
CPPFLAGS += -DUNICODE -D_UNICODE
|
||||
CURL_LDFLAGS_BIN += -municode
|
||||
endif
|
||||
ifneq ($(findstring -sync,$(CFG)),)
|
||||
CPPFLAGS += -DUSE_SYNC_DNS
|
||||
|
@ -135,6 +184,7 @@ ifneq ($(findstring -schannel,$(CFG)),)
|
|||
endif
|
||||
ifneq ($(findstring -zlib,$(CFG))$(ZLIB),)
|
||||
ZLIB_PATH ?= $(PROOT)/../zlib
|
||||
# These CPPFLAGS are also required when compiling the curl tool via 'src'.
|
||||
CPPFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
|
||||
CPPFLAGS += -I"$(ZLIB_PATH)"
|
||||
LDFLAGS += -L"$(ZLIB_PATH)"
|
||||
|
@ -185,26 +235,14 @@ endif
|
|||
ifneq ($(findstring -ldaps,$(CFG)),)
|
||||
CPPFLAGS += -DHAVE_LDAP_SSL
|
||||
endif
|
||||
ifeq ($(findstring -lldap,$(LIBS)),)
|
||||
LIBS += -lwldap32
|
||||
ifndef DYN
|
||||
ifeq ($(findstring -lldap,$(LIBS)),)
|
||||
LIBS += -lwldap32
|
||||
endif
|
||||
LIBS += -lws2_32 -lcrypt32 -lbcrypt
|
||||
endif
|
||||
LIBS += -lws2_32 -lcrypt32 -lbcrypt
|
||||
|
||||
### Sources and targets
|
||||
|
||||
# Provides CSOURCES and HHEADERS
|
||||
include Makefile.inc
|
||||
|
||||
libcurl_dll_LIBRARY := libcurl$(CURL_DLL_SUFFIX).dll
|
||||
libcurl_dll_a_LIBRARY := libcurl.dll.a
|
||||
libcurl_a_LIBRARY := libcurl.a
|
||||
|
||||
libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
|
||||
libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
|
||||
|
||||
RESOURCE := libcurl.res
|
||||
|
||||
### Rules
|
||||
### Global rules
|
||||
|
||||
CC ?= $(CROSSPREFIX)gcc
|
||||
RC ?= $(CROSSPREFIX)windres
|
||||
|
@ -216,24 +254,16 @@ else
|
|||
DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
||||
endif
|
||||
|
||||
all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
|
||||
|
||||
$(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
|
||||
@$(call DEL, $@)
|
||||
$(AR) rcs $@ $(libcurl_a_OBJECTS)
|
||||
|
||||
$(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE)
|
||||
$(CC) $(LDFLAGS) -shared $(CURL_LDFLAGS_LIB) -o $@ $(libcurl_a_OBJECTS) $(RESOURCE) $(LIBS) \
|
||||
-Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY)
|
||||
all: $(TARGETS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
||||
|
||||
%.res: %.rc
|
||||
$(RC) -O coff $(RCFLAGS) -i $< -o $@
|
||||
|
||||
clean:
|
||||
@$(call DEL, $(libcurl_a_OBJECTS) $(RESOURCE))
|
||||
@$(call DEL, $(TOCLEAN))
|
||||
|
||||
distclean vclean: clean
|
||||
@$(call DEL, $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY))
|
||||
@$(call DEL, $(TARGETS) $(TOVCLEAN))
|
||||
|
|
155
src/Makefile.m32
155
src/Makefile.m32
|
@ -22,173 +22,44 @@
|
|||
#
|
||||
#***************************************************************************
|
||||
|
||||
# Makefile for building curl with MinGW and optional features.
|
||||
#
|
||||
# Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
|
||||
# Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
|
||||
#
|
||||
# Set component roots via envvar <feature>_PATH. CPPFLAGS, LDFLAGS, LIBS,
|
||||
# CFLAGS, RCFLAGS (and more) are also available for customization.
|
||||
# See usage in lib/Makefile.m32
|
||||
|
||||
PROOT := ..
|
||||
|
||||
CPPFLAGS += -I. -I$(PROOT)/include -I$(PROOT)/lib
|
||||
RCFLAGS += -I$(PROOT)/include -DCURL_EMBED_MANIFEST
|
||||
RCFLAGS += -DCURL_EMBED_MANIFEST
|
||||
CPPFLAGS += -I$(PROOT)/lib
|
||||
LDFLAGS += -L$(PROOT)/lib
|
||||
LIBS += -lcurl
|
||||
|
||||
ifneq ($(ARCH),custom)
|
||||
# Set environment var ARCH to your architecture to override autodetection.
|
||||
ifndef ARCH
|
||||
ifneq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),)
|
||||
ARCH := w64
|
||||
else
|
||||
ARCH := w32
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -m64
|
||||
LDFLAGS += -m64
|
||||
RCFLAGS += --target=pe-x86-64
|
||||
else
|
||||
CFLAGS += -m32
|
||||
LDFLAGS += -m32
|
||||
RCFLAGS += --target=pe-i386
|
||||
endif
|
||||
endif
|
||||
|
||||
### Optional features
|
||||
|
||||
ifneq ($(findstring -dyn,$(CFG)),)
|
||||
curl_DEPENDENCIES := $(PROOT)/lib/libcurl$(CURL_DLL_SUFFIX).dll
|
||||
curl_DEPENDENCIES += $(PROOT)/lib/libcurl.dll.a
|
||||
DYN := 1
|
||||
else
|
||||
curl_DEPENDENCIES := $(PROOT)/lib/libcurl.a
|
||||
CPPFLAGS += -DCURL_STATICLIB
|
||||
LDFLAGS += -static
|
||||
endif
|
||||
|
||||
ifneq ($(findstring -unicode,$(CFG)),)
|
||||
CPPFLAGS += -DUNICODE -D_UNICODE
|
||||
LDFLAGS += -municode
|
||||
endif
|
||||
ifneq ($(findstring -sync,$(CFG)),)
|
||||
else
|
||||
ifneq ($(findstring -ares,$(CFG)),)
|
||||
LIBCARES_PATH ?= $(PROOT)/../c-ares
|
||||
LDFLAGS += -L"$(LIBCARES_PATH)/lib"
|
||||
LIBS += -lcares
|
||||
endif
|
||||
endif
|
||||
ifneq ($(findstring -rtmp,$(CFG)),)
|
||||
LIBRTMP_PATH ?= $(PROOT)/../librtmp
|
||||
LDFLAGS += -L"$(LIBRTMP_PATH)/librtmp"
|
||||
LIBS += -lrtmp -lwinmm
|
||||
ZLIB := 1
|
||||
endif
|
||||
ifneq ($(findstring -ssh2,$(CFG)),)
|
||||
LIBSSH2_PATH ?= $(PROOT)/../libssh2
|
||||
LDFLAGS += -L"$(LIBSSH2_PATH)/lib"
|
||||
LDFLAGS += -L"$(LIBSSH2_PATH)/win32"
|
||||
LIBS += -lssh2
|
||||
endif
|
||||
ifneq ($(findstring -nghttp2,$(CFG)),)
|
||||
NGHTTP2_PATH ?= $(PROOT)/../nghttp2
|
||||
LDFLAGS += -L"$(NGHTTP2_PATH)/lib"
|
||||
LIBS += -lnghttp2
|
||||
endif
|
||||
ifneq ($(findstring -nghttp3,$(CFG)),)
|
||||
ifneq ($(findstring -ngtcp2,$(CFG)),)
|
||||
NGHTTP3_PATH ?= $(PROOT)/../nghttp3
|
||||
LDFLAGS += -L"$(NGHTTP3_PATH)/lib"
|
||||
LIBS += -lnghttp3
|
||||
NGTCP2_PATH ?= $(PROOT)/../ngtcp2
|
||||
LDFLAGS += -L"$(NGTCP2_PATH)/lib"
|
||||
NGTCP2_LIBS ?= -lngtcp2 -lngtcp2_crypto_openssl
|
||||
LIBS += $(NGTCP2_LIBS)
|
||||
endif
|
||||
endif
|
||||
ifneq ($(findstring -ssl,$(CFG)),)
|
||||
OPENSSL_PATH ?= $(PROOT)/../openssl
|
||||
OPENSSL_LIBPATH ?= $(OPENSSL_PATH)/lib
|
||||
LDFLAGS += -L"$(OPENSSL_LIBPATH)"
|
||||
OPENSSL_LIBS ?= -lssl -lcrypto
|
||||
LIBS += $(OPENSSL_LIBS)
|
||||
endif
|
||||
ifneq ($(findstring -zlib,$(CFG))$(ZLIB),)
|
||||
ZLIB_PATH ?= $(PROOT)/../zlib
|
||||
CPPFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
|
||||
CPPFLAGS += -I"$(ZLIB_PATH)"
|
||||
LDFLAGS += -L"$(ZLIB_PATH)"
|
||||
LIBS += -lz
|
||||
endif
|
||||
ifneq ($(findstring -zstd,$(CFG)),)
|
||||
ZSTD_PATH ?= $(PROOT)/../zstd
|
||||
LDFLAGS += -L"$(ZSTD_PATH)/lib"
|
||||
ZSTD_LIBS ?= -lzstd
|
||||
LIBS += $(ZSTD_LIBS)
|
||||
endif
|
||||
ifneq ($(findstring -brotli,$(CFG)),)
|
||||
BROTLI_PATH ?= $(PROOT)/../brotli
|
||||
LDFLAGS += -L"$(BROTLI_PATH)/lib"
|
||||
BROTLI_LIBS ?= -lbrotlidec -lbrotlicommon
|
||||
LIBS += $(BROTLI_LIBS)
|
||||
endif
|
||||
ifneq ($(findstring -gsasl,$(CFG)),)
|
||||
LIBGSASL_PATH ?= $(PROOT)/../gsasl
|
||||
LDFLAGS += -L"$(LIBGSASL_PATH)/lib"
|
||||
LIBS += -lgsasl
|
||||
endif
|
||||
ifneq ($(findstring -idn2,$(CFG)),)
|
||||
LIBIDN2_PATH ?= $(PROOT)/../libidn2
|
||||
LDFLAGS += -L"$(LIBIDN2_PATH)/lib"
|
||||
LIBS += -lidn2
|
||||
else
|
||||
ifneq ($(findstring -winidn,$(CFG)),)
|
||||
LIBS += -lnormaliz
|
||||
endif
|
||||
endif
|
||||
ifeq ($(findstring -lldap,$(LIBS)),)
|
||||
LIBS += -lwldap32
|
||||
endif
|
||||
LIBS += -lws2_32 -lcrypt32 -lbcrypt
|
||||
|
||||
### Sources and targets
|
||||
|
||||
# Provides CURL_CFILES and CURLX_CFILES
|
||||
# Provides CURL_CFILES, CURLX_CFILES, CURL_RCFILES
|
||||
include Makefile.inc
|
||||
|
||||
TARGETS := curl.exe
|
||||
|
||||
curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
|
||||
curl_OBJECTS += $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
|
||||
curl_OBJECTS += $(patsubst %.rc,%.res,$(strip $(CURL_RCFILES)))
|
||||
vpath %.c $(PROOT)/lib
|
||||
|
||||
RESOURCE := curl.res
|
||||
TOCLEAN := $(curl_OBJECTS)
|
||||
|
||||
### Rules
|
||||
### Local rules
|
||||
|
||||
CC ?= $(CROSSPREFIX)gcc
|
||||
RC ?= $(CROSSPREFIX)windres
|
||||
$(TARGETS): $(curl_OBJECTS) $(curl_DEPENDENCIES)
|
||||
$(CC) $(LDFLAGS) $(CURL_LDFLAGS_BIN) -o $@ $(curl_OBJECTS) $(LIBS)
|
||||
|
||||
ifneq ($(findstring /sh,$(SHELL)),)
|
||||
DEL = rm -f $1
|
||||
else
|
||||
DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
||||
endif
|
||||
### Global script
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
$(TARGETS): $(curl_OBJECTS) $(RESOURCE) $(curl_DEPENDENCIES)
|
||||
$(CC) $(LDFLAGS) $(CURL_LDFLAGS_BIN) -o $@ $(curl_OBJECTS) $(RESOURCE) $(LIBS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
||||
|
||||
%.res: %.rc
|
||||
$(RC) -O coff $(RCFLAGS) -i $< -o $@
|
||||
|
||||
clean:
|
||||
@$(call DEL, $(curl_OBJECTS) $(RESOURCE))
|
||||
|
||||
distclean vclean: clean
|
||||
@$(call DEL, $(TARGETS))
|
||||
include $(PROOT)/lib/Makefile.m32
|
||||
|
|
Загрузка…
Ссылка в новой задаче