libtreestore

view Makefile @ 0:740fec9866b1

treestore initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 11 Apr 2014 08:56:46 +0300
parents
children
line source
1 PREFIX = /usr/local
3 csrc = $(wildcard src/*.c)
4 ccsrc = $(wildcard src/*.cc)
5 cobj = $(csrc:.c=.o)
6 ccobj = $(ccsrc:.cc=.o)
7 obj = $(cobj) $(ccobj)
8 dep = $(obj:.o=.d)
10 cname = treestore
11 ccname = treestorepp
13 capi_major = 0
14 capi_minor = 1
15 ccapi_major = 0
16 ccapi_minor = 1
18 clib_a = lib$(cname).a
19 cclib_a = lib$(ccname).a
21 ifeq ($(shell uname -s), Darwin)
22 clib_so = lib$(cname).dylib
23 cclib_so = lib$(ccname).dylib
24 cshared = -dynamiclib
25 ccshared = -dynamiclib
26 else
27 clib_so = lib$(cname).so.$(capi_major).$(capi_minor)
28 csoname = lib$(cname).so.$(capi_major)
29 cdevlink = lib$(cname).so
30 cclib_so = lib$(ccname).so.$(ccapi_major).$(ccapi_minor)
31 ccsoname = lib$(ccname).so.$(ccapi_major)
32 ccdevlink = lib$(ccname).so
34 cshared = -shared -Wl,-soname=$(csoname)
35 ccshared = -shared -Wl,-soname=$(ccsoname)
36 pic = -fPIC
37 endif
39 dbg = -g
40 cxx11 = -std=c++11 -DTS_USE_CPP11
42 CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic)
43 CXXFLAGS = $(cxx11) $(CFLAGS)
45 .PHONY: all
46 all: $(clib_so) $(clib_a) $(cclib_so) $(cclib_a)
48 $(clib_a): $(cobj)
49 $(AR) rcs $@ $(cobj)
51 $(clib_so): $(cobj)
52 $(CC) -o $@ $(cshared) $(cobj) $(LDFLAGS)
54 $(cclib_a): $(ccobj)
55 $(AR) rcs $@ $(ccobj)
57 $(cclib_so): $(ccobj)
58 $(CXX) -o $@ $(ccshared) $(ccobj) $(LDFLAGS)
60 -include $(dep)
62 %.d: %.c
63 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
65 %.d: %.cc
66 @$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@
68 .PHONY: clean
69 clean:
70 rm -f $(obj) $(clib_so) $(cclib_so) $(clib_a) $(cclib_a)
72 .PHONY: cleandep
73 cleandep: clean
74 rm -f $(dep)
77 .PHONY: install
78 install: all
79 mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
80 cp src/treestore.h src/treestorepp.h $(DESTDIR)$(PREFIX)/include
81 cp $(clib_a) $(clib_so) $(cclib_a) $(cclib_so) $(DESTDIR)$(PREFIX)/lib
82 [ -n "$(csoname)" ] && \
83 cd $(DESTDIR)$(PREFIX) && \
84 rm -f $(csoname) $(cdevlink) $(ccsoname) $(ccdevlink) && \
85 ln -s $(clib_so) $(csoname) && \
86 ln -s $(cclib_so) $(ccsoname) && \
87 ln -s $(csoname) $(cdevlink) && \
88 ln -s $(ccsoname) $(ccdevlink) || \
89 true