-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakefile
91 lines (78 loc) · 2.95 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Compiler and tool configurations
CC := gcc
BISON := bison
FLEX := flex
PYTHON := python3
# Compiler and linker flags
CFLAGS := -Wall -Wextra -O2
LDFLAGS := -lfl -lm
# Source files and directories
SRC_DIR := lib
SRCS := $(SRC_DIR)/hm.c $(SRC_DIR)/mem.c ast.c
GENERATED_SRCS := lang.tab.c lex.yy.c
ALL_SRCS := $(SRCS) $(GENERATED_SRCS)
# Output files
TARGET := brainrot
BISON_OUTPUT := lang.tab.c
FLEX_OUTPUT := lex.yy.c
# Default target
.PHONY: all
all: $(TARGET)
# Main executable build
$(TARGET): $(ALL_SRCS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
@echo "Skibidi toilet: $(TARGET) compiled with max gyatt."
# Generate parser files using Bison
$(BISON_OUTPUT): lang.y
$(BISON) -d -Wcounterexamples $< -o $@
@echo "Bison is sigma grinding with $(BISON_OUTPUT)."
# Generate lexer files using Flex
$(FLEX_OUTPUT): lang.l
$(FLEX) $<
@echo "Flex is literally hitting the griddy to generate $(FLEX_OUTPUT)."
# Run tests
.PHONY: test
test:
$(PYTHON) -m pytest -v
@echo "Tests ran bussin', no cap."
# Clean build artifacts
.PHONY: clean
clean:
rm -f $(TARGET) $(GENERATED_SRCS) lang.tab.h
rm -f *.o
@echo "Blud cleaned up the mess like a true sigma coder."
# Check dependencies
.PHONY: check-deps
check-deps:
@command -v $(CC) >/dev/null 2>&1 || { echo "Error: gcc not found. Blud, install gcc!"; exit 1; }
@command -v $(BISON) >/dev/null 2>&1 || { echo "Error: bison not found. Duke Dennis did you pray today?"; exit 1; }
@command -v $(FLEX) >/dev/null 2>&1 || { echo "Error: flex not found. Ayo, where's flex?"; exit 1; }
@command -v $(PYTHON) >/dev/null 2>&1 || { echo "Error: python3 not found. Python in Ohio moment."; exit 1; }
@$(PYTHON) -c "import pytest" >/dev/null 2>&1 || { echo "Error: pytest not found. Install with: pip install pytest. That's the ocky way."; exit 1; }
# Development helper to rebuild everything from scratch
.PHONY: rebuild
rebuild: clean all
@echo "Whole bunch of turbulence cleared. Rebuilt everything."
# Format source files (requires clang-format)
.PHONY: format
format:
@command -v clang-format >/dev/null 2>&1 || { echo "Error: clang-format not found. Ratioed by clang."; exit 1; }
find . -name "*.c" -o -name "*.h" | xargs clang-format -i
@echo "Source files got the rizz treatment, goated with the sauce."
# Show help
.PHONY: help
help:
@echo "Available targets (rizzy edition):"
@echo " all : Build the main executable (default target). Sigma grindset activated."
@echo " test : Run the test suite. Huggy Wuggy approves."
@echo " clean : Remove all generated files. Amogus sussy imposter mode."
@echo " check-deps : Verify all required bro apps are installed."
@echo " rebuild : Clean and re-grind the project."
@echo " format : Format source files using clang-format. No cringe, all kino."
@echo " help : Show this help for n00bs."
@echo ""
@echo "Configuration (poggers):"
@echo " CC = $(CC)"
@echo " CFLAGS = $(CFLAGS)"
@echo " LDFLAGS = $(LDFLAGS)"
@echo " TARGET = $(TARGET)"