Permalink
Browse files

Improve usage of erlc

  • Loading branch information...
1 parent 52d5499 commit 53a6fa5553a78094c88b444f3a17385c8fe4e137 @rvirding committed Jun 16, 2011
Showing with 23 additions and 6 deletions.
  1. +23 −6 Makefile
View
@@ -2,7 +2,7 @@
# This simple Makefile uses rebar to compile/clean if it
# exists, else does it explicitly.
-EBINDIR = ebin
+BINDIR = ebin
SRCDIR = src
INCDIR = include
DOCDIR = doc
@@ -11,7 +11,7 @@ EMACSDIR = emacs
VPATH = $(SRCDIR)
ERLCFLAGS = -W0 +debug_info
-ERLC = erlc -I $(INCDIR) -o $(EBINDIR) $(ERLCFLAGS)
+ERLC = erlc
## The .erl and .beam files
SRCS = $(notdir $(wildcard $(SRCDIR)/*.erl))
@@ -20,18 +20,35 @@ EBINS = $(SRCS:.erl=.beam)
## Where we install LFE, in the ERL_LIBS directory.
INSTALLDIR = $(ERL_LIBS)/lfe
+.SUFFIXES: .erl .beam
+
+$(BINDIR)/%.beam: %.erl
+ $(ERLC) -I $(INCDIR) -o $(BINDIR) $(ERLCFLAGS) $<
+
+$(SRCDIR)/%.erl: %.xrl
+ $(ERLC) -o $(SRCDIR) $<
+
+$(SRCDIR)/%.erl: %.yrl
+ $(ERLC) -o $(SRCDIR) $<
+
all: compile docs
+.PHONY: compile erlc_compile install docs clean
+
+## Compile using rebar if it exists else using make
compile:
if which -s rebar; \
then rebar compile; \
- else $(ERLC) $(addprefix $(SRCDIR)/, $(SRCS)); \
+ else $(MAKE) $(MFLAGS) erlc_compile; \
fi
+## Compile using erlc
+erlc_compile: $(addprefix $(BINDIR)/, $(EBINS))
+
install:
if [ "$$ERL_LIBS" != "" ]; \
- then mkdir -p $(INSTALLDIR)/$(EBINDIR) ; \
- cp -pPR $(EBINDIR) $(INSTALLDIR); \
+ then mkdir -p $(INSTALLDIR)/$(BINDIR) ; \
+ cp -pPR $(BINDIR) $(INSTALLDIR); \
cp -pPR $(EMACSDIR) $(INSTALLDIR); \
cp -pPR $(INCDIR) $(INSTALLDIR); \
else exit 1; \
@@ -42,6 +59,6 @@ docs:
clean:
if which -s rebar; \
then rebar clean; \
- else rm -rf $(EBINDIR)/*.beam; \
+ else rm -rf $(BINDIR)/*.beam; \
fi
rm -rf erl_crash.dump

0 comments on commit 53a6fa5

Please sign in to comment.