aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/core.mk6
-rw-r--r--erlang.mk6
2 files changed, 12 insertions, 0 deletions
diff --git a/core/core.mk b/core/core.mk
index d25897b..f73ef7f 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -62,6 +62,12 @@ help::
# Core functions.
+ifeq ($(shell which wget 2>/dev/null | wc -l), 1)
define core_http_get
wget --no-check-certificate -O $(1) $(2)|| rm $(1)
endef
+else
+define core_http_get
+ erl -noshell -eval ' ssl:start(), inets:start(), case httpc:request(get, {"$(2)", []}, [{autoredirect, true}], []) of {ok, {{_V, 200, _R}, _H, Body}} -> case file:write_file("$(1)", Body) of ok -> ok ; {error, R1} -> halt(R1) end ; {error, R2} -> halt(R2) end, halt(0). '
+endef
+endif
diff --git a/erlang.mk b/erlang.mk
index f37307d..acdcb70 100644
--- a/erlang.mk
+++ b/erlang.mk
@@ -62,9 +62,15 @@ help::
# Core functions.
+ifeq ($(shell which wget 2>/dev/null | wc -l), 1)
define core_http_get
wget --no-check-certificate -O $(1) $(2)|| rm $(1)
endef
+else
+define core_http_get
+ erl -noshell -eval ' ssl:start(), inets:start(), case httpc:request(get, {"$(2)", []}, [{autoredirect, true}], []) of {ok, {{_V, 200, _R}, _H, Body}} -> case file:write_file("$(1)", Body) of ok -> ok ; {error, R1} -> halt(R1) end ; {error, R2} -> halt(R2) end, halt(0). '
+endef
+endif
# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.