-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
187 lines (166 loc) · 4.5 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
ROOT_DIR=$(shell pwd)
BUILD_MODE ?= dev
LIBRARY_TYPE ?= static
PROCESSORS ?= 0
ALL_LIBRARY_TYPES = static static-pic relocatable
GNATFORMAT_LIBRARY_PROJECT = gnat/gnatformat.gpr
GNATFORMAT_DRIVER_PROJECT = gnat/gnatformat_driver.gpr
PARTIAL_GNATFORMAT_DRIVER_PROJECT = testsuite/partial_gnatformat/partial_gnatformat.gpr
COVERAGE ?=
COVERAGE_BUILD_FLAGS = \
--implicit-with=gnatcov_rts \
--src-subdirs=gnatcov-instr \
-gnatyN
BASE_BUILD_FLAGS = \
-XGNATFORMAT_BUILD_MODE=$(BUILD_MODE) \
-v \
-k \
-p \
-j$(PROCESSORS)
ifeq ($(COVERAGE),)
COMMON_BUILD_FLAGS = \
$(BASE_BUILD_FLAGS)
else
COMMON_BUILD_FLAGS = \
$(BASE_BUILD_FLAGS) \
$(COVERAGE_BUILD_FLAGS)
endif
COMMON_INSTRUMENT_FLAGS = \
--level=stmt+decision \
--dump-trigger=atexit \
--no-subprojects \
-XGNATFORMAT_LIBRARY_TYPE=$(LIBRARY_TYPE) \
-XLIBRARY_TYPE=$(LIBRARY_TYPE) \
-XGNATFORMAT_BUILD_MODE=$(BUILD_MODE) \
--projects=gnatformat
.PHONY: all
all: lib bin partial-gnatformat
.PHONY: lib
lib:
for library_type in $(ALL_LIBRARY_TYPES) ; do \
gprbuild \
-P $(GNATFORMAT_LIBRARY_PROJECT) \
-XGNATFORMAT_LIBRARY_TYPE=$$library_type \
-XLIBRARY_TYPE=$$library_type \
$(COMMON_BUILD_FLAGS) ; \
done ;
.PHONY: bin
bin: coverage-instrumentation
gprbuild \
-P $(GNATFORMAT_DRIVER_PROJECT) \
-XGNATFORMAT_LIBRARY_TYPE=$(LIBRARY_TYPE) \
-XLIBRARY_TYPE=$(LIBRARY_TYPE) \
$(COMMON_BUILD_FLAGS) ;
.PHONY: install
install: install-lib install-bin
.PHONY: install-lib
install-lib:
for library_type in $(ALL_LIBRARY_TYPES) ; do \
gprinstall \
-XGNATFORMAT_LIBRARY_TYPE=$$library_type \
-XLIBRARY_TYPE=$$library_type \
-XGNATFORMAT_BUILD_MODE=$(BUILD_MODE) \
--install-name=gnatformat \
--prefix="$(PREFIX)" \
--sources-subdir=include/gnatformat \
--build-name=$$library_type \
--build-var=LIBRARY_TYPE \
-P $(GNATFORMAT_LIBRARY_PROJECT) \
-p \
-f ; \
done ;
.PHONY: install-bin
install-bin:
gprinstall \
-XGNATFORMAT_LIBRARY_TYPE=$(LIBRARY_TYPE) \
-XLIBRARY_TYPE=$(LIBRARY_TYPE) \
-XBUILD_MODE=$(BUILD_MODE) \
--install-name=gnatformat \
--prefix="$(PREFIX)" \
-P $(GNATFORMAT_DRIVER_PROJECT) \
-p \
-f ;
ifneq ($(COVERAGE),)
mkdir -p $(PREFIX)/share/gnatformat/sids || true
cp obj/*.sid $(PREFIX)/share/gnatformat/sids/
cp obj/*/*.sid $(PREFIX)/share/gnatformat/sids/
endif
.PHONY: install-bin-stripped
install-bin-stripped:
gprinstall \
-XGNATFORMAT_LIBRARY_TYPE=$(LIBRARY_TYPE) \
-XLIBRARY_TYPE=$(LIBRARY_TYPE) \
-XBUILD_MODE=$(BUILD_MODE) \
--install-name=gnatformat \
--prefix="$(PREFIX)" \
-P $(GNATFORMAT_DRIVER_PROJECT) \
-p \
-f ;
ifneq ($(BUILD_MODE),dev)
strip $(PREFIX)/bin/gnatformat
endif
.PHONY: partial-gnatformat
partial-gnatformat: partial-gnatformat-coverage-instrumentation
gprbuild \
-P$(PARTIAL_GNATFORMAT_DRIVER_PROJECT) \
-XGNATFORMAT_LIBRARY_TYPE=$(LIBRARY_TYPE) \
-XLIBRARY_TYPE=$(LIBRARY_TYPE) \
$(COMMON_BUILD_FLAGS) ;
.PHONY: install-partial-gnatformat
install-partial-gnatformat:
gprinstall \
-XGNATFORMAT_LIBRARY_TYPE=$(LIBRARY_TYPE) \
-XLIBRARY_TYPE=$(LIBRARY_TYPE) \
-XGNATFORMAT_BUILD_MODE=$(BUILD_MODE) \
--prefix="$(PREFIX)" \
--install-name=partial_gnatformat \
--mode=usage \
-P$(PARTIAL_GNATFORMAT_DRIVER_PROJECT) \
-p \
-f ;
ifneq ($(COVERAGE),)
mkdir -p $(PREFIX)/share/gnatformat/sids || true
cp testsuite/partial_gnatformat/obj/*.sid $(PREFIX)/share/gnatformat/sids/
endif
.PHONY: test
test:
python testsuite/testsuite.py
.PHONY: clean
clean:
rm -rf bin;
rm -rf lib;
rm -rf obj;
rm -rf testsuite/partial_gnatformat/obj;
rm -rf testsuite/partial_gnatformat/bin;
.PHONY: coverage-setup
coverage-setup:
ifneq ($(COVERAGE),)
gnatcov setup --prefix gnatcov_rts_prefix
endif
.PHONY: coverage-instrumentation
coverage-instrumentation:
ifneq ($(COVERAGE),)
rm -rf obj/*gnatcov-instr
rm -rf obj/*/*gnatcov-instr
gnatcov \
instrument \
-P $(GNATFORMAT_DRIVER_PROJECT) \
$(COMMON_INSTRUMENT_FLAGS) \
--projects=gnatformat_driver ;
endif
.PHONY: partial-gnatformat-coverage-instrumentation
partial-gnatformat-coverage-instrumentation:
ifneq ($(COVERAGE),)
rm -rf testsuite/partial_gnatformat/obj/*gnatcov-instr
rm -rf testsuite/partial_gnatformat/obj/*/*gnatcov-instr
gnatcov \
instrument \
-P $(PARTIAL_GNATFORMAT_DRIVER_PROJECT) \
$(COMMON_INSTRUMENT_FLAGS) \
--projects=partial_gnatformat ;
endif
.PHONY: coverage-run
coverage-run: bin partial-gnatformat
ifneq ($(COVERAGE),)
python testsuite/testsuite.py --gnatcov obj/ obj/$(LIBRARY_TYPE).$(BUILD_MODE) testsuite/partial_gnatformat/obj --gnatcov-source-root $(ROOT_DIR)
endif