{"thread":{"id":"36413","subject":"[PATCH v2 1/2] Makefile: use curl-config to determine curl flags","startedAt":"2014-04-15T10:40:30Z","lastAt":"2014-04-15T10:40:31Z","messageCount":2,"participants":["Dave Borowitz"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"238883","messageId":"1397558431-22417-1-git-send-email-dborowitz@google.com","threadId":"36413","inReplyTo":null,"subject":"[PATCH v2 1/2] Makefile: use curl-config to determine curl flags","fromName":"Dave Borowitz","fromEmail":"dborowitz@google.com","sentAt":"2014-04-15T10:40:30Z","receivedAt":"2014-04-15T10:40:30Z","isPatch":true,"sender":{"key":"dborowitz@google.com","avatar":"https://avatars.githubusercontent.com/u/194927?v=4"},"body":"curl-config should always be installed alongside a curl distribution,\nand its purpose is to provide flags for building against libcurl, so\nuse it instead of guessing flags and dependent libraries.\n\nAllow overriding CURL_CONFIG to a custom path to curl-config, to\ncompile against a curl installation other than the first in PATH.\n\nDepending on the set of features curl is compiled with, there may be\nmore libraries required than the previous two options of -lssl and\n-lidn. For example, with a vanilla build of libcurl-7.36.0 on Mac OS X\n10.9:\n\n$ ~/d/curl-out-7.36.0/lib/curl-config --libs\n-L/Users/dborowitz/d/curl-out-7.36.0/lib -lcurl -lgssapi_krb5 -lresolv -lldap -lz\n\nUse this only when CURLDIR is not explicitly specified, to continue\nsupporting older builds.\n\nSigned-off-by: Dave Borowitz <dborowitz@google.com>\n---\n Makefile | 35 +++++++++++++++++++++++------------\n 1 file changed, 23 insertions(+), 12 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 2128ce3..d6330bc 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -34,8 +34,12 @@ all::\n # git-http-push are not built, and you cannot use http:// and https://\n # transports (neither smart nor dumb).\n #\n+# Define CURL_CONFIG to the path to a curl-config binary other than the\n+# default 'curl-config'.\n+#\n # Define CURLDIR=/foo/bar if your curl header and library files are in\n-# /foo/bar/include and /foo/bar/lib directories.\n+# /foo/bar/include and /foo/bar/lib directories.  This overrides CURL_CONFIG,\n+# but is less robust.\n #\n # Define NO_EXPAT if you do not have expat installed.  git-http-push is\n # not built, and you cannot push using http:// and https:// transports (dumb).\n@@ -143,9 +147,11 @@ all::\n #\n # Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).\n #\n-# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).\n+# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).  Only used\n+# if CURLDIR is set.\n #\n-# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).\n+# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).  Only\n+# used if CURLDIR is set.\n #\n # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).\n #\n@@ -1121,18 +1127,23 @@ else\n \t\t# Try \"-Wl,-rpath=$(CURLDIR)/$(lib)\" in such a case.\n \t\tBASIC_CFLAGS += -I$(CURLDIR)/include\n \t\tCURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl\n+\t\tifdef NEEDS_SSL_WITH_CURL\n+\t\t\tCURL_LIBCURL += -lssl\n+\t\t\tifdef NEEDS_CRYPTO_WITH_SSL\n+\t\t\t\tCURL_LIBCURL += -lcrypto\n+\t\t\tendif\n+\t\tendif\n+\t\tifdef NEEDS_IDN_WITH_CURL\n+\t\t\tCURL_LIBCURL += -lidn\n+\t\tendif\n \telse\n-\t\tCURL_LIBCURL = -lcurl\n-\tendif\n-\tifdef NEEDS_SSL_WITH_CURL\n-\t\tCURL_LIBCURL += -lssl\n-\t\tifdef NEEDS_CRYPTO_WITH_SSL\n-\t\t\tCURL_LIBCURL += -lcrypto\n+\t\tCURL_CONFIG ?= curl-config\n+\t\tBASIC_CFLAGS += $(shell $(CURL_CONFIG) --cflags)\n+\t\tCURL_LIBCURL = $(shell $(CURL_CONFIG) --libs)\n+\t\tifeq \"$(CURL_LIBCURL)\" \"\"\n+\t\t\t$(error curl not detected; try setting CURLDIR)\n \t\tendif\n \tendif\n-\tifdef NEEDS_IDN_WITH_CURL\n-\t\tCURL_LIBCURL += -lidn\n-\tendif\n \n \tREMOTE_CURL_PRIMARY = git-remote-http$X\n \tREMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X\n-- \n1.9.1.423.g4596e3a\n"},{"id":"238884","messageId":"1397558431-22417-2-git-send-email-dborowitz@google.com","threadId":"36413","inReplyTo":"1397558431-22417-1-git-send-email-dborowitz@google.com","subject":"[PATCH v2 2/2] Makefile: allow static linking against libcurl","fromName":"Dave Borowitz","fromEmail":"dborowitz@google.com","sentAt":"2014-04-15T10:40:31Z","receivedAt":"2014-04-15T10:40:31Z","isPatch":true,"sender":{"key":"dborowitz@google.com","avatar":"https://avatars.githubusercontent.com/u/194927?v=4"},"body":"This requires more flags than can be guessed with the old-style\nCURLDIR and related options, so is only supported when curl-config is\npresent.\n\nSigned-off-by: Dave Borowitz <dborowitz@google.com>\n---\n Makefile | 16 +++++++++++++---\n 1 file changed, 13 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex d6330bc..e4c93f6 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -37,6 +37,9 @@ all::\n # Define CURL_CONFIG to the path to a curl-config binary other than the\n # default 'curl-config'.\n #\n+# Define CURL_STATIC to statically link libcurl.  Only applies if\n+# CURL_CONFIG is used.\n+#\n # Define CURLDIR=/foo/bar if your curl header and library files are in\n # /foo/bar/include and /foo/bar/lib directories.  This overrides CURL_CONFIG,\n # but is less robust.\n@@ -1139,9 +1142,16 @@ else\n \telse\n \t\tCURL_CONFIG ?= curl-config\n \t\tBASIC_CFLAGS += $(shell $(CURL_CONFIG) --cflags)\n-\t\tCURL_LIBCURL = $(shell $(CURL_CONFIG) --libs)\n-\t\tifeq \"$(CURL_LIBCURL)\" \"\"\n-\t\t\t$(error curl not detected; try setting CURLDIR)\n+\t\tifdef CURL_STATIC\n+\t\t\tCURL_LIBCURL = $(shell $(CURL_CONFIG) --static-libs)\n+\t\t\tifeq \"$(CURL_LIBCURL)\" \"\"\n+\t\t\t\t$(error libcurl not detected or not compiled with static support)\n+\t\t\tendif\n+\t\telse\n+\t\t\tCURL_LIBCURL = $(shell $(CURL_CONFIG) --libs)\n+\t\t\tifeq \"$(CURL_LIBCURL)\" \"\"\n+\t\t\t\t$(error libcurl not detected; try setting CURLDIR)\n+\t\t\tendif\n \t\tendif\n \tendif\n \n-- \n1.9.1.423.g4596e3a\n"}]}