Makefile 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. NAME := epgsql
  2. VERSION := $(shell git describe --always --tags)
  3. ERL := erl
  4. ERLC := erlc
  5. # ------------------------------------------------------------------------
  6. ERLC_FLAGS := -Wall -I include +debug_info
  7. SRC := $(wildcard src/*.erl)
  8. TESTS := $(wildcard test/*.erl)
  9. RELEASE := $(NAME)-$(VERSION).tar.gz
  10. APPDIR := $(NAME)-$(VERSION)
  11. BEAMS := $(SRC:src/%.erl=ebin/%.beam)
  12. compile: $(BEAMS) ebin/$(NAME).app
  13. app: compile
  14. @mkdir -p $(APPDIR)/ebin
  15. @cp -r ebin/* $(APPDIR)/ebin/
  16. @cp -r include $(APPDIR)
  17. release: app
  18. @tar czvf $(RELEASE) $(APPDIR)
  19. clean:
  20. @rm -f ebin/*.beam
  21. @rm -f ebin/$(NAME).app
  22. @rm -rf $(NAME)-$(VERSION) $(NAME)-*.tar.gz
  23. test: $(TESTS:test/%.erl=test_ebin/%.beam) compile
  24. $(ERL) -pa ebin/ -pa test_ebin/ -noshell -s pgsql_tests run_tests -s init stop
  25. # ------------------------------------------------------------------------
  26. .SUFFIXES: .erl .beam
  27. .PHONY: app compile clean test
  28. ebin/%.beam : src/%.erl
  29. $(ERLC) $(ERLC_FLAGS) -o $(dir $@) $<
  30. ebin/%.app : src/%.app.src Makefile
  31. sed -e 's|git|\"$(VERSION)\"|g' $< > $@
  32. test_ebin/%.beam : test/%.erl
  33. $(ERLC) $(ERLC_FLAGS) -o $(dir $@) $<
  34. dialyzer: build.plt compile
  35. dialyzer --plt $< ebin
  36. build.plt:
  37. dialyzer -q --build_plt --apps kernel stdlib ssl --output_plt $@