-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
36 lines (28 loc) · 1011 Bytes
/
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
SOURCEDIR := src
INCLUDEDIR := include
TARGETDIR := ebin
INCLUDEFLAGS := $(patsubst %,-I %, $(INCLUDEDIR))
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) -o $(TARGETDIR) $<
$(APPFILES) : $(TARGETDIR)/%.app: $(SOURCEDIR)/%.app
@echo "Copying application $*"
@cp $< $@
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