-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
203 lines (160 loc) · 5.8 KB
/
Makefile
File metadata and controls
203 lines (160 loc) · 5.8 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# TED - Termux Editor Makefile
# Modern C Makefile based on gnaro project template
# Termux compatibility: avoid /tmp permissions
export TMPDIR := $(CURDIR)/tmp
# Project Configuration
NAME := ted
DIGITAL_RAIN_NAME := digital_rain
VERSION := 0.1.0
# Directories
SRC_DIR := src
BUILD_DIR := build
BIN_DIR := bin
# Source files
SRCS := $(filter-out src/digital_rain_main.c, $(wildcard $(SRC_DIR)/*.c))
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
DIGITAL_RAIN_SRCS := src/digital_rain.c src/digital_rain_main.c
DIGITAL_RAIN_OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(DIGITAL_RAIN_SRCS))
MQJS_DIR := vendor/mquickjs
MQJS_SRCS := $(MQJS_DIR)/mquickjs.c $(MQJS_DIR)/dtoa.c $(MQJS_DIR)/libm.c $(MQJS_DIR)/cutils.c
MQJS_OBJS := $(BUILD_DIR)/mqjs_vm_mquickjs.o $(BUILD_DIR)/mqjs_vm_dtoa.o $(BUILD_DIR)/mqjs_vm_libm.o $(BUILD_DIR)/mqjs_vm_cutils.o
TS_DIR := vendor/tree-sitter
TS_C_DIR := vendor/tree-sitter-c
TS_SRCS := $(TS_DIR)/lib/src/lib.c $(TS_C_DIR)/src/parser.c
TS_OBJS := $(BUILD_DIR)/ts_runtime_lib.o $(BUILD_DIR)/ts_grammar_c.o
LIBIUI_DIR := vendor/libiui
LIBIUI_SRC_DIR := $(LIBIUI_DIR)/src
LIBIUI_SRCS := $(wildcard $(LIBIUI_SRC_DIR)/*.c)
LIBIUI_OBJS := $(patsubst $(LIBIUI_SRC_DIR)/%.c,$(BUILD_DIR)/libiui_%.o,$(LIBIUI_SRCS))
# Compiler Configuration
CC := clang
CFLAGS := -std=gnu17 -Wall -Wextra -pedantic -Wno-strict-prototypes -O2 -D_GNU_SOURCE
CFLAGS += -Iinclude -I$(MQJS_DIR) -I$(TS_DIR)/lib/include -I$(TS_C_DIR)/src -I$(LIBIUI_DIR)/include -I$(LIBIUI_SRC_DIR) -fPIC -DSP_PS_DISABLE
# Debug build support
debug ?= 0
ifeq ($(debug),1)
CFLAGS := -std=gnu17 -Wall -Wextra -pedantic -Wno-strict-prototypes -g -O0 -D_GNU_SOURCE -DDEBUG
CFLAGS += -Iinclude -fPIC
endif
# Linker flags
LDFLAGS := -lm
# Platform detection
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LDFLAGS += -lpthread
endif
# Install prefix detection
# Override with: make install PREFIX=/your/custom/path
# Termux: check for Termux environment
ifneq ($(TERMUX_VERSION),)
PREFIX := /data/data/com.termux/files/usr
else
# Standard Unix paths
PREFIX := /usr/local
# If no write permission to /usr/local, use user's home
ifeq ($(shell test -w $(PREFIX)/bin 2>/dev/null && echo yes || echo no),no)
PREFIX := $(HOME)/.local
endif
endif
# Default target
.PHONY: all clean debug format install uninstall smoke autoresearch-metric tui-beauty-metric autoresearch-baseline autoresearch-focus autoresearch-next autoresearch-status autoresearch-module autoresearch-refresh autoresearch-loop deps-mqjs deps-libiui plugins plugins-install plugins-sync plugins-align
ARGS ?=
all: dir deps-mqjs deps-libiui $(BIN_DIR)/$(NAME)
# Create directories
dir:
@mkdir -p $(BUILD_DIR) $(BIN_DIR)
# Link executable
$(BIN_DIR)/$(NAME): $(OBJS) $(MQJS_OBJS) $(TS_OBJS) $(LIBIUI_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
@echo "Built: $@"
# Compile source files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c include/sp.h | dir
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/mqjs_vm_%.o: $(MQJS_DIR)/%.c $(MQJS_DIR)/mquickjs.h $(MQJS_DIR)/mqjs_stdlib.h | dir deps-mqjs
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/ts_runtime_lib.o: $(TS_DIR)/lib/src/lib.c $(TS_DIR)/lib/include/tree_sitter/api.h | dir
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/ts_grammar_c.o: $(TS_C_DIR)/src/parser.c $(TS_C_DIR)/src/tree_sitter/parser.h | dir
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/libiui_%.o: $(LIBIUI_SRC_DIR)/%.c $(LIBIUI_DIR)/include/iui.h $(LIBIUI_SRC_DIR)/iui_config.h | dir deps-libiui
$(CC) $(CFLAGS) -c $< -o $@
# Build with debug symbols
debug:
$(MAKE) debug=1
# Clean build artifacts
clean:
@rm -rf $(BUILD_DIR) $(BIN_DIR)
@echo "Cleaned build artifacts"
# Format code with clang-format
format:
@which clang-format > /dev/null 2>&1 && \
clang-format -i $(SRCS) $(SRC_DIR)/*.h include/digital_rain.h || \
echo "clang-format not installed"
# Install binary to PREFIX/bin
install: all
@install -d $(PREFIX)/bin
@install -m 755 $(BIN_DIR)/$(NAME) $(PREFIX)/bin/
@echo "Installed to $(PREFIX)/bin/$(NAME)"
@echo "Make sure $(PREFIX)/bin is in your PATH"
# Uninstall
uninstall:
@rm -f $(PREFIX)/bin/$(NAME)
@echo "Uninstalled $(NAME)"
# Development helpers
run: all
./$(BIN_DIR)/$(NAME)
# Print build info
info:
@echo "Project: $(NAME)"
@echo "Version: $(VERSION)"
@echo "Sources: $(SRCS)"
@echo "Objects: $(OBJS)"
@echo "Compiler: $(CC)"
@echo "CFLAGS: $(CFLAGS)"
@echo "Install prefix: $(PREFIX)"
# Smoke regression checks
smoke:
./scripts/regression.sh
autoresearch-metric:
sh ./scripts/autoresearch-metric.sh
tui-beauty-metric:
sh ./scripts/tui-beauty-metric.sh
autoresearch-baseline:
@printf 'goal\tTED autoresearch readiness\n'
@printf 'metric\t'
@sh ./scripts/autoresearch-metric.sh
@printf 'guard\tmake smoke\n'
autoresearch-focus:
sh ./scripts/autoresearch-focus.sh
autoresearch-next:
sh ./scripts/autoresearch-next.sh
autoresearch-status:
sh ./scripts/autoresearch-status.sh
autoresearch-module:
sh ./scripts/autoresearch-module.sh --summary
autoresearch-refresh:
sh ./scripts/autoresearch-refresh.sh
autoresearch-loop:
sh ./scripts/autoresearch-loop.sh $(ARGS)
# Build MicroQuickJS vendored binary for :js/:source runtime
deps-mqjs:
$(MAKE) -C vendor/mquickjs mqjs
# Fetch libiui source for future terminal renderer porting
deps-libiui:
@if [ -d "$(LIBIUI_DIR)" ]; then \
echo "libiui already present at $(LIBIUI_DIR)"; \
else \
git clone https://github.com/sysprog21/libiui.git $(LIBIUI_DIR); \
fi
@if [ ! -f "$(LIBIUI_SRC_DIR)/iui_config.h" ]; then \
$(MAKE) -C $(LIBIUI_DIR) defconfig >/dev/null; \
fi
@if [ ! -f "$(LIBIUI_SRC_DIR)/md3-flags-gen.inc" ] || [ ! -f "$(LIBIUI_SRC_DIR)/md3-validate-gen.inc" ]; then \
$(MAKE) -C $(LIBIUI_DIR) gen-md3 >/dev/null; \
fi
plugins-install:
sh ./scripts/install-plugins.sh
plugins-sync:
sh ./scripts/sync-plugins-from-home.sh
plugins-align: plugins-sync plugins-install
plugins: plugins-install