aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 6576a87c622be4c6495451d1de780114fd279753 (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
CC?=gcc

CFLAGS:=-std=c99 -O0 -g -Wall -DDEBUG

INC_DIRS=$(addprefix -iquote,include)

BUILDIR:=build
OBJDIR:=$(BUILDIR)/obj

PARCINI_SRCS:=$(wildcard src/*.c)
PARCINI_OBJS:=$(PARCINI_SRCS:%.c=$(OBJDIR)/%.o)

ifdef ASAN
CFLAGS+= -fsanitize=address -fno-omit-frame-pointer
endif

test: 
test: $(BUILDIR) tests/parcini

tests/%: $(OBJDIR)/src/tests/%.o $(PARCINI_OBJS)
	mkdir -p $(BUILDIR)/$(@D)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(BUILDIR)/$@ $^
	$(BUILDIR)/$@

example: CFLAGS := -std=c99 -O2 -Wall
example: $(OBJDIR)/example/example.o $(PARCINI_OBJS)
	mkdir -p $(@D)
	$(CC) $(LDFLAGS) -o $(BUILDIR)/example/$@ $^

$(OBJDIR)/%.o: %.c
	mkdir -p $(@D)
	$(CC) -c $(CFLAGS) $(INC_DIRS) -o $@ $<

clean:
	rm -r $(BUILDIR)

.PHONY: clean test

.PRECIOUS: $(OBJDIR)/tests/%.o $(OBJDIR)/%.o