-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
771 lines (644 loc) · 22.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
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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
#
# Copyright 2014, General Dynamics C4 Systems
#
# This software may be distributed and modified according to the terms of
# the GNU General Public License version 2. Note that NO WARRANTY is provided.
# See "LICENSE_GPLv2.txt" for details.
#
# @TAG(GD_GPL)
#
# Disable built-in rules.
.SUFFIXES:
############################################################
### Build parameters
############################################################
SEL4_ARCH_LIST:=aarch32 aarch64 ia32 x86_64
ARCH_LIST:=arm x86
CPU_LIST:=arm1136jf-s ixp420 cortex-a7 cortex-a8 cortex-a9 cortex-a15 cortex-a53 cortex-a57
PLAT_LIST:=imx31 pc99 ixp420 omap3 am335x exynos4 exynos5 imx6 imx7 apq8064 zynq7000 allwinnerA20 tk1 hikey bcm2837 tx1
ARMV_LIST:=armv6 armv7-a armv8-a
ifndef SOURCE_ROOT
# Assume we're in the source directory if not specified.
SOURCE_ROOT=.
export SOURCE_ROOT
endif
# The if statements below check to see if the make target doesn't require
# values for the ARCH, PLAT, or SEL4_ARCH variables.
ifneq (${MAKECMDGOALS},)
ifeq (${MAKECMDGOALS}, $(filter ${MAKECMDGOALS}, style astyle xmllint pylint))
# Pick an arbitrary value for ARCH, PLAT, and SEL4_ARCH to placate
# other rules that depend on them being defined.
ARCH:=x86
PLAT:=pc99
SEL4_ARCH:=ia32
endif
endif
# we do need them if we want to build anything else
$(if $(filter ${ARCH},${ARCH_LIST}),, \
$(error ARCH ${ARCH} invalid or undefined, should be one of [${ARCH_LIST}]))
$(if $(filter ${PLAT},${PLAT_LIST}),, \
$(error PLAT ${PLAT} invalid or undefined, should be one of [${PLAT_LIST}]))
ifeq (${ARCH}, arm)
$(if $(filter ${CPU},${CPU_LIST}),, \
$(error CPU ${CPU} invalid or undefined, should be one of [${CPU_LIST}]))
$(if $(filter ${ARMV},${ARMV_LIST}),, \
$(error ARMV ${ARMV} invalid or undefined, should be one of [${ARMV_LIST}]))
ifneq (${SEL4_ARCH}, aarch64)
SEL4_ARCH:=aarch32
endif
endif
$(if $(filter ${SEL4_ARCH},${SEL4_ARCH_LIST}),, \
$(error SEL4_ARCH ${SEL4_ARCH} invalid or undefined, should be one of [${SEL4_ARCH_LIST}]))
# If no domain configuration file was specified, use a default
# configuration of just a single domain.
ifeq (${CONFIG_DOMAIN_SCHEDULE},)
DOMAIN_CONFIG_FILE=${SOURCE_ROOT}/src/config/default_domain.c
else
DOMAIN_CONFIG_FILE=$(wildcard ${CONFIG_DOMAIN_SCHEDULE})
ifeq ($(DOMAIN_CONFIG_FILE),)
$(error Domain schedule, ${CONFIG_DOMAIN_SCHEDULE}, does not exist)
endif
endif
### Verbose building
########################################
# Set V=1 for verbose building, this can be passed in on the command line
# Set V=2 to have make echo out commands before executing them
ifeq ($V, 1)
BUILD_VERBOSE = 1
MAKE_SILENT = -s
quiet =
Q =
else
ifeq ($V, 2)
BUILD_VERBOSE = 1
MAKE_SILENT =
quiet =
Q =
else
ifeq ($V, 3)
BUILD_VERBOSE = 1
MAKE_SILENT =
quiet =
Q =
else
MAKE_SILENT = -s
quiet = quiet_
Q = @
endif
endif
endif
### Benchmarking parameters
########################################
CONFIG_DEFS=
ifdef BENCHMARK_PROFILER
CONFIG_DEFS += PROFILER
ifdef CHECKPOINT_PROFILER
CONFIG_DEFS += CHECKPOINT_PROFILER
endif # CHECKPOINT_PROFILER
else
CONFIG_DEFS = CYCLE_COUNTER
endif # BENCHMARK_PROFILER
ifdef BENCHMARK_ICACHE
CONFIG_DEFS += PERF_COUNTER=ARM_INSTRUCTION_CACHE_MISS
else
ifdef BENCHMARK_DCACHE
CONFIG_DEFS += PERF_COUNTER=ARM_DATA_CACHE_MISS
else
CONFIG_DEFS += PERF_COUNTER=CYCLE_COUNTER
endif # BENCHMARK_DCACHE
endif # BENCHMARK_ICACHE
ifdef IOMMU
CONFIG_DEFS += CONFIG_IOMMU
endif
CONFIG_DEFS += $(strip $(foreach var, \
CONFIG_ROOT_CNODE_SIZE_BITS \
CONFIG_TIME_SLICE \
CONFIG_NUM_DOMAINS \
CONFIG_NUM_PRIORITIES \
CONFIG_RETYPE_FAN_OUT_LIMIT \
CONFIG_MAX_NUM_WORK_UNITS_PER_PREEMPTION \
CONFIG_MAX_NUM_BOOTINFO_DEVICE_REGIONS \
CONFIG_MAX_NUM_BOOTINFO_UNTYPED_CAPS \
CONFIG_TIMER_TICK_MS, \
$(if $(value ${var}), ${var}=$(value ${var}), )))
ifdef BUILD_VERBOSE
$(info seL4 build options:)
$(info ===================)
$(info ARCH = ${ARCH})
$(info PLAT = ${PLAT})
$(info CPU = ${CPU})
$(info TOOLPREFIX = ${TOOLPREFIX})
$(info PATH = ${PATH})
$(info DEBUG = ${DEBUG})
$(info ASSERT = ${ASSERT})
$(info CONFIG_DEFS = ${CONFIG_DEFS})
$(info DANGEROUS_CODE_INJECTION = ${DANGEROUS_CODE_INJECTION})
endif
.PHONY: all default clean preprocess validate
default: all
############################################################
### Tool setup
############################################################
PATH := "${SOURCE_ROOT}/tools:${PATH}"
export PATH
PARSER = c-parser
CC =
# Allow manually specifying a compiler.
ifdef CONFIG_KERNEL_COMPILER
ifneq (${CONFIG_KERNEL_COMPILER},)
ifneq (${CONFIG_KERNEL_COMPILER},"")
CC = ${CONFIG_KERNEL_COMPILER}
# Assume that this is a non-GNU compiler.
CPPFLAGS += -U__GNUC__
endif
endif
endif
ifeq (${CC},)
CC = ${TOOLPREFIX}gcc
endif
ifeq (${PYTHON},)
PYTHON = python
endif
# Allow manually appending CPP flags.
ifneq (${CONFIG_KERNEL_EXTRA_CPPFLAGS},)
ifneq (${CONFIG_KERNEL_EXTRA_CPPFLAGS},"")
CPPFLAGS += ${CONFIG_KERNEL_EXTRA_CPPFLAGS}
endif
endif
CPP = ${TOOLPREFIX}cpp
AS = ${TOOLPREFIX}as
LD = ${TOOLPREFIX}ld
STRIP = ${TOOLPREFIX}strip
BF_GEN_PATH = ${SOURCE_ROOT}/tools/bitfield_gen.py
CHANGED = ${SOURCE_ROOT}/tools/changed.sh
CPP_GEN = ${SOURCE_ROOT}/tools/cpp_gen.sh
SYSCALL_ID_GEN_PATH = ${SOURCE_ROOT}/tools/syscall_header_gen.py
INVOCATION_ID_GEN_PATH = ${SOURCE_ROOT}/tools/invocation_header_gen.py
XMLLINT = xmllint.sh
CIRCULAR_INCLUDES = ${SOURCE_ROOT}/tools/circular_includes.py
########################################
## Check tools
########################################
ifdef BUILD_VERBOSE
$(info CC = ${CC})
$(info CC_PATH = ${CC_PATH})
$(info CPP = ${CPP})
$(info CPP_PATH = ${CPP_PATH})
$(info AS = ${AS})
$(info AS_PATH = ${AS_PATH})
$(info LD = ${LD})
$(info LD_PATH = ${LD_PATH})
$(info PARSER = ${PARSER})
$(info PARSER_PATH = ${PARSER_PATH})
$(info BF_GEN_PATH = ${BF_GEN_PATH})
$(info SYSCALL_ID_GEN_PATH = ${SYSCALL_ID_GEN_PATH})
$(info INVOCATION_ID_GEN_PATH = ${INVOCATION_ID_GEN_PATH})
$(info XMLLINT_PATH = ${XMLLINT_PATH})
$(info XMLLINT = ${XMLLINT})
endif
ifndef SKIP_PATH_CHECKS
CC_PATH = $(shell PATH=${PATH} sh -c "which ${CC}")
$(if ${CC_PATH},,$(error ${CC} not in PATH or not executable))
CPP_PATH = $(shell PATH=${PATH} sh -c "which ${CPP}")
$(if ${CPP_PATH},,$(error ${CPP} not in PATH or not executable))
AS_PATH = $(shell PATH=${PATH} sh -c "which ${AS}")
$(if ${AS_PATH},,$(error ${AS} not in PATH or not executable))
LD_PATH = $(shell PATH=${PATH} sh -c "which ${LD}")
$(if ${LD_PATH},,$(error ${LD} not in PATH or not executable))
STRIP_PATH = $(shell PATH=${PATH} sh -c "which ${STRIP}")
$(if ${STRIP_PATH},,$(error ${STRIP} not in PATH or not executable))
PYTHON_PATH = $(shell PATH=${PATH} sh -c "which ${PYTHON}")
$(if ${PYTHON_PATH},,$(error ${PYTHON} not in PATH or not executable))
XMLLINT_PATH = $(shell PATH=${PATH} sh -c "which ${XMLLINT}")
$(if ${XMLLINT_PATH},,$(error ${XMLLINT} not in PATH or not executable))
endif
ifeq ($(SORRY_BITFIELD_PROOFS),1)
SORRY_ARG:=--sorry_lemmas
else
SORRY_ARG:=
endif
# If a parent Makefile has passed us DEFINES, assume they will be missing -D.
DEFINES := ${DEFINES:%=-D%}
INCLUDES = ${INCLUDE_DIRS:%=-I%}
DEFINES += ${CONFIG_DEFS:%=-D%}
ifdef DEBUG
DEFINES += -DDEBUG
CFLAGS += -ggdb -g3
endif
ifdef DANGEROUS_CODE_INJECTION
DEFINES += -DDANGEROUS_CODE_INJECTION
endif
ifdef ASSERT
DEFINES += -DASSERT
endif
ifdef FASTPATH
DEFINES += -DFASTPATH
endif
# Only set CFLAGS if we're building standalone.
# common/Makefile.Flags sets NK_CFLAGS in Kbuild environments.
#
# This entire block is not executed if building a stand alone kernel!
ifndef NK_CFLAGS
STATICHEADERS += autoconf.h
DEFINES += -DHAVE_AUTOCONF
ifdef DEBUG
DEFINES += -DCONFIG_DEBUG_BUILD
DEFINE += -DCONFIG_PRINTING
DEFINES += -DCONFIG_USER_STACK_TRACE_LENGTH=1
endif
ifeq (${ARCH}, arm)
CFLAGS += -mtune=${CPU} -marm -march=${ARMV}
ASFLAGS += -Wa,-mcpu=${CPU} -Wa,-march=${ARMV}
DEFINES += -D$(shell echo ${ARMV}|tr [:lower:] [:upper:]|tr - _)
DEFINES += -DARCH_ARM
ifeq (${SEL4_ARCH}, aarch32)
DEFINES += -D__KERNEL_32__ -DAARCH32
TYPE_SUFFIX:=32
export __ARM_32__ = y
ifeq (${CPU},cortex-a7)
DEFINES += -DARM_CORTEX_A7
endif
ifeq (${CPU},cortex-a8)
DEFINES += -DARM_CORTEX_A8
endif
ifeq (${CPU},cortex-a9)
DEFINES += -DARM_CORTEX_A9
endif
ifeq (${CPU},cortex-a15)
DEFINES += -DARM_CORTEX_A15
endif
ifeq ($(PLAT),imx6)
DEFINES += -DIMX6
endif
ifeq ($(PLAT),imx7)
DEFINES += -DIMX7
endif
ifeq ($(PLAT),imx31)
DEFINES += -DIMX31
endif
ifeq ($(PLAT),pc99)
DEFINES += -DPC99
endif
ifeq ($(PLAT),ixp420)
DEFINES += -DIXP420
endif
ifeq ($(PLAT),omap3)
DEFINES += -DOMAP3
endif
ifeq ($(PLAT),am335x)
DEFINES += -DAM335X
endif
ifeq ($(PLAT),exynos4)
DEFINES += -DEXYNOS4
endif
ifeq ($(PLAT),exynos5)
DEFINES += -DEXYNOS5
endif
ifeq ($(PLAT),apq8064)
DEFINES += -DAPQ8064
endif
ifeq ($(PLAT),zynq7000)
DEFINES += -DZYNQ7000
endif
ifeq ($(PLAT),allwinnerA20)
DEFINES += -DALLWINNERA20
endif
ifeq ($(PLAT),bcm2837)
DEFINES += -DBCM2837
endif
endif # SEL4_ARCH=aarch32
ifeq (${SEL4_ARCH}, aarch64)
DEFINES += -D__KERNEL_64__ -DAARCH64
TYPE_SUFFIX:=64
export __ARM_64__ = y
endif # SEL4_ARCH=aarch64
ifeq (${CPU},cortex-a53)
DEFINES += -DARM_CORTEX_A53
endif
ifeq ($(PLAT),hikey)
DEFINES += -DHIKEY
endif
endif # ARCH=arm
ifeq (${SEL4_ARCH}, x86_64)
CFLAGS += -m64 -fno-asynchronous-unwind-tables
ASFLAGS += -Wa,--64
DEFINES += -DARCH_X86 -DX86_64 -DCONFIG_X86_64=y -D__KERNEL_64__ -DKERNEL_64=y -D__X86_64__=y
export __X86_64__ = y
TYPE_SUFFIX:=64
endif
ifeq (${SEL4_ARCH}, ia32)
CFLAGS += -m32
ASFLAGS += -Wa,--32
DEFINES += -DARCH_IA32 -DARCH_X86 -DX86_32 -D__KERNEL_32__
LDFLAGS += -Wl,-m,elf_i386
TYPE_SUFFIX:=32
export __X86_32__ = y
endif
else # NK_CFLAGS
# Require autoconf to be provided if larger build
$(if ${HAVE_AUTOCONF},,$(error autoconf.h not provided))
STATICHEADERS += $(srctree)/include/generated/autoconf.h
endif # NK_CFLAGS
ifeq (${SEL4_ARCH}, ia32)
INCLUDES += "-I${SOURCE_ROOT}/include/arch/$(ARCH)/arch/32"
INCLUDES += "-I${SOURCE_ROOT}/include/plat/$(PLAT)/plat/32"
else
ifeq ($(SEL4_ARCH), x86_64)
INCLUDES += "-I${SOURCE_ROOT}/include/arch/$(ARCH)/arch/64"
INCLUDES += "-I${SOURCE_ROOT}/include/plat/$(PLAT)/plat/64"
endif
endif
ifeq ($(SEL4_ARCH), aarch32)
INCLUDES += "-I${SOURCE_ROOT}/include/arch/$(ARCH)/arch/32"
INCLUDES += "-I${SOURCE_ROOT}/include/plat/$(PLAT)/plat/32"
else
ifeq ($(SEL4_ARCH), aarch64)
INCLUDES += "-I${SOURCE_ROOT}/include/arch/$(ARCH)/arch/64"
INCLUDES += "-I${SOURCE_ROOT}/include/plat/$(PLAT)/plat/64"
endif
endif
ifeq (${CPU}, arm1136jf-s)
DEFINES += -DARM1136_WORKAROUND
# Add definition for verified platform to support standalone kernel builds
DEFINES += -DCONFIG_ARM1136JF_S
endif
WARNINGS = all error strict-prototypes missing-prototypes nested-externs \
missing-declarations undef pointer-arith no-nonnull
CFLAGS += --std=c99 -nostdlib -nostdinc -ffreestanding \
${WARNINGS:%=-W%} ${INCLUDES} -fno-pic
CPPFLAGS += -nostdinc
LDFLAGS += -nostdlib -nostdinc -static
LDFLAGS += -Wl,--build-id=none
ASFLAGS += ${INCLUDES}
# Compiler optimisation level. Note that you can't build the kernel with
# GCC -Os without linking against libgcc.
ifeq (${CONFIG_OPTIMISATION_Os},y)
CFLAGS += -Os
LDFLAGS += -Os
else
ifeq (${CONFIG_OPTIMISATION_O0},y)
CFLAGS += -O0
LDFLAGS += -O0
else
ifeq (${CONFIG_OPTIMISATION_O1},y)
CFLAGS += -O1
LDFLAGS += -O1
else
ifeq (${CONFIG_OPTIMISATION_O3},y)
CFLAGS += -O3
LDFLAGS += -O3
else # Make -O2 the default for kernel builds.
CFLAGS += -O2
LDFLAGS += -O2
endif # CONFIG_OPTIMISATION_O3
endif # CONFIG_OPTIMISATION_O1
endif # CONFIG_OPTIMISATION_O0
endif # CONFIG_OPTIMISATION_Os
# Attempt to enable -fwhole-program if it was requested. Considered harmful
ifeq (${CONFIG_WHOLE_PROGRAM_OPTIMISATIONS_KERNEL}, y)
CFLAGS += -fwhole-program
endif
# Set kernel build specific flags for the different x86 variants
# These are set here and not by the common build system as they
# only apply to building the kernel, and nothing else
ifeq (${ARCH}, x86)
CFLAGS += -mno-mmx -mno-sse -mno-sse2 -mno-3dnow
endif
ifeq (${SEL4_ARCH}, x86_64)
CFLAGS += -mcmodel=kernel
endif
# Allow overriding of the CFLAGS. Use with caution.
ifdef CONFIG_KERNEL_CFLAGS
ifneq (${CONFIG_KERNEL_CFLAGS},)
ifneq (${CONFIG_KERNEL_CFLAGS},"")
CFLAGS := ${CONFIG_KERNEL_CFLAGS}
endif
endif
endif
CFLAGS += ${DEFINES}
CPPFLAGS += ${DEFINES} ${INCLUDES}
ifdef BUILD_VERBOSE
$(info CFLAGS = ${CFLAGS})
$(info ASFLAGS = ${ASFLAGS})
$(info CPPFLAGS = ${CPPFLAGS})
$(info LDFLAGS = ${LDFLAGS})
endif
############################################################
### Paths
############################################################
PYTHONPATH := ${PYTHONPATH}:${SOURCE_ROOT}/tools
export PYTHONPATH
vpath %.c ${SOURCE_ROOT}
vpath %.S ${SOURCE_ROOT}
vpath %.h ${SOURCE_ROOT}
vpath %.bf ${SOURCE_ROOT}/include \
${SOURCE_ROOT}/include/arch/${ARCH} \
${SOURCE_ROOT}/include/plat/${PLAT}
vpath %.lds ${SOURCE_ROOT}
INCLUDE_DIRS = ${SOURCE_ROOT}/include ${SOURCE_ROOT}/include/arch/${ARCH} \
${SOURCE_ROOT}/include/plat/${PLAT} .
############################################################
### Sub-makefiles
############################################################
include ${SOURCE_ROOT}/include/arch/${ARCH}/arch/Makefile
include ${SOURCE_ROOT}/include/plat/${PLAT}/plat/Makefile
include ${SOURCE_ROOT}/src/arch/${ARCH}/Makefile
include ${SOURCE_ROOT}/src/plat/${PLAT}/Makefile
include ${SOURCE_ROOT}/include/Makefile
include ${SOURCE_ROOT}/src/Makefile
DIRECTORIES += arch plat src arch/api
############################################################
### Sources and targets
############################################################
C_SOURCES += $(patsubst %, src/arch/${ARCH}/%, ${ARCH_C_SOURCES})
ASM_SOURCES += $(patsubst %, src/arch/${ARCH}/%, ${ARCH_ASM_SOURCES})
C_SOURCES += $(patsubst %, src/plat/${PLAT}/%, ${PLAT_C_SOURCES})
ASM_SOURCES += $(patsubst %, src/plat/${PLAT}/%, ${PLAT_ASM_SOURCES})
GENHEADERS = $(patsubst %.bf, %.pbf, ${BF_SOURCES}) \
$(patsubst %.bf, %_gen.h, ${BF_SOURCES})
GENHEADERS += arch/api/invocation.h arch/api/sel4_invocation.h api/invocation.h arch/api/syscall.h
DEFTHEORIES = $(patsubst %.bf, %_defs.thy, ${BF_SOURCES})
PROOFTHEORIES = $(patsubst %.bf, %_proofs.thy, ${BF_SOURCES})
THEORIES = ${DEFTHEORIES} ${PROOFTHEORIES}
C_SOURCES_WITH_PARSE = $(sort ${C_SOURCES})
STATICHEADERS := $(shell find ${SOURCE_ROOT}/include/ -name "*.h" \
! -regex ".*include/arch.*" \
! -regex ".*include/plat.*") \
$(shell find ${SOURCE_ROOT}/include/arch/${ARCH} -name "*.h") \
$(shell find ${SOURCE_ROOT}/include/plat/${PLAT} -name "*.h")
ifeq (${HAVE_AUTOCONF}, 1)
STATICHEADERS += $(srctree)/include/generated/autoconf.h
endif
STATICSOURCES = $(foreach file,${C_SOURCES_WITH_PARSE} ${ASM_SOURCES}, \
${SOURCE_ROOT}/${file})
OBJECTS = ${ASM_SOURCES:.S=.o} kernel.o
MAKEFILES := $(shell find ${SOURCE_ROOT} -name "Makefile")
############################################################
### Top-level targets
############################################################
all: kernel.elf kernel.elf.strip
theories: ${THEORIES}
preprocess: ${PPFILES}
.PHONY: style astyle xmllint pylint
# Combine style-checking rules into a single rule
style: astyle xmllint pylint
astyle: $(shell find ${SOURCE_ROOT}/src ${SOURCE_ROOT}/include ${SOURCE_ROOT}/libsel4 -name '*.[ch]')
@echo " [Checking C style]"
$(Q)astyle --max-instatement-indent=120 --style=otbs --pad-header --indent=spaces=4 --pad-oper $^
API_DTD = libsel4/tools/sel4_idl.dtd
xmllint: libsel4/include/interfaces/sel4.xml $(wildcard ${SOURCE_ROOT}/libsel4/arch_include/*/interfaces/sel4arch.xml) \
$(wildcard ${SOURCE_ROOT}/libsel4/sel4_arch_include/*/interfaces/sel4arch.xml)
@echo " [Checking XML API descriptions against $(API_DTD)]"
$(Q)xmllint --dtdvalid $(API_DTD) --noout $^
pylint: $(shell find ${SOURCE_ROOT}/tools ${SOURCE_ROOT}/manual/tools ${SOURCE_ROOT}/libsel4/tools -name '*.py')
@echo " [Checking for errors in python scripts]"
$(Q)pylint --errors-only $^
validate: c-parser.log
c-parser.log: kernel_all.c_pp
@echo " [VALIDATE] $<"
$(Q)${PARSER} $^ 2>&1 | tee [email protected]
$(Q)mv [email protected] $@
# The list of sources is a variable, not a file, so there is no sane way to ask make to depend
# upon it. This rule exists to touch a file to force the regeneration of kernel_all.c if we
# suspect that anything has changed that may have caused the sources list to change.
# Depend upon STATICHEADERS for autoconf/config related changes. Then try and depend upon
# any Makefiles. If you change environment variables (such as debug or fastpath in cases where
# not using autoconf) then you should make clean yourself. These dependencies really should
# just be on the kernel_all.c rule, but there is some magic in the usage of the $^ variable
# which has had the prerequsites located in the VPATH, and doing this ourselves from the
# C_SOURCES_WITH_PARSE variable is more trouble than this horrible intermediate file.
sources_list_updated: ${STATICHEADERS} ${MAKEFILES}
@echo " [TOUCH] $@"
$(Q)touch $@
kernel_all.c: sources_list_updated ${C_SOURCES_WITH_PARSE} ${DOMAIN_CONFIG_FILE}
@echo " [CPP_GEN] $@"
$(Q)${CPP_GEN} $(wordlist 2, $(words $^), $^) > $@
kernel.o: kernel_final.s
@echo " [AS] $@"
# Clear any .arch directive from the .s file in case we are assembling
# for a different architecture. This happens when the compiler supports
# a subset architecture compared to the assembler. For example where the
# compiler only supports armv7-a, where the assembler supports armv7ve
$(Q)sed -i 's/^[ \t]*\.arch .*$$//' $<
$(Q)${CC} ${ASFLAGS} -o $@ -c $<
kernel_final.s: kernel_final.c
@echo " [CC] $@"
$(Q)${CC} ${CFLAGS} -S -o $@ $<
# Awkward rule to get around passing -x to CC and having a .c input file.
kernel_final.c: kernel_all.c_pp
@echo " [Circular includes] $<"
$(Q)${CIRCULAR_INCLUDES} < $<
@echo " [CP] $@"
$(Q)cp -a $< $@
LINKER_SCRIPT = src/plat/${PLAT}/linker.lds
linker.lds_pp: ${LINKER_SCRIPT}
@echo " [CPP] $@"
$(Q)${CPP} ${CPPFLAGS} -P -E -o $@ -x c $<
kernel.elf: ${OBJECTS} linker.lds_pp
@echo " [LD] $@"
$(Q)${CHANGED} $@ ${CC} ${LDFLAGS} -T linker.lds_pp -Wl,-n \
-o $@ ${OBJECTS}
autoconf.h: include/plat/${PLAT}/autoconf.h
${Q}cp $< $@
############################################################
### Pattern rules
############################################################
%.elf.strip: %.elf | ${DIRECTORIES}
@echo " [STRIP] $@"
$(Q)${STRIP} -o $@ $<
%.o: %.s_pp | ${DIRECTORIES}
@echo " [AS] $@"
$(Q)${CC} ${ASFLAGS} -x assembler -c $< -o $@
###################
# Header generation
###################
arch/api/invocation.h: ${SOURCE_ROOT}/libsel4/arch_include/${ARCH}/interfaces/sel4arch.xml ${INVOCATION_ID_GEN_PATH} | ${DIRECTORIES}
$(Q)rm -f ${SOURCE_ROOT}/include/arch/${ARCH}/arch/api/invocation.h
$(Q)${INVOCATION_ID_GEN_PATH} --arch --xml $< \
--dest $@
arch/api/sel4_invocation.h: ${SOURCE_ROOT}/libsel4/sel4_arch_include/${SEL4_ARCH}/interfaces/sel4arch.xml ${INVOCATION_ID_GEN_PATH} | ${DIRECTORIES}
$(Q)rm -f ${SOURCE_ROOT}/include/arch/${ARCH}/arch/api/sel4_invocation.h
$(Q)${INVOCATION_ID_GEN_PATH} --sel4_arch --xml $< \
--dest $@
api/invocation.h: ${SOURCE_ROOT}/libsel4/include/interfaces/sel4.xml ${INVOCATION_ID_GEN_PATH} | ${DIRECTORIES}
$(Q)rm -f ${SOURCE_ROOT}/include/api/invocation.h
$(Q)${INVOCATION_ID_GEN_PATH} --xml $< \
--dest $@
arch/api/syscall.h: ${SOURCE_ROOT}/include/api/syscall.xsd ${SOURCE_ROOT}/include/api/syscall.xml | ${DIRECTORIES} ${SYSCALL_ID_GEN_PATH}
$(Q)${XMLLINT_PATH} --noout --schema $^
$(Q)rm -f ${SOURCE_ROOT}/include/arch/${ARCH}/arch/api/syscall.h
$(Q)${SYSCALL_ID_GEN_PATH} --xml $(word 2, $^) \
--kernel_header $@
####################
# Bitfield generation
####################
PRUNES = $(foreach file,${STATICSOURCES} ${STATICHEADERS}, \
--prune ${file} )
TOPLEVELTYPES=cte_C tcb_C endpoint_C notification_C asid_pool_C pte_C \
pde_C user_data_C user_data_device_C
TOPTYPES = $(foreach tp,${TOPLEVELTYPES}, \
--toplevel ${tp} )
%.pbf: %.bf ${STATICHEADERS} | ${DIRECTORIES}
@echo " [PBF_GEN] $@"
$(Q)${CPP} ${CPPFLAGS} -P $< > $@
%_gen.h: %.pbf ${STATICSOURCES} ${STATICHEADERS} ${BF_GEN_PATH} | ${DIRECTORIES}
@echo " [BF_GEN] $@"
$(Q)${PYTHON} ${BF_GEN_PATH} $< $@ ${PRUNES}
ifdef SKIP_MODIFIES
SM_ARG=--skip_modifies
else
SM_ARG=
endif
${DEFTHEORIES}: %_defs.thy: %.pbf ${BF_GEN_PATH} ${STATICSOURCES} \
${STATICHEADERS} ${SOURCE_ROOT}/Makefile | ${DIRECTORIES}
@echo " [BF_DEFS] $@"
$(Q)${PYTHON} ${BF_GEN_PATH} --cspec-dir ${CSPEC_DIR} --hol_defs $< $@ ${PRUNES} ${SM_ARG}
${PROOFTHEORIES}: %_proofs.thy: %.pbf ${BF_GEN_PATH} ${STATICSOURCES} \
${STATICHEADERS} ${SOURCE_ROOT}/Makefile ${UMM_TYPES} | ${DIRECTORIES}
@echo " [BF_PROOFS] $@"
@$(if ${UMM_TYPES}, , echo "UMM_TYPES unset" ; false)
$(Q)${PYTHON} ${BF_GEN_PATH} --cspec-dir ${CSPEC_DIR} --hol_proofs ${SORRY_ARG} $< $@ ${TOPTYPES} \
--umm_types ${UMM_TYPES} ${PRUNES} ${SM_ARG}
###########################
# Preprocessed source files
###########################
%.s_pp: %.S ${GENHEADERS} ${STATICHEADERS} | ${DIRECTORIES}
@echo " [CPP] $@"
$(Q)${CPP} ${CPPFLAGS} -CC -E -o $@ $<
%.c_pp: %.c ${GENHEADERS} ${STATICHEADERS} | ${DIRECTORIES}
@echo " [CPP] $@"
ifdef NO_PRESERVE_TIMESTAMP
# Preserving the timestamp can cause repeated rebuilding if a file is touched
# with trivial modifications such that it has a future timestamp, but every time
# we rebuild we restore this timestamp back into the past. This results in partial
# rebuilds all the time. This flag allows you to stop this happening if you find it upsetting.
$(Q)${CPP} ${CPPFLAGS} -CC -E -o $@ $<
else
$(Q)${CHANGED} $@ ${CPP} ${CPPFLAGS} -CC -E -o $@ $<
endif
%.h_pp: %.h ${GENHEADERS} ${STATICHEADERS} | ${DIRECTORIES}
@echo " [CPP] $@"
$(Q)${CPP} ${CPPFLAGS} -CC -E -o $@ $<
############################################################
### Utility targets
############################################################
CLEANTARGETS = kernel.elf kernel.elf.strip ${GENHEADERS} ${OBJECTS} autoconf.h \
parser.out parsetab.py \
kernel_final.s kernel_final.c kernel_all.c kernel_all.c_pp \
${PPFILES} ${THEORIES} c-parser.log c-parser-all.log \
arch api plat ${ASM_SOURCES:.S=.s_pp} linker.lds_pp
clean:
@echo " [CLEAN]"
rm -f ${SOURCE_ROOT}/include/arch/${ARCH}/arch/api/invocation.h
rm -f ${SOURCE_ROOT}/include/api/invocation.h
rm -f ${SOURCE_ROOT}/include/arch/${ARCH}/arch/api/syscall.h
rm -Rf ${CLEANTARGETS}
.PHONY: distclean
distclean: clean
@echo " [CLEAN]"
$(Q)rm -f tools/*.pyc
${DIRECTORIES}:
@echo " [MKDIR] $@"
$(Q)mkdir -p ${DIRECTORIES}
.FORCE:
.PHONY: .FORCE