libtreestore

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Makefile	Fri Apr 11 08:56:46 2014 +0300
     1.3 @@ -0,0 +1,89 @@
     1.4 +PREFIX = /usr/local
     1.5 +
     1.6 +csrc = $(wildcard src/*.c)
     1.7 +ccsrc = $(wildcard src/*.cc)
     1.8 +cobj = $(csrc:.c=.o)
     1.9 +ccobj = $(ccsrc:.cc=.o)
    1.10 +obj = $(cobj) $(ccobj)
    1.11 +dep = $(obj:.o=.d) 
    1.12 +
    1.13 +cname = treestore
    1.14 +ccname = treestorepp
    1.15 +
    1.16 +capi_major = 0
    1.17 +capi_minor = 1
    1.18 +ccapi_major = 0
    1.19 +ccapi_minor = 1
    1.20 +
    1.21 +clib_a = lib$(cname).a
    1.22 +cclib_a = lib$(ccname).a
    1.23 +
    1.24 +ifeq ($(shell uname -s), Darwin)
    1.25 +	clib_so = lib$(cname).dylib
    1.26 +	cclib_so = lib$(ccname).dylib
    1.27 +	cshared = -dynamiclib
    1.28 +	ccshared = -dynamiclib
    1.29 +else
    1.30 +	clib_so = lib$(cname).so.$(capi_major).$(capi_minor)
    1.31 +	csoname = lib$(cname).so.$(capi_major)
    1.32 +	cdevlink = lib$(cname).so
    1.33 +	cclib_so = lib$(ccname).so.$(ccapi_major).$(ccapi_minor)
    1.34 +	ccsoname = lib$(ccname).so.$(ccapi_major)
    1.35 +	ccdevlink = lib$(ccname).so
    1.36 +
    1.37 +	cshared = -shared -Wl,-soname=$(csoname)
    1.38 +	ccshared = -shared -Wl,-soname=$(ccsoname)
    1.39 +	pic = -fPIC
    1.40 +endif
    1.41 +
    1.42 +dbg = -g
    1.43 +cxx11 = -std=c++11 -DTS_USE_CPP11
    1.44 +
    1.45 +CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic)
    1.46 +CXXFLAGS = $(cxx11) $(CFLAGS)
    1.47 +
    1.48 +.PHONY: all
    1.49 +all: $(clib_so) $(clib_a) $(cclib_so) $(cclib_a)
    1.50 +
    1.51 +$(clib_a): $(cobj)
    1.52 +	$(AR) rcs $@ $(cobj)
    1.53 +
    1.54 +$(clib_so): $(cobj)
    1.55 +	$(CC) -o $@ $(cshared) $(cobj) $(LDFLAGS)
    1.56 +
    1.57 +$(cclib_a): $(ccobj)
    1.58 +	$(AR) rcs $@ $(ccobj)
    1.59 +
    1.60 +$(cclib_so): $(ccobj)
    1.61 +	$(CXX) -o $@ $(ccshared) $(ccobj) $(LDFLAGS)
    1.62 +
    1.63 +-include $(dep)
    1.64 +
    1.65 +%.d: %.c
    1.66 +	@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
    1.67 +
    1.68 +%.d: %.cc
    1.69 +	@$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@
    1.70 +
    1.71 +.PHONY: clean
    1.72 +clean:
    1.73 +	rm -f $(obj) $(clib_so) $(cclib_so) $(clib_a) $(cclib_a)
    1.74 +
    1.75 +.PHONY: cleandep
    1.76 +cleandep: clean
    1.77 +	rm -f $(dep)
    1.78 +
    1.79 +
    1.80 +.PHONY: install
    1.81 +install: all
    1.82 +	mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
    1.83 +	cp src/treestore.h src/treestorepp.h $(DESTDIR)$(PREFIX)/include
    1.84 +	cp $(clib_a) $(clib_so) $(cclib_a) $(cclib_so) $(DESTDIR)$(PREFIX)/lib
    1.85 +	[ -n "$(csoname)" ] && \
    1.86 +		cd $(DESTDIR)$(PREFIX) && \
    1.87 +		rm -f $(csoname) $(cdevlink) $(ccsoname) $(ccdevlink) && \
    1.88 +		ln -s $(clib_so) $(csoname) && \
    1.89 +		ln -s $(cclib_so) $(ccsoname) && \
    1.90 +		ln -s $(csoname) $(cdevlink) && \
    1.91 +		ln -s $(ccsoname) $(ccdevlink) || \
    1.92 +		true