lhttpc / Makefile

SOURCES := $(wildcard src/*.erl)
HEADERS := $(wildcard src/*.hrl)
MODULES := $(patsubst src/%.erl,%,$(SOURCES))
BEAMS := $(patsubst %,ebin/%.beam,$(MODULES))

comma := ,
e :=
space := $(e) $(e)
MODULELIST := $(subst $(space),$(comma),$(MODULES))

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

include vsn.mk

.PHONY: all clean dialyzer

all: $(APPLICATION) doc


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 +warn_missing_spec -o ebin/ $<

	@echo Creating ebin/
	@mkdir ebin/

doc: doc/edoc-info

	@echo Running dialyzer on sources
	@dialyzer --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

	@echo Cleaning
	@rm -f ebin/*.{beam,app} test/*.beam doc/*.{html,css,png} doc/edoc-info
	@rm -rf cover_report
	@rm -f util/*.beam

release: clean all test dialyzer
	@util/releaser $(APPLICATION) $(VSN)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.