aboutsummaryrefslogtreecommitdiffstats
path: root/core/erlc.mk
diff options
context:
space:
mode:
Diffstat (limited to 'core/erlc.mk')
-rw-r--r--core/erlc.mk74
1 files changed, 41 insertions, 33 deletions
diff --git a/core/erlc.mk b/core/erlc.mk
index 80affca..fbba7ae 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -40,13 +40,15 @@ asn1_verbose = $(asn1_verbose_$(V))
mib_verbose_0 = @echo " MIB " $(filter %.bin %.mib,$(?F));
mib_verbose = $(mib_verbose_$(V))
+ifneq ($(wildcard src/),)
+
# Targets.
ifeq ($(wildcard ebin/test),)
-app::
+app:: $(PROJECT).d
$(verbose) $(MAKE) --no-print-directory app-build
else
-app:: clean
+app:: clean $(PROJECT).d
$(verbose) $(MAKE) --no-print-directory app-build
endif
@@ -55,7 +57,7 @@ define app_file
{application, $(PROJECT), [
{description, "$(PROJECT_DESCRIPTION)"},
{vsn, "$(PROJECT_VERSION)"},
- {id, "$(1)"},
+ $(if $(IS_DEP),{id$(comma)$(space)"$(1)"}$(comma))
{modules, [$(call comma_list,$(2))]},
{registered, []},
{applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(DEPS))]}
@@ -66,7 +68,7 @@ define app_file
{application, $(PROJECT), [
{description, "$(PROJECT_DESCRIPTION)"},
{vsn, "$(PROJECT_VERSION)"},
- {id, "$(1)"},
+ $(if $(IS_DEP),{id$(comma)$(space)"$(1)"}$(comma))
{modules, [$(call comma_list,$(2))]},
{registered, [$(call comma_list,$(PROJECT)_sup $(PROJECT_REGISTERED))]},
{applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(DEPS))]},
@@ -76,25 +78,10 @@ endef
endif
app-build: ebin/$(PROJECT).app
- $(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true))
- $(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename $(shell find ebin -type f -name *.beam))))))
-ifeq ($(wildcard src/$(PROJECT).app.src),)
- $(app_verbose) echo $(subst $(newline),,$(subst ",\",$(call app_file,$(GITDESCRIBE),$(MODULES)))) \
- > ebin/$(PROJECT).app
-else
- $(verbose) if [ -z "$$(grep -E '^[^%]*{\s*modules\s*,' src/$(PROJECT).app.src)" ]; then \
- echo "Empty modules entry not found in $(PROJECT).app.src. Please consult the erlang.mk README for instructions." >&2; \
- exit 1; \
- fi
- $(appsrc_verbose) cat src/$(PROJECT).app.src \
- | sed "s/{[[:space:]]*modules[[:space:]]*,[[:space:]]*\[\]}/{modules, \[$(call comma_list,$(MODULES))\]}/" \
- | sed "s/{id,[[:space:]]*\"git\"}/{id, \"$(GITDESCRIBE)\"}/" \
- > ebin/$(PROJECT).app
-endif
+ $(verbose) echo -n
# Source files.
-ifneq ($(wildcard src/),)
ERL_FILES = $(sort $(call core_find,src/,*.erl))
CORE_FILES = $(sort $(call core_find,src/,*.core))
@@ -121,10 +108,10 @@ endif
ifneq ($(wildcard mibs/),)
MIB_FILES = $(sort $(call core_find,mibs/,*.mib))
-$(PROJECT).d:: $(MIB_FILES)
+$(PROJECT).d:: $(COMPILE_MIB_FIRST_PATHS) $(MIB_FILES)
$(verbose) mkdir -p include/ priv/mibs/
- $(mib_verbose) erlc -v $(ERLC_MIB_OPTS) -o priv/mibs/ -I priv/mibs/ $(COMPILE_MIB_FIRST_PATHS) $(MIB_FILES)
- $(mib_verbose) erlc -o include/ -- priv/mibs/*.bin
+ $(mib_verbose) erlc -v $(ERLC_MIB_OPTS) -o priv/mibs/ -I priv/mibs/ $?
+ $(mib_verbose) erlc -o include/ -- $(addprefix priv/mibs/,$(patsubst %.mib,%.bin,$(notdir $?)))
endif
# Leex and Yecc files.
@@ -170,7 +157,7 @@ define makedep.erl
end
end,
Depend = [begin
- case epp:parse_file(F, [{includes, ["include/"]}]) of
+ case epp:parse_file(F, ["include/"], []) of
{ok, Forms} ->
Deps = lists:usort(lists:foldl(fun
({attribute, _, behavior, Dep}, Acc) -> Add(Dep, Acc);
@@ -179,7 +166,10 @@ define makedep.erl
({attribute, _, file, {Dep, _}}, Acc) -> AddHd(Dep, Acc);
(_, Acc) -> Acc
end, [], Forms)),
- [F, ":", [[" ", D] || D <- Deps], "\n", CompileFirst(Deps)];
+ case Deps of
+ [] -> "";
+ _ -> [F, "::", [[" ", D] || D <- Deps], "; @touch \$$@\n", CompileFirst(Deps)]
+ end;
{error, enoent} ->
[]
end
@@ -188,12 +178,16 @@ define makedep.erl
halt()
endef
+ifeq ($(if $(NO_MAKEDEP),$(wildcard $(PROJECT).d),),)
$(PROJECT).d:: $(ERL_FILES) $(call core_find,include/,*.hrl)
$(makedep_verbose) $(call erlang,$(call makedep.erl,$@))
+endif
-include $(PROJECT).d
-ebin/$(PROJECT).app:: $(PROJECT).d
+ebin/$(PROJECT).app:: ebin/
+
+ebin/:
$(verbose) mkdir -p ebin/
define compile_erl
@@ -203,16 +197,30 @@ endef
ebin/$(PROJECT).app:: $(ERL_FILES) $(CORE_FILES)
$(if $(strip $?),$(call compile_erl,$?))
-
-$(sort $(ERL_FILES) $(CORE_FILES)):
- @touch $@
+ $(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true))
+ $(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename \
+ $(filter-out $(ERLC_EXCLUDE_PATHS),$(ERL_FILES) $(CORE_FILES)))))))
+ifeq ($(wildcard src/$(PROJECT).app.src),)
+ $(app_verbose) echo "$(subst $(newline),,$(subst ",\",$(call app_file,$(GITDESCRIBE),$(MODULES))))" \
+ > ebin/$(PROJECT).app
+else
+ $(verbose) if [ -z "$$(grep -E '^[^%]*{\s*modules\s*,' src/$(PROJECT).app.src)" ]; then \
+ echo "Empty modules entry not found in $(PROJECT).app.src. Please consult the erlang.mk README for instructions." >&2; \
+ exit 1; \
+ fi
+ $(appsrc_verbose) cat src/$(PROJECT).app.src \
+ | sed "s/{[[:space:]]*modules[[:space:]]*,[[:space:]]*\[\]}/{modules, \[$(call comma_list,$(MODULES))\]}/" \
+ | sed "s/{id,[[:space:]]*\"git\"}/{id, \"$(GITDESCRIBE)\"}/" \
+ > ebin/$(PROJECT).app
endif
clean:: clean-app
clean-app:
$(gen_verbose) rm -rf $(PROJECT).d ebin/ priv/mibs/ $(XRL_ERL_FILES) $(YRL_ERL_FILES) \
- $(addprefix include/,$(patsubst %.mib,.hrl,$(notdir $(MIB_FILES)))) \
- $(addprefix include/,$(patsubst %.asn1,.hrl,$(notdir $(ASN1_FILES)))) \
- $(addprefix include/,$(patsubst %.asn1,.asn1db,$(notdir $(ASN1_FILES)))) \
- $(addprefix src/,$(patsubst %.erl,.asn1db,$(notdir $(ASN1_FILES))))
+ $(addprefix include/,$(patsubst %.mib,%.hrl,$(notdir $(MIB_FILES)))) \
+ $(addprefix include/,$(patsubst %.asn1,%.hrl,$(notdir $(ASN1_FILES)))) \
+ $(addprefix include/,$(patsubst %.asn1,%.asn1db,$(notdir $(ASN1_FILES)))) \
+ $(addprefix src/,$(patsubst %.asn1,%.erl,$(notdir $(ASN1_FILES))))
+
+endif