-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (118 loc) · 3.85 KB
/
Copy pathMakefile
File metadata and controls
141 lines (118 loc) · 3.85 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
CC = gcc
CFLAGS = -Wall -Wextra -std=c11 -O2 -g
LDFLAGS =
# Targets
TARGET = vibe_example
TEST_TARGET = vibe_test
PARSER_TOOL_TARGET = vibe_parser_tool
# Source files
VIBE_SRC = vibe.c
EXAMPLE_SRC = examples/example.c
TEST_SRC = tests/test.c
PARSER_TOOL_SRC = vibe_parser_tool.c
# Object files
VIBE_OBJ = vibe.o
EXAMPLE_OBJ = examples/example.o
TEST_OBJ = tests/test.o
PARSER_TOOL_OBJ = vibe_parser_tool.o
# Headers
HEADERS = vibe.h
# Example VIBE files
EXAMPLES = examples/simple.vibe examples/config.vibe examples/web_server.vibe examples/database.vibe
.PHONY: all clean test test-suite demo run help install parser_tool
all: $(TARGET)
# Build parsing tool
parser_tool: $(PARSER_TOOL_TARGET)
$(PARSER_TOOL_TARGET): $(VIBE_OBJ) $(PARSER_TOOL_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ -lncurses -lpanel
@echo "✓ VIBE Parser Tool built successfully!"
@echo ""
@echo "Run with: ./$(PARSER_TOOL_TARGET) examples/simple.vibe"
$(PARSER_TOOL_OBJ): $(PARSER_TOOL_SRC) $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<
# Build example program
$(TARGET): $(VIBE_OBJ) $(EXAMPLE_OBJ)
$(CC) $(LDFLAGS) -o $@ $^
# Build test suite
$(TEST_TARGET): $(VIBE_OBJ) $(TEST_OBJ)
$(CC) $(LDFLAGS) -o $@ $^
# Object files
vibe.o: $(VIBE_SRC) $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<
examples/example.o: $(EXAMPLE_SRC) $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<
tests/test.o: $(TEST_SRC) $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<
# Run example files
test: $(TARGET)
@echo "=== Running Example File Tests ==="
@echo ""
@echo "Testing simple.vibe..."
@./$(TARGET) examples/simple.vibe || exit 1
@echo ""
@echo "Testing config.vibe..."
@./$(TARGET) examples/config.vibe || exit 1
@echo ""
@echo "Testing web_server.vibe..."
@./$(TARGET) examples/web_server.vibe || exit 1
@echo ""
@echo "Testing database.vibe..."
@./$(TARGET) examples/database.vibe || exit 1
@echo ""
@echo "✓ All example tests passed!"
# Run comprehensive test suite
test-suite: $(TEST_TARGET)
@echo "=== Running Comprehensive Test Suite ==="
@echo ""
@./$(TEST_TARGET)
# Run all tests
test-all: test test-suite
@echo ""
@echo "✓ All tests completed successfully!"
run: $(TARGET)
./$(TARGET) examples/simple.vibe
demo: all
@echo "=== VIBE Parser Demo ==="
@echo ""
@./$(TARGET) examples/simple.vibe
clean:
rm -f $(VIBE_OBJ) $(EXAMPLE_OBJ) $(TEST_OBJ) $(PARSER_TOOL_OBJ)
rm -f examples/*.o
rm -f $(TARGET) $(TEST_TARGET) $(PARSER_TOOL_TARGET)
rm -f *.gcov *.gcda *.gcno
rm -f libvibe.a
help:
@echo "VIBE Parser Build System"
@echo ""
@echo "Targets:"
@echo " all Build the example program (default)"
@echo " parser_tool Build interactive parsing tool (requires ncurses)"
@echo " test Run example file tests"
@echo " test-suite Run comprehensive test suite"
@echo " test-all Run all tests (examples + suite)"
@echo " demo Run quick demo"
@echo " run Run with simple.vibe"
@echo " clean Remove build artifacts"
@echo " install Install to /usr/local (requires sudo)"
@echo " help Show this help message"
@echo ""
@echo "Examples:"
@echo " make # Build"
@echo " make parser_tool # Build parsing tool"
@echo " make test # Test with example files"
@echo " make test-suite # Run unit tests"
@echo " make test-all # Run all tests"
@echo " ./vibe_example examples/config.vibe"
@echo " ./vibe_parser_tool examples/simple.vibe # Interactive TUI"
@echo " ./vibe_test # Run test suite directly"
# Install to system (optional)
install: all
@echo "Installing VIBE parser..."
install -d $(DESTDIR)/usr/local/lib
install -d $(DESTDIR)/usr/local/include
install -m 644 vibe.h $(DESTDIR)/usr/local/include/
ar rcs libvibe.a vibe.o
install -m 644 libvibe.a $(DESTDIR)/usr/local/lib/
@echo "✓ Installation complete!"
@echo " Header: /usr/local/include/vibe.h"
@echo " Library: /usr/local/lib/libvibe.a"