-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
62 lines (46 loc) · 1.72 KB
/
Makefile
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
# BEGIN CONFIG
# Where are the erl and app files?
SOURCEDIR := src
# Where are the hrl files?
INCLUDEDIR := include /lib/ejabberd/include /lib/ejabberd/include/mod_pubsub /lib/ejabberd/include/web
# Where shall the apps and beams be compiled?
TARGETDIR := ebin
# Where shall the apps and beams be installed?
INSTALLDIR := /lib/ejabberd/ebin
# Where are any extra code paths? (e.g. behaviour beams)
PREPENDPATH :=
APPENDPATH := /lib/ejabberd/ebin
# END CONFIG
INCLUDEFLAGS := $(patsubst %,-I %, $(INCLUDEDIR))
SPECIALFLAGS := $(patsubst %,-pa %, $(PREPENDPATH)) $(patsubst %,-pz %, $(APPENDPATH))
MODULES := $(patsubst $(SOURCEDIR)/%.erl,%,$(wildcard $(SOURCEDIR)/*.erl))
APPS := $(patsubst $(SOURCEDIR)/%.app,%,$(wildcard $(SOURCEDIR)/*.app))
INCLUDES := $(wildcard $(INCLUDEDIR)/*.hrl)
TARGETS := $(patsubst %,$(TARGETDIR)/%.beam,$(MODULES))
APPFILES := $(patsubst %,$(TARGETDIR)/%.app,$(APPS))
all : $(TARGETDIR) $(APPFILES) $(TARGETS)
$(TARGETDIR) :
@echo "Creating target directory $(TARGETDIR)"
@mkdir -p $(TARGETDIR)
$(TARGETS) : $(TARGETDIR)/%.beam: $(SOURCEDIR)/%.erl $(INCLUDES)
@echo "Compiling module $*"
@erlc $(INCLUDEFLAGS) $(SPECIALFLAGS) -o $(TARGETDIR) $<
$(APPFILES) : $(TARGETDIR)/%.app: $(SOURCEDIR)/%.app
@echo "Copying application $*"
@cp $< $@
e : $(TARGETDIR) $(APPFILES)
@erl -noinput -eval 'case make:all() of up_to_date -> halt(0); _ -> halt(1) end.'
install : all
ifdef INSTALLDIR
@echo "Copying to $(INSTALLDIR)"
@install -m 644 $(TARGETDIR)/* $(INSTALLDIR)
endif
clean :
@if [ -d $(TARGETDIR) ]; then \
echo "Deleting ebin and app files from $(TARGETDIR)..."; \
rm -f $(TARGETS) $(APPFILES); \
rmdir $(TARGETDIR); \
else \
echo "Nothing to clean."; \
fi
@rm -f erl_crash.dump