-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
103 lines (86 loc) · 3.05 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
# Build system for CertiKOS
#
# Although we have several components, as listed in $(SUBDIRS) below, which are
# mostly loosely-coupled,
# * all of them mostly are built in the same way (use coqc to compile a bunch
# of .v files into .vo files);
# * we would like to have at least some support for cross-component
# dependencies (and be able to rebuild only the relevant parts of another
# component that we depend on);
# * we don't want to modify compcert/Makefile too much, instead we would
# prefer to use it as-is, yet integrate it as a part of our build system.
#
# The approach we take is the following. Each component has its own Makefile,
# but they can include "subdir.mk" which contains the common parts. The
# dependencies are computed by the top-level Makefile, after querying each
# subdirectory for its list of files. The resulting top-level .depend can be
# specialized for each subdirectory. This way, even sub-makes can have a global
# view of dependencies and are able to rebuild foreign files if requested.
SUBDIRS=\
compcert \
compcertx \
liblayers \
mcertikos \
default: all
## Basics
.PHONY: all documentation clean
all: sub-all
documentation: sub-documentation
clean: sub-clean
# This pseudo-target can be used to recurse into $(SUBDIRS)
sub-%: compcert/Makefile.config
set -e; \
for d in $(SUBDIRS); do \
$(MAKE) -C $$d $*; \
done
# Before we can recurse into compcert/, we need to configure
compcert/Makefile.config:
@echo "You need to run ./configure first"
@false
## Dependencies
# .filelist records the list of files to be fed to coqdep.
# Since files are listed in the subdirectories' Makefiles, it needs
# to be rebuilt whenever those change.
.filelist: $(patsubst %,.filelist.%,$(SUBDIRS))
set -e; \
for d in $(SUBDIRS); do \
sed "s_^_../$$d/_" ".filelist.$$d"; \
done > [email protected]
mv [email protected] $@
# Once we have the list, we can use coqdep to compute dependencies.
# We need to move to some subdirectory so that coqdep produces suitable paths.
# The redundant -R arguments tweak which versions of duplicate files are used.
.depend: .filelist
mkdir -p fakedir
(cd fakedir && xargs coqdep -R .. . \
-R ../compcert/ia32 compcert.ia32 \
-R ../mcertikos/mm mcertikos.mm) \
<$< >[email protected] 2>/dev/null
rmdir fakedir
mv [email protected] $@
# For listing files in an individual subdirectory, we use this rule as a
# fallback default.
.filelist.%: %/Makefile
$(MAKE) -C $* -s listfiles > [email protected]
mv [email protected] $@
# Compcert is a special case because we don't want to tweak its Makefile.
# Instead, we extract the list from the compcert/.depend file.
.filelist.compcert: compcert/Makefile
$(MAKE) -C compcert .depend
perl -e 'while(<>) {print "$$1\n" if /^(.*?\.v)o/;}' compcert/.depend \
| sed 's/$$(ARCH)/ia32/' \
| sed 's/$$(VARIANT)/standard/' \
mv [email protected] $@
# Clean up dependency-related files
.PHONY: clean-dep
clean: clean-dep
clean-dep:
$(RM) .depend .filelist $(patsubst %,.filelist.%,$(SUBDIRS))
Makefile: .depend
install: all
./mcertikos/ccertikos -S
cp -v certikos.s kernel/sys/kern/certikos.S
image:
cd kernel
./make.sh rebuild gcc