diff --git a/src/makefile b/src/makefile index 8f23ce9f55e7e68e62b4618c6bc3e3a8046f4867..c92c416f285819f0071ec2e866d1b15318a79cb8 100644 --- a/src/makefile +++ b/src/makefile @@ -143,6 +143,7 @@ OBJ += TCmdFiga.o #include $(ROOTSYS)/etc/root/Makefile.arch UNAME = $(shell uname) +ROOTVER := $(shell root-config --version | cut -c 1) ifeq ($(UNAME),Darwin) SOEXT = dylib #SOEXT = so @@ -166,21 +167,38 @@ DEPENDS = $(addprefix $(DEPDIR)/, $(notdir $(OBJ:.o=.d))) OBJDIR = .objects OBJECTS = $(addprefix $(OBJDIR)/, $(OBJ)) +# include files to be installed HDR = $(OBJ:.o=.h) DICTSRC = $(LIBNAME)_dict.cc DICTOBJ = $(DICTSRC:.cc=.o) DICTHDR = $(DICTSRC:.cc=.h) +DICTPCM = $(DICTSRC:.cc=_rdict.pcm) CXX = $(shell artemis-config --cxx) WARNING = -Wall -Wextra CXXFLAGS = -O2 $(WARNING) -I. $(INCLUDE) `artemis-config --cflags` -fPIC `root-config --cflags` -g -LDFLAGS = -L$(HOME)/local/lib `artemis-config --libs` `root-config --libs` -lTreePlayer +LDFLAGS = -L$(HOME)/local/lib `artemis-config --libs` `root-config --libs` -lTreePlayer +PREFIX := $(shell artemis-config --prefix) +LIBDIR := $(PREFIX)/lib +INCDIR := $(PREFIX)/include + +HEADERS = $(foreach file, $(HDR), $(shell find . -name $(file))) all: $(TARGET) + @echo compile with ROOT$(ROOTVER) + +ifeq ($(ROOTVER),5) +install: install-root5 +uninstall: uninstall-root5 +else +install: install-root6 +uninstall: uninstall-root6 +endif + .PHONY: all clean $(TARGET): $(OBJECTS) $(DICTOBJ) @@ -208,3 +226,21 @@ $(OBJDIR)/%.o: %.cc clean: rm -f $(DEPDIR)/*.d $(OBJDIR)/*.o $(LIBNAME).$(SOEXT) $(DICTOBJ) $(DICTSRC) $(DICTHDR) rmdir $(OBJDIR) $(DEPDIR) + + +install-root5: $(TARGET) $(HEADERS) + test -f $(TARGET) && install -c -m 644 $(TARGET) $(LIBDIR) + install -c -m 644 $(HEADERS) $(INCDIR) +install-root6: $(DICTPCM) $(TARGET) $(HEADERS) + test -f $(DICTPCM) && install -c -m 644 $(DICTPCM) $(LIBDIR) + test -f $(TARGET) && install -c -m 644 $(TARGET) $(LIBDIR) + install -c -m 644 $(HEADERS) $(INCDIR) + + +uninstall-root5: $(TARGET) $(HEADERS) + cd $(LIBDIR) && rm -f $(TARGET) + cd $(INCDIR) && rm -f $(HDR) +uninstall-root6: $(DICTPCM) $(TARGET) $(HEADERS) + cd $(LIBDIR) && rm -f $(DICTPCM) + cd $(LIBDIR) && rm -f $(TARGET) + cd $(INCDIR) && rm -f $(HDR)