-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (43 loc) · 1.65 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
# Define directories and filenames
SRC_DIR_LOX = com/craftinginterpreters/lox
SRC_FILE_LOX = $(SRC_DIR_LOX)/Lox.java
CLASS_FILE_LOX = $(SRC_DIR_LOX)/Lox.class
SRC_DIR_TOOL = com/craftinginterpreters/tool
SRC_FILE_TOOL = $(SRC_DIR_TOOL)/GenerateAst.java
CLASS_FILE_TOOL = $(SRC_DIR_TOOL)/GenerateAst.class
# Output directory for GenerateAst (lox subdirectory)
OUTPUT_DIR = com/craftinginterpreters/lox
# Compiler options
JAVAC = javac
JAVA = java
# Targets
all: $(CLASS_FILE_LOX) $(CLASS_FILE_TOOL) generate_ast
# Rule to compile Lox.java
$(CLASS_FILE_LOX): $(SRC_FILE_LOX)
$(JAVAC) $(SRC_FILE_LOX)
# Rule to compile GenerateAst.java
$(CLASS_FILE_TOOL): $(SRC_FILE_TOOL)
$(JAVAC) $(SRC_FILE_TOOL)
# Rule to run the Lox program
run: $(CLASS_FILE_LOX)
$(JAVA) com.craftinginterpreters.lox.Lox
# Rule to run GenerateAst program and output to lox subdirectory
generate_ast: $(CLASS_FILE_TOOL)
#mkdir -p $(OUTPUT_DIR)
$(JAVA) com.craftinginterpreters.tool.GenerateAst $(OUTPUT_DIR)
# Clean up generated class files
clean:
rm -f $(SRC_DIR_LOX)/*.class
rm -f $(SRC_DIR_TOOL)/*.class
#rm $(SRC_DIR_LOX)/Expr.java
#rm $(SRC_DIR_LOX)/Stmt.java
# Rule to help with usage
help:
@echo "Makefile for compiling and running the Lox and GenerateAst Java programs."
@echo "Usage:"
@echo " make - Compiles the Lox.java and GenerateAst.java files."
@echo " make run - Compiles and runs the Lox program."
@echo " make generate_ast - Compiles and runs the GenerateAst program, outputting to the lox subdirectory."
@echo " make clean - Removes compiled class files."
@echo " make help - Displays this help message."
.PHONY: all run generate_ast clean help