summaryrefslogtreecommitdiff
path: root/git/makefile
blob: c6d5aebfb23e051e956c6dd5fc5c796a87b8de02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Root makefile that can be used to build/run tests and examples for some
# or all databases:
#
# make           - build tests and examples for all the databases
# make test      - build and run tests and examples for all the databases
# make <db>      - build tests and examples for <db>
# make <db>-test - build and run tests and examples for <db>
#
# Additional command line variables:
#
# conf           - configuration to build
#
db := mssql oracle pgsql sqlite mysql

ifeq ($(conf),)
conf_suffix := default
else
conf_suffix := builds/$(conf)
endif

.PHONY: all test clean $(db) $(addsuffix -test,$(db)) $(addsuffix -clean,$(db))

all: $(db)
test: $(addsuffix -test,$(db))
clean: $(addsuffix -clean,$(db))

define set_dirs
edir := $$(wildcard examples-$1-$(conf_suffix))
tdir := $$(wildcard tests-$1-$(conf_suffix))

ifeq ($(conf),)
ifeq ($$(edir),)
edir := examples-$1
endif

ifeq ($$(tdir),)
tdir := tests-$1
endif
endif

endef

define build_rule
$1: edir := $$(edir)
$1: tdir := $$(tdir)

$1:
	@$$(MAKE) -C $$(edir)
	@$$(MAKE) -C $$(tdir)
endef

define test_rule
$1-test: edir := $$(edir)
$1-test: tdir := $$(tdir)

$1-test:
	@$$(MAKE) -C $$(edir) test
	@$$(MAKE) -C $$(tdir) test
endef

define clean_rule
$1-clean: edir := $$(edir)
$1-clean: tdir := $$(tdir)

$1-clean:
	@$$(MAKE) -C $$(edir) clean
	@$$(MAKE) -C $$(tdir) clean
endef

# Note: empty line at the end is important.
#
#
define rules
$(call set_dirs,$1)
$(call build_rule,$1)
$(call test_rule,$1)
$(call clean_rule,$1)

endef

$(eval $(foreach d,$(db),$(call rules,$d)))