-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
27 lines (20 loc) · 738 Bytes
/
Makefile
File metadata and controls
27 lines (20 loc) · 738 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
ANTLR_JAR = lib/antlr-4.13.1-complete.jar
SRC_DIR = src
GEN_DIR = gen
BIN_DIR = bin
CLASSPATH = "$(BIN_DIR):$(ANTLR_JAR)"
GRAMMAR = $(SRC_DIR)/MLang.g4
# Default target
all: run
# Generate parser and lexer using ANTLR
$(GEN_DIR)/MLangParser.java: $(GRAMMAR)
cd src && java -jar ../lib/antlr-4.13.1-complete.jar -visitor -Dlanguage=Java -o ../gen MLang.g4
# Compile everything (after gen is complete)
build: $(GEN_DIR)/MLangParser.java
javac -cp $(ANTLR_JAR) -d $(BIN_DIR) $(wildcard $(GEN_DIR)/*.java) $(SRC_DIR)/ast/*.java $(SRC_DIR)/runtime/*.java $(SRC_DIR)/MLangASTBuilder.java $(SRC_DIR)/TestMLang.java
# Run the program
run: build
java -cp $(CLASSPATH) TestMLang
# Clean everything
clean:
rm -rf $(GEN_DIR)/* $(BIN_DIR)/*