aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.ci/Makefile
blob: 9553238087fdaabc92dd01580aa283564ac02e3f (plain) (blame)
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# Travis/AppVeyor commands.
# Basically, make is used as a kinda-portable shell.

.DEFAULT_GOAL := all
.SUFFIXES:

windows := 0
ifeq ($(OS),Windows_NT)
windows := 1
endif

# Shell
ifeq ($(windows),1)
# Make might pick up sh.exe if it's available:
SHELL := cmd
.SHELLFLAGS := /c
else
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
endif

# Shut Boost.Build's executable up:
b2_flags = -d0

# Basic stuff that needed to be abstracted away:
ifeq ($(windows),1)
ext := .exe
newline := @echo.
cwd := $(shell cd)
ls := dir /a-D /S /B
else
ext :=
newline := @echo
cwd := $(shell pwd)
ls := function my_ls() { find "$$@" -type f | sort ; } ; my_ls
endif

# Python executable might be named differently, depending on the environment:
ifeq ($(windows),1)
ifdef appveyor_python_exe
python := $(appveyor_python_exe)
else
python := python
endif
else
python := python3
endif

# The build scripts are not completely OS-agnostic, unfortunately:
ifeq ($(windows),1)
x64_args = -A x64
x86_args = -A Win32
install_prefix = C:/install
else
makefile_dir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
x64_args := -D "CMAKE_TOOLCHAIN_FILE=$(makefile_dir)/../cmake/toolchains/gcc-x64.cmake"
x86_args := -D "CMAKE_TOOLCHAIN_FILE=$(makefile_dir)/../cmake/toolchains/gcc-x86.cmake"
install_prefix := $$HOME/install
endif

# Script to verify executable's target architecture:
ifeq ($(windows),1)
verify_arch = powershell -file ./.ci/verify_arch.ps1
else
verify_arch := ./.ci/verify_arch.sh
endif

.PHONY: all
all: simple static dynamic

.PHONY: FORCE
FORCE:

echo/%/build: FORCE
	$(newline)
	@echo =====================================================================
	@echo Building cmake/examples/$*
	@echo =====================================================================

echo/%/run: FORCE
	@echo ---------------------------------------------------------------------
	@echo Running $*/bin/foo
	@echo ---------------------------------------------------------------------

echo/%/verify: FORCE
	@echo ---------------------------------------------------------------------
	@echo Verifying $*/bin/foo
	@echo ---------------------------------------------------------------------

echo/%/finished: FORCE
	@echo =====================================================================
	$(newline)

# examples/simple: x64/Release build.

.PHONY: simple/build
simple/build: echo/simple/build
	"$(python)" cmake/build/build.py --install "$(install_prefix)/simple" --configuration Release -- cmake/examples/simple $(x64_args)

.PHONY: simple/run
simple/run: echo/simple/run
	"$(install_prefix)/simple/bin/foo"

.PHONY: simple/verify
simple/verify: echo/simple/verify
	$(verify_arch) "$(install_prefix)/simple/bin/foo$(ext)" x64

.PHONY: simple
simple: simple/build simple/run simple/verify echo/simple/finished

# examples/static: x86/Debug build.

.PHONY: static/build
static/build: echo/static/build
	"$(python)" cmake/build/build.py --install "$(install_prefix)/static" --configuration Debug -- cmake/examples/static $(x86_args)

.PHONY: static/run
static/run: echo/static/run
	"$(install_prefix)/static/bin/foo"

.PHONY: static/verify
static/verify: echo/static/verify
	$(verify_arch) "$(install_prefix)/static/bin/foo$(ext)" x86

.PHONY: static
static: static/build static/run static/verify echo/static/finished

# examples/dynamic: x64/RelWithDebInfo build.

.PHONY: dynamic/build
dynamic/build: echo/dynamic/build
	"$(python)" cmake/build/build.py --install "$(install_prefix)/dynamic" --configuration RelWithDebInfo -- cmake/examples/dynamic $(x64_args)

.PHONY: dynamic/run
# Windows can pick up DLLs in the same directory, otherwise we need to add them
# to PATH.
dynamic/run: echo/dynamic/run
ifeq ($(windows),1)
	"$(install_prefix)/dynamic/bin/foo"
