Skip to content

Commit

Permalink
KAZOO-4362: refactor build system
Browse files Browse the repository at this point in the history
  • Loading branch information
fenollp committed Jan 26, 2016
1 parent 9c5ff84 commit 4d19d11
Show file tree
Hide file tree
Showing 95 changed files with 364 additions and 3,747 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ $(MAKEDIRS):

clean: ACTION = clean
clean: $(MAKEDIRS)
rm -f *crash.dump
rm -rf scripts/log/*
$(if $(wildcard *crash.dump), rm *crash.dump)
$(if $(wildcard scripts/log/*), rm -rf scripts/log/*)

clean-test : ACTION = clean-test
clean-test : $(KAZOODIRS)
Expand Down
2 changes: 1 addition & 1 deletion applications/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ROOT = ../
ROOT = ..

MAKEDIRS = */Makefile

Expand Down
52 changes: 4 additions & 48 deletions applications/acdc/Makefile
Original file line number Diff line number Diff line change
@@ -1,53 +1,9 @@
PROJECT = acdc
ROOT = ../..
PROJECT = acdc

EBINS = $(shell find $(ROOT)/core/whistle-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_couch-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/lager-* -maxdepth 2 -name ebin -print)
PA = $(foreach EBIN,$(EBINS),-pa $(EBIN))

ERLC_OPTS += -Werror +debug_info +warn_export_all $(PA)

.PHONY: all compile clean
EBINS = $(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_couch-* -maxdepth 2 -name ebin -print)

all: compile

MODULES = $(shell ls src/*.erl | sed 's/src\///;s/\.erl/,/' | sed '$$s/.$$//')
TEST_MODULES = $(shell ls test/*.erl | sed 's/test\///;s/\.erl/,/' | sed '$$s/.$$//')

compile: ebin/$(PROJECT).app json
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' \
> ebin/$(PROJECT).app
-@$(MAKE) ebin/$(PROJECT).app

ebin/$(PROJECT).app: src/*.erl
@mkdir -p ebin/
ERL_LIBS=$(ERL_LIBS) erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ $?

json: JSON = $(shell find priv/couchdb -name *.json -print)
json:
@$(ROOT)/scripts/format-json.sh $(JSON)

compile-test: test/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES),$(TEST_MODULES)\]}/' \
> test/$(PROJECT).app
-@$(MAKE) test/$(PROJECT).app

test/$(PROJECT).app: src/*.erl test/*.erl
@mkdir -p test/
ERL_LIBS=$(ERL_LIBS) erlc -v $(ERLC_OPTS) -DTEST -o test/ -pa test/ $?

clean:
rm -f ebin/*
rm -f erl_crash.dump

clean-test:
rm -f test/*.beam test/$(PROJECT).app

test: clean-test compile-test eunit

eunit: compile-test
erl -noshell $(PA) -pa test -eval "case eunit:test([$(TEST_MODULES),$(MODULES)], [verbose]) of 'ok' -> init:stop(); _ -> init:stop(1) end."
-include $(ROOT)/make/kz.mk
49 changes: 4 additions & 45 deletions applications/blackhole/Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,9 @@
PROJECT = blackhole
ROOT = ../..
PROJECT = blackhole

EBINS = $(shell find $(ROOT)/core/whistle-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/rabbitmq_client-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/lager-* -maxdepth 2 -name ebin -print)
PA = $(foreach EBIN,$(EBINS),-pa $(EBIN))

ERLC_OPTS += -Werror +debug_info +warn_export_all $(PA)
ELIBS = $(ERL_LIBS):$(subst $(eval) ,:,$(wildcard $(ROOT)/deps/rabbitmq_client-*/deps))

.PHONY: all compile clean
EBINS = $(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/rabbitmq_client-* -maxdepth 2 -name ebin -print)

all: compile

