-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (32 loc) · 971 Bytes
/
Makefile
File metadata and controls
44 lines (32 loc) · 971 Bytes
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
default:
@echo 'Targets:'
@echo '- generate_ast'
@echo '- jlox'
@echo '- clean_jlox'
@echo '- clox'
@echo '- clean_clox'
# jlox
JLOX_LOX_SRC = $(wildcard java/com/craftinginterpreters/lox/*.java)
JLOX_LOX_CLS = $(addprefix build/, $(JLOX_LOX_SRC:.java=.class))
JLOX_TOOL_SRC = $(wildcard java/com/craftinginterpreters/tool/*.java)
JLOX_TOOL_CLS = $(addprefix build/, $(JLOX_TOOL_SRC:.java=.class))
generate_ast: $(JLOX_TOOL_CLS)
jlox: $(JLOX_LOX_CLS)
build/java/%.class: java/%.java
javac -cp java -d build/java -Werror -implicit:none $<
clean_jlox:
rm -rf build/java/*
rm -f java/com/craftinginterpreters/lox/Expr.java
rm -f java/com/craftinginterpreters/lox/Stmt.java
# clox
CLOX_BIN = bin/clox
CLOX_SRC = $(wildcard c/src/*.c)
CLOX_OBJ = $(CLOX_SRC:c/src/%.c=c/obj/%.o)
clox: clean_clox $(CLOX_BIN)
$(CLOX_BIN): $(CLOX_OBJ)
gcc -o $@ $?
$(CLOX_OBJ): c/obj/%.o: c/src/%.c
gcc -c $< -o $@ -Ic/include
clean_clox:
rm -f bin/clox
rm -f c/obj/*.o