Skip to content

Commit

Permalink
Improve usage of erlc
Browse files Browse the repository at this point in the history
  • Loading branch information
rvirding committed Jun 16, 2011
1 parent 52d5499 commit 53a6fa5
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions Makefile
Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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; \
Expand All @@ -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.