blob: 3a1281582a26f12bb574857558f0bf01f72ae45c (
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
47
48
49
50
51
52
53
54
55
56
|
CC ?= gcc
AR ?= ar
OUTDIR = dist
LIB = libtinyff.a
INCLUDES = -Iinclude
BASE_CFLAGS = -Wall -Wextra -Werror -std=c11 $(INCLUDES)
DEBUG_FLAGS = -g -O0 -fno-omit-frame-pointer
RELEASE_FLAGS = -O2
SANFLAGS = -fsanitize=address,undefined -g -O1
SRC = $(shell find src -name "*.c")
ifeq ($(USE_HOSTED),1)
INCLUDES += -Iinclude/bridges
BASE_CFLAGS += -DUSE_HOSTED
SRC += $(shell find src/bridges -name "*.c")
endif
OBJ = $(patsubst %.c,$(OUTDIR)/%.o,$(SRC))
all: release
$(OUTDIR)/$(LIB): $(OBJ)
mkdir -p $(OUTDIR)
$(AR) rcs $@ $^
$(OUTDIR)/%.o: %.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(OUTDIR) png_test
debug: CFLAGS = $(BASE_CFLAGS) $(DEBUG_FLAGS)
debug: $(OUTDIR)/$(LIB)
release: CFLAGS = $(BASE_CFLAGS) $(RELEASE_FLAGS)
release: $(OUTDIR)/$(LIB)
asan: CC = clang
asan: CFLAGS = $(BASE_CFLAGS) $(SANFLAGS)
asan: clean $(OUTDIR)/$(LIB)
test-png: clean
$(MAKE) USE_HOSTED=1 debug
$(CC) $(BASE_CFLAGS) $(DEBUG_FLAGS) -DUSE_HOSTED tests/format/image/png/png_open.c -o png_test -Iinclude/bridges -Ldist -ltinyff && ./png_test
test: test-png
gdb: debug
gdb -x debug/.gdbinit
.PHONY: all clean debug release asan test test-png gdb
|