diff options
author | Loïc Hoguin <[email protected]> | 2015-05-14 13:53:25 +0300 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-05-14 13:53:25 +0300 |
commit | 22f9e544248ad52ffb5756d697b2c3d0be08c630 (patch) | |
tree | f3c73dce87167b16fda2a87768fc24f387a58172 | |
parent | 1493e9394c9a44bb381cd687485f7eab128b040d (diff) | |
download | erlang.mk-22f9e544248ad52ffb5756d697b2c3d0be08c630.tar.gz erlang.mk-22f9e544248ad52ffb5756d697b2c3d0be08c630.tar.bz2 erlang.mk-22f9e544248ad52ffb5756d697b2c3d0be08c630.zip |
Get rid of the autopatch hack for proper
-rw-r--r-- | core/core.mk | 27 | ||||
-rw-r--r-- | core/deps.mk | 38 |
2 files changed, 54 insertions, 11 deletions
diff --git a/core/core.mk b/core/core.mk index 473013f..a2afe0d 100644 --- a/core/core.mk +++ b/core/core.mk @@ -32,6 +32,33 @@ gen_verbose = $(gen_verbose_$(V)) ERL = erl +A0 -noinput -boot start_clean +# Platform detection. +# @todo Add Windows/Cygwin detection eventually. + +ifeq ($(PLATFORM),) +UNAME_S := $(shell uname -s) + +ifeq ($(UNAME_S),Linux) +PLATFORM = linux +else ifeq ($(UNAME_S),Darwin) +PLATFORM = darwin +else ifeq ($(UNAME_S),SunOS) +PLATFORM = solaris +else ifeq ($(UNAME_S),GNU) +PLATFORM = gnu +else ifeq ($(UNAME_S),FreeBSD) +PLATFORM = freebsd +else ifeq ($(UNAME_S),NetBSD) +PLATFORM = netbsd +else ifeq ($(UNAME_S),OpenBSD) +PLATFORM = openbsd +else +$(error Unable to detect platform. Please open a ticket with the output of uname -a.) +endif + +export PLATFORM +endif + # Core targets. ifneq ($(words $(MAKECMDGOALS)),1) 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 |