PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/Makefile

http://credis.googlecode.com/
Makefile | 54 lines | 38 code | 13 blank | 3 comment | 0 complexity | bfff3f681921d3959739cdcc14f67411 MD5 | raw file
 1CFLAGS ?= -g -O2 -Wall
 2LDFLAGS ?=
 3#CPPFLAGS += -DPRINTDEBUG
 4
 5VER_MAJOR = 0
 6VER_MINOR = 3
 7VER_PATCH = 0
 8VER=$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
 9
10INSTALL ?= /usr/bin/install -c
11MKDIR ?= /bin/mkdir -p
12CP ?= /bin/cp -fd
13LN ?= /bin/ln -fs
14
15INSTALLDIR ?= /usr/local
16LIBDIR = $(INSTALLDIR)/lib
17INCLUDEDIR = $(INSTALLDIR)/include
18
19# build shared lib under OS X or Linux
20OS = $(shell uname -s)
21ifeq ($(OS),Darwin)
22	SHAREDLIB_LINK_OPTIONS=-dynamiclib -Wl,-install_name -Wl,
23else
24	SHAREDLIB_LINK_OPTIONS=-shared -Wl,-soname,
25endif
26
27# targets to build with 'make all'
28TARGETS = credis-test libcredis.a libcredis.so
29
30all: $(TARGETS)
31
32credis-test: credis-test.o libcredis.a
33	$(CC) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) -o $@ $^
34
35libcredis.a: credis.o
36	$(AR) -cvq $@ $^
37
38libcredis.so: credis.o
39	$(CC) $(SHAREDLIB_LINK_OPTIONS)$@.$(VER_MAJOR) -o $@.$(VER) $^
40	$(LN) $@.$(VER) $@.$(VER_MAJOR)
41	$(LN) $@.$(VER_MAJOR) $@
42
43credis.o: credis.c credis.h Makefile
44	$(CC) -c -fPIC $(CFLAGS) $(CPPFLAGS) -o $@ credis.c
45
46install: all installdirs
47	$(INSTALL) -m644 *.h $(INCLUDEDIR)
48	$(INSTALL) -m755 *.so* *.a $(LIBDIR)
49
50installdirs:
51	$(MKDIR) $(LIBDIR) $(INCLUDEDIR)
52
53clean:
54	rm -f *.o *~ *.so* $(TARGETS)