diff options
| -rw-r--r-- | erlang.mk | 112 |
1 files changed, 62 insertions, 50 deletions
@@ -16,7 +16,7 @@ ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST))) -ERLANG_MK_VERSION = 1.2.0-634-g2f69190-dirty +ERLANG_MK_VERSION = 1.2.0-646-g8f925a4 # Core configuration. @@ -4035,7 +4035,7 @@ define dep_autopatch $(call dep_autopatch2,$(1)); \ elif [ 0 != `grep -ci rebar $(DEPS_DIR)/$(1)/Makefile` ]; then \ $(call dep_autopatch2,$(1)); \ - elif [ -n "`find $(DEPS_DIR)/$(1)/ -type f -name \*.mk -not -name erlang.mk | xargs -r grep -i rebar`" ]; then \ + elif [ -n "`find $(DEPS_DIR)/$(1)/ -type f -name \*.mk -not -name erlang.mk -exec grep -i rebar '{}' \;`" ]; then \ $(call dep_autopatch2,$(1)); \ else \ if [ -f $(DEPS_DIR)/$(1)/erlang.mk ]; then \ @@ -4169,7 +4169,7 @@ define dep_autopatch_rebar.erl false -> ok; {Name, Source} -> {Method, Repo, Commit} = case Source of - {hex, V} -> {hex, undefined, V}; + {hex, V} -> {hex, V, undefined}; {git, R} -> {git, R, master}; {M, R, {branch, C}} -> {M, R, C}; {M, R, {ref, C}} -> {M, R, C}; @@ -4440,7 +4440,25 @@ define dep_autopatch_appsrc.erl halt() endef -define hex_fetch.erl +define dep_fetch_git + git clone -q -n -- $(call dep_repo,$(1)) $(DEPS_DIR)/$(call dep_name,$(1)); \ + cd $(DEPS_DIR)/$(call dep_name,$(1)) && git checkout -q $(call dep_commit,$(1)); +endef + +define dep_fetch_hg + hg clone -q -U $(call dep_repo,$(1)) $(DEPS_DIR)/$(call dep_name,$(1)); \ + cd $(DEPS_DIR)/$(call dep_name,$(1)) && hg update -q $(call dep_commit,$(1)); +endef + +define dep_fetch_svn + svn checkout -q $(call dep_repo,$(1)) $(DEPS_DIR)/$(call dep_name,$(1)); +endef + +define dep_fetch_cp + cp -R $(call dep_repo,$(1)) $(DEPS_DIR)/$(call dep_name,$(1)); +endef + +define dep_fetch_hex.erl ssl:start(), inets:start(), {ok, {{_, 200, _}, _, Body}} = httpc:request(get, @@ -4452,49 +4470,42 @@ define hex_fetch.erl halt() endef +# Hex only has a package version. No need to look in the Erlang.mk packages. +define dep_fetch_hex + $(call erlang,$(call dep_fetch_hex.erl,$(1),$(strip $(word 2,$(dep_$(1)))))); +endef + +define dep_fetch_fail + echo "Unknown or invalid dependency: $(1). Please consult the erlang.mk README for instructions." >&2; \ + exit 78; +endef + +# Kept for compatibility purposes with older Erlang.mk configuration. +define dep_fetch_legacy + $(warning WARNING: '$(1)' dependency configuration uses deprecated format.) \ + git clone -q -n -- $(word 1,$(dep_$(1))) $(DEPS_DIR)/$(1); \ + cd $(DEPS_DIR)/$(1) && git checkout -q $(if $(word 2,$(dep_$(1))),$(word 2,$(dep_$(1))),master); +endef + define dep_fetch - if [ "$(2)" = "git" ]; then \ - git clone -q -n -- $(3) $(DEPS_DIR)/$(1); \ - cd $(DEPS_DIR)/$(1) && git checkout -q $(4); \ - elif [ "$(2)" = "hg" ]; then \ - hg clone -q -U $(3) $(DEPS_DIR)/$(1); \ - cd $(DEPS_DIR)/$(1) && hg update -q $(4); \ - elif [ "$(2)" = "svn" ]; then \ - svn checkout -q $(3) $(DEPS_DIR)/$(1); \ - elif [ "$(2)" = "cp" ]; then \ - cp -R $(3) $(DEPS_DIR)/$(1); \ - elif [ "$(2)" = "hex" ]; then \ - $(call erlang,$(call hex_fetch.erl,$(1),$(strip $(4)))); \ - else \ - echo "Unknown or invalid dependency: $(1). Please consult the erlang.mk README for instructions." >&2; \ - exit 78; \ - fi + $(if $(dep_$(1)), \ + $(if $(dep_fetch_$(word 1,$(dep_$(1)))), \ + $(word 1,$(dep_$(1))), \ + legacy), \ + $(if $(filter $(1),$(PACKAGES)), \ + $(pkg_$(1)_fetch), \ + fail)) endef +dep_name = $(if $(dep_$(1)),$(1),$(pkg_$(1)_name)) +dep_repo = $(patsubst git://github.com/%,https://github.com/%, \ + $(if $(dep_$(1)),$(word 2,$(dep_$(1))),$(pkg_$(1)_repo))) +dep_commit = $(if $(dep_$(1)),$(word 3,$(dep_$(1))),$(pkg_$(1)_commit)) + define dep_target $(DEPS_DIR)/$(1): $(verbose) mkdir -p $(DEPS_DIR) -ifeq (,$(dep_$(1))) - $(dep_verbose) $(call dep_fetch,$(pkg_$(1)_name),$(pkg_$(1)_fetch), \ - $(patsubst git://github.com/%,https://github.com/%,$(pkg_$(1)_repo)), \ - $(pkg_$(1)_commit)) -else -ifeq (1,$(words $(dep_$(1)))) - $(dep_verbose) $(call dep_fetch,$(1),git, \ - $(patsubst git://github.com/%,https://github.com/%,$(dep_$(1))), \ - master) -else -ifeq (2,$(words $(dep_$(1)))) - $(dep_verbose) $(call dep_fetch,$(1),git, \ - $(patsubst git://github.com/%,https://github.com/%,$(word 1,$(dep_$(1)))), \ - $(word 2,$(dep_$(1)))) -else - $(dep_verbose) $(call dep_fetch,$(1),$(word 1,$(dep_$(1))), \ - $(patsubst git://github.com/%,https://github.com/%,$(word 2,$(dep_$(1)))), \ - $(word 3,$(dep_$(1)))) -endif -endif -endif + $(dep_verbose) $(call dep_fetch_$(strip $(call dep_fetch,$(1))),$(1)) $(verbose) if [ -f $(DEPS_DIR)/$(1)/configure.ac -o -f $(DEPS_DIR)/$(1)/configure.in ]; then \ echo " AUTO " $(1); \ cd $(DEPS_DIR)/$(1) && autoreconf -Wall -vif -I m4; \ @@ -4634,9 +4645,9 @@ define app_file endef endif -app-build: erlc-include ebin/$(PROJECT).app +app-build: $(EXTRA_SOURCES) erlc-include 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 $(wildcard ebin/*.beam)))))) + $(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 @@ -4651,7 +4662,7 @@ else > ebin/$(PROJECT).app endif -erlc-include: +erlc-include: $(filter %.erl %.hrl,$(EXTRA_SOURCES)) - $(verbose) if [ -d ebin/ ]; then \ find include/ src/ -type f -name \*.hrl -newer ebin -exec touch $(shell find src/ -type f -name "*.erl") \; 2>/dev/null || printf ''; \ fi @@ -4682,25 +4693,25 @@ define compile_mib endef ifneq ($(wildcard src/),) -ebin/$(PROJECT).app:: +ebin/$(PROJECT).app:: erlc-include $(verbose) mkdir -p ebin/ ifneq ($(wildcard asn1/),) -ebin/$(PROJECT).app:: $(sort $(call core_find,asn1/,*.asn1)) +ebin/$(PROJECT).app:: $(sort $(call core_find,asn1/,*.asn1) $(filter %.asn1,$(EXTRA_SOURCES))) $(verbose) mkdir -p include $(if $(strip $?),$(call compile_asn1,$?)) endif ifneq ($(wildcard mibs/),) -ebin/$(PROJECT).app:: $(sort $(call core_find,mibs/,*.mib)) +ebin/$(PROJECT).app:: $(sort $(call core_find,mibs/,*.mib) $(filter %.mib,$(EXTRA_SOURCES))) $(verbose) mkdir -p priv/mibs/ include $(if $(strip $?),$(call compile_mib,$?)) endif -ebin/$(PROJECT).app:: $(sort $(call core_find,src/,*.erl *.core)) +ebin/$(PROJECT).app:: $(sort $(call core_find,src/,*.erl *.core) $(filter %.erl %.core,$(EXTRA_SOURCES))) $(if $(strip $?),$(call compile_erl,$?)) -ebin/$(PROJECT).app:: $(sort $(call core_find,src/,*.xrl *.yrl)) +ebin/$(PROJECT).app:: $(sort $(call core_find,src/,*.xrl *.yrl) $(filter %.xrl %.yrl,$(EXTRA_SOURCES))) $(if $(strip $?),$(call compile_xyrl,$?)) endif @@ -4709,6 +4720,7 @@ clean:: clean-app clean-app: $(gen_verbose) rm -rf ebin/ priv/mibs/ \ $(addprefix include/,$(addsuffix .hrl,$(notdir $(basename $(call core_find,mibs/,*.mib))))) + $(gen_verbose) rm -f $(EXTRA_SOURCES) # Copyright (c) 2015, Viktor Söderqvist <viktor@zuiderkwast.se> # This file is part of erlang.mk and subject to the terms of the ISC License. @@ -5523,7 +5535,7 @@ EDOC_OPTS ?= # Core targets. -#docs:: distclean-edoc edoc +docs:: distclean-edoc edoc distclean:: distclean-edoc |