MODULES = $(shell ls src/*.erl | sed 's/src\///;s/\.erl/,/' | sed '$$s/.$$//')
BH_MODULES = $(shell ls src/modules/*.erl | sed 's/src\/modules\///;s/\.erl/,/' | sed '$$s/.$$//')

compile: ebin/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES),$(BH_MODULES)\]}/' \
> ebin/$(PROJECT).app
-@$(MAKE) ebin/$(PROJECT).app

ebin/$(PROJECT).app: src/*.erl src/modules/*.erl
@mkdir -p ebin/
ERL_LIBS=$(ELIBS) erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ $?

compile-test: test/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES),$(BH_MODULES)\]}/' \
> test/$(PROJECT).app
-@$(MAKE) test/$(PROJECT).app

test/$(PROJECT).app: src/*.erl src/modules/*.erl
@mkdir -p test/
ERL_LIBS=$(ELIBS) erlc -v $(ERLC_OPTS) -DTEST -o test/ -pa test/ $?

clean:
rm -f ebin/*
rm -f erl_crash.dump

clean-test:
rm -f test/*.beam test/$(PROJECT).app

test: clean-test compile-test eunit

eunit: compile-test
erl -noshell $(PA) -pa test -eval "case eunit:test([$(MODULES),$(BH_MODULES)], [verbose]) of 'ok' -> init:stop(); _ -> init:stop(1) end."
-include $(ROOT)/make/kz.mk
48 changes: 2 additions & 46 deletions applications/call_inspector/Makefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,11 @@
PROJECT = call_inspector
ROOT = ../..
PROJECT = call_inspector

EBINS = $(shell find $(ROOT)/core/whistle-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/lager-* -maxdepth 2 -name ebin -print)
PA = $(foreach EBIN,$(EBINS),-pa $(EBIN))

ERLC_OPTS += -Werror +debug_info +warn_export_all $(PA)
ELIBS = $(ERL_LIBS):$(subst $(eval) ,:,$(wildcard $(ROOT)/core))

TEST_EBINS = $(shell find $(ROOT)/deps/mochiweb-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/ejson-* -maxdepth 2 -name ebin -print)
TEST_PA = $(foreach EBIN,$(TEST_EBINS),-pa $(EBIN))

.PHONY: all compile clean

all: compile

MODULES = $(shell ls src/*.erl | sed 's/src\///;s/\.erl/,/' | sed '$$s/.$$//')
TEST_MODULES = $(shell ls test/*.erl | sed 's/test\///;s/\.erl/,/' | sed '$$s/.$$//')
CI_ANALYZERS = $(shell ls src/analyzers/*.erl | sed 's/src\/analyzers\///;s/\.erl/,/' | sed '$$s/.$$//')
CI_PARSERS = $(shell ls src/parsers/*.erl | sed 's/src\/parsers\///;s/\.erl/,/' | sed '$$s/.$$//')

compile: ebin/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES),$(CI_ANALYZERS),$(CI_PARSERS)\]}/' \
> ebin/$(PROJECT).app
-@$(MAKE) ebin/$(PROJECT).app

ebin/$(PROJECT).app: src/*.erl src/*/*.erl
@mkdir -p ebin/
ERL_LIBS=$(ELIBS) erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ $?

compile-test: test/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES),$(CI_ANALYZERS),$(CI_PARSERS),$(TEST_MODULES)\]}/' \
> test/$(PROJECT).app
-@$(MAKE) test/$(PROJECT).app

test/$(PROJECT).app: ERLC_OPTS += +export_all
test/$(PROJECT).app: src/*.erl src/*/*.erl test/*.erl
@mkdir -p test/
ERL_LIBS=$(ELIBS) erlc -v $(ERLC_OPTS) $(TEST_PA) -DTEST -o test/ -pa test/ $?

clean:
rm -f ebin/*
rm -f erl_crash.dump

clean-test:
rm -f test/*.beam test/$(PROJECT).app

test: clean-test compile-test eunit

eunit: compile-test
erl -noshell $(PA) $(TEST_PA) -pa test -eval "case eunit:test([$(MODULES),$(CI_ANALYZERS),$(CI_PARSERS)], [verbose]) of 'ok' -> init:stop(); _ -> init:stop(1) end."
-include $(ROOT)/make/kz.mk
53 changes: 4 additions & 49 deletions applications/callflow/Makefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,10 @@
PROJECT = callflow
ROOT = ../..
PROJECT = callflow

EBINS = $(shell find $(ROOT)/core/whistle-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
EBINS = $(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_number_manager-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/kazoo_documents-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/lager-* -maxdepth 2 -name ebin -print)
PA = $(foreach EBIN,$(EBINS),-pa $(EBIN))

ERLC_OPTS += -Werror +debug_info +warn_export_all $(PA)

.PHONY: all compile clean
$(shell find $(ROOT)/core/kazoo_documents-* -maxdepth 2 -name ebin -print)

all: compile

MODULES = $(shell ls src/*.erl | sed 's/src\///;s/\.erl/,/' | sed '$$s/.$$//')
CF_MODULES = $(shell ls src/module/*.erl | sed 's/src\/module\///;s/\.erl/,/' | sed '$$s/.$$//')
TEST_MODULES = $(shell ls test/*.erl | sed 's/test\///;s/\.erl/,/' | sed '$$s/.$$//')

compile: ebin/$(PROJECT).app json
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES),$(CF_MODULES)\]}/' \
> ebin/$(PROJECT).app
-@$(MAKE) ebin/$(PROJECT).app

ebin/$(PROJECT).app: src/*.erl src/module/*.erl
@mkdir -p ebin/
erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ $?

json: JSON = $(shell find priv/couchdb -name *.json -print)
json:
@$(ROOT)/scripts/format-json.sh $(JSON)

compile-test: test/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES),$(CF_MODULES),$(TEST_MODULES)\]}/' \
> test/$(PROJECT).app
-@$(MAKE) test/$(PROJECT).app

test/$(PROJECT).app: src/*.erl src/module/*.erl test/*.erl
@mkdir -p test/
erlc -v $(ERLC_OPTS) -DTEST -o test/ -pa test/ $?

clean:
rm -f ebin/*
rm -f erl_crash.dump

clean-test:
rm -f test/*.beam test/$(PROJECT).app

test: clean-test compile-test eunit

eunit: compile-test
erl -noshell $(PA) -pa test -eval "case eunit:test([$(TEST_MODULES),$(MODULES),$(CF_MODULES)], [verbose]) of 'ok' -> init:stop(); _ -> init:stop(1) end."
-include $(ROOT)/make/kz.mk
46 changes: 3 additions & 43 deletions applications/camper/Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,9 @@
PROJECT = camper
ROOT = ../..
PROJECT = camper

EBINS = $(shell find $(ROOT)/core/whistle-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/lager-* -maxdepth 2 -name ebin -print) \
EBINS = $(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/rabbitmq_client-* -maxdepth 2 -name ebin -print)
PA = $(foreach EBIN,$(EBINS),-pa $(EBIN))

ERLC_OPTS += -Werror +debug_info +warn_export_all $(PA)
ELIBS = $(ERL_LIBS):$(subst $(eval) ,:,$(wildcard $(ROOT)/deps/rabbitmq_client-*/deps))

