nuclear@0: PREFIX = /usr/local nuclear@0: nuclear@0: csrc = $(wildcard src/*.c) nuclear@0: ccsrc = $(wildcard src/*.cc) nuclear@0: cobj = $(csrc:.c=.o) nuclear@0: ccobj = $(ccsrc:.cc=.o) nuclear@0: obj = $(cobj) $(ccobj) nuclear@0: dep = $(obj:.o=.d) nuclear@0: nuclear@0: cname = treestore nuclear@0: ccname = treestorepp nuclear@0: nuclear@0: capi_major = 0 nuclear@0: capi_minor = 1 nuclear@0: ccapi_major = 0 nuclear@0: ccapi_minor = 1 nuclear@0: nuclear@0: clib_a = lib$(cname).a nuclear@0: cclib_a = lib$(ccname).a nuclear@0: nuclear@0: ifeq ($(shell uname -s), Darwin) nuclear@0: clib_so = lib$(cname).dylib nuclear@0: cclib_so = lib$(ccname).dylib nuclear@0: cshared = -dynamiclib nuclear@0: ccshared = -dynamiclib nuclear@0: else nuclear@0: clib_so = lib$(cname).so.$(capi_major).$(capi_minor) nuclear@0: csoname = lib$(cname).so.$(capi_major) nuclear@0: cdevlink = lib$(cname).so nuclear@0: cclib_so = lib$(ccname).so.$(ccapi_major).$(ccapi_minor) nuclear@0: ccsoname = lib$(ccname).so.$(ccapi_major) nuclear@0: ccdevlink = lib$(ccname).so nuclear@0: nuclear@0: cshared = -shared -Wl,-soname=$(csoname) nuclear@0: ccshared = -shared -Wl,-soname=$(ccsoname) nuclear@0: pic = -fPIC nuclear@0: endif nuclear@0: nuclear@0: dbg = -g nuclear@0: cxx11 = -std=c++11 -DTS_USE_CPP11 nuclear@0: nuclear@0: CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic) nuclear@0: CXXFLAGS = $(cxx11) $(CFLAGS) nuclear@0: nuclear@0: .PHONY: all nuclear@0: all: $(clib_so) $(clib_a) $(cclib_so) $(cclib_a) nuclear@0: nuclear@0: $(clib_a): $(cobj) nuclear@0: $(AR) rcs $@ $(cobj) nuclear@0: nuclear@0: $(clib_so): $(cobj) nuclear@0: $(CC) -o $@ $(cshared) $(cobj) $(LDFLAGS) nuclear@0: nuclear@0: $(cclib_a): $(ccobj) nuclear@0: $(AR) rcs $@ $(ccobj) nuclear@0: nuclear@0: $(cclib_so): $(ccobj) nuclear@0: $(CXX) -o $@ $(ccshared) $(ccobj) $(LDFLAGS) nuclear@0: nuclear@0: -include $(dep) nuclear@0: nuclear@0: %.d: %.c nuclear@0: @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ nuclear@0: nuclear@0: %.d: %.cc nuclear@0: @$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@ nuclear@0: nuclear@0: .PHONY: clean nuclear@0: clean: nuclear@0: rm -f $(obj) $(clib_so) $(cclib_so) $(clib_a) $(cclib_a) nuclear@0: nuclear@0: .PHONY: cleandep nuclear@0: cleandep: clean nuclear@0: rm -f $(dep) nuclear@0: nuclear@0: nuclear@0: .PHONY: install nuclear@0: install: all nuclear@0: mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib nuclear@0: cp src/treestore.h src/treestorepp.h $(DESTDIR)$(PREFIX)/include nuclear@0: cp $(clib_a) $(clib_so) $(cclib_a) $(cclib_so) $(DESTDIR)$(PREFIX)/lib nuclear@0: [ -n "$(csoname)" ] && \ nuclear@0: cd $(DESTDIR)$(PREFIX) && \ nuclear@0: rm -f $(csoname) $(cdevlink) $(ccsoname) $(ccdevlink) && \ nuclear@0: ln -s $(clib_so) $(csoname) && \ nuclear@0: ln -s $(cclib_so) $(ccsoname) && \ nuclear@0: ln -s $(csoname) $(cdevlink) && \ nuclear@0: ln -s $(ccsoname) $(ccdevlink) || \ nuclear@0: true