forked from kframework/c-semantics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (78 loc) · 4.21 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
SEMANTICS_DIR = semantics
SCRIPTS_DIR = scripts
PARSER_DIR = parser
LIBC_DIR = libc
TESTS_DIR = tests
PARSER = $(PARSER_DIR)/cparser
DIST_DIR = dist
KCCFLAGS =
PASS_TESTS_DIR = tests/unit-pass
FAIL_TESTS_DIR = tests/unit-fail
FAIL_COMPILE_TESTS_DIR = tests/unit-fail-compilation
FILES_TO_DIST = \
$(SCRIPTS_DIR)/query-kcc-prof \
$(SCRIPTS_DIR)/analyzeProfile.pl \
$(SCRIPTS_DIR)/kcc \
$(SCRIPTS_DIR)/xml-to-k \
$(SCRIPTS_DIR)/program-runner \
$(PARSER_DIR)/cparser \
.PHONY: default check-vars semantics clean fast semantics-fast $(DIST_DIR) $(SEMANTICS_DIR)/settings.k test-build
default: dist
fast: $(DIST_DIR)/lib/libc.so $(DIST_DIR)/c11-kompiled/c11-kompiled/context.bin
check-vars:
@if ! ocaml -version > /dev/null 2>&1; then echo "ERROR: You don't seem to have ocaml installed. You need to install this before continuing. Please see INSTALL.md for more information."; false; fi
@if ! gcc-4.9 -v > /dev/null 2>&1; then if ! clang -v 2>&1 | grep "LLVM 3.5" > /dev/null; then echo "ERROR: You don't seem to have gcc 4.9 or clang 3.5 installed. You need to install this before continuing. Please see INSTALL.md for more information."; false; fi fi
@if ! kompile --version > /dev/null 2>&1; then echo "ERROR: You don't seem to have kompile installed. You need to install this before continuing. Please see INSTALL.md for more information."; false; fi
@if ! krun --version > /dev/null 2>&1; then echo "ERROR: You don't seem to have krun installed. You need to install this before continuing. Please see INSTALL.md for more information."; false; fi
@perl $(SCRIPTS_DIR)/checkForModules.pl
$(DIST_DIR)/kcc: $(FILES_TO_DIST) | check-vars
@mkdir -p $(DIST_DIR)
@mkdir -p $(DIST_DIR)/lib
@cp -r $(LIBC_DIR)/includes $(DIST_DIR)
@cp -p $(FILES_TO_DIST) $(DIST_DIR)
@cp -p $(SCRIPTS_DIR)/kcc $(DIST_DIR)/kclang
$(DIST_DIR)/c11-kompiled/c11-kompiled/context.bin: $(DIST_DIR)/kcc semantics-fast
@cp -p -r $(SEMANTICS_DIR)/c11-kompiled $(DIST_DIR)
$(DIST_DIR)/c11-translation-kompiled/c11-translation-kompiled/context.bin: $(DIST_DIR)/kcc semantics-fast
@cp -p -r $(SEMANTICS_DIR)/c11-translation-kompiled $(DIST_DIR)
$(DIST_DIR)/c11-nd-kompiled/c11-nd-kompiled/context.bin: semantics
@cp -r $(SEMANTICS_DIR)/c11-nd-kompiled $(DIST_DIR)
$(DIST_DIR)/c11-nd-thread-kompiled/c11-nd-thread-kompiled/context.bin: semantics
@cp -r $(SEMANTICS_DIR)/c11-nd-thread-kompiled $(DIST_DIR)
$(DIST_DIR)/lib/libc.so: $(DIST_DIR)/c11-translation-kompiled/c11-translation-kompiled/context.bin $(wildcard $(LIBC_DIR)/src/*) $(SCRIPTS_DIR)/kcc
@echo "Translating the standard library... ($(LIBC_DIR))"
$(DIST_DIR)/kcc -s -shared -o $(DIST_DIR)/lib/libc.so $(wildcard $(LIBC_DIR)/src/*.c) $(KCCFLAGS) -I $(LIBC_DIR)/src/
@echo "Done."
$(DIST_DIR): test-build $(DIST_DIR)/c11-nd-kompiled/c11-nd-kompiled/context.bin $(DIST_DIR)/c11-nd-thread-kompiled/c11-nd-thread-kompiled/context.bin
test-build: fast
@echo "Testing kcc..."
echo '#include <stdio.h>\nint main(void) {printf("x"); return 42;}\n' | $(DIST_DIR)/kcc - -o $(DIST_DIR)/testProgram.compiled
$(DIST_DIR)/testProgram.compiled 2> /dev/null > $(DIST_DIR)/testProgram.out; test $$? -eq 42
grep x $(DIST_DIR)/testProgram.out > /dev/null
@echo "Done."
@echo "Cleaning up..."
@rm -f $(DIST_DIR)/testProgram.compiled
@rm -f $(DIST_DIR)/testProgram.out
@echo "Done."
parser/cparser:
@echo "Building the C parser..."
@$(MAKE) -C $(PARSER_DIR)
semantics-fast: check-vars $(SEMANTICS_DIR)/settings.k
@$(MAKE) -C $(SEMANTICS_DIR) fast
$(SEMANTICS_DIR)/settings.k:
@diff $(LIBC_DIR)/semantics/settings.k $(SEMANTICS_DIR)/settings.k > /dev/null 2>&1 || cp $(LIBC_DIR)/semantics/settings.k $(SEMANTICS_DIR)
semantics: check-vars $(SEMANTICS_DIR)/settings.k
@$(MAKE) -C $(SEMANTICS_DIR) all
check: fast
@$(MAKE) -C $(PASS_TESTS_DIR) comparison
@$(MAKE) -C $(FAIL_TESTS_DIR) comparison
@$(MAKE) -C $(FAIL_COMPILE_TESTS_DIR) comparison
clean:
-$(MAKE) -C $(PARSER_DIR) clean
-$(MAKE) -C $(SEMANTICS_DIR) clean
-$(MAKE) -C $(TESTS_DIR) clean
-$(MAKE) -C $(PASS_TESTS_DIR) clean
-$(MAKE) -C $(FAIL_TESTS_DIR) clean
-$(MAKE) -C $(FAIL_COMPILE_TESTS_DIR) clean
@-rm -rf $(DIST_DIR)
@-rm -f ./*.tmp ./*.log ./*.cil ./*-gen.maude ./*.gen.maude ./*.pre.gen ./*.prepre.gen ./a.out ./*.kdump ./*.pre.pre $(SEMANTICS_DIR)/settings.k