-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (55 loc) · 1.86 KB
/
Makefile
File metadata and controls
69 lines (55 loc) · 1.86 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
# ────────────────────────────────
# Makefile for CLI project
# ────────────────────────────────
# Compiler and flags
CC := gcc
CFLAGS := -Wall -g -Wno-unused-function \
-I build -I src -I src/commands -I src/scaffold -I src/template -I src/project -I src/utils -I src/api -I src/store
LDFLAGS := -lfl -lreadline -lcurl -ljson-c
# Build paths
BUILD_DIR := build
TARGET := $(BUILD_DIR)/cli
UTIL_SRCS := $(wildcard src/utils/*.c)
# Source files
SRCS := src/main.c \
src/commands/commands.c \
src/commands/helpcommand.c \
src/scaffold/scaffold.c \
src/template/template.c \
src/project/project.c \
src/api/download_template.c \
src/api/supabase.c \
src/store/store.c \
$(UTIL_SRCS) \
$(BUILD_DIR)/lex.yy.c \
$(BUILD_DIR)/cli.tab.c
# Parser / Lexer
LEX_SRC := src/parser/cli.l
YACC_SRC := src/parser/cli.y
# Generated files
LEX_OUT := $(BUILD_DIR)/lex.yy.c
YACC_OUT := $(BUILD_DIR)/cli.tab.c
YACC_HDR := $(BUILD_DIR)/cli.tab.h
# ────────────────────────────────
# Rules
# ────────────────────────────────
all: $(TARGET)
# Ensure build directory exists
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
# Generate parser
$(YACC_OUT) $(YACC_HDR): $(YACC_SRC) | $(BUILD_DIR)
@bison -d -t -o $(YACC_OUT) $(YACC_SRC)
# Generate lexer
$(LEX_OUT): $(LEX_SRC) $(YACC_HDR) | $(BUILD_DIR)
@flex -o $(LEX_OUT) $(LEX_SRC)
# Compile everything
$(TARGET): $(SRCS) src/utils/defs.h | $(BUILD_DIR)
@$(CC) $(CFLAGS) $(SRCS) -o $(TARGET) $(LDFLAGS)
# Run CLI
run: $(TARGET)
@export $$(grep -v '^#' .env | xargs) && ./$(TARGET)
# Clean build
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)