blob: d5b07ebb411d6836f8d6c4d2d27cfe9f45512107 (
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
|
CC?=gcc
XFLAGS=-D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L
CFLAGS?=-std=c99 -O2 -Wall $(XFLAGS)
LIBS:=-lexif
LIBS+=$(shell pkg-config --cflags --libs GraphicsMagickWand)
IDIRS:=$(addprefix -iquote,include unja/src unja parcini/include)
BUILDIR?=build/release
ifdef DEBUG
BUILDIR:=build/debug
CFLAGS:=-std=c99 -O0 -g -DDEBUG $(XFLAGS)
endif
ifdef ASAN
CFLAGS+= -fsanitize=address -fno-omit-frame-pointer
endif
OBJDIR=$(BUILDIR)/obj
UNJA_SRCS+=$(shell find unja -name '*.c' -not -path '*/tests/*')
UNJA_OBJS:=$(UNJA_SRCS:%.c=$(OBJDIR)/%.o)
PARCINI_SRCS:=$(wildcard parcini/src/*.c)
PARCINI_OBJS:=$(PARCINI_SRCS:%.c=$(OBJDIR)/%.o)
REVELA_SRCS:=$(shell find src -name '*.c' -not -path '*/tests/*')
REVELA_OBJS:=$(REVELA_SRCS:%.c=$(OBJDIR)/%.o)
ALL_OBJS:=$(UNJA_OBJS) $(PARCINI_OBJS) $(REVELA_OBJS)
TEST_OBJS:=$(filter-out $(OBJDIR)/src/revela.o,$(ALL_OBJS))
all: revela
test: tests/config tests/fs
tests/%: $(OBJDIR)/src/tests/%.o $(TEST_OBJS)
mkdir -p $(BUILDIR)/$(@D)
$(CC) -o $(BUILDIR)/$@ $^ $(LDFLAGS) $(IDIRS) $(LIBS)
$(OBJDIR)/%.o: %.c
mkdir -p $(@D)
$(CC) -c $(CFLAGS) $(IDIRS) -o $@ $< $(LIBS)
revela: $(ALL_OBJS)
mkdir -p $(@D)
$(CC) $(LDFLAGS) -o $(BUILDIR)/$@ $^ $(LIBS) $(CFLAGS)
clean:
rm -r build
.PHONY: clean all test
.PRECIOUS: $(OBJDIR)/src/tests/%.o
|