|
@@ -22,89 +22,96 @@
|
|
|
#
|
|
|
#***************************************************************************
|
|
|
|
|
|
-# Makefile for building curl parts with MinGW and optional features.
|
|
|
+# Makefile to build curl parts with GCC-like toolchains and optional features.
|
|
|
#
|
|
|
-# Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
|
|
|
-# Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
|
|
|
+# Usage: [mingw32-]make -f Makefile.mk CFG=-feat1[-feat2][-feat3][...]
|
|
|
+# Example: [mingw32-]make -f Makefile.mk CFG=-zlib-ssl-libssh2-ipv6
|
|
|
#
|
|
|
# Set component roots via envvar <feature>_PATH. Also available for
|
|
|
-# customization: CC, RC, AR, CPPFLAGS, LDFLAGS, LIBS, CFLAGS, RCFLAGS,
|
|
|
-# ARCH[=custom], CROSSPREFIX, CURL_LDFLAGS_BIN, CURL_LDFLAGS_LIB, CURL_DLL_SUFFIX,
|
|
|
+# customization: CC, AR, RC, CPPFLAGS, LDFLAGS, LIBS, CFLAGS, RCFLAGS,
|
|
|
+# TRIPLET, CROSSPREFIX, CURL_LDFLAGS_BIN, CURL_LDFLAGS_LIB, CURL_DLL_SUFFIX,
|
|
|
# and more for individual components (see below).
|
|
|
|
|
|
-# This script is reused by 'src' and 'docs/examples' Makefile.m32 scripts.
|
|
|
-# Skip lib-specific parts when called through them.
|
|
|
-ifndef PROOT
|
|
|
-PROOT := ..
|
|
|
-
|
|
|
-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
|
|
|
+# This script is reused by 'src' and 'docs/examples' Makefile.mk scripts.
|
|
|
|
|
|
-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
|
|
|
+ifndef PROOT
|
|
|
+ PROOT := ..
|
|
|
+ LOCAL := 1
|
|
|
+endif
|
|
|
|
|
|
-TOCLEAN := $(libcurl_dll_OBJECTS)
|
|
|
-TOVCLEAN := $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY)
|
|
|
+### Common
|
|
|
|
|
|
-### Local rules
|
|
|
+ifeq ($(CC),cc)
|
|
|
+ CC := gcc
|
|
|
+endif
|
|
|
+CC := $(CROSSPREFIX)$(CC)
|
|
|
+AR := $(CROSSPREFIX)$(AR)
|
|
|
+RC ?= $(CROSSPREFIX)windres
|
|
|
|
|
|
-# Keep this at the top to act as the default target.
|
|
|
-all: $(TARGETS)
|
|
|
+# For compatibility
|
|
|
+ifeq ($(ARCH),w64)
|
|
|
+ TRIPLET := x86_64-w64-mingw32
|
|
|
+ CFLAGS += -m64
|
|
|
+ LDFLAGS += -m64
|
|
|
+ RCFLAGS += --target=pe-x86-64
|
|
|
+else ifdef ARCH
|
|
|
+ TRIPLET := i686-w64-mingw32
|
|
|
+ CFLAGS += -m32
|
|
|
+ LDFLAGS += -m32
|
|
|
+ RCFLAGS += --target=pe-i386
|
|
|
+else
|
|
|
+ TRIPLET ?= $(shell $(CC) -dumpmachine)
|
|
|
+endif
|
|
|
|
|
|
-$(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
|
|
|
- @$(call DEL, $@)
|
|
|
- $(AR) rcs $@ $(libcurl_a_OBJECTS)
|
|
|
+BIN_EXT := .exe
|
|
|
|
|
|
-$(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)
|
|
|
+ifneq ($(findstring -w,$(TRIPLET)),)
|
|
|
+ WIN32 := 1
|
|
|
+else ifneq ($(findstring msdos,$(TRIPLET)),)
|
|
|
+ # Cross-tools: https://github.com/andrewwutw/build-djgpp
|
|
|
+ MSDOS := 1
|
|
|
+else ifneq ($(findstring amigaos,$(TRIPLET)),)
|
|
|
+ # Cross-tools: https://github.com/bebbo/amiga-gcc
|
|
|
+ AMIGA := 1
|
|
|
endif
|
|
|
|
|
|
CPPFLAGS += -I. -I$(PROOT)/include
|
|
|
RCFLAGS += -I$(PROOT)/include
|
|
|
|
|
|
-CC := $(CROSSPREFIX)$(CC)
|
|
|
-AR := $(CROSSPREFIX)$(AR)
|
|
|
-RC ?= $(CROSSPREFIX)windres
|
|
|
+ifndef WIN32
|
|
|
+ DYN :=
|
|
|
+endif
|
|
|
|
|
|
-ifneq ($(ARCH),custom)
|
|
|
- # Set environment var ARCH to your architecture to override auto-detection.
|
|
|
- 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
|
|
|
+ifdef AMIGA
|
|
|
+ BIN_EXT :=
|
|
|
+endif
|
|
|
+
|
|
|
+### Deprecated settings. For compatibility.
|
|
|
+
|
|
|
+ifdef WATT_ROOT
|
|
|
+ WATT_PATH := $(realpath $(WATT_ROOT))
|
|
|
endif
|
|
|
|
|
|
### Optional features
|
|
|
|
|
|
-ifneq ($(findstring -unicode,$(CFG)),)
|
|
|
- CPPFLAGS += -DUNICODE -D_UNICODE
|
|
|
- CURL_LDFLAGS_BIN += -municode
|
|
|
+ifneq ($(findstring -debug,$(CFG)),)
|
|
|
+ CPPFLAGS += -DDEBUGBUILD
|
|
|
+ LDFLAGS += -g
|
|
|
+else
|
|
|
+ CPPFLAGS += -DNDEBUG
|
|
|
+endif
|
|
|
+ifneq ($(findstring -trackmem,$(CFG)),)
|
|
|
+ CPPFLAGS += -DCURLDEBUG
|
|
|
+endif
|
|
|
+ifneq ($(findstring -map,$(CFG)),)
|
|
|
+ MAP := 1
|
|
|
+endif
|
|
|
+
|
|
|
+ifdef WIN32
|
|
|
+ ifneq ($(findstring -unicode,$(CFG)),)
|
|
|
+ CPPFLAGS += -DUNICODE -D_UNICODE
|
|
|
+ CURL_LDFLAGS_BIN += -municode
|
|
|
+ endif
|
|
|
endif
|
|
|
|
|
|
# CPPFLAGS below are only necessary when building libcurl via 'lib' (see
|
|
@@ -139,7 +146,9 @@ ifneq ($(findstring -ssh2,$(CFG)),)
|
|
|
CPPFLAGS += -DUSE_LIBSSH2
|
|
|
CPPFLAGS += -I"$(LIBSSH2_PATH)/include"
|
|
|
_LDFLAGS += -L"$(LIBSSH2_PATH)/lib"
|
|
|
- _LDFLAGS += -L"$(LIBSSH2_PATH)/win32"
|
|
|
+ ifdef WIN32
|
|
|
+ _LDFLAGS += -L"$(LIBSSH2_PATH)/win32"
|
|
|
+ endif
|
|
|
_LIBS += -lssh2
|
|
|
else ifneq ($(findstring -libssh,$(CFG)),)
|
|
|
LIBSSH_PATH ?= $(PROOT)/../libssh
|
|
@@ -232,9 +241,11 @@ ifneq ($(findstring -zlib,$(CFG))$(ZLIB),)
|
|
|
ZLIB_PATH ?= $(PROOT)/../zlib
|
|
|
# These CPPFLAGS are also required when compiling the curl tool via 'src'.
|
|
|
CPPFLAGS += -DHAVE_LIBZ
|
|
|
- CPPFLAGS += -I"$(ZLIB_PATH)"
|
|
|
- _LDFLAGS += -L"$(ZLIB_PATH)"
|
|
|
- _LIBS += -lz
|
|
|
+ CPPFLAGS += -I"$(ZLIB_PATH)/include"
|
|
|
+ _LDFLAGS += -L"$(ZLIB_PATH)/lib"
|
|
|
+ ZLIB_LIBS ?= -lz
|
|
|
+ _LIBS += $(ZLIB_LIBS)
|
|
|
+ ZLIB := 1
|
|
|
endif
|
|
|
ifneq ($(findstring -zstd,$(CFG)),)
|
|
|
ZSTD_PATH ?= $(PROOT)/../zstd
|
|
@@ -280,7 +291,9 @@ else ifneq ($(findstring -winidn,$(CFG)),)
|
|
|
endif
|
|
|
|
|
|
ifneq ($(findstring -sspi,$(CFG)),)
|
|
|
- CPPFLAGS += -DUSE_WINDOWS_SSPI
|
|
|
+ ifdef WIN32
|
|
|
+ CPPFLAGS += -DUSE_WINDOWS_SSPI
|
|
|
+ endif
|
|
|
endif
|
|
|
ifneq ($(findstring -ipv6,$(CFG)),)
|
|
|
CPPFLAGS += -DENABLE_IPV6
|
|
@@ -289,10 +302,19 @@ ifneq ($(findstring -ldaps,$(CFG)),)
|
|
|
CPPFLAGS += -DHAVE_LDAP_SSL
|
|
|
endif
|
|
|
|
|
|
-ifeq ($(findstring -lldap,$(LIBS)),)
|
|
|
- _LIBS += -lwldap32
|
|
|
+ifneq ($(findstring -watt,$(CFG))$(MSDOS),)
|
|
|
+ WATT_PATH ?= $(PROOT)/../watt
|
|
|
+ CPPFLAGS += -I"$(WATT_PATH)/inc"
|
|
|
+ _LDFLAGS += -L"$(WATT_PATH)/lib"
|
|
|
+ _LIBS += -lwatt
|
|
|
+endif
|
|
|
+
|
|
|
+ifdef WIN32
|
|
|
+ ifeq ($(findstring -lldap,$(LIBS)),)
|
|
|
+ _LIBS += -lwldap32
|
|
|
+ endif
|
|
|
+ _LIBS += -lws2_32 -lcrypt32 -lbcrypt
|
|
|
endif
|
|
|
-_LIBS += -lws2_32 -lcrypt32 -lbcrypt
|
|
|
|
|
|
ifneq ($(findstring 11,$(subst $() ,,$(SSLLIBS))),)
|
|
|
CPPFLAGS += -DCURL_WITH_MULTI_SSL
|
|
@@ -303,26 +325,86 @@ ifndef DYN
|
|
|
LIBS += $(_LIBS)
|
|
|
endif
|
|
|
|
|
|
-### Global rules
|
|
|
+### Common rules
|
|
|
+
|
|
|
+OBJ_DIR := $(TRIPLET)
|
|
|
|
|
|
ifneq ($(findstring /sh,$(SHELL)),)
|
|
|
-DEL = rm -f $1
|
|
|
-COPY = -cp -afv $1 $2
|
|
|
+DEL = rm -f $1
|
|
|
+COPY = -cp -afv $1 $2
|
|
|
+MKDIR = mkdir -p $1
|
|
|
+RMDIR = rm -fr $1
|
|
|
+WHICH = command -v
|
|
|
else
|
|
|
-DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
|
|
-COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
|
|
|
+DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
|
|
+COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
|
|
|
+MKDIR = -md 2>NUL $(subst /,\,$1)
|
|
|
+RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
|
|
|
+WHICH = where
|
|
|
endif
|
|
|
|
|
|
all: $(TARGETS)
|
|
|
|
|
|
-%.o: %.c
|
|
|
- $(CC) -W -Wall $(CFLAGS) $(CPPFLAGS) -c $<
|
|
|
+$(OBJ_DIR):
|
|
|
+ -$(MKDIR) $(OBJ_DIR)
|
|
|
+
|
|
|
+$(OBJ_DIR)/%.o: %.c
|
|
|
+ $(CC) -W -Wall $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
|
|
|
|
|
-%.res: %.rc
|
|
|
+$(OBJ_DIR)/%.res: %.rc
|
|
|
$(RC) -O coff $(RCFLAGS) -i $< -o $@
|
|
|
|
|
|
clean:
|
|
|
@$(call DEL, $(TOCLEAN))
|
|
|
+ @$(RMDIR) $(OBJ_DIR)
|
|
|
|
|
|
distclean vclean: clean
|
|
|
@$(call DEL, $(TARGETS) $(TOVCLEAN))
|
|
|
+
|
|
|
+### Local
|
|
|
+
|
|
|
+ifdef LOCAL
|
|
|
+
|
|
|
+CPPFLAGS += -DBUILDING_LIBCURL
|
|
|
+
|
|
|
+### Sources and targets
|
|
|
+
|
|
|
+# Provides CSOURCES, HHEADERS, LIB_RCFILES
|
|
|
+include Makefile.inc
|
|
|
+
|
|
|
+vpath %.c vauth vquic vssh vtls
|
|
|
+
|
|
|
+libcurl_a_LIBRARY := libcurl.a
|
|
|
+ifdef WIN32
|
|
|
+libcurl_dll_LIBRARY := libcurl$(CURL_DLL_SUFFIX).dll
|
|
|
+libcurl_dll_a_LIBRARY := libcurl.dll.a
|
|
|
+ifdef MAP
|
|
|
+libcurl_map_LIBRARY := libcurl$(CURL_DLL_SUFFIX).map
|
|
|
+CURL_LDFLAGS_LIB += -Wl,-Map,$(libcurl_map_LIBRARY)
|
|
|
+endif
|
|
|
+endif
|
|
|
+
|
|
|
+TARGETS := $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
|
|
|
+
|
|
|
+libcurl_a_OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(notdir $(strip $(CSOURCES))))
|
|
|
+libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
|
|
|
+ifdef WIN32
|
|
|
+libcurl_dll_OBJECTS := $(libcurl_a_OBJECTS)
|
|
|
+libcurl_dll_OBJECTS += $(patsubst %.rc,$(OBJ_DIR)/%.res,$(strip $(LIB_RCFILES)))
|
|
|
+endif
|
|
|
+
|
|
|
+TOCLEAN := $(libcurl_dll_OBJECTS)
|
|
|
+TOVCLEAN := $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY) $(libcurl_map_LIBRARY)
|
|
|
+
|
|
|
+### Rules
|
|
|
+
|
|
|
+$(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)
|
|
|
+
|
|
|
+all: $(OBJ_DIR) $(TARGETS)
|
|
|
+endif
|