.PHONY: all compile clean

all: compile

MODULES = $(shell ls src/*.erl | sed 's/src\///;s/\.erl/,/' | sed '$$s/.$$//')

compile: ebin/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' \
> ebin/$(PROJECT).app
-@$(MAKE) ebin/$(PROJECT).app

ebin/$(PROJECT).app: src/*.erl
@mkdir -p ebin/
ERL_LIBS=$(ELIBS) erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ $?

compile-test: test/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' \
> test/$(PROJECT).app
-@$(MAKE) test/$(PROJECT).app

test/$(PROJECT).app: src/*.erl
@mkdir -p test/
ERL_LIBS=$(ELIBS) erlc -v $(ERLC_OPTS) -DTEST -o test/ -pa test/ $?

clean:
rm -f ebin/*
rm -f erl_crash.dump

clean-test:
rm -f test/*.beam test/$(PROJECT).app

test: clean-test compile-test eunit

eunit: compile-test
erl -noshell $(PA) -pa test -eval "case eunit:test([$(MODULES)], [verbose]) of 'ok' -> init:stop(); _ -> init:stop(1) end."
-include $(ROOT)/make/kz.mk
46 changes: 3 additions & 43 deletions applications/cccp/Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,10 @@
PROJECT = cccp
ROOT = ../..
PROJECT = cccp

EBINS = $(shell find $(ROOT)/core/whistle-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
EBINS = $(shell find $(ROOT)/core/whistle_apps-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/core/whistle_number_manager-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/lager-* -maxdepth 2 -name ebin -print) \
$(shell find $(ROOT)/deps/rabbitmq_client-* -maxdepth 2 -name ebin -print)
PA = $(foreach EBIN,$(EBINS),-pa $(EBIN))

ERLC_OPTS += -Werror +debug_info +warn_export_all $(PA)
ELIBS = $(ERL_LIBS):$(subst $(eval) ,:,$(wildcard $(ROOT)/deps/rabbitmq_client-*/deps))

.PHONY: all compile clean

all: compile

MODULES = $(shell ls src/*.erl | sed 's/src\///;s/\.erl/,/' | sed '$$s/.$$//')

compile: ebin/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' \
> ebin/$(PROJECT).app
-@$(MAKE) ebin/$(PROJECT).app

ebin/$(PROJECT).app: src/*.erl
@mkdir -p ebin/
ERL_LIBS=$(ELIBS) erlc -v $(ERLC_OPTS) -o ebin/ -pa ebin/ $?

compile-test: test/$(PROJECT).app
@cat src/$(PROJECT).app.src \
| sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' \
> test/$(PROJECT).app
-@$(MAKE) test/$(PROJECT).app

test/$(PROJECT).app: src/*.erl
@mkdir -p test/
ERL_LIBS=$(ELIBS) erlc -v $(ERLC_OPTS) -DTEST -o test/ -pa test/ $?

clean:
rm -f ebin/*
rm -f erl_crash.dump

clean-test:
rm -f test/*.beam test/$(PROJECT).app

test: clean-test compile-test eunit

eunit: compile-test
erl -noshell $(PA) -pa test -eval "case eunit:test([$(MODULES)], [verbose]) of 'ok' -> init:stop(); _ -> init:stop(1) end."
-include $(ROOT)/make/kz.mk
Loading

0 comments on commit 4d19d11

Please sign in to comment.