-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathMakefile
83 lines (62 loc) · 2.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
#
# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
#
# SPDX-License-Identifier: BSD-2-Clause
#
ifndef CPARSER_PFX
CPARSER_PFX := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
endif
ifndef CPARSER_INCLUDED
CPARSER_INCLUDED=true
.PHONY: all
all: CParser cparser_test cparser_tools
include $(CPARSER_PFX)/globalmakevars
include $(CPARSER_PFX)/standalone-parser/Makefile
include $(CPARSER_PFX)/tools/mllex/Makefile
include $(CPARSER_PFX)/tools/mlyacc/Makefile
.PHONY: cparser_tools
cparser_tools: stp_all
# Setup heaps we use.
HEAPS += Simpl-VCG CParser
# l4v root dir. Will be ".." if this is a separate C parser release.
L4V_ROOT_DIR = ../..
# Path to Isabelle
ifndef ISABELLE_HOME
export ISABELLE_HOME=${L4V_ROOT_DIR}/isabelle
endif
ifndef ISABELLE
export ISABELLE=${ISABELLE_HOME}/bin/isabelle
endif
# Setup rules for the heaps.
$(HEAPS): .FORCE
$(ISABELLE) build -d $(L4V_ROOT_DIR) -b -v $@
.PHONY: $(HEAPS)
# Generate lexer and parser files for CParser
CParser: c-parser-deps
#
# cparser_test: Execute a large number of testcases in the "testfiles"
# directory.
#
# We dynamically generate a ROOT file containing all the test files, and
# then build it using Isabelle.
#
cparser_test: c-parser-deps testfiles/$(L4V_ARCH)/ROOT .FORCE
$(ISABELLE) build -d $(L4V_ROOT_DIR) -d testfiles/$(L4V_ARCH) -v CParserTest
testfiles/$(L4V_ARCH)/ROOT: testfiles testfiles/*.c testfiles/*.thy ../../misc/scripts/gen_isabelle_root.py
python3 ../../misc/scripts/gen_isabelle_root.py -i testfiles -i testfiles/$(L4V_ARCH) -o testfiles/$(L4V_ARCH)/ROOT -s CParserTest -b CParser --dir ".." --dir "imports"
all_tests_$(L4V_ARCH).thy: testfiles testfiles/*.c ../../misc/scripts/gen_isabelle_root.py
python3 ../../misc/scripts/gen_isabelle_root.py -T -o $@ -b CParser -i testfiles -i testfiles/$(L4V_ARCH)
.PHONY: tools_all
tools_all: $(CPARSER_PFX)/tools/mllex/mllex $(CPARSER_PFX)/tools/mlyacc/mlyacc
MLYACC=$(MLYACC_PFX)/mlyacc
RUN_MLYACC=$(TOOLRUN_PFX)$(MLYACC)
%.lex.sml: %.lex $(MLLEX)
$(RUN_MLLEX) $<
%.grm.sml %.grm.sig: %.grm $(MLYACC)
$(RUN_MLYACC) $<
GRAMMAR_PRODUCTS = StrictC.lex.sml StrictC.grm.sig StrictC.grm.sml
.PHONY: c-parser-deps
c-parser-deps: $(GRAMMAR_PRODUCTS)
.PHONY: .FORCE
.FORCE:
endif