summaryrefslogtreecommitdiff
path: root/Makefile
blob: f24c6e22a324fb9ad1f3a760d968ffcc4b5485bc (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
CC ?= gcc
AR ?= ar

OUTDIR = dist
LIB = libtinyff.a

CFLAGS = -Wall -Wextra -Werror -std=c11 -Iinclude
DEBUG_FLAGS = -g -O0
RELEASE_FLAGS = -O2
SANFLAGS = -fsanitize=address,undefined -g -O1

SRC = $(shell find src -name "*.c")

ifeq ($(USE_HOSTED),1)
SRC += $(wildcard bridges/*.c)
endif

OBJ = $(patsubst src/%.c,$(OUTDIR)/src/%.o,$(SRC))

all: $(OUTDIR)/$(LIB)

$(OUTDIR)/$(LIB): $(OBJ)
	mkdir -p $(OUTDIR)
	$(AR) rcs $@ $^

$(OUTDIR)/src/%.o: src/%.c
	mkdir -p $(dir $@)
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -rf $(OUTDIR)

debug: CFLAGS += $(DEBUG_FLAGS)
debug: clean all

release: CFLAGS += $(RELEASE_FLAGS)
release: clean all

asan: CC=clang
asan: CFLAGS += $(SANFLAGS)
asan: clean all

.PHONY: all clean debug release asan