-
Notifications
You must be signed in to change notification settings - Fork 143
/
Makefile
72 lines (55 loc) · 2.15 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
AR ?= ar
CC ?= gcc
STRIP ?= strip
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
INCLUDESUBDIR ?= /clibs
DESTDIR ?=
CFLAGS = -O3 -std=c99 -Wall -Wextra -Ideps
LDFLAGS ?= -Wl,-z,now
SRCS = src/list.c \
src/list_node.c \
src/list_iterator.c
OBJS = $(SRCS:.c=.o)
MAJOR_VERSION = 0
MINOR_VERSION = 4
PATCH_VERSION = 1
all: build/libclibs_list.a build/libclibs_list.so.$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)
install: all
test -d $(DESTDIR)$(LIBDIR) || mkdir -p $(DESTDIR)$(LIBDIR)
cp -f build/libclibs_list.a $(DESTDIR)$(LIBDIR)/libclibs_list.a
cp -f build/libclibs_list.so.$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION) $(DESTDIR)$(LIBDIR)/libclibs_list.so.$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)
ln -sf libclibs_list.so.$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION) $(DESTDIR)$(LIBDIR)/libclibs_list.so.$(MAJOR_VERSION)
ln -sf libclibs_list.so.$(MAJOR_VERSION) $(DESTDIR)$(LIBDIR)/libclibs_list.so
test -d $(DESTDIR)$(INCLUDEDIR)$(INCLUDESUBDIR) || mkdir -p $(DESTDIR)$(INCLUDEDIR)$(INCLUDESUBDIR)/
cp -f src/list.h $(DESTDIR)$(INCLUDEDIR)$(INCLUDESUBDIR)/list.h
uninstall:
rm -f $(DESTDIR)$(LIBDIR)/libclibs_list.a
rm -f $(DESTDIR)$(LIBDIR)/libclibs_list.so
rm -f $(DESTDIR)$(LIBDIR)/libclibs_list.so.$(MAJOR_VERSION)
rm -f $(DESTDIR)$(LIBDIR)/libclibs_list.so.$(MAJOR_VERSION).$(MINOR_VERSION)
rm -f $(DESTDIR)$(LIBDIR)/libclibs_list.so.$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)
rm -f $(DESTDIR)$(INCLUDEDIR)$(INCLUDESUBDIR)/list.h
build/libclibs_list.a: $(OBJS)
@mkdir -p build
$(AR) rcs $@ $^
build/libclibs_list.so.$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION): $(OBJS)
@mkdir -p build
$(CC) $(LDFLAGS) -shared -lc -Wl,-soname,`basename $@ | sed s/\.${MINOR_VERSION}.${PATCH_VERSION}//` src/*.o -o $@
$(STRIP) --strip-unneeded --remove-section=.comment --remove-section=.note $@
bin/test: test.o $(OBJS)
@mkdir -p bin
$(CC) $^ -o $@
bin/benchmark: benchmark.o $(OBJS)
@mkdir -p bin
$(CC) $^ -o $@
%.o: %.c
$(CC) $< $(CFLAGS) -c -o $@
clean:
rm -fr bin build *.o src/*.o
test: bin/test
@./$<
benchmark: bin/benchmark
@./$<
.PHONY: test benchmark clean install uninstall