Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (39 loc) · 1.36 KB
/
Copy pathMakefile
File metadata and controls
55 lines (39 loc) · 1.36 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
BUILD_DIR ?= build
SRC_FILES := $(shell find src tests -name '*.c' -o -name '*.h' -o -name '*.cc' -o -name '*.cpp')
# Detect platform
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
SIMD_ASM := src/tokenizer/simd_x86_64.S
else
SIMD_ASM := src/tokenizer/simd_arm64.S
endif
TOKENIZE_SRCS := examples/tokenize.c src/tokenizer/tiktoken.c src/tokenizer/gpt2bpe.c \
src/tokenizer/sentencepiece.c src/tokenizer/simd.c $(SIMD_ASM) \
src/tokenizer/unicode_tables.c
.PHONY: all configure build build-all run clean distclean format format-check tokenize example test
all: build
configure:
cmake -S $(CURDIR) -B $(BUILD_DIR)
build: configure
cmake --build $(BUILD_DIR) --target sillytui
build-all: configure
cmake --build $(BUILD_DIR)
run: build
./$(BUILD_DIR)/sillytui
clean:
[ ! -d $(BUILD_DIR) ] || cmake --build $(BUILD_DIR) --target clean
distclean:
rm -rf $(BUILD_DIR)
format:
clang-format -i $(SRC_FILES)
format-check:
@echo "Checking code formatting..."
@clang-format --dry-run --Werror $(SRC_FILES) && echo "All files properly formatted!" || (echo "Some files need formatting. Run 'make format' to fix." && exit 1)
tokenize: $(BUILD_DIR)/tokenize
$(BUILD_DIR)/tokenize: $(TOKENIZE_SRCS)
@mkdir -p $(BUILD_DIR)
$(CC) -O3 -o $@ $(TOKENIZE_SRCS) -Isrc
example: tokenize
@./$(BUILD_DIR)/tokenize $(ARGS)
test: build-all
@./$(BUILD_DIR)/run_all_tests