-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (41 loc) · 1.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
CFLAGS ?= -g -O2 -Wall
LDFLAGS ?=
#CPPFLAGS += -DPRINTDEBUG
VER_MAJOR = 0
VER_MINOR = 3
VER_PATCH = 0
VER=$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
INSTALL ?= /usr/bin/install -c
MKDIR ?= /bin/mkdir -p
CP ?= /bin/cp -fd
LN ?= /bin/ln -fs
INSTALLDIR ?= /usr/local
LIBDIR = $(INSTALLDIR)/lib
INCLUDEDIR = $(INSTALLDIR)/include
# build shared lib under OS X or Linux
OS = $(shell uname -s)
ifeq ($(OS),Darwin)
SHAREDLIB_LINK_OPTIONS=-dynamiclib -Wl,-install_name -Wl,
else
SHAREDLIB_LINK_OPTIONS=-shared -Wl,-soname,
endif
# targets to build with 'make all'
TARGETS = credis-test libcredis.a libcredis.so
all: $(TARGETS)
credis-test: credis-test.o libcredis.a
$(CC) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) -o $@ $^
libcredis.a: credis.o
$(AR) -cvq $@ $^
libcredis.so: credis.o
$(CC) $(SHAREDLIB_LINK_OPTIONS)$@.$(VER_MAJOR) -o $@.$(VER) $^
$(LN) $@.$(VER) $@.$(VER_MAJOR)
$(LN) $@.$(VER_MAJOR) $@
credis.o: credis.c credis.h Makefile
$(CC) -c -fPIC $(CFLAGS) $(CPPFLAGS) -o $@ credis.c
install: all installdirs
$(INSTALL) -m644 *.h $(INCLUDEDIR)
$(INSTALL) -m755 *.so* *.a $(LIBDIR)
installdirs:
$(MKDIR) $(LIBDIR) $(INCLUDEDIR)
clean:
rm -f *.o *~ *.so* $(TARGETS)