aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 3a23f4f5ecba3291afa62ce5107c54d3bd982742 (plain)
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
CC = clang

STATIC_LIB = include/libccdjit.a
SHARED_LIB = include/libccdjit.so

SRC = src/main.c src/app.c src/completion.c src/path.c src/media.c src/render.c src/font.c src/util.c src/log.c src/buffers.c src/ecex.c src/plugin.c src/config.c src/eval.c
BIN = bin/ecex

PKG_CFLAGS = $(shell pkg-config --cflags glfw3 2>/dev/null)
PKG_LIBS   = $(shell pkg-config --libs glfw3 2>/dev/null || echo -lglfw)

CFLAGS ?= -std=c11 -Wall -Wextra -pedantic -Iinclude $(PKG_CFLAGS)
LDLIBS = $(PKG_LIBS) -lGL -lm

.PHONY: all static shared clean run check sanitize debug release

all: static

static: $(SRC) $(STATIC_LIB)
	@mkdir -p bin
	$(CC) $(CFLAGS) $(SRC) $(STATIC_LIB) -o $(BIN) $(LDLIBS)

shared: $(SRC) $(SHARED_LIB)
	@mkdir -p bin
	$(CC) $(CFLAGS) $(SRC) -Linclude -lccdjit -o $(BIN) $(LDLIBS)

run: static
	LD_LIBRARY_PATH=include ./$(BIN)

debug: CFLAGS += -O0 -g3 -DDEBUG
debug: static

release: CFLAGS += -O2 -DNDEBUG
release: static

sanitize: CFLAGS += -O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer
sanitize: LDLIBS += -fsanitize=address,undefined
sanitize: static

check:
	@mkdir -p bin
	$(CC) -std=c11 -Wall -Wextra -pedantic -Iinclude tests/test_core.c src/buffers.c src/completion.c src/path.c src/util.c src/log.c src/plugin.c -o bin/ecex-tests
	./bin/ecex-tests

clean:
	rm -f $(BIN) bin/ecex-tests