esc
Externally Scriptable Editor
git clone git://mccd.space/esc
| Log | Files | Refs | README |
Makefile (2219B)
1 CC = cc
2 CFLAGS = -Wall -Wextra -g
3 CFLAGS_OPT = -O3
4 SANITIZE = -fsanitize=address,undefined
5 SDL3_CFLAGS = $(shell pkg-config --cflags sdl3)
6 SDL3_LIBS = $(shell pkg-config --libs sdl3)
7
8 # Optional tree-sitter
9 TS_CFLAGS := $(shell pkg-config --cflags tree-sitter 2>/dev/null)
10 TS_LIBS := $(shell pkg-config --libs tree-sitter 2>/dev/null)
11 TS_C_CFLAGS := $(shell pkg-config --cflags tree-sitter-c 2>/dev/null)
12 TS_C_LIBS := $(shell pkg-config --libs tree-sitter-c 2>/dev/null)
13 TS_MARKDOWN_CFLAGS := $(shell pkg-config --cflags tree-sitter-markdown 2>/dev/null)
14 TS_MARKDOWN_LIBS := $(shell pkg-config --libs tree-sitter-markdown 2>/dev/null)
15
16 EXTRA_SRCS :=
17 EXTRA_FLAGS :=
18 EXTRA_LIBS :=
19
20 ifneq ($(TS_CFLAGS),)
21 EXTRA_FLAGS += -DHAVE_TREESITTER $(TS_CFLAGS)
22 EXTRA_LIBS += $(TS_LIBS)
23 EXTRA_SRCS += treesitter.c
24 ifneq ($(TS_C_CFLAGS),)
25 EXTRA_FLAGS += -DHAVE_TS_C $(TS_C_CFLAGS)
26 EXTRA_LIBS += $(TS_C_LIBS)
27 endif
28 ifneq ($(TS_MARKDOWN_CFLAGS),)
29 EXTRA_FLAGS += -DHAVE_TS_MARKDOWN $(TS_MARKDOWN_CFLAGS)
30 EXTRA_LIBS += $(TS_MARKDOWN_LIBS)
31 endif
32 endif
33
34 .PHONY: all test clean
35
36 all: esc
37
38 esc: main.c unix_utils.c unix_utils.h editor.c editor.h \
39 strbuf.c strbuf.h fuse_ipc.c fuse_ipc.h renderer.c renderer.h \
40 treesitter.h $(EXTRA_SRCS)
41 $(CC) $(CFLAGS) $(CFLAGS_OPT) $(EXTRA_FLAGS) \
42 main.c unix_utils.c editor.c strbuf.c \
43 fuse_ipc.c renderer.c $(EXTRA_SRCS) -o esc \
44 $(shell pkg-config --cflags --libs sdl3 sdl3-ttf fuse) \
45 $(EXTRA_LIBS)
46
47 test: tests/test_strbuf tests/test_editor
48 @echo "--- running test_strbuf ---"
49 ASAN_OPTIONS=detect_leaks=1 tests/test_strbuf
50 @echo "--- running test_editor ---"
51 ASAN_OPTIONS=detect_leaks=1 tests/test_editor
52 @echo "All tests passed."
53
54 tests/test_strbuf: tests/test_strbuf.c tests/test_harness.h strbuf.c strbuf.h
55 $(CC) $(CFLAGS) $(SANITIZE) tests/test_strbuf.c strbuf.c -o tests/test_strbuf
56
57 tests/test_editor: tests/test_editor.c tests/test_harness.h \
58 editor.c editor.h strbuf.c strbuf.h
59 $(CC) $(CFLAGS) $(SANITIZE) $(SDL3_CFLAGS) \
60 tests/test_editor.c editor.c strbuf.c \
61 $(SDL3_LIBS) -o tests/test_editor
62
63 clean:
64 rm -f esc tests/test_strbuf tests/test_editor