diff --git a/Makefile b/Makefile index 55c10b7d..f01df32f 100644 --- a/Makefile +++ b/Makefile @@ -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