-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGNUmakevars.inc
More file actions
559 lines (366 loc) · 15.8 KB
/
Copy pathGNUmakevars.inc
File metadata and controls
559 lines (366 loc) · 15.8 KB
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
# Prerequisite: SEAPLUS_TOP must be set.
# To understand why taking into account such conditionals requires to specify
# them first, and in each layer, rather than at the end of the last one, refer
# to the section about conditionals at the top of the GNUmakevars.inc of Myriad.
# Overall settings section.
#EXECUTION_TARGET = production
ifndef EXECUTION_TARGET
# Other possible value: production
EXECUTION_TARGET = development
endif
ifeq ($(EXECUTION_TARGET),development)
#$(info Execution target is development)
# In general vs Seaplus-specific:
ENABLE_DEBUG = true
# Otherwise the upper layers would inherit it was well:
#ENABLE_SEAPLUS_DEBUG = true
else ifeq ($(EXECUTION_TARGET),production)
#$(info Execution target is production)
# In general vs Seaplus-specific:
ENABLE_DEBUG = false
ENABLE_SEAPLUS_DEBUG = false
else
$(error Invalid Seaplus execution target '$(EXECUTION_TARGET)'; expecting either 'development' or 'production')
endif
# One may define here:
# - EXECUTION_TARGET := production / development [the default]
# - ENABLE_DEBUG: the general, inherited flag for the enabling of debugging
# - ENABLE_SEAPLUS_DEBUG := false / true [the default]; this debug mode enables
# verbose logging (details about ongoing Seaplus operations being reported)
#
# The build of a Seaplus-based driver for a given application may set
# DEBUG_SEAPLUS (e.g. with -DDEBUG_SEAPLUS) in order to enable the traces
# ("extendend logs") it may send, in addition to any traces ("base logs") sent
# by the Seaplus library itself (as controlled by the ENABLE_SEAPLUS_DEBUG
# flag); indeed the LOG_* macros are gated by: '#if SEAPLUS_ENABLE_LOG > 0
# && DEBUG_SEAPLUS' (refer to seaplus.h).
# Now in all cases (even non-debug), we enable the (driver-side) Seaplus logs
# (not implying enabling all traces) through the C compiler options, as we want
# at least some information to be reported in case of a driver crash:
#
SEAPLUS_DEBUG_OPT += -DSEAPLUS_ENABLE_LOG=1
# Not using ENABLE_DEBUG here, as upper layers could set it for themselves
# without wanting Seaplus to behave the same. So ENABLE_SEAPLUS_DEBUG is defined
# and used here.
ifndef ENABLE_SEAPLUS_DEBUG
# Not activated unless requested:
ENABLE_SEAPLUS_DEBUG=false
endif
# Tells whether the debug mode will be activated for the next Seaplus modules to
# be built (maximum performance versus extended checkings).
#
ifeq ($(ENABLE_SEAPLUS_DEBUG),true)
SEAPLUS_DEBUG_OPT := -DDEBUG_SEAPLUS
# Does not seem to be actually used now:
ENABLE_SEAPLUS_DEBUG_OPT = -Dseaplus_debug_mode
else
SEAPLUS_DEBUG_OPT :=
ENABLE_SEAPLUS_DEBUG_OPT =
endif
# Defining (optional) layer-specific flags, typically used by in-code
# conditional compilation primitives (see cond_utils for their management):
# Topics covered by flags:
# - general: how Seaplus behaves in general
# - port: how the service port is managed
# - driver: information about the Seaplus-generated driver
# Defining debug flags (at least the most verbose are by default commented-out):
ifeq ($(ENABLE_SEAPLUS_DEBUG),true)
#SEAPLUS_DEBUG_FLAGS += -Dseaplus_debug_general
#SEAPLUS_DEBUG_FLAGS += -Dseaplus_debug_port
#SEAPLUS_DEBUG_FLAGS += -Dseaplus_debug_driver
endif
# Defining check flags:
ifeq ($(EXECUTION_TARGET),development)
#SEAPLUS_CHECK_FLAGS += -Dseaplus_check_driver
endif
ERLANG_COMPILER_OPT_BASE += -Dseaplus_version=\"$(SEAPLUS_VERSION)\" \
$(SEAPLUS_DEBUG_FLAGS) \
$(SEAPLUS_CHECK_FLAGS)
# Useful to target for example the root of the current layer (e.g. to locate the
# relevant, layer-local '_build' directory):
#
ifndef LAYER_TOP
LAYER_TOP := $(SEAPLUS_TOP)
endif
# Project section.
# PROJECT_NAME should be defined on a per-project basis.
ifndef PROJECT_NAME
PROJECT_NAME := Ceylan-Seaplus
endif
# PROJECT_SHORT_NAME should be defined on a per-project basis.
ifndef PROJECT_SHORT_NAME
PROJECT_SHORT_NAME := seaplus
endif
# PROJECT_NAME_FOR_OTP should be defined on a per-project basis.
ifndef PROJECT_NAME_FOR_OTP
PROJECT_NAME_FOR_OTP := $(PROJECT_SHORT_NAME)
endif
# The uniquely-defined version of this layer, for all uses (including rebar, hex
# and the code itself, see seaplus:get_seaplus_version{_string,}/0):
#
SEAPLUS_VERSION := 1.2.2
# PROJECT_VERSION should be defined on a per-project basis.
ifndef PROJECT_VERSION
PROJECT_VERSION := $(SEAPLUS_VERSION)
endif
ifndef PACKAGE_TOP
PACKAGE_TOP = $(SEAPLUS_TOP)
endif
# For any quick, local, non release-packaged update thereof:
MYRIAD_CHECKOUT_BUILD = $(LAYER_TOP)/_checkouts/myriad
MYRIAD_SIBLING_BUILD = $(LAYER_TOP)/../myriad
# The OTP tree of the Myriad application within a local OTP _build tree:
MYRIAD_LOCAL_APP := $(LAYER_TOP)/_build/default/lib/myriad
# Where Myriad BEAMs are to lie when used as an OTP application:
MYRIAD_LOCAL_EBIN := $(MYRIAD_LOCAL_APP)/ebin
SEAPLUS_RELEASE_BASE := seaplus-$(PROJECT_VERSION)
SEAPLUS_RELEASE_ARCHIVE_ZIP := $(SEAPLUS_RELEASE_BASE).zip
SEAPLUS_RELEASE_ARCHIVE_BZ2 := $(SEAPLUS_RELEASE_BASE).tar.bz2
SEAPLUS_RELEASE_ARCHIVE_XZ := $(SEAPLUS_RELEASE_BASE).tar.xz
# Source section.
SEAPLUS_SRC := $(SEAPLUS_TOP)/src
# BEAM path section.
SEAPLUS_BEAM := $(SEAPLUS_SRC)
# Include path section.
SEAPLUS_INC = -I$(SEAPLUS_TOP)/include
# See Myriad counterpart variable (MYRIAD_BEAM_DIRS) for explanations:
SEAPLUS_BEAM_DIRS := $(SEAPLUS_BEAM) $(SEAPLUS_TOP)/..
# For OTP releases and all:
SEAPLUS_REBAR_BUILD_BASE = $(REBAR_BUILD_DIR)/lib/seaplus
# When building Seaplus in an OTP context from its usual (GIT) root (e.g. with
# 'make rebar3-application'), the BEAMs of Myriad are to be found in the OTP
# build tree - rather than in a supposedly fully-built usual root for Myriad:
#
# (these information are useful only at compilation-time, in order to locate the
# needed parse transforms and their dependencies; at runtime, the OTP rules
# ensure that the relevant ebin directories are in the code path)
#
# Note that this implies that the BEAM files in all ebin directories should be
# up to date with the ones in the build trees, otherwise hard-to-debug
# discrepancies may happen (these OTP/rebar-related directories act as default
# catch-alls, should no prior directory correspond in the BEAM paths).
#
MYRIAD_OTP_BEAM_DIR_FROM_USUAL = $(LAYER_TOP)/$(MYRIAD_REBAR_BUILD_BASE)/ebin
# In an OTP/rebar3-style application layout (not speaking of sibling base
# directories here), at compilation time as well, modules compiled (directly or
# not) by the Myriad parse transform will expect its modules to be located in:
#
# (a third place could be considered, in the _build tree of Myriad itself, yet
# it would not provide any additional chance)
#
MYRIAD_OTP_BEAM_DIR_FROM_OTP = $(LAYER_TOP)/../myriad/ebin/
# To locate Myriad modules from all OTP contexts:
MYRIAD_PARSE_TRANSFORMS_PZ_OPT = -pz $(MYRIAD_OTP_BEAM_DIR_FROM_USUAL) \
-pz $(MYRIAD_OTP_BEAM_DIR_FROM_OTP)
# Library referencing section.
SEAPLUS_LIB = libseaplus-$(SEAPLUS_VERSION).so
SEAPLUS_LIB_DIR = $(SEAPLUS_TOP)/src
SEAPLUS_LIB_PATH = $(SEAPLUS_LIB_DIR)/$(SEAPLUS_LIB)
SEAPLUS_LIB_OPT = -L$(SEAPLUS_LIB_DIR) -lseaplus-$(SEAPLUS_VERSION)
# See Myriad counterpart variable (MYRIAD_BEAM_DIRS) for explanations:
SEAPLUS_BEAM_DIRS = $(SEAPLUS_TOP)/src
# We rely on Myriad as well:
BEAM_DIRS += $(SEAPLUS_BEAM_DIRS)
ifndef VM_TEST_NAME
VM_NAME := seaplus_debug
endif
ifndef VM_TEST_NAME
VM_TEST_NAME := seaplus_test
endif
# Build section.
# libtool not used anymore, was making the build degenerate in a mess:
#LIBTOOL = $(shell which libtool 2>/dev/null)
# This is a C-based (not C++) example:
#LIBTOOL_C_OPT += --tag=CC --verbose
# Compiler section.
SEAPLUS_BASE_NAME := seaplus
# C subsection.
ERL_INTERFACE_INC = -I$(ERL_INTERFACE)/include
ERL_INTERFACE_LIB = -L$(ERL_INTERFACE)/lib
C_COMPILER := $(shell which gcc 2>/dev/null)
C_INC = $(ERL_INTERFACE_INC) -I. $(SEAPLUS_INC)
C_LIB = $(ERL_INTERFACE_LIB)
ifndef C_COMPILER_OPT
C_COMPILER_OPT = $(C_INC) $(SEAPLUS_DEBUG_OPT) -Wall -Werror -g
endif
ifndef C_COMPILER_OPT_FOR_OBJ
C_COMPILER_OPT_FOR_OBJ = $(C_COMPILER_OPT) -fPIC
endif
# Erlang subsection.
# Base Erlang installation (e.g the base directory from which lib/erlang/emacs
# can be found), either hardcoded or deduced from the selected interpreter:
#
#ERL_BASE := $(HOME)/Software/Erlang/Erlang-current-install
#ERL_BASE = $(shell dirname $(ERLANG_INTERPRETER) 2>/dev/null)/..
# As installation structures may vary:
# Typically if installed thanks to our install-erlang.sh script in one's user
# account:
#
ERL_BASE_FIRST_CANDIDATE = $(shell dirname $(ERLANG_INTERPRETER) 2>/dev/null)/..
# Typically if installed thanks to our install-erlang.sh script in the system
# tree (hence as /usr/local/lib):
#
ERL_BASE_SECOND_CANDIDATE = $(shell dirname $(ERLANG_INTERPRETER) 2>/dev/null)/../../..
# Typically if using an erlang:latest image (e.g. in Github's continuous
# integration):
#
ERL_BASE_THIRD_CANDIDATE = $(shell dirname $(ERLANG_INTERPRETER) 2>/dev/null)/../../../..
ERL_BASE = $(shell if [ -d $(ERL_BASE_FIRST_CANDIDATE)/lib/erlang/lib/erl_interface-* ]; then echo "$(ERL_BASE_FIRST_CANDIDATE)"; elif [ -d $(ERL_BASE_SECOND_CANDIDATE)/lib/erlang/lib/erl_interface-* ]; then echo "$(ERL_BASE_SECOND_CANDIDATE)"; else echo "$(ERL_BASE_THIRD_CANDIDATE)"; fi)
# As version numbers are in the way:
ERL_INTERFACE = $(shell /bin/ls -d $(ERL_BASE)/lib/erlang/lib/erl_interface-* 2>/dev/null)
# Allows to ensure that we have a proper base installation (and not for example
# an empty directory due to a failed filtering):
#
ERL_BASE_CONTENT = $(ERL_BASE)/lib/erlang
# Modules needed for the bootstrapping for others (hence to be built first, and
# not parse-transformed; typically *used* by parse-transforms, or being a
# parse-transform themselves)
#
# (see the 'Bootstrap section' in GNUmakerules-explicit.inc for their
# special-cased build)
#
ifndef BOOTSTRAP_MODULES
# We want to bootstrap all relevant Seaplus modules (Myriad expected to be
# already fully built)
# We list here all the Seaplus-level prerequisites of the Seaplus
# parse-transform:
#
# - seaplus_info: to manage layer-level information
#BOOTSTRAP_MODULES = $(SEAPLUS_TOP)/src/seaplus_info.beam
# Needed to be defined and set to empty, otherwise deemed undefined and
# inheriting thus the Myriad ones:
#
BOOTSTRAP_MODULES = $(empty)
endif
ifndef COMPILER_OPT_FOR_SEAPLUS_MODULES
COMPILER_OPT_FOR_SEAPLUS_MODULES = \
$(ERLANG_COMPILER_OPT_BASE) \
$(ENABLE_SEAPLUS_DEBUG_OPT) \
$(ERLANG_COMPILER_PARSE_TRANSFORM_OPT_FOR_SEAPLUS)
endif
# With Seaplus, *all* modules (being Seaplus stubs or not) shall be compiled
# with the Seaplus parse-transform, which operates only if needed, and triggers
# the Myriad one appropriately:
#
ifndef ERLANG_COMPILER_PARSE_TRANSFORM_OPT_FOR_STANDARD_MODULES
# All modules (being Seaplus stubs or not) shall be compiled with the
# Seaplus parse-transform, which operates only if needed, driving the Myriad
# one appropriately:
#
ERLANG_COMPILER_PARSE_TRANSFORM_OPT_FOR_STANDARD_MODULES = \
$(ERLANG_COMPILER_PARSE_TRANSFORM_OPT_FOR_SEAPLUS) \
$(MYRIAD_PARSE_TRANSFORMS_PZ_OPT)
endif
# Conditionally defined so that upper layer may update these settings (e.g.
# by adding pz directories):
#
ifndef ERLANG_COMPILER_OPT_FOR_STANDARD_MODULES
# Same rules for all modules:
ERLANG_COMPILER_OPT_FOR_STANDARD_MODULES = \
$(ERLANG_COMPILER_OPT_BASE) \
$(ERLANG_COMPILER_PARSE_TRANSFORM_OPT_FOR_STANDARD_MODULES) \
$(ENABLE_SEAPLUS_DEBUG_OPT)
endif
## Parse-transform related section.
# List here all the directories expected to contain parse transforms:
#
# (to be overridden by each upper layer)
#
ifndef PARSE_TRANSFORM_DIRS
PARSE_TRANSFORM_DIRS = $(SEAPLUS_TOP)/src
endif
# So that the (compilation of the) Seaplus parse transform can benefit from the
# Myriad parse transform:
#
ERLANG_COMPILER_OPT_FOR_PT = $(ERLANG_COMPILER_PARSE_TRANSFORM_OPT_FOR_MYRIAD) \
$(ENABLE_SEAPLUS_DEBUG_OPT)
# Variable defined to be re-usable by upper layers, so that compiling their own
# parse transforms can take advantage of the Seaplus one:
#
# (to find seaplus_parse_transform.beam, both the Seaplus 'src' and 'ebin'
# directories are specified: the former for our native build, the latter for a
# rebar3-based one)
#
ERLANG_COMPILER_PARSE_TRANSFORM_OPT_FOR_SEAPLUS = \
$(OVERALL_PA_OPTS) \
-Dseaplus_root=\"$(SEAPLUS_TOP)\" \
-pz $(SEAPLUS_TOP)/ebin \
-pz $(SEAPLUS_TOP)/src \
$(MYRIAD_PARSE_TRANSFORMS_PZ_OPT) \
'+{parse_transform,seaplus_parse_transform}'
# We conditionally defined this option, as upper layers may want to trigger
# their own parse transforms *instead* (probably that they will call directly,
# by themselves, at the Erlang level, this 'Seaplus' parse transform):
#
ifndef ERLANG_COMPILER_PARSE_TRANSFORM_OPT
ERLANG_COMPILER_PARSE_TRANSFORM_OPT = $(ERLANG_COMPILER_PARSE_TRANSFORM_OPT_FOR_SEAPLUS)
endif
# Variable defined to be re-usable by upper layers, so that compiling their own
# parse transforms can take advantage of the Seaplus one:
#
COMPILER_PARSE_TRANSFORM_FOR_SEAPLUS_CLASSES_OPT = \
'+{parse_transform,seaplus_parse_transform}'
# Linking section.
C_LINKER := $(C_COMPILER)
# -shared probably unwelcome with libtool:
C_LINKER_OPT := -g
# Not used anymore since Erl_interface is deprecated: -lerl_interface
C_LINKER_LIBS = $(ERL_INTERFACE_LIB) -lei -lpthread
# Checking section.
# For later reuse in the next layer of the software stack:
SEAPLUS_PLT_FILE := $(SEAPLUS_TOP)/Ceylan-Seaplus.plt
# This is the merged PLT of the level just below in the software stack.
# For 'Seaplus', it is the PLT of 'Myriad':
#
ifndef PREDECESSOR_PLT_FILE
PREDECESSOR_PLT_FILE = $(MYRIAD_PLT_FILE)
endif
# Foobar-related section.
FOOBAR_ROOT = $(SEAPLUS_TOP)/test/c-test/foobar
FOOBAR_INC = $(FOOBAR_ROOT)/inc
FOOBAR_INC_OPT = -I$(FOOBAR_INC)
FOOBAR_LIB_DIR = $(FOOBAR_ROOT)/lib
FOOBAR_LIBRARY = libfoobar.so
FOOBAR_LIB_PATH = $(FOOBAR_LIB_DIR)/$(FOOBAR_LIBRARY)
# Documentation section.
# No $(LAYER_TOP) in includes, it would be misleading as edoc is run from the
# clone root, not from doc:
#
ifndef EDOC_OPTS
EDOC_OPTS = '[{dir,"$(API_DOC_ROOT)"}, {def,{vsn,"$(PROJECT_VERSION)"}}, {preprocess,true}, {macros,[{$(PROJECT_EDOC_VERSION_KEY),"$(PROJECT_VERSION)"}]}, {includes,["..", "$(MYRIAD_TOP)/.."]}, {overview, "doc/overview.edoc"}]'
endif
# We define the path to the Myriad layer (possibly available as a symbolic
# link).
#
# For the sake of these build-related makefiles, Ceylan dependencies will be
# searched (in that order, the one enforced in otp_utils) in a local _checkouts
# child directory (if checkout directories are used and if the top-level package
# of interest is the current one), otherwise in sibling directories (i.e. whose
# build root is at the same level as this one).
#
# This last case happens notably if not using checkout directories, or if using
# them and if all the packages mentioned here are themselves dependencies (in
# which case they are all sitting together in the _checkouts child directory).
#
# Note also we rely on the names of build roots (e.g. myriad) as opposed to
# project/repository names (e.g. Ceylan-Myriad):
#
# First priority is an existing checkout directory:
ifneq ($(wildcard $(SEAPLUS_TOP)/_checkouts/myriad/.),)
MYRIAD_TOP = $(SEAPLUS_TOP)/_checkouts/myriad
else
# Second, a sibling one is searched for:
ifneq ($(wildcard $(SEAPLUS_TOP)/../myriad/.),)
MYRIAD_TOP = $(SEAPLUS_TOP)/../myriad
else
# Otherwise most probably in a 'rebar3 compile' context:
ifneq ($(wildcard $(SEAPLUS_TOP)/_build/default/lib/myriad/.),)
MYRIAD_TOP = $(SEAPLUS_TOP)/_build/default/lib/myriad
else
FORCE_EVAL := $(error Unable to find the build root of Ceylan-Myriad from '$(realpath .)'.)
endif
endif
endif
ifndef PREDECESSOR_LAYER_TOPS
PREDECESSOR_LAYER_TOPS := $(MYRIAD_TOP)
endif