-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
48 lines (34 loc) · 1.11 KB
/
Makefile
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
##
## Makefile
##
## Licensed under MIT license
##
CC ?= gcc
NAME := senpai
TEST_NAME := test_senpai
WARNINGS := -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wuninitialized -Wstrict-prototypes
CFLAGS ?= -O2 -g3 -fopenmp
CFLAGS := $(CFLAGS) -std=c99 -U__STRICT_ANSI__ -I./headers $(WARNINGS)
LDLIBS := -lm -fopenmp
TEST_LDLIBS := -lm -fopenmp -lcriterion
DEPFILES := $(wildcard sources/*.d)
DEPFILES += $(wildcard tests/*.d)
SRCS := $(wildcard sources/*.c)
OBJS := $(SRCS:.c=.o)
TEST_SRCS := $(wildcard tests/*.c)
TEST_SRCS += $(filter-out sources/main.c, $(wildcard sources/*.c))
TEST_OBJS := $(TEST_SRCS:.c=.o)
$(NAME): $(OBJS)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(TEST_NAME): $(TEST_OBJS)
$(CC) $(LDFLAGS) $^ $(TEST_LDLIBS) -o $@
%.o: %.c
$(CC) -MMD -MP -MF $*.d $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
test: $(TEST_NAME)
./$(TEST_NAME) --verbose
clean:
$(RM) -rf $(DEPFILES) $(OBJS) $(NAME) $(TEST_OBJS) $(TEST_NAME)
install:
cp senpai /usr/bin/senpai
-include $(DEPFILES)
.PHONY: clean install