libtreestore

annotate Makefile @ 0:740fec9866b1

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