-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (55 loc) · 1.5 KB
/
Copy pathMakefile
File metadata and controls
67 lines (55 loc) · 1.5 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
67
# PL/0 Compiler Makefile
#
# Build system for PL/0 educational compiler.
# All safety flags enabled for robust code generation.
# Compiler and flags
CC = gcc
CFLAGS = -std=c99 -pedantic -Wall -Wextra -Werror \
-Wno-unused-parameter \
-ftrapv \
-fstack-protector-all \
-D_POSIX_C_SOURCE=200809L \
-O2
# Target executable
TARGET = pl0c
# Source files (all in root folder)
SRCS = main.c lexer.c parser.c symbol.c vm.c
OBJS = $(SRCS:.c=.o)
# Default target
all: $(TARGET)
# Link executable
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^
# Compile source files
%.o: %.c pl0.h
$(CC) $(CFLAGS) -c -o $@ $<
# Clean build artifacts
clean:
rm -f $(OBJS) $(TARGET)
# Run tests with example programs
test: all
@echo "Running PL/0 examples..."
@echo "=== Factorial ==="
@./$(TARGET) examples/factorial.pl0
@echo "=== Primes ==="
@./$(TARGET) examples/primes.pl0
@echo "=== Fibonacci ==="
@./$(TARGET) examples/fibonacci.pl0
# Debug build with symbols
debug: CFLAGS += -g -DDEBUG
debug: clean $(TARGET)
# Format source code
format:
clang-format -i -style=file $(SRCS) pl0.h
# Show help
help:
@echo "PL/0 Compiler Makefile"
@echo ""
@echo "Targets:"
@echo " all - Build the compiler (default)"
@echo " clean - Remove build artifacts"
@echo " test - Run example programs"
@echo " format - Format source code with clang-format"
@echo " debug - Build with debug symbols"
@echo " help - Show this help"
.PHONY: all clean test format debug help