-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (37 loc) · 1.28 KB
/
Makefile
File metadata and controls
47 lines (37 loc) · 1.28 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
# Project settings
TARGET := cubit
SRCDIR := src
BUILDDIR := builds
UNIW := libs/unicode_width/unicode_width.c
GRAPHEME := libs/libgrapheme/src/*.c
CJSON := libs/cjson/cJSON.c
TREE_SITTER_RUBY := libs/tree-sitter-ruby/libtree-sitter-ruby.a
TREE_SITTER_C := libs/tree-sitter-c/libtree-sitter-c.a
TREE_SITTER := libs/tree-sitter/libtree-sitter.a
# Sources
SRC := $(wildcard $(SRCDIR)/*.c) $(UNIW) $(GRAPHEME) $(CJSON)
# Linker flags (libraries you want to link against)
LIBS := $(TREE_SITTER) $(TREE_SITTER_RUBY) $(TREE_SITTER_C)
# Compiler settings
CC := gcc
CFLAGS := -Wall -Wextra
DBGFLAGS := -O0 -g -fsanitize=address -fno-omit-frame-pointer
OPTFLAGS := -O3 -march=native -flto -fomit-frame-pointer
# Default target
all: release
# Debug/test build (with sanitizers, does NOT run automatically)
test: $(BUILDDIR)/$(TARGET)-tst
@echo "Built test binary at $(BUILDDIR)/$(TARGET)-tst"
$(BUILDDIR)/$(TARGET)-tst: $(SRC)
@mkdir -p $(BUILDDIR)
env ASAN_OPTIONS=verbosity=1:halt_on_error=1 $(CC) $(CFLAGS) $(DBGFLAGS) -o $@ $^ $(LIBS)
# Release build (optimized, no sanitizers)
release: $(BUILDDIR)/$(TARGET)
$(BUILDDIR)/$(TARGET): $(SRC)
@mkdir -p $(BUILDDIR)
$(CC) $(CFLAGS) $(OPTFLAGS) -o $@ $^ $(LIBS)
strip $@
# Clean
clean:
rm -rf $(BUILDDIR)
.PHONY: all test release clean