This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
49 lines (40 loc) · 1.39 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
CFLAGS+= -Werror -Wall -Isrc/ -g
VPATH= src
LEXER_SRC= lexer.c
PARSER_SRC= parser.c $(LEXER_SRC)
COMPILER_SRC= compiler.c object.c symbol_table.c opcode.c builtins.c $(PARSER_SRC)
VM_SRC= vm.c opcode.c object.c symbol_table.c $(COMPILER_SRC)
PREFIX= /usr/local
TESTS= bin/lexer_test bin/parser_test bin/opcode_test bin/compiler_test bin/vm_test bin/symbol_table_test
# disable crossjumping when using gcc so it doesn't optimize away our (optimized) dispatch table
ifeq "$(CC)" "gcc"
CFLAGS+= -fno-gcse
endif
all: bin/monkey
bin/:
mkdir -p bin/
bin/monkey: monkey.c $(VM_SRC) monkey.c | bin/
$(CC) $(CFLAGS) $^ -Ofast -march=native -o $@
# tests
bin/lexer_test: tests/lexer_test.c $(LEXER_SRC) | bin/
$(CC) $(CFLAGS) $^ -o $@
bin/parser_test: tests/parser_test.c $(PARSER_SRC) | bin/
$(CC) $(CFLAGS) $^ -o $@
bin/opcode_test: tests/opcode_test.c opcode.c | bin/
$(CC) $(CFLAGS) $^ -o $@
bin/compiler_test: tests/compiler_test.c $(COMPILER_SRC) | bin/
$(CC) $(CFLAGS) $^ -o $@
bin/vm_test: tests/vm_test.c $(VM_SRC) compiler.c | bin/
$(CC) $(CFLAGS) $^ -o $@
bin/symbol_table_test: tests/symbol_table_test.c symbol_table.c | bin/
$(CC) $(CFLAGS) $^ -o $@
check: $(TESTS)
for test in $^; do $$test || exit 1; done
memcheck: $(TESTS)
for test in $^; do valgrind $$test || exit 1; done
.PHONY: clean
clean:
rm -r bin
.PHONY: install
install: bin/monkey
cp bin/monkey /usr/local/bin/monkey