aboutsummaryrefslogtreecommitdiffstats
path: root/core/deps.mk
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-05-14 13:53:25 +0300
committerLoïc Hoguin <[email protected]>2015-05-14 13:53:25 +0300
commit22f9e544248ad52ffb5756d697b2c3d0be08c630 (patch)
treef3c73dce87167b16fda2a87768fc24f387a58172 /core/deps.mk
parent1493e9394c9a44bb381cd687485f7eab128b040d (diff)
downloaderlang.mk-22f9e544248ad52ffb5756d697b2c3d0be08c630.tar.gz
erlang.mk-22f9e544248ad52ffb5756d697b2c3d0be08c630.tar.bz2
erlang.mk-22f9e544248ad52ffb5756d697b2c3d0be08c630.zip
Get rid of the autopatch hack for proper
Diffstat (limited to 'core/deps.mk')
-rw-r--r--core/deps.mk38
1 files changed, 27 insertions, 11 deletions
diff --git a/core/deps.mk b/core/deps.mk
index bae195b..24eea71 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -99,7 +99,9 @@ define dep_autopatch_gen
endef
define dep_autopatch_rebar
- rm -f $(DEPS_DIR)/$(1)/Makefile; \
+ if [ -f $(DEPS_DIR)/$(1)/Makefile ]; then \
+ mv $(DEPS_DIR)/$(1)/Makefile $(DEPS_DIR)/$(1)/Makefile.orig.mk; \
+ fi; \
$(call erlang,$(call dep_autopatch_rebar.erl,$(1))); \
$(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
endef
@@ -109,6 +111,9 @@ define dep_autopatch_rebar.erl
Write = fun (Text) ->
file:write_file("$(DEPS_DIR)/$(1)/Makefile", Text, [append])
end,
+ Escape = fun (Text) ->
+ re:replace(Text, "\\\\$$$$", "\$$$$$$$$", [global, {return, list}])
+ end,
Write("ERLC_OPTS = +debug_info\n\n"),
fun() ->
File = case lists:keyfind(deps, 1, Conf) of
@@ -136,32 +141,43 @@ define dep_autopatch_rebar.erl
fun() ->
case lists:keyfind(port_env, 1, Conf) of
{_, Vars} ->
- [Write(K ++ " = $$$$\(shell echo " ++ re:replace(V, "\\\\$$$$", "\$$$$$$$$", [global, {return, list}]) ++ "\)\n")
- || {K, V} <- Vars],
+ [Write(K ++ " = $$$$\(shell echo " ++ Escape(V) ++ "\)\n") || {K, V} <- Vars],
Write("CFLAGS += $$$$\(DRV_CFLAGS\)\n"),
Write("CXXFLAGS += $$$$\(DRV_CFLAGS\)\n"),
Write("LDFLAGS += $$$$\(DRV_LDFLAGS\)\n");
_ -> ok
end
end(),
+ Write("\n\nrebar_dep: pre-deps deps pre-app app\n"),
+ Write("\npre-deps::\n"),
+ Write("\npre-app::\n"),
fun() ->
case lists:keyfind(pre_hooks, 1, Conf) of
false -> ok;
{_, Hooks} ->
[case H of
{'get-deps', Command} ->
- Write("\npre::\n\t" ++ Command ++ "\n");
+ Write("\npre-deps::\n\t" ++ Escape(Command) ++ "\n");
{compile, Command} ->
- Write("\npre::\n\t" ++ Command ++ "\n");
+ Write("\npre-app::\n\t" ++ Escape(Command) ++ "\n");
+ {Regex, compile, Command0} ->
+ case re:run("$(PLATFORM)", Regex, [{capture, none}]) of
+ match ->
+ Command = case Command0 of
+ "make -C" ++ _ -> Escape(Command0);
+ "gmake -C" ++ _ -> Escape(Command0);
+ "make " ++ Command1 -> "make -f Makefile.orig.mk " ++ Escape(Command1);
+ "gmake " ++ Command1 -> "gmake -f Makefile.orig.mk " ++ Escape(Command1);
+ _ -> Command0
+ end,
+ Write("\npre-app::\n\t" ++ Command ++ "\n");
+ nomatch ->
+ ok
+ end;
_ -> ok
- end || H <- Hooks],
- Write("\npre:: deps app\n\n")
+ end || H <- Hooks]
end
end(),
- case $(1) of
- proper -> Write("\n# Proper hack.\napp::\n\t./write_compile_flags include/compile_flags.hrl\n");
- _ -> ok
- end,
Write("\ninclude ../../erlang.mk"),
halt()
endef