-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (29 loc) · 907 Bytes
/
Makefile
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
FC ?= gfortran
testdir := tests
builddir := build
features := $(wildcard $(testdir)/*)
tests := $(subst $(testdir)/,,$(foreach feature,$(features),$(wildcard $(feature)/*)))
all: $(foreach test,$(tests),$(builddir)/$(test)/RESULT)
$(builddir):
mkdir $@
define FEATURE_DIR_RULE
$(builddir)/$(subst $(testdir)/,,$(1)): $(builddir)
mkdir $@
endef
$(foreach feature,$(features),$(eval $(call FEATURE_DIR_RULE,$(feature))))
define TEST_DIR_RULE
$(builddir)/$(1): $(builddir)/$(1)
mkdir $@
endef
$(foreach test,$(tests),$(eval $(call TEST_DIR_RULE,$(test))))
define TEST_RULE
$(builddir)/$(1)/RESULT: $(builddir)/$(1)/main.exe
$^ || true
$(if $(not $(exists $@)) echo "FAILED" > $@)
$(builddir)/$(1)/main.exe: $(1)/main.f90 $(builddir)/$(1)
$FC $^ -o $@ || true
$(if $(not $(exits $@)) touch $@)
endef
$(foreach test,$(tests),$(eval $(call TEST_RULE,$(test))))
clean:
rm -rf $(builddir)