-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (52 loc) · 1.75 KB
/
Makefile
File metadata and controls
67 lines (52 loc) · 1.75 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
# FORGE Toolchain Makefile
# C99 standard, simple build system
CC = gcc
CFLAGS = -std=c99 -Wall -Wextra -Wpedantic -g -I src
RELEASE_FLAGS = -std=c99 -O2 -DNDEBUG -I src
LDFLAGS = -lm
# Optional GUI support (raylib + raygui) — vendored in vendor/raylib/
# Build with: make GUI=1
ifeq ($(GUI),1)
CFLAGS += -DFORGE_HAS_GUI -I vendor/raylib/include
RELEASE_FLAGS += -DFORGE_HAS_GUI -I vendor/raylib/include
LDFLAGS += -L vendor/raylib/lib -lraylib -lGL -lpthread -ldl -lrt -lX11
endif
# Source files - all subdirectories
SRC_UTIL = $(wildcard src/util/*.c)
SRC_LEXER = $(wildcard src/lexer/*.c)
SRC_PARSER = $(wildcard src/parser/*.c)
SRC_INTERP = $(wildcard src/interp/*.c)
SRC_TYPECHECK = $(wildcard src/typecheck/*.c)
SRC_EMIT_C = $(wildcard src/emit_c/*.c)
SRC_EMIT_LLVM = $(wildcard src/emit_llvm/*.c)
SRC_CLI = $(wildcard src/cli/*.c)
SRC_RUNTIME = $(wildcard runtime/*.c)
# Combine all sources (including runtime for interpreter serial/buffer support)
SRC = $(SRC_UTIL) $(SRC_LEXER) $(SRC_PARSER) $(SRC_INTERP) $(SRC_TYPECHECK) $(SRC_EMIT_C) $(SRC_EMIT_LLVM) $(SRC_CLI) $(SRC_RUNTIME)
OBJ = $(SRC:.c=.o)
TARGET = forge
.PHONY: all clean test release
all: $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
release:
$(CC) $(RELEASE_FLAGS) -o $(TARGET) $(SRC) $(LDFLAGS)
test:
@echo "Running tests..."
@bash tests/runner.sh
test-lexer: $(TARGET)
@echo "Running lexer tests..."
@for f in tests/forge/01_lexer/*.fg; do \
echo "Testing $$f"; \
./$(TARGET) lex "$$f"; \
done
clean:
rm -f $(OBJ) $(TARGET)
rm -rf forge-build/
# Development helpers
valgrind: $(TARGET)
valgrind --leak-check=full --show-leak-kinds=all ./$(TARGET) $(ARGS)
debug: CFLAGS += -DDEBUG
debug: $(TARGET)