else
	LD_LIBRARY_PATH="$(install_prefix)/dynamic/lib" "$(install_prefix)/dynamic/bin/foo"
endif

.PHONY: dynamic/verify
dynamic/verify: echo/dynamic/verify
	$(verify_arch) "$(install_prefix)/dynamic/bin/foo$(ext)" x64

.PHONY: dynamic
dynamic: dynamic/build dynamic/run dynamic/verify echo/dynamic/finished

echo/boost/%/build: FORCE
	$(newline)
	@echo =====================================================================
	@echo Building Boost 1.$*.0
	@echo =====================================================================

echo/boost/%/ls: FORCE
	@echo ---------------------------------------------------------------------
	@echo Boost 1.$*.0: stage/
	@echo ---------------------------------------------------------------------

echo/boost/%/exe/build: FORCE
	@echo ---------------------------------------------------------------------
	@echo Boost 1.$*.0: building cmake/examples/boost
	@echo ---------------------------------------------------------------------

echo/boost/%/exe/run: FORCE
	@echo ---------------------------------------------------------------------
	@echo Boost 1.$*.0: running boost_1_$*_0/bin/foo
	@echo ---------------------------------------------------------------------

echo/boost/%/exe/verify: FORCE
	@echo ---------------------------------------------------------------------
	@echo Boost 1.$*.0: verifying boost_1_$*_0/bin/foo
	@echo ---------------------------------------------------------------------

echo/boost/%/finished: FORCE
	@echo =====================================================================
	$(newline)

# Boost 1.58.0:
# * temporary download,
# * x86, Debug, static libraries only.
# examples/boost:
# * x86/Debug build.

.PHONY: boost/58/download
boost/58/download: echo/boost/58/build
	"$(python)" boost/build/build.py download 1.58.0

.PHONY: boost/58/build
boost/58/build:
	"$(python)" boost/build/build.py build --configuration Debug --platform x86 --link static -- ./boost_1_58_0 --with-filesystem --with-program_options $(b2_flags)

.PHONY: boost/58/ls
boost/58/ls: echo/boost/58/ls
	$(ls) "./boost_1_58_0/stage"

.PHONY: boost/58/exe/build
boost/58/exe/build: echo/boost/58/exe/build
	"$(python)" cmake/build/build.py --install "$(install_prefix)/boost_1_58_0" --configuration Debug -- cmake/examples/boost $(x86_args) -D "BOOST_ROOT=$(cwd)/boost_1_58_0" -D "BOOST_LIBRARYDIR=$(cwd)/boost_1_58_0/stage/x86/Debug/lib"

.PHONY: boost/58/exe/run
# Boost should be linked statically, no need to adjust PATH:
boost/58/exe/run: echo/boost/58/exe/run
	"$(install_prefix)/boost_1_58_0/bin/foo"

.PHONY: boost/58/exe/verify
boost/58/exe/verify: echo/boost/58/exe/verify
	$(verify_arch) "$(install_prefix)/boost_1_58_0/bin/foo$(ext)" x86

.PHONY: boost/58/exe
boost/58/exe: boost/58/exe/build boost/58/exe/run boost/58/exe/verify

.PHONY: boost/58
boost/58: boost/58/download boost/58/build boost/58/ls boost/58/exe echo/boost/58/finished

# Boost 1.72.0:
# * cached download,
# * x86 & x64, Debug & Release, shared libraries only.
# examples/boost:
# * x64/Release build.

.PHONY: boost/72/download
boost/72/download: echo/boost/72/build
	"$(python)" boost/build/build.py download --cache . 1.72.0

.PHONY: boost/72/build
boost/72/build:
	"$(python)" boost/build/build.py build --platform x86 x64 --link shared -- ./boost_1_72_0 --with-filesystem --with-program_options $(b2_flags)

.PHONY: boost/72/ls
boost/72/ls: echo/boost/72/ls
	$(ls) "./boost_1_72_0/stage"

