@@ -470,6 +470,11 @@ include shared.mak
470
470
#
471
471
# CURL_LDFLAGS=-lcurl
472
472
#
473
+ # Define LAZYLOAD_LIBCURL to dynamically load the libcurl; This can be useful
474
+ # if Multiple libcurl versions exist (with different file names) that link to
475
+ # various SSL/TLS backends, to support the `http.sslBackend` runtime switch in
476
+ # such a scenario.
477
+ #
473
478
# === Optional library: libpcre2 ===
474
479
#
475
480
# Define USE_LIBPCRE if you have and want to use libpcre. Various
@@ -1663,10 +1668,19 @@ else
1663
1668
CURL_LIBCURL =
1664
1669
endif
1665
1670
1666
- ifndef CURL_LDFLAGS
1667
- CURL_LDFLAGS = $(eval CURL_LDFLAGS := $$(shell $$(CURL_CONFIG) --libs))$(CURL_LDFLAGS)
1671
+ ifdef LAZYLOAD_LIBCURL
1672
+ LAZYLOAD_LIBCURL_OBJ = compat/lazyload-curl.o
1673
+ OBJECTS += $(LAZYLOAD_LIBCURL_OBJ)
1674
+ # The `CURL_STATICLIB` constant must be defined to avoid seeing the functions
1675
+ # declared as DLL imports
1676
+ CURL_CFLAGS = -DCURL_STATICLIB
1677
+ CURL_LIBCURL = -ldl
1678
+ else
1679
+ ifndef CURL_LDFLAGS
1680
+ CURL_LDFLAGS = $(eval CURL_LDFLAGS := $$(shell $$(CURL_CONFIG) --libs))$(CURL_LDFLAGS)
1681
+ endif
1682
+ CURL_LIBCURL += $(CURL_LDFLAGS)
1668
1683
endif
1669
- CURL_LIBCURL += $(CURL_LDFLAGS)
1670
1684
1671
1685
ifndef CURL_CFLAGS
1672
1686
CURL_CFLAGS = $(eval CURL_CFLAGS := $$(shell $$(CURL_CONFIG) --cflags))$(CURL_CFLAGS)
@@ -1687,7 +1701,7 @@ else
1687
1701
endif
1688
1702
ifdef USE_CURL_FOR_IMAP_SEND
1689
1703
BASIC_CFLAGS += -DUSE_CURL_FOR_IMAP_SEND
1690
- IMAP_SEND_BUILDDEPS = http.o
1704
+ IMAP_SEND_BUILDDEPS = http.o $(LAZYLOAD_LIBCURL_OBJ)
1691
1705
IMAP_SEND_LDFLAGS += $(CURL_LIBCURL)
1692
1706
endif
1693
1707
ifndef NO_EXPAT
@@ -2893,10 +2907,10 @@ git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)
2893
2907
$(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) \
2894
2908
$(IMAP_SEND_LDFLAGS ) $(LIBS )
2895
2909
2896
- git-http-fetch$X : http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS )
2910
+ git-http-fetch$X : http.o http-walker.o http-fetch.o $( LAZYLOAD_LIBCURL_OBJ ) GIT-LDFLAGS $(GITLIBS )
2897
2911
$(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) \
2898
2912
$(CURL_LIBCURL ) $(LIBS )
2899
- git-http-push$X : http.o http-push.o GIT-LDFLAGS $(GITLIBS )
2913
+ git-http-push$X : http.o http-push.o $( LAZYLOAD_LIBCURL_OBJ ) GIT-LDFLAGS $(GITLIBS )
2900
2914
$(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) \
2901
2915
$(CURL_LIBCURL ) $(EXPAT_LIBEXPAT ) $(LIBS )
2902
2916
@@ -2906,7 +2920,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
2906
2920
ln -s $< $@ 2> /dev/null || \
2907
2921
cp $< $@
2908
2922
2909
- $(REMOTE_CURL_PRIMARY ) : remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS )
2923
+ $(REMOTE_CURL_PRIMARY ) : remote-curl.o http.o http-walker.o $( LAZYLOAD_LIBCURL_OBJ ) GIT-LDFLAGS $(GITLIBS )
2910
2924
$(QUIET_LINK )$(CC ) $(ALL_CFLAGS ) -o $@ $(ALL_LDFLAGS ) $(filter % .o,$^ ) \
2911
2925
$(CURL_LIBCURL ) $(EXPAT_LIBEXPAT ) $(LIBS )
2912
2926
0 commit comments