mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Update erlang.mk
This should fix an issue with DEPS on FreeBSD.
This commit is contained in:
parent
b57f94661f
commit
f670562a4a
3 changed files with 120 additions and 21 deletions
20
build.config
Normal file
20
build.config
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Core modules.
|
||||||
|
#
|
||||||
|
# Do *not* comment or remove them
|
||||||
|
# unless you know what you are doing!
|
||||||
|
core/core
|
||||||
|
core/deps
|
||||||
|
core/erlc
|
||||||
|
|
||||||
|
# Plugins.
|
||||||
|
#
|
||||||
|
# Comment to disable, uncomment to enable.
|
||||||
|
plugins/bootstrap
|
||||||
|
#plugins/c_src
|
||||||
|
plugins/ct
|
||||||
|
plugins/dialyzer
|
||||||
|
#plugins/edoc
|
||||||
|
#plugins/elvis
|
||||||
|
plugins/erlydtl
|
||||||
|
plugins/relx
|
||||||
|
plugins/shell
|
120
erlang.mk
vendored
120
erlang.mk
vendored
|
@ -12,7 +12,7 @@
|
||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
.PHONY: all deps app rel docs tests clean distclean help
|
.PHONY: all deps app rel docs tests clean distclean help erlang-mk
|
||||||
|
|
||||||
ERLANG_MK_VERSION = 1
|
ERLANG_MK_VERSION = 1
|
||||||
|
|
||||||
|
@ -62,9 +62,27 @@ help::
|
||||||
|
|
||||||
# Core functions.
|
# Core functions.
|
||||||
|
|
||||||
|
ifeq ($(shell which wget 2>/dev/null | wc -l), 1)
|
||||||
define core_http_get
|
define core_http_get
|
||||||
wget --no-check-certificate -O $(1) $(2)|| rm $(1)
|
wget --no-check-certificate -O $(1) $(2)|| rm $(1)
|
||||||
endef
|
endef
|
||||||
|
else
|
||||||
|
define core_http_get
|
||||||
|
erl -noshell -eval 'ssl:start(), inets:start(), case httpc:request(get, {"$(2)", []}, [{autoredirect, true}], []) of {ok, {{_, 200, _}, _, Body}} -> case file:write_file("$(1)", Body) of ok -> ok; {error, R1} -> halt(R1) end; {error, R2} -> halt(R2) end, halt(0).'
|
||||||
|
endef
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Automated update.
|
||||||
|
|
||||||
|
ERLANG_MK_BUILD_CONFIG ?= build.config
|
||||||
|
ERLANG_MK_BUILD_DIR ?= .erlang.mk.build
|
||||||
|
|
||||||
|
erlang-mk:
|
||||||
|
git clone https://github.com/ninenines/erlang.mk $(ERLANG_MK_BUILD_DIR)
|
||||||
|
if [ -f $(ERLANG_MK_BUILD_CONFIG) ]; then cp $(ERLANG_MK_BUILD_CONFIG) $(ERLANG_MK_BUILD_DIR); fi
|
||||||
|
cd $(ERLANG_MK_BUILD_DIR) && make
|
||||||
|
cp $(ERLANG_MK_BUILD_DIR)/erlang.mk ./erlang.mk
|
||||||
|
rm -rf $(ERLANG_MK_BUILD_DIR)
|
||||||
|
|
||||||
# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
|
# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
|
||||||
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
||||||
|
@ -102,7 +120,7 @@ deps:: $(ALL_DEPS_DIRS)
|
||||||
if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ] ; then \
|
if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ] ; then \
|
||||||
$(MAKE) -C $$dep ; \
|
$(MAKE) -C $$dep ; \
|
||||||
else \
|
else \
|
||||||
echo "include $(CURDIR)/erlang.mk" | $(MAKE) -f - -C $$dep ; \
|
echo "include $(CURDIR)/erlang.mk" | ERLC_OPTS=+debug_info $(MAKE) -f - -C $$dep ; \
|
||||||
fi ; \
|
fi ; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -114,7 +132,11 @@ define dep_fetch
|
||||||
if [ "$$$$VS" = "git" ]; then \
|
if [ "$$$$VS" = "git" ]; then \
|
||||||
git clone -n -- $$$$REPO $(DEPS_DIR)/$(1); \
|
git clone -n -- $$$$REPO $(DEPS_DIR)/$(1); \
|
||||||
cd $(DEPS_DIR)/$(1) && git checkout -q $$$$COMMIT; \
|
cd $(DEPS_DIR)/$(1) && git checkout -q $$$$COMMIT; \
|
||||||
|
elif [ "$$$$VS" = "hg" ]; then \
|
||||||
|
hg clone -U $$$$REPO $(DEPS_DIR)/$(1); \
|
||||||
|
cd $(DEPS_DIR)/$(1) && hg update -q $$$$COMMIT; \
|
||||||
else \
|
else \
|
||||||
|
echo "Unknown or invalid dependency: $(1). Please consult the erlang.mk README for instructions." >&2; \
|
||||||
exit 78; \
|
exit 78; \
|
||||||
fi
|
fi
|
||||||
endef
|
endef
|
||||||
|
@ -122,15 +144,15 @@ endef
|
||||||
define dep_target
|
define dep_target
|
||||||
$(DEPS_DIR)/$(1):
|
$(DEPS_DIR)/$(1):
|
||||||
@mkdir -p $(DEPS_DIR)
|
@mkdir -p $(DEPS_DIR)
|
||||||
@if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
|
|
||||||
ifeq (,$(dep_$(1)))
|
ifeq (,$(dep_$(1)))
|
||||||
DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);) \
|
@if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
|
||||||
|
@DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);); \
|
||||||
VS=$$$$(echo $$$$DEPPKG | cut -d " " -f1); \
|
VS=$$$$(echo $$$$DEPPKG | cut -d " " -f1); \
|
||||||
REPO=$$$$(echo $$$$DEPPKG | cut -d " " -f2); \
|
REPO=$$$$(echo $$$$DEPPKG | cut -d " " -f2); \
|
||||||
COMMIT=$$$$(echo $$$$DEPPKG | cut -d " " -f3); \
|
COMMIT=$$$$(echo $$$$DEPPKG | cut -d " " -f3); \
|
||||||
$(call dep_fetch,$(1))
|
$(call dep_fetch,$(1))
|
||||||
else
|
else
|
||||||
VS=$(word 1,$(dep_$(1))); \
|
@VS=$(word 1,$(dep_$(1))); \
|
||||||
REPO=$(word 2,$(dep_$(1))); \
|
REPO=$(word 2,$(dep_$(1))); \
|
||||||
COMMIT=$(word 3,$(dep_$(1))); \
|
COMMIT=$(word 3,$(dep_$(1))); \
|
||||||
$(call dep_fetch,$(1))
|
$(call dep_fetch,$(1))
|
||||||
|
@ -145,7 +167,7 @@ distclean-deps:
|
||||||
# Packages related targets.
|
# Packages related targets.
|
||||||
|
|
||||||
$(PKG_FILE2):
|
$(PKG_FILE2):
|
||||||
$(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL))
|
@$(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL))
|
||||||
|
|
||||||
pkg-list: $(PKG_FILE2)
|
pkg-list: $(PKG_FILE2)
|
||||||
@cat $(PKG_FILE2) | awk 'BEGIN { FS = "\t" }; { print \
|
@cat $(PKG_FILE2) | awk 'BEGIN { FS = "\t" }; { print \
|
||||||
|
@ -166,8 +188,10 @@ pkg-search:
|
||||||
$(error Usage: make pkg-search q=STRING)
|
$(error Usage: make pkg-search q=STRING)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(PKG_FILE2),$(CURDIR)/.erlang.mk.packages.v2)
|
||||||
distclean-pkg:
|
distclean-pkg:
|
||||||
$(gen_verbose) rm -f $(PKG_FILE2)
|
$(gen_verbose) rm -f $(PKG_FILE2)
|
||||||
|
endif
|
||||||
|
|
||||||
help::
|
help::
|
||||||
@printf "%s\n" "" \
|
@printf "%s\n" "" \
|
||||||
|
@ -200,11 +224,17 @@ xyrl_verbose = $(xyrl_verbose_$(V))
|
||||||
|
|
||||||
# Core targets.
|
# Core targets.
|
||||||
|
|
||||||
app:: ebin/$(PROJECT).app
|
app:: erlc-include ebin/$(PROJECT).app
|
||||||
$(eval MODULES := $(shell find ebin -type f -name \*.beam \
|
$(eval MODULES := $(shell find ebin -type f -name \*.beam \
|
||||||
| sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//'))
|
| sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//'))
|
||||||
|
@if [ -z "$$(grep -E '^[^%]*{modules,' 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
|
||||||
|
$(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true))
|
||||||
$(appsrc_verbose) cat src/$(PROJECT).app.src \
|
$(appsrc_verbose) cat src/$(PROJECT).app.src \
|
||||||
| sed "s/{modules,[[:space:]]*\[\]}/{modules, \[$(MODULES)\]}/" \
|
| sed "s/{modules,[[:space:]]*\[\]}/{modules, \[$(MODULES)\]}/" \
|
||||||
|
| sed "s/{id,[[:space:]]*\"git\"}/{id, \"$(GITDESCRIBE)\"}/" \
|
||||||
> ebin/$(PROJECT).app
|
> ebin/$(PROJECT).app
|
||||||
|
|
||||||
define compile_erl
|
define compile_erl
|
||||||
|
@ -235,6 +265,11 @@ clean:: clean-app
|
||||||
|
|
||||||
# Extra targets.
|
# Extra targets.
|
||||||
|
|
||||||
|
erlc-include:
|
||||||
|
-@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
|
||||||
|
|
||||||
clean-app:
|
clean-app:
|
||||||
$(gen_verbose) rm -rf ebin/
|
$(gen_verbose) rm -rf ebin/
|
||||||
|
|
||||||
|
@ -252,13 +287,14 @@ help::
|
||||||
" bootstrap-lib Generate a skeleton of an OTP library" \
|
" bootstrap-lib Generate a skeleton of an OTP library" \
|
||||||
" bootstrap-rel Generate the files needed to build a release" \
|
" bootstrap-rel Generate the files needed to build a release" \
|
||||||
" new t=TPL n=NAME Generate a module NAME based on the template TPL" \
|
" new t=TPL n=NAME Generate a module NAME based on the template TPL" \
|
||||||
" bootstrap-lib List available templates"
|
" list-templates List available templates"
|
||||||
|
|
||||||
# Bootstrap templates.
|
# Bootstrap templates.
|
||||||
|
|
||||||
bs_appsrc = "{application, $(PROJECT), [" \
|
bs_appsrc = "{application, $(PROJECT), [" \
|
||||||
" {description, \"\"}," \
|
" {description, \"\"}," \
|
||||||
" {vsn, \"0.1.0\"}," \
|
" {vsn, \"0.1.0\"}," \
|
||||||
|
" {id, \"git\"}," \
|
||||||
" {modules, []}," \
|
" {modules, []}," \
|
||||||
" {registered, []}," \
|
" {registered, []}," \
|
||||||
" {applications, [" \
|
" {applications, [" \
|
||||||
|
@ -271,6 +307,7 @@ bs_appsrc = "{application, $(PROJECT), [" \
|
||||||
bs_appsrc_lib = "{application, $(PROJECT), [" \
|
bs_appsrc_lib = "{application, $(PROJECT), [" \
|
||||||
" {description, \"\"}," \
|
" {description, \"\"}," \
|
||||||
" {vsn, \"0.1.0\"}," \
|
" {vsn, \"0.1.0\"}," \
|
||||||
|
" {id, \"git\"}," \
|
||||||
" {modules, []}," \
|
" {modules, []}," \
|
||||||
" {registered, []}," \
|
" {registered, []}," \
|
||||||
" {applications, [" \
|
" {applications, [" \
|
||||||
|
@ -402,7 +439,7 @@ tpl_cowboy_rest = "-module($(n))." \
|
||||||
" {upgrade, protocol, cowboy_rest}." \
|
" {upgrade, protocol, cowboy_rest}." \
|
||||||
"" \
|
"" \
|
||||||
"content_types_provided(Req, State) ->" \
|
"content_types_provided(Req, State) ->" \
|
||||||
" {[{{<<\"text\">>, <<\"html\">>, '_'}, get_html}], Req, State}." \
|
" {[{{<<\"text\">>, <<\"html\">>, '*'}, get_html}], Req, State}." \
|
||||||
"" \
|
"" \
|
||||||
"get_html(Req, State) ->" \
|
"get_html(Req, State) ->" \
|
||||||
" {<<\"<html><body>This is REST!</body></html>\">>, Req, State}."
|
" {<<\"<html><body>This is REST!</body></html>\">>, Req, State}."
|
||||||
|
@ -561,7 +598,7 @@ build-ct-deps: $(ALL_TEST_DEPS_DIRS)
|
||||||
@for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
|
@for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
|
||||||
|
|
||||||
build-ct-suites: build-ct-deps
|
build-ct-suites: build-ct-deps
|
||||||
$(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -o test/ \
|
$(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -I include/ -o test/ \
|
||||||
$(wildcard test/*.erl test/*/*.erl) -pa ebin/
|
$(wildcard test/*.erl test/*/*.erl) -pa ebin/
|
||||||
|
|
||||||
tests-ct: ERLC_OPTS = $(TEST_ERLC_OPTS)
|
tests-ct: ERLC_OPTS = $(TEST_ERLC_OPTS)
|
||||||
|
@ -603,6 +640,7 @@ DIALYZER_PLT ?= $(CURDIR)/.$(PROJECT).plt
|
||||||
export DIALYZER_PLT
|
export DIALYZER_PLT
|
||||||
|
|
||||||
PLT_APPS ?=
|
PLT_APPS ?=
|
||||||
|
DIALYZER_DIRS ?= --src -r src
|
||||||
DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions \
|
DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions \
|
||||||
-Wunmatched_returns # -Wunderspecs
|
-Wunmatched_returns # -Wunderspecs
|
||||||
|
|
||||||
|
@ -618,14 +656,20 @@ help::
|
||||||
|
|
||||||
# Plugin-specific targets.
|
# Plugin-specific targets.
|
||||||
|
|
||||||
plt: deps app
|
$(DIALYZER_PLT): deps app
|
||||||
@dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(ALL_DEPS_DIRS)
|
@dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(ALL_DEPS_DIRS)
|
||||||
|
|
||||||
|
plt: $(DIALYZER_PLT)
|
||||||
|
|
||||||
distclean-plt:
|
distclean-plt:
|
||||||
$(gen_verbose) rm -f $(DIALYZER_PLT)
|
$(gen_verbose) rm -f $(DIALYZER_PLT)
|
||||||
|
|
||||||
|
ifneq ($(wildcard $(DIALYZER_PLT)),)
|
||||||
dialyze:
|
dialyze:
|
||||||
@dialyzer --no_native --src -r src $(DIALYZER_OPTS)
|
else
|
||||||
|
dialyze: $(DIALYZER_PLT)
|
||||||
|
endif
|
||||||
|
@dialyzer --no_native $(DIALYZER_DIRS) $(DIALYZER_OPTS)
|
||||||
|
|
||||||
# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
|
# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
|
||||||
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
||||||
|
@ -656,14 +700,12 @@ endif
|
||||||
# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
|
# Copyright (c) 2013-2014, Loïc Hoguin <essen@ninenines.eu>
|
||||||
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
||||||
|
|
||||||
.PHONY: distclean-rel
|
.PHONY: relx-rel distclean-relx-rel distclean-relx
|
||||||
|
|
||||||
# Configuration.
|
# Configuration.
|
||||||
|
|
||||||
RELX_CONFIG ?= $(CURDIR)/relx.config
|
RELX_CONFIG ?= $(CURDIR)/relx.config
|
||||||
|
|
||||||
ifneq ($(wildcard $(RELX_CONFIG)),)
|
|
||||||
|
|
||||||
RELX ?= $(CURDIR)/relx
|
RELX ?= $(CURDIR)/relx
|
||||||
export RELX
|
export RELX
|
||||||
|
|
||||||
|
@ -673,14 +715,17 @@ RELX_OUTPUT_DIR ?= _rel
|
||||||
|
|
||||||
ifeq ($(firstword $(RELX_OPTS)),-o)
|
ifeq ($(firstword $(RELX_OPTS)),-o)
|
||||||
RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
|
RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
|
||||||
|
else
|
||||||
|
RELX_OPTS += -o $(RELX_OUTPUT_DIR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Core targets.
|
# Core targets.
|
||||||
|
|
||||||
rel:: distclean-rel $(RELX)
|
ifneq ($(wildcard $(RELX_CONFIG)),)
|
||||||
@$(RELX) -c $(RELX_CONFIG) $(RELX_OPTS)
|
rel:: distclean-relx-rel relx-rel
|
||||||
|
endif
|
||||||
|
|
||||||
distclean:: distclean-rel
|
distclean:: distclean-relx-rel distclean-relx
|
||||||
|
|
||||||
# Plugin-specific targets.
|
# Plugin-specific targets.
|
||||||
|
|
||||||
|
@ -692,7 +737,40 @@ endef
|
||||||
$(RELX):
|
$(RELX):
|
||||||
@$(call relx_fetch)
|
@$(call relx_fetch)
|
||||||
|
|
||||||
distclean-rel:
|
relx-rel: $(RELX)
|
||||||
$(gen_verbose) rm -rf $(RELX) $(RELX_OUTPUT_DIR)
|
@$(RELX) -c $(RELX_CONFIG) $(RELX_OPTS)
|
||||||
|
|
||||||
endif
|
distclean-relx-rel:
|
||||||
|
$(gen_verbose) rm -rf $(RELX_OUTPUT_DIR)
|
||||||
|
|
||||||
|
distclean-relx:
|
||||||
|
$(gen_verbose) rm -rf $(RELX)
|
||||||
|
|
||||||
|
# Copyright (c) 2014, M Robert Martin <rob@version2beta.com>
|
||||||
|
# This file is contributed to erlang.mk and subject to the terms of the ISC License.
|
||||||
|
|
||||||
|
.PHONY: shell
|
||||||
|
|
||||||
|
# Configuration.
|
||||||
|
|
||||||
|
SHELL_PATH ?= -pa ../$(PROJECT)/ebin $(DEPS_DIR)/*/ebin
|
||||||
|
SHELL_OPTS ?=
|
||||||
|
|
||||||
|
ALL_SHELL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(SHELL_DEPS))
|
||||||
|
|
||||||
|
# Core targets
|
||||||
|
|
||||||
|
help::
|
||||||
|
@printf "%s\n" "" \
|
||||||
|
"Shell targets:" \
|
||||||
|
" shell Run an erlang shell with SHELL_OPTS or reasonable default"
|
||||||
|
|
||||||
|
# Plugin-specific targets.
|
||||||
|
|
||||||
|
$(foreach dep,$(SHELL_DEPS),$(eval $(call dep_target,$(dep))))
|
||||||
|
|
||||||
|
build-shell-deps: $(ALL_SHELL_DEPS_DIRS)
|
||||||
|
@for dep in $(ALL_SHELL_DEPS_DIRS) ; do $(MAKE) -C $$dep ; done
|
||||||
|
|
||||||
|
shell: build-shell-deps
|
||||||
|
$(gen_verbose) erl $(SHELL_PATH) $(SHELL_OPTS)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
{application, cowboy, [
|
{application, cowboy, [
|
||||||
{description, "Small, fast, modular HTTP server."},
|
{description, "Small, fast, modular HTTP server."},
|
||||||
{vsn, "1.0.0"},
|
{vsn, "1.0.0"},
|
||||||
|
{id, "git"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [cowboy_clock, cowboy_sup]},
|
{registered, [cowboy_clock, cowboy_sup]},
|
||||||
{applications, [
|
{applications, [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue