-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
228 lines (209 loc) · 7.18 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# You probably need to adjust the *_dir variables before running "make"
cxxflags_release="-DWITH_THREADS=0"
cxxflags_debug=$(cxxflags_release)
cxxflags_gprof=$(cxxflags_debug)
cxxflags_profiler=$(cxxflags_release)
cxxflags_release32="-DWITH_THREADS=0 -m32 -DNO_UNICODE"
cxxflags_static=$(cxxflags_release)
cxxflags_static32=$(cxxflags_release32)
gringo_dir=$(CURDIR)/../gringo-4.5.4-source
gringo_lib=$(gringo_dir)/build/release/libgringo.a
gringo_lib_debug=$(gringo_dir)/build/debug/libgringo.a
gringo_lib_gprof=$(gringo_dir)/build/release/libgringo.a
gringo_lib_profiler=$(gringo_dir)/build/release/libgringo.a
gringo_lib_release32=$(gringo_dir)/build/release32/libgringo.a
gringo_lib_static=$(gringo_dir)/build/static/libgringo.a
gringo_lib_static32=$(gringo_dir)/build/static32/libgringo.a
clasp_dir=$(CURDIR)/../clasp-3.1.4
clasp_lib=$(clasp_dir)/build/release/libclasp/lib/libclasp.a
clasp_lib_debug=$(clasp_dir)/build/debug/libclasp/lib/libclasp.a
clasp_lib_gprof=$(clasp_dir)/build/gprof/libclasp/lib/libclasp.a
clasp_lib_profiler=$(clasp_dir)/build/release/libclasp/lib/libclasp.a
clasp_lib_release32=$(clasp_dir)/build/release_m32/libclasp/lib/libclasp.a
clasp_lib_static=$(clasp_dir)/build/static/libclasp/lib/libclasp.a
clasp_lib_static32=$(clasp_dir)/build/static32/libclasp/lib/libclasp.a
htd_dir=$(CURDIR)/../htd-1.0.1
htd_lib=$(htd_dir)/build/release/lib/libhtd.a
htd_lib_debug=$(htd_dir)/build/debug/lib/libhtd.a
htd_lib_gprof=$(htd_dir)/build/release/lib/libhtd.a
htd_lib_profiler=$(htd_dir)/build/release/lib/libhtd.a
htd_lib_release32=$(htd_dir)/build/release32/lib/libhtd.a
htd_lib_static=$(htd_dir)/build/static/lib/libhtd.a
htd_lib_static32=$(htd_dir)/build/static32/lib/libhtd.a
gtest_dir=/usr/src/gtest
# You may also want to use --output-sync if you use multiple processes, but
# this has the unfortunate side-effect of disabling color output.
GNUMAKEFLAGS=--no-print-directory
export CTEST_OUTPUT_ON_FAILURE=1
cmake_extra_options=-DCMAKE_MODULE_PATH=$(CURDIR)
ifeq ($(CXX),clang++)
cmake_extra_options+=\
-DCMAKE_USER_MAKE_RULES_OVERRIDE=$(CURDIR)/clang-overrides \
-D_CMAKE_TOOLCHAIN_PREFIX=llvm-
endif
write_version_header = (grep -q "\"$(shell git describe | sed 's/^v\([0-9]\+\.[0-9]\+.[0-9]\+\)$$/\1/')\"" version.h 2> /dev/null || echo "\#define VERSION_NUMBER \"$(shell git describe | sed 's/^v\([0-9]\+\.[0-9]\+.[0-9]\+\)$$/\1/')\"" > version.h)
.PHONY: all
all: release
.PHONY: release
release:
mkdir -p build/release
cd build/release && \
$(call write_version_header) && \
cmake ../../src \
$(cmake_extra_options) \
-DCMAKE_BUILD_TYPE=release \
-DCMAKE_CXX_FLAGS:STRING=$(cxxflags_release) \
-Dgringo_lib=$(gringo_lib) \
-Dclasp_lib=$(clasp_lib) \
-Dhtd_lib=$(htd_lib) \
-Dgringo_dir=$(gringo_dir) \
-Dclasp_dir=$(clasp_dir) \
-Dhtd_dir=$(htd_dir) \
&& $(MAKE)
.PHONY: debug
debug:
mkdir -p build/debug
cd build/debug && \
$(call write_version_header) && \
cmake ../../src \
$(cmake_extra_options) \
-DCMAKE_BUILD_TYPE=debug \
-DCMAKE_CXX_FLAGS:STRING=$(cxxflags_debug) \
-Dgringo_lib=$(gringo_lib_debug) \
-Dclasp_lib=$(clasp_lib_debug) \
-Dhtd_lib=$(htd_lib_debug) \
-Dgringo_dir=$(gringo_dir) \
-Dclasp_dir=$(clasp_dir) \
-Dhtd_dir=$(htd_dir) \
&& $(MAKE)
.PHONY: gprof
gprof:
mkdir -p build/gprof
cd build/gprof && \
$(call write_version_header) && \
cmake ../../src \
$(cmake_extra_options) \
-DCMAKE_BUILD_TYPE=gprof \
-DCMAKE_CXX_FLAGS:STRING=$(cxxflags_gprof) \
-Dgringo_lib=$(gringo_lib_gprof) \
-Dclasp_lib=$(clasp_lib_gprof) \
-Dhtd_lib=$(htd_lib_gprof) \
-Dgringo_dir=$(gringo_dir) \
-Dclasp_dir=$(clasp_dir) \
-Dhtd_dir=$(htd_dir) \
&& $(MAKE)
.PHONY: profiler
profiler:
mkdir -p build/profiler
cd build/profiler && \
$(call write_version_header) && \
cmake ../../src \
$(cmake_extra_options) \
-DCMAKE_BUILD_TYPE=profiler \
-DCMAKE_CXX_FLAGS:STRING=$(cxxflags_profiler) \
-Dgringo_lib=$(gringo_lib_profiler) \
-Dclasp_lib=$(clasp_lib_profiler) \
-Dhtd_lib=$(htd_lib_profiler) \
-Dgringo_dir=$(gringo_dir) \
-Dclasp_dir=$(clasp_dir) \
-Dhtd_dir=$(htd_dir) \
&& $(MAKE)
.PHONY: release32
release32:
mkdir -p build/release32
cd build/release32 && \
$(call write_version_header) && \
cmake ../../src \
$(cmake_extra_options) \
-DCMAKE_BUILD_TYPE=release \
-DCMAKE_CXX_FLAGS:STRING=$(cxxflags_release32) \
-Dgringo_lib=$(gringo_lib_release32) \
-Dclasp_lib=$(clasp_lib_release32) \
-Dhtd_lib=$(htd_lib_release32) \
-Dgringo_dir=$(gringo_dir) \
-Dclasp_dir=$(clasp_dir) \
-Dhtd_dir=$(htd_dir) \
&& $(MAKE)
.PHONY: static
static:
mkdir -p build/static
cd build/static && \
$(call write_version_header) && \
cmake ../../src \
$(cmake_extra_options) \
-DUSE_STATIC_LIBS=ON \
-DCMAKE_BUILD_TYPE=release \
-DCMAKE_CXX_FLAGS:STRING=$(cxxflags_static) \
-Dgringo_lib=$(gringo_lib_static) \
-Dclasp_lib=$(clasp_lib_static) \
-Dhtd_lib=$(htd_lib_static) \
-Dgringo_dir=$(gringo_dir) \
-Dclasp_dir=$(clasp_dir) \
-Dhtd_dir=$(htd_dir) \
&& $(MAKE)
.PHONY: static32
static32:
mkdir -p build/static32
cd build/static32 && \
$(call write_version_header) && \
cmake ../../src \
$(cmake_extra_options) \
-DUSE_STATIC_LIBS=ON \
-DCMAKE_BUILD_TYPE=release \
-DCMAKE_CXX_FLAGS:STRING=$(cxxflags_static32) \
-Dgringo_lib=$(gringo_lib_static32) \
-Dclasp_lib=$(clasp_lib_static32) \
-Dhtd_lib=$(htd_lib_static32) \
-Dgringo_dir=$(gringo_dir) \
-Dclasp_dir=$(clasp_dir) \
-Dhtd_dir=$(htd_dir) \
&& $(MAKE)
.PHONY: dist
dist: release
$(eval RELEASE := dflat-$(shell git describe | sed 's/^v\([0-9]\+\.[0-9]\+.[0-9]\+\)$$/\1/')-x86_64)
$(eval DIST_DIR := build/dist/$(RELEASE))
mkdir -p $(DIST_DIR)/lib
cp build/release/dflat $(DIST_DIR)/dflat.bin
strip $(DIST_DIR)/dflat.bin
cp run-dflat.sh $(DIST_DIR)/dflat
cp -L $(shell ldd build/release/dflat | awk '/=> .*\.so/ { printf("%s ",$$3) } /ld-linux/ { printf("%s ",$$1) }') $(DIST_DIR)/lib
cp -R applications $(DIST_DIR)
cd build/dist && tar czf $(RELEASE).tar.gz $(RELEASE)
mv build/dist/$(RELEASE).tar.gz build
rm -rf build/dist
.PHONY: dist32
dist32: release32
$(eval RELEASE := dflat-$(shell git describe | sed 's/^v\([0-9]\+\.[0-9]\+.[0-9]\+\)$$/\1/')-i386)
$(eval DIST_DIR := build/dist32/$(RELEASE))
mkdir -p $(DIST_DIR)/lib
cp build/release32/dflat $(DIST_DIR)/dflat.bin
strip $(DIST_DIR)/dflat.bin
cp run-dflat.sh $(DIST_DIR)/dflat
cp -L $(shell ldd build/release32/dflat | awk '/=> .*\.so/ { printf("%s ",$$3) } /ld-linux/ { printf("%s ",$$1) }') $(DIST_DIR)/lib
cp -R applications $(DIST_DIR)
cd build/dist32 && tar czf $(RELEASE).tar.gz $(RELEASE)
mv build/dist32/$(RELEASE).tar.gz build
rm -rf build/dist32
.PHONY: test
test:
@mkdir -p build/debug
@cd build/debug && \
$(call write_version_header) && \
cmake ../../src \
$(cmake_extra_options) \
-DCMAKE_BUILD_TYPE=debug \
-DCMAKE_CXX_FLAGS:STRING=$(cxxflags_debug) \
-Dbuild_tests=BOOL:ON \
-Dgtest_dir=$(gtest_dir) \
-Dgringo_lib=$(gringo_lib_debug) \
-Dclasp_lib=$(clasp_lib_debug) \
-Dhtd_lib=$(htd_lib_debug) \
-Dgringo_dir=$(gringo_dir) \
-Dclasp_dir=$(clasp_dir) \
-Dhtd_dir=$(htd_dir) \
&& $(MAKE) && dflat-tests/tests
# For what it's worth, it should also be possible to run "make test" in
# build/release if you want to use ctest.
.PHONY: clean
clean:
rm -rf build