Skip to content

Commit

Permalink
Refactoring Makefile to use rebar
Browse files Browse the repository at this point in the history
  • Loading branch information
dizzyd committed Jun 15, 2010
1 parent 30a1334 commit bbd3761
Showing 1 changed file with 8 additions and 78 deletions.
86 changes: 8 additions & 78 deletions Makefile
Expand Up @@ -14,86 +14,16 @@
## limitations under the License.
##==============================================================================

APPLICATION := triq
APP_FILE := ebin/$(APPLICATION).app
SOURCES := $(wildcard src/*.erl)
HEADERS := $(wildcard src/*.hrl) $(wildcard include/*.hrl)
MODULES := $(patsubst src/%.erl,%,$(SOURCES))
BEAMS := ebin/triq_autoexport.beam $(patsubst %,ebin/%.beam,$(MODULES))
.PHONY: doc

comma := ,
e :=
space := $(e) $(e)
MODULELIST := $(subst $(space),$(comma),$(MODULES))
all:
./rebar compile eunit

TEST_SOURCES := $(wildcard test/*.erl)
TEST_BEAMS := $(patsubst %.erl,%.beam, $(TEST_SOURCES))

include vsn.mk

.PHONY: all clean dialyzer

all: $(APPLICATION) doc

$(APPLICATION): $(BEAMS) $(APP_FILE)

test: $(APPLICATION) $(TEST_BEAMS) util/run_test.beam
@echo Running tests
@erl -pa util/ -pa ebin/ -pa test/ -noinput -s run_test run

test_shell: $(APPLICATION) $(TEST_BEAMS)
@echo Starting a shell with test paths included
@erl -pa ebin/ -pa test/

test/%.beam: test/%.erl
@echo Compiling $<
@erlc +debug_info -o test/ $<

$(APP_FILE): src/$(APPLICATION).app.src vsn.mk
@echo Generating $@
@sed -e 's/@MODULES@/$(MODULELIST)/' -e 's/@VSN@/$(VSN)/' $< > $@

ebin/%.beam: src/%.erl $(HEADERS) $(filter-out $(wildcard ebin), ebin)
@echo Compiling $<
@erlc +debug_info -o ebin/ -pz ebin/ -I include/ $<

ebin:
@echo Creating ebin/
@mkdir ebin/

doc: doc/edoc-info

dialyzer:
@echo Running dialyzer on sources
@dialyzer -pa ebin/ --src -r src/

doc/edoc-info: doc/overview.edoc $(SOURCES)
@erlc -o util/ util/make_doc.erl
@echo Generating documentation from edoc
@erl -pa util/ -noinput -s make_doc edoc

util/%.beam: util/%.erl
@erlc -o util/ util/run_test.erl
doc:
./rebar doc

clean:
@echo Cleaning
@rm -f ebin/*.beam \
ebin/*.app \
test/*.beam \
test/*.log \
doc/*.html \
doc/*.css \
doc/*.png \
doc/edoc-info \
util/*.beam \
erl_crash.dump
@rm -rf cover_report \
.eunit
./rebar clean

release: clean all test dialyzer
@util/releaser $(APPLICATION) $(VSN)

tar: clean all
tar cvzf $(APPLICATION)-$(VSN).tgz \
-s '#^#$(APPLICATION)-$(VSN)/~#' \
$(SOURCES) $(HEADERS) $(APP_FILE) $(BEAMS) doc/*
dialyzer:
./rebar analyze

0 comments on commit bbd3761

Please sign in to comment.