.PHONY: boost/72/exe/build
boost/72/exe/build: echo/boost/72/exe/build
	"$(python)" cmake/build/build.py --install "$(install_prefix)/boost_1_72_0" --configuration Release -- cmake/examples/boost $(x64_args) -D "BOOST_ROOT=$(cwd)/boost_1_72_0" -D "BOOST_LIBRARYDIR=$(cwd)/boost_1_72_0/stage/x64/Release/lib" -D Boost_USE_STATIC_LIBS=OFF

.PHONY: boost/72/exe/run
# Boost is linked dynamically, we need to adjust PATH:
boost/72/exe/run: echo/boost/72/exe/run
ifeq ($(windows),1)
	set "PATH=$(cwd)\boost_1_72_0\stage\x64\Release\lib;%PATH%" && "$(install_prefix)/boost_1_72_0/bin/foo"
else
	LD_LIBRARY_PATH="$(cwd)/boost_1_72_0/stage/x64/Release/lib" "$(install_prefix)/boost_1_72_0/bin/foo"
endif

.PHONY: boost/72/exe/verify
boost/72/exe/verify: echo/boost/72/exe/verify
	$(verify_arch) "$(install_prefix)/boost_1_72_0/bin/foo$(ext)" x64

.PHONY: boost/72/exe
boost/72/exe: boost/72/exe/build boost/72/exe/run boost/72/exe/verify

.PHONY: boost/72
boost/72: boost/72/download boost/72/build boost/72/ls boost/72/exe echo/boost/72/finished

# Boost 1.65.0:
# * download to $HOME (on Travis), C:\projects (on AppVeyor),
# * x64, MinSizeRel (= Release), static & shared libraries.
# examples/boost:
# * x64/MinSizeRel build (set in .travis.yml and .appveyor.yml).

ifdef TRAVIS
.PHONY: boost/65/build
boost/65/build: echo/boost/65/build
	"$(python)" boost/build/ci/travis.py --link static -- --with-filesystem --with-program_options $(b2_flags)

.PHONY: boost/65/ls
boost/65/ls: echo/boost/65/ls
	$(ls) "$$HOME/boost/stage"

.PHONY: boost/65/exe/build
boost/65/exe/build: echo/boost/65/exe/build
	TRAVIS_BUILD_DIR="$$TRAVIS_BUILD_DIR/cmake/examples/boost" "$(python)" cmake/build/ci/travis.py --install "$(install_prefix)/boost_1_65_0" -- -D "BOOST_ROOT=$$HOME/boost" -D "BOOST_LIBRARYDIR=$$HOME/boost/stage/$$platform/$$configuration/lib"
endif
ifdef APPVEYOR
.PHONY: boost/65/build
boost/65/build: echo/boost/65/build
	"$(python)" boost/build/ci/appveyor.py --link static -- --with-filesystem --with-program_options $(b2_flags)

.PHONY: boost/65/ls
boost/65/ls: echo/boost/65/ls
	$(ls) "C:/projects/boost/stage"

.PHONY: boost/65/exe/build
boost/65/exe/build: echo/boost/65/exe/build
	set "APPVEYOR_BUILD_FOLDER=%APPVEYOR_BUILD_FOLDER%\cmake\examples\boost" && "$(python)" cmake/build/ci/appveyor.py --install "$(install_prefix)/boost_1_65_0" -- -D "BOOST_ROOT=C:\projects\boost" -D "BOOST_LIBRARYDIR=C:\projects\boost\stage\%PLATFORM%\%CONFIGURATION%\lib"
endif

.PHONY: boost/65/exe/run
boost/65/exe/run: echo/boost/65/exe/run
	"$(install_prefix)/boost_1_65_0/bin/foo"

.PHONY: boost/65/exe/verify
boost/65/exe/verify: echo/boost/65/exe/verify
	$(verify_arch) "$(install_prefix)/boost_1_65_0/bin/foo$(ext)" x64

.PHONY: boost/65/exe
boost/65/exe: boost/65/exe/build boost/65/exe/run boost/65/exe/verify

.PHONY: boost/65
boost/65: boost/65/build boost/65/ls boost/65/exe echo/boost/65/finished