summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-12 17:01:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-12 17:01:33 +0200
commitd091725b9af5057d0ff85fb84bb792450b4a1f92 (patch)
treecd3f74275a0d42c02db2b219201589b08555e927 /makefile
parentd6477bdc97008e9bdd14cc4e31fcce82734afc74 (diff)
Remove git scripts, they are now in separate repositoryas
Diffstat (limited to 'makefile')
-rw-r--r--makefile168
1 files changed, 168 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..3abd510
--- /dev/null
+++ b/makefile
@@ -0,0 +1,168 @@
+# Root makefile that can be used to build/run tests and/or examples for
+# some or all databases:
+#
+# make - build tests and examples for all the databases
+# make t - build only tests for all the databases
+# make e - build only examples for all the databases
+#
+# make <db> - build tests and examples for <db>
+# make <db>-t - build only tests for <db>
+# make <db>-e - build only examples for <db>
+#
+# make test - run tests and examples for all the databases
+# make ttest - run only tests for all the databases
+# make etest - run only examples for all the databases
+#
+# make <db>-test - run tests and examples for <db>
+# make <db>-ttest - run only tests for <db>
+# make <db>-etest - run only examples for <db>
+#
+# make clean - clean tests and examples for all the databases
+# make tclean - clean only tests for all the databases
+# make eclean - clean only examples for all the databases
+#
+# make <db>-clean - clean tests and examples for <db>
+# make <db>-tclean - clean only tests for <db>
+# make <db>-eclean - clean only examples for <db>
+#
+# Additional command line variables:
+#
+# conf - configuration to build (e.g., conf=c++)
+#
+# Note that you can run tests and examples with -j; the makefile is
+# smart enough to build the tests and examples in parallel but run
+# them sequentially.
+#
+# Ordering:
+# - tests before examples
+# - build before run
+#
+db := mssql oracle pgsql sqlite mysql common
+
+tdb := $(db)
+edb := $(filter-out common,$(db)) # No multi-database build for examples.
+
+# Disable parallelism for this makefile (the sub-directories will
+# still be built with parallelism). This makes this makefile much
+# more usable.
+#
+.NOTPARALLEL:
+
+ifeq ($(conf),)
+conf_suffix := default
+else
+conf_suffix := builds/$(conf)
+endif
+
+.PHONY: t e all $(db) \
+ttest etest test $(addsuffix -test,$(db)) \
+tclean eclean clean $(addsuffix -clean,$(db))
+
+all: t e
+t: $(addsuffix -t,$(tdb))
+e: $(addsuffix -e,$(edb))
+
+test: ttest etest
+ttest: t $(addsuffix -ttest,$(tdb))
+etest: e $(addsuffix -etest,$(edb))
+
+clean: tclean eclean
+tclean: $(addsuffix -tclean,$(tdb))
+eclean: $(addsuffix -eclean,$(edb))
+
+define test_deps
+$1-test: $1-t $(if $(filter $1,$(edb)),$1-e)
+
+endef
+
+$(eval $(foreach d,$(tdb),$(call test_deps,$d)))
+
+define set_edir
+edir := $$(wildcard examples-$1-$(conf_suffix))
+ifeq ($(conf),)
+ifeq ($$(edir),)
+edir := examples-$1
+endif
+endif
+endef
+
+define set_tdir
+tdir := $$(wildcard tests-$1-$(conf_suffix))
+ifeq ($(conf),)
+ifeq ($$(tdir),)
+tdir := tests-$1
+endif
+endif
+endef
+
+define ebuild_rule
+.PHONY: $1-e
+$1: $1-e
+$1-e: dir := $$(edir)
+$1-e:
+ @$$(MAKE) -C $$(dir)
+endef
+
+define tbuild_rule
+.PHONY: $1-t
+$1: $1-t
+$1-t: dir := $$(tdir)
+$1-t:
+ @$$(MAKE) -C $$(dir)
+endef
+
+define etest_rule
+.PHONY: $1-etest
+$1-test: $1-etest
+$1-etest: dir := $$(edir)
+$1-etest: $1-e
+ @$$(MAKE) -C $$(dir) -j 1 test
+endef
+
+define ttest_rule
+.PHONY: $1-ttest
+$1-test: $1-ttest
+$1-ttest: dir := $$(tdir)
+$1-ttest: $1-t
+ @$$(MAKE) -C $$(dir) -j 1 test
+endef
+
+define eclean_rule
+.PHONY: $1-eclean
+$1-clean: $1-eclean
+$1-eclean: dir := $$(edir)
+$1-eclean:
+ @$$(MAKE) -C $$(dir) clean
+endef
+
+define tclean_rule
+.PHONY: $1-tclean
+$1-clean: $1-tclean
+$1-tclean: dir := $$(tdir)
+$1-tclean:
+ @$$(MAKE) -C $$(dir) clean
+endef
+
+# Note: empty line at the end is important.
+#
+#
+define erules
+$(call set_edir,$1)
+$(call ebuild_rule,$1)
+$(call etest_rule,$1)
+$(call eclean_rule,$1)
+
+endef
+
+define trules
+$(call set_tdir,$1)
+$(call tbuild_rule,$1)
+$(call ttest_rule,$1)
+$(call tclean_rule,$1)
+
+endef
+
+# Do all tests for all the database first. Then examples.
+#
+$(eval $(foreach d,$(tdb),$(call trules,$d)))
+$(eval $(foreach d,$(edb),$(call erules,$d)))