-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
129 lines (101 loc) · 4.17 KB
/
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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Define the base directory and default config file to read in
base := .
makedir = $(base)/makefiles
cfg := $(base)/config.mk
# Include project directory hierarchy information
include $(makedir)/srcdirs.mk
################## Build directory related variables that can reset in the config file or cmd line ####################
# Location in which the build directory should be created
where = $(base)
# The name prefix of the build directory
builddir ?= build
################## Determine if we'll need info from a configuration file ##################
infoTargets:= help docs doxygen
shouldInclude := no
ifeq (,$(MAKECMDGOALS))
shouldInclude := yes
endif
ifneq (,$(filter-out $(infoTargets),$(MAKECMDGOALS)))
shouldInclude := yes
endif
################## Include the configuration file if we're going to need it ##################
ifeq (yes,$(shouldInclude))
isExist := $(shell test -r $(cfg) || echo "no")
ifeq (no,$(isExist))
$(error $(cfg) does not exist! Please copy $(makedir)/config.MACHINE.mk to $(cfg) and customize it for your build)
endif
include $(cfg)
endif
################## Compute the build directory name ####################
# The computed suffix of the build directory
buildsuffix = $(shell echo $(sort $(OPT)) | sed "s| ||g")
# The actual build directory name and location
build = $(strip $(where))/$(strip $(builddir))$(strip $(buildsuffix))
absbuild = $(call realpath,$(build))
################## Test directory related stuff ####################
# The directory within which any tests are run
testop = $(build)/test-output
testop_regr = $(testop)/regression
testop_unit = $(testop)/unit
testop_perf = $(testop)/scaling
################## Arguments to the sub-makes ####################
# Define the command line args to sub-make
BUILDARGS =-C "$(call realpath,$(build))" \
-f "$(call realpath,$(makedir)/mainrecipe.mk)" \
-r \
base="$(call abs2rel,$(base),$(call realpath,$(build)))" \
cfg="$(call abs2rel,$(cfg),$(call realpath,$(build)))"
TESTARGS =-C "$(call realpath,$1)" \
-f "$(call realpath,$(makedir)/$2)" \
-r \
base="$(call abs2rel,$(base),$(call realpath,$1))" \
cfg="$(call abs2rel,$(cfg),$(call realpath,$1))" \
build="$(call abs2rel,$(build),$(call realpath,$1))"
.PHONY: all \
compile driver physics libs \
again clean clean_driver clean_physics clean_libs \
test test-regr test-unit clean_test retest \
perf perf-setup perf-chk clean_perf
docs doxygen
all: compile
################## Build-related targets ####################
compile driver physics libs again: $(build)
@$(MAKE) $(BUILDARGS) $@
@echo "=========== Build results are in the build directory: $(build)"
clean clean_driver clean_physics clean_libs: $(build)
@$(MAKE) $(BUILDARGS) $@
realclean:
@test ! -d $(testop) || $(RM) -r $(testop)
@test ! -d $(build) || $(RM) -r $(build)
################## Testing-related targets ####################
test: compile
cd python; python test_driver.py $(absbuild) make_test.config
test-pimd: compile
cd python; python test_driver.py $(absbuild) pimd_test.config
test-full: compile
cd python; python test_driver.py $(absbuild) full_test.config
test-jenkins: compile
cd python; python test_driver.py $(absbuild) jenkins.config
retest: clean_test test
clean_test:
@test ! -d $(testop) || $(RM) -r $(testop)
################## Scaling / Performance measurement related targets ####################
perf perf-setup perf-chk: compile $(testop_perf)
@$(MAKE) $(call TESTARGS,$(testop_perf),perfrecipe.mk) $@
@echo "=========== Performance measurement output is in the scaling directory: $(testop_perf)"
clean_perf:
@test ! -d $(testop) || $(RM) -r $(testop_perf)
################## Other targets ####################
docs:
@cd $(docs) && $(MAKE)
doxygen:
@cd $(docs) && doxygen Doxyfile
clean_docs:
@cd $(docs) && $(MAKE) clean
@$(RM) -r $(docs)/html
################## Utility targets ####################
$(build) $(testop) $(testop_regr) $(testop_unit) $(testop_perf):
@echo "=========== Creating directory: $@"
@mkdir -p $@
help:
@less $(makedir)/makehelp.txt