-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (36 loc) · 1.81 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
# works for me with python2 or python3...
PYTHON := python
CC := gcc
CC_OPTS := -nostdlib -Wl,--build-id=none
# either --x64-64 or --ia32 . very unlikely to generate portable code!
BF_ARCH := --x86-64
all: build/bf_compiler_self_hosted.out
.PHONY: all
build/bf_compiler.brainfuck: macros/self_hosting_bf_compiler.py
$(PYTHON) abfc/compile_macro.py $(BF_ARCH) $< > $@
build/bf_compiler_boot.s: build/bf_compiler.brainfuck
$(PYTHON) abfc/bootstrap_bf.py $(BF_ARCH) $< > $@
build/bf_compiler_boot.out: build/bf_compiler_boot.s
$(CC) $< $(CC_OPTS) -o $@
build/bf_compiler_self_hosted.s: build/bf_compiler_boot.out build/bf_compiler.brainfuck
cat build/bf_compiler.brainfuck | ./$< > $@
build/bf_compiler_self_hosted.out: build/bf_compiler_self_hosted.s
$(CC) $< $(CC_OPTS) -o $@
# TEST stuff
TESTCHECK := ./tools/testcheck.sh
TESTREPORT := python ./tools/testreport.py
test: test_fixed_point/testresult test_hello/testresult
$(TESTREPORT) $^
.PHONY: test
test_fixed_point/testresult: build/bf_compiler.brainfuck build/bf_compiler_self_hosted.s build/bf_compiler_self_hosted.out
mkdir -p test_fixed_point
cp build/bf_compiler.brainfuck test_fixed_point/in.brainfuck
cp build/bf_compiler_self_hosted.s test_fixed_point/expected_output.s
cat test_fixed_point/in.brainfuck | build/bf_compiler_self_hosted.out > test_fixed_point/output.s
diff test_fixed_point/output.s test_fixed_point/expected_output.s
$(TESTCHECK) test_fixed_point/output.s test_fixed_point/expected_output.s $@
test_hello/testresult: build/bf_compiler_self_hosted.out test_hello/hello.brainfuck
cat test_hello/hello.brainfuck | build/bf_compiler_self_hosted.out > test_hello/hello.s
$(CC) test_hello/hello.s $(CC_OPTS) -o test_hello/hello.out
test_hello/hello.out > test_hello/output.txt
$(TESTCHECK) test_hello/output.txt test_hello/expected_output.txt $@