blob: 9d6fcdb004fdf7ed93b3544b093b23f41bce8055 [file] [log] [blame]
Anthony F. Molinaroef164202010-09-07 03:35:30 +00001# ----------------------------------------------------
2# Application version
3# ----------------------------------------------------
4
5APP_NAME=$(PACKAGE_NAME)
6VSN=$(PACKAGE_VERSION)
7
8# ----------------------------------------------------
9# FLAGS
10# ----------------------------------------------------
11
12ERL_FLAGS =
13ERL_INCLUDE = -I../include
14ERL_BEHAV_PATH = -pz ../ebin
15ERL_COMPILE_FLAGS = $(ERL_INCLUDE) $(ERL_BEHAV_PATH)
16
17EBIN ?= ../ebin
18ESRC ?= .
19EMULATOR = beam
20
21ERLC_WFLAGS = -W
22ERLC = erlc $(ERLC_WFLAGS) $(ERLC_FLAGS)
23ERL = erl -boot start_clean
24
25$(EBIN)/%.beam: $(ESRC)/%.erl
26 @echo " ERLC $<"
27 @$(ERLC) $(ERL_FLAGS) $(ERL_COMPILE_FLAGS) -o$(EBIN) $<
28
29.erl.beam:
30 $(ERLC) $(ERL_FLAGS) $(ERL_COMPILE_FLAGS) -o$(dir $@) $<
31
32# ----------------------------------------------------
33# Target Specs
34# ----------------------------------------------------
35
36MODULES = $(shell find . -name \*.erl | sed 's:^\./::' | sed 's/\.erl//')
37MODULES_STRING_LIST = $(shell find . -name \*.erl | sed 's:^\./::' | sed 's/\.erl/,/')
38BEHAV_MODULES = $(shell find . -name \*.erl | xargs grep -l behaviour_info | sed 's:^\./::' | sed 's/\.erl//')
39
40ERL_FILES= $(MODULES:%=%.erl)
41DOC_FILES=$(ERL_FILES)
42
43APP_FILE= $(APP_NAME).app
44APP_SRC= $(APP_FILE).src
45APP_TARGET= $(EBIN)/$(APP_FILE)
46
47BEAMS= $(MODULES:%=$(EBIN)/%.$(EMULATOR))
48BEHAV_BEAMS= $(BEHAV_MODULES:%=$(EBIN)/%.$(EMULATOR))
49TARGET_FILES= $(BEHAV_BEAMS) $(BEAMS) $(APP_TARGET) $(APPUP_TARGET)
50
51# ----------------------------------------------------
52# Targets
53# ----------------------------------------------------
54
55all debug opt: $(EBIN) $(TARGET_FILES)
56
57# Note: In the open-source build clean must not destroy the preloaded
58# beam files.
59clean:
60 rm -f $(TARGET_FILES)
61 rm -f *~
62 rm -f core
63 rm -rf $(EBIN)
64 rm -rf *html
65
66$(EBIN):
67 mkdir $(EBIN)
68
69dialyzer: $(TARGET_FILES)
70 dialyzer --src -r . $(ERL_INCLUDE)
71
72# ----------------------------------------------------
73# Special Build Targets
74# ----------------------------------------------------
75
76$(APP_TARGET): $(APP_SRC) $(BEAMS)
77 sed -e 's;%VSN%;$(VSN);' \
78 -e 's;%APP_NAME%;$(APP_NAME);' \
79 -e 's;%MODULES%;%MODULES%$(MODULES_STRING_LIST);' \
80 $< > $<".tmp"
81 sed -e 's/%MODULES%\(.*\),/\1/' \
82 $<".tmp" > $@
83 rm $<".tmp"