-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (68 loc) · 2.16 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
WARNINGS += -Wpedantic
WARNINGS += -Wall
WARNINGS += -Wextra
WARNINGS += -Waggregate-return
WARNINGS += -Wbad-function-cast
WARNINGS += -Wcast-align
WARNINGS += -Wcast-qual
WARNINGS += -Wdeclaration-after-statement
WARNINGS += -Wfloat-equal
WARNINGS += -Wformat=2
WARNINGS += -Wmissing-declarations
WARNINGS += -Wmissing-include-dirs
WARNINGS += -Wmissing-prototypes
WARNINGS += -Wnested-externs
WARNINGS += -Wpointer-arith
WARNINGS += -Wredundant-decls
WARNINGS += -Wsequence-point
WARNINGS += -Wshadow
WARNINGS += -Wstrict-prototypes
WARNINGS += -Wswitch
WARNINGS += -Wundef
WARNINGS += -Wunreachable-code
WARNINGS += -Wunused-parameter
WARNINGS += -Wwrite-strings
WARNINGS += -Werror
DEBUG = -g
OPTIM = -O3 -march=native -mtune=native
CFLAGS= $(WARNINGS) $(DEBUG) $(OPTIM) -std=c99 -fPIC -o $@
CC=gcc
OCC=$(CC) -c
AR=ar
V=@
.PHONY : all static dynamic test
all : static dynamic test
static : libmds.a
dynamic : libmds.so
libmds.a : dynstr/strop.o llist/llist.o vector/vector.o
$V printf "Creating static library \033[1m$@\033[0m...\n"
$V $(AR) rcs $@ $^
libmds.so : dynstr/strop.o llist/llist.o vector/vector.o
$V printf "Creating shared library \033[1m$@\033[0m...\n"
$V $(CC) $(CFLAGS) -shared $^
%.o : %.c
$V $(OCC) $(CFLAGS) $^
$V printf "Compiling \033[1m$@\033[0m from $^...\n"
###############################################################################
test : tests/hello tests/llist tests/llist_huge tests/vector tests/vector_huge
tests/hello : tests/hello.c libmds.a
$V $(CC) $(CFLAGS) $^
$V printf "Compiling and linking \033[1m$@\033[0m...\n"
tests/llist : tests/llist.c libmds.a
$V $(CC) $(CFLAGS) $^
$V printf "Compiling and linking \033[1m$@\033[0m...\n"
tests/llist_huge : tests/llist_huge.c libmds.a
$V $(CC) $(CFLAGS) $^
$V printf "Compiling and linking \033[1m$@\033[0m...\n"
tests/vector : tests/vector.c libmds.a
$V $(CC) $(CFLAGS) $^
$V printf "Compiling and linking \033[1m$@\033[0m...\n"
tests/vector_huge : tests/vector_huge.c libmds.a
$V $(CC) $(CFLAGS) $^
$V printf "Compiling and linking \033[1m$@\033[0m...\n"
clean : FORCE
rm -f */*.o
(cd tests/; rm -f `grep --colour=never -r -I -L .`)
cleanproper : clean FORCE
rm -f *.a *.so
FORCE :