1616
1717ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST ) ) )
1818
19- ERLANG_MK_VERSION = 2.0.0-pre.2-207-g9e9b7d2
19+ ERLANG_MK_VERSION = 2.0.0-pre.2-220-g7a200f5
2020
2121# Make 3.81 and 3.82 are deprecated.
2222
@@ -4203,17 +4203,16 @@ endif
42034203# in practice only Makefile is needed so far.
42044204define dep_autopatch
42054205 if [ -f $(DEPS_DIR ) /$(1 ) /erlang.mk ]; then \
4206+ rm -rf $(DEPS_DIR ) /$1/ebin/; \
42064207 $(call erlang,$(call dep_autopatch_appsrc.erl,$(1 ) ) ) ; \
42074208 $(call dep_autopatch_erlang_mk,$(1 ) ) ; \
42084209 elif [ -f $(DEPS_DIR ) /$(1 ) /Makefile ]; then \
42094210 if [ 0 != `grep -c "include ../\w*\.mk" $(DEPS_DIR ) /$(1 ) /Makefile` ]; then \
42104211 $(call dep_autopatch2,$(1 ) ) ; \
4211- elif [ 0 != `grep -ci rebar $(DEPS_DIR ) /$(1 ) /Makefile` ]; then \
4212+ elif [ 0 != `grep -ci "^[^ # ].* rebar" $(DEPS_DIR)/$(1)/Makefile` ]; then \
42124213 $(call dep_autopatch2,$(1)); \
4213- elif [ -n "`find $(DEPS_DIR ) /$(1 ) / -type f -name \*.mk -not -name erlang.mk -exec grep -i rebar '{}' \;`" ]; then \
4214+ elif [ -n "`find $(DEPS_DIR)/$(1)/ -type f -name \*.mk -not -name erlang.mk -exec grep -i "^[^#].* rebar" '{}' \;`" ]; then \
42144215 $(call dep_autopatch2,$(1)); \
4215- else \
4216- $(call erlang,$(call dep_autopatch_app.erl,$(1 ) ) ) ; \
42174216 fi \
42184217 else \
42194218 if [ ! -d $(DEPS_DIR)/$(1)/src/ ]; then \
@@ -4225,6 +4224,8 @@ define dep_autopatch
42254224endef
42264225
42274226define dep_autopatch2
4227+ mv -n $(DEPS_DIR ) /$1/ebin/$1.app $(DEPS_DIR ) /$1/src/$1.app.src; \
4228+ rm -f $(DEPS_DIR ) /$1/ebin/$1.app; \
42284229 if [ -f $(DEPS_DIR ) /$1/src/$1.app.src.script ]; then \
42294230 $(call erlang,$(call dep_autopatch_appsrc_script.erl,$(1 ) ) ) ; \
42304231 fi; \
@@ -4536,22 +4537,6 @@ define dep_autopatch_rebar.erl
45364537 halt()
45374538endef
45384539
4539- define dep_autopatch_app.erl
4540- UpdateModules = fun(App) ->
4541- case filelib:is_regular(App) of
4542- false -> ok;
4543- true ->
4544- {ok, [{application, '$(1 ) ', L0}]} = file:consult(App),
4545- Mods = filelib:fold_files("$(call core_native_path,$(DEPS_DIR ) /$1/src) ", "\\\\.erl$$", true,
4546- fun (F, Acc) -> [list_to_atom(filename:rootname(filename:basename(F)))|Acc] end, []),
4547- L = lists:keystore(modules, 1, L0, {modules, Mods}),
4548- ok = file:write_file(App, io_lib:format("~p.~n", [{application, '$(1 ) ', L}]))
4549- end
4550- end,
4551- UpdateModules("$(call core_native_path,$(DEPS_DIR ) /$1/ebin/$1.app) "),
4552- halt()
4553- endef
4554-
45554540define dep_autopatch_appsrc_script.erl
45564541 AppSrc = "$(call core_native_path,$(DEPS_DIR ) /$1/src/$1.app.src) ",
45574542 AppSrcScript = AppSrc ++ ".script",
@@ -4828,6 +4813,8 @@ COMPILE_FIRST_PATHS = $(addprefix src/,$(addsuffix .erl,$(COMPILE_FIRST)))
48284813ERLC_EXCLUDE ?=
48294814ERLC_EXCLUDE_PATHS = $(addprefix src/,$(addsuffix .erl,$(ERLC_EXCLUDE ) ) )
48304815
4816+ ERLC_ASN1_OPTS ?=
4817+
48314818ERLC_MIB_OPTS ?=
48324819COMPILE_MIB_FIRST ?=
48334820COMPILE_MIB_FIRST_PATHS = $(addprefix mibs/,$(addsuffix .mib,$(COMPILE_MIB_FIRST ) ) )
@@ -4877,7 +4864,7 @@ endif
48774864
48784865ifeq ($(wildcard src/$(PROJECT_MOD ) .erl) ,)
48794866define app_file
4880- {application, $(PROJECT ) , [
4867+ {application, ' $(PROJECT ) ' , [
48814868 {description, "$(PROJECT_DESCRIPTION ) "},
48824869 {vsn, "$(PROJECT_VERSION ) "},$(if $(IS_DEP ) ,
48834870 {id$(comma )$(space ) "$(1 ) "}$(comma ) )
@@ -4889,7 +4876,7 @@ define app_file
48894876endef
48904877else
48914878define app_file
4892- {application, $(PROJECT ) , [
4879+ {application, ' $(PROJECT ) ' , [
48934880 {description, "$(PROJECT_DESCRIPTION ) "},
48944881 {vsn, "$(PROJECT_VERSION ) "},$(if $(IS_DEP ) ,
48954882 {id$(comma )$(space ) "$(1 ) "}$(comma ) )
@@ -4920,7 +4907,7 @@ ERL_FILES += $(addprefix src/,$(patsubst %.asn1,%.erl,$(notdir $(ASN1_FILES))))
49204907
49214908define compile_asn1
49224909 $(verbose ) mkdir -p include/
4923- $(asn1_verbose ) erlc -v -I include/ -o asn1/ +noobj $(1 )
4910+ $(asn1_verbose ) erlc -v -I include/ -o asn1/ +noobj $(ERLC_ASN1_OPTS ) $( 1 )
49244911 $(verbose ) mv asn1/*.erl src/
49254912 $(verbose ) mv asn1/*.hrl include/
49264913 $(verbose ) mv asn1/*.asn1db include/
@@ -5052,7 +5039,7 @@ $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES):
50525039ebin/$(PROJECT ) .app :: $(ERLANG_MK_TMP ) /last-makefile-change
50535040endif
50545041
5055- - include $(PROJECT ) .d
5042+ include $(wildcard $( PROJECT ) .d)
50565043
50575044ebin/$(PROJECT ) .app :: ebin/
50585045
@@ -5277,6 +5264,7 @@ MAN_VERSION ?= $(PROJECT_VERSION)
52775264define asciidoc2man.erl
52785265try
52795266 [begin
5267+ io:format(" ADOC ~s~n", [F]),
52805268 ok = asciideck:to_manpage(asciideck:parse_file(F), # {
52815269 compress => gzip,
52825270 outdir => filename:dirname(F),
@@ -5285,7 +5273,8 @@ try
52855273 })
52865274 end || F <- [$(shell echo $(addprefix $(comma ) \",$(addsuffix \",$1) ) | sed 's/^.//') ]],
52875275 halt(0)
5288- catch _:_ ->
5276+ catch C:E ->
5277+ io:format("Exception ~p:~p~nStacktrace: ~p~n", [C, E, erlang:get_stacktrace()]),
52895278 halt(1)
52905279end.
52915280endef
@@ -6123,6 +6112,7 @@ CT_SUITES := $(sort $(subst _SUITE.erl,,$(notdir $(call core_find,$(TEST_DIR)/,*
61236112endif
61246113endif
61256114CT_SUITES ?=
6115+ CT_LOGS_DIR ?= $(CURDIR ) /logs
61266116
61276117# Core targets.
61286118
@@ -6145,13 +6135,13 @@ CT_RUN = ct_run \
61456135 -noinput \
61466136 -pa $(CURDIR ) /ebin $(DEPS_DIR ) /*/ebin $(APPS_DIR ) /*/ebin $(TEST_DIR ) \
61476137 -dir $(TEST_DIR ) \
6148- -logdir $(CURDIR ) /logs
6138+ -logdir $(CT_LOGS_DIR )
61496139
61506140ifeq ($(CT_SUITES ) ,)
61516141ct : $(if $(IS_APP ) ,,apps-ct)
61526142else
61536143ct : test-build $(if $(IS_APP ) ,,apps-ct)
6154- $(verbose ) mkdir -p $(CURDIR ) /logs/
6144+ $(verbose ) mkdir -p $(CT_LOGS_DIR )
61556145 $(gen_verbose ) $(CT_RUN ) -sname ct_$(PROJECT ) -suite $(addsuffix _SUITE,$(CT_SUITES ) ) $(CT_OPTS )
61566146endif
61576147
@@ -6179,14 +6169,14 @@ endif
61796169
61806170define ct_suite_target
61816171ct-$(1 ) : test-build
6182- $(verbose ) mkdir -p $(CURDIR ) /logs/
6172+ $(verbose ) mkdir -p $(CT_LOGS_DIR )
61836173 $(gen_verbose ) $(CT_RUN ) -sname ct_$(PROJECT ) -suite $(addsuffix _SUITE,$(1 ) ) $(CT_EXTRA ) $(CT_OPTS )
61846174endef
61856175
61866176$(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
61876177
61886178distclean-ct :
6189- $(gen_verbose ) rm -rf $(CURDIR ) /logs/
6179+ $(gen_verbose ) rm -rf $(CT_LOGS_DIR )
61906180
61916181# Copyright (c) 2013-2016, Loïc Hoguin <[email protected] >61926182# This file is part of erlang.mk and subject to the terms of the ISC License.
@@ -6232,8 +6222,10 @@ define filter_opts.erl
62326222endef
62336223
62346224$(DIALYZER_PLT ) : deps app
6235- $(verbose ) dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS ) $(OTP_DEPS ) $(LOCAL_DEPS ) \
6236- ` test -f $( ERLANG_MK_TMP) /deps.log && cat $( ERLANG_MK_TMP) /deps.log`
6225+ $(eval DEPS_LOG := $(shell test -f $(ERLANG_MK_TMP ) /deps.log && \
6226+ while read p; do test -d $$ p/ebin && echo $$ p/ebin; done < $(ERLANG_MK_TMP ) /deps.log))
6227+ $(verbose ) dialyzer --build_plt --apps erts kernel stdlib \
6228+ $(PLT_APPS ) $(OTP_DEPS ) $(LOCAL_DEPS ) $(DEPS_LOG )
62376229
62386230plt : $(DIALYZER_PLT )
62396231
@@ -6319,7 +6311,7 @@ escript:: escript-zip
63196311 $(verbose ) chmod +x $(ESCRIPT_FILE )
63206312
63216313distclean-escript :
6322- $(gen_verbose ) rm -f $(ESCRIPT_NAME )
6314+ $(gen_verbose ) rm -f $(ESCRIPT_FILE )
63236315
63246316# Copyright (c) 2015-2016, Loïc Hoguin <[email protected] >63256317# Copyright (c) 2014, Enrique Fernandez <[email protected] >@@ -6495,6 +6487,20 @@ build-shell-deps: $(ALL_SHELL_DEPS_DIRS)
64956487shell : build-shell-deps
64966488 $(gen_verbose ) $(SHELL_ERL ) -pa $(SHELL_PATHS ) $(SHELL_OPTS )
64976489
6490+ # Copyright (c) 2017, Jean-Sébastien Pédron <[email protected] >6491+ # This file is contributed to erlang.mk and subject to the terms of the ISC License.
6492+
6493+ .PHONY : show-ERL_LIBS show-ERLC_OPTS show-TEST_ERLC_OPTS
6494+
6495+ show-ERL_LIBS :
6496+ @echo $(ERL_LIBS )
6497+
6498+ show-ERLC_OPTS :
6499+ @$(foreach opt,$(ERLC_OPTS ) -pa ebin -I include,echo "$(opt ) ";)
6500+
6501+ show-TEST_ERLC_OPTS :
6502+ @$(foreach opt,$(TEST_ERLC_OPTS ) -pa ebin -I include,echo "$(opt ) ";)
6503+
64986504# Copyright (c) 2015-2016, Loïc Hoguin <[email protected] >64996505# This file is part of erlang.mk and subject to the terms of the ISC License.
65006506
0 commit comments