-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (42 loc) · 1.08 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
49
50
51
52
53
CFLAGS := -s
CFLAGS += -std=c17
CFLAGS += -no-pie
#CFLAGS += -g3
#CFLAGS += -ggdb
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Warray-bounds
CFLAGS += -Wconversion
CFLAGS += -Wmissing-braces
CFLAGS += -Wno-parentheses
CFLAGS += -Wno-format-truncation
CFLAGS += -Wpedantic
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wwrite-strings
CFLAGS += -Winline
CFLAGS += -O2
NAME := libslist_$(shell uname -m)-$(shell uname -s)
LIBDIR := bin
SLIB := $(LIBDIR)/$(NAME).a
DLIB := $(LIBDIR)/$(NAME).so
SRCS := $(wildcard src/*.c)
OBJS := $(patsubst src/%.c, obj/%.o, $(SRCS))
LDLIBS := -lcriterion
TESTBIN := $(patsubst test/%.c, test/bin/%, $(wildcard test/*.c))
all: $(SLIB) $(DLIB)
$(SLIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
$(DLIB): $(OBJS)
$(CC) $(CFLAGS) -fPIC -shared $(SRCS) -o $@
obj/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@
test/bin/%: test/%.c
$(CC) $(CFLAGS) $< $(OBJS) -o $@ $(LDLIBS)
test: $(SLIB) $(TESTBIN)
for test in $(TESTBIN) ; do ./$$test ; done
clean:
$(RM) -rf $(OBJS) $(TESTBIN)
fclean:
$(RM) $(SLIB) $(DLIB)
.PHONY: fclean clean all test
.DELETE_ON_ERROR: