forked from zotonic/zotonic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
116 lines (90 loc) · 4.39 KB
/
GNUmakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
ERL ?= erl
ERLC ?= $(ERL)c
APP := zotonic
# Erlang Rebar downloading
# see: https://groups.google.com/forum/?fromgroups=#!topic/erlang-programming/U0JJ3SeUv5Y
REBAR := ./rebar3
REBAR_URL := https://s3.amazonaws.com/rebar3/rebar3
REBAR_ETAG := rebar_etag
REBAR_OPTS ?=
ifneq (${https_proxy},)
PROXY_HOSTNAME=$(shell echo ${https_proxy} | awk -F ":" '{print $$2}' | cut -c 3-)
PROXY_PORT=$(shell echo ${https_proxy} | awk -F ":" '{print $$3}')
SET_HTTPS_PROXY=ok = httpc:set_options([{https_proxy, {{"${PROXY_HOSTNAME}", ${PROXY_PORT}}, []}}]),
endif
.PHONY: all upgrade-deps compile-core compile dev test update-cotonic update
# Default target - update sources and call all compile rules in succession
all: compile-core compile
@echo "Zotonic" `bin/zotonic -v` "was successfully compiled"
$(REBAR): $(REBAR_ETAG)
$(ERL) -noshell -s inets -s ssl \
-eval 'file:delete("$(REBAR)"), $(SET_HTTPS_PROXY) {ok, saved_to_file} = httpc:request(get, {"$(REBAR_URL)", []}, [{ssl, [ {verify, verify_none} ]}], [{stream, "$(REBAR)"}])' \
-s init stop
chmod +x $(REBAR)
# Use Rebar to get, update and compile dependencies
.PHONY: upgrade-deps compile-zotonic compile test
upgrade-deps: $(REBAR)
$(REBAR) $(REBAR_OPTS) upgrade --all
compile-core: $(REBAR) _build/default/lib/zotonic_core/include/zotonic.hrl
_build/default/lib/zotonic_core/include/zotonic.hrl: $(REBAR)
@echo ============================================================================
@echo ======================= Compiling Zotonic core apps =========================
@echo ============================================================================
ZOTONIC_APPS=none $(REBAR) $(REBAR_OPTS) compile
compile: $(REBAR)
@echo ============================================================================
@echo =========================== Compiling user apps ============================
@echo ============================================================================
ZOTONIC_UMBRELLA=1 $(REBAR) $(REBAR_OPTS) compile
dev:
docker-compose run --rm --service-ports zotonic sh
test: compile
bin/zotonic runtests
update:
@echo "Updating Zotonic from branch: " `git rev-parse --abbrev-ref HEAD`
@git pull
@(cd apps/zotonic_mod_base/; ./cotonic-update.sh)
update-cotonic:
@(cd apps/zotonic_mod_base/; ./cotonic-update.sh)
.PHONY: xref dialyzer
xref: $(REBAR)
./rebar3 xref
dialyzer: $(REBAR)
./rebar3 dialyzer
# Generate documentation
.PHONY: docs edocs
docs:
@echo Building HTML documentation...
cd doc && $(MAKE) stubs && $(MAKE) html
@echo HTML documentation is now available in doc/_build/html/
edocs: $(REBAR)
@echo Building reference edoc documentation...
@ZOTONIC=`pwd` bin/generate_edoc.escript
# Get ETAG from rebar3 amazon cloud and update etag file if different.
# First use if it does not exist at all
# used by "make compile" dependencies
$(REBAR_ETAG):
$(ERL) -noshell -s inets -s ssl \
-eval '$(SET_HTTPS_PROXY) case httpc:request(head, {"$(REBAR_URL)", []}, [{ssl, [ {verify, verify_none} ]},{timeout, 2000}], []) of {ok, {_, Headers,_}} -> Etag = proplists:get_value("etag", Headers), Bin = list_to_binary(Etag), case file:read_file("$(REBAR_ETAG)") of {ok, Bin} -> io:fwrite("ETag update not needed~n"); {ok, _OldEtag} -> file:write_file("$(REBAR_ETAG)", Bin); {error, enoent} -> file:write_file("$(REBAR_ETAG)", Bin); _ -> ok end, io:fwrite("Etag: ~s~n",[Etag]); Error -> io:fwrite("Failed to get rebar3 etag: ~p~n",[Error]) end' \
-s init stop
.PHONY: pull
pull:
$(ERL) -noshell -s inets -s ssl \
-eval '$(SET_HTTPS_PROXY) case httpc:request(head, {"$(REBAR_URL)", []}, [{ssl, [ {verify, verify_none} ]},{timeout, 2000}], []) of {ok, {_, Headers,_}} -> Etag = proplists:get_value("etag", Headers), Bin = list_to_binary(Etag), case file:read_file("$(REBAR_ETAG)") of {ok, Bin} -> io:fwrite("ETag update not needed~n"); {ok, _OldEtag} -> file:write_file("$(REBAR_ETAG)", Bin); {error, enoent} -> file:write_file("$(REBAR_ETAG)", Bin); _ -> ok end, io:fwrite("Etag: ~s~n",[Etag]); Error -> io:fwrite("Failed to get rebar3 etag: ~p~n",[Error]) end' \
-s init stop
# Cleaning
.PHONY: clean_logs
clean_logs:
@echo "deleting logs:"
rm -f erl_crash.dump
rm -rf priv/log/*
.PHONY: clean
clean: clean_logs $(REBAR)
@echo "cleaning ebin:"
# There could be an ebin directory left by a previous 0.x branch compilation
rm -rf ebin
$(REBAR) $(REBAR_OPTS) clean
.PHONY: dist-clean
dist-clean: clean
$(REBAR) $(REBAR_OPTS) clean -a
rm -f ./rebar3