# Makefile for TPH1F
#
# Copyright (c) 2000 Rene Brun and Fons Rademakers
#
# Author: Fons Rademakers,   29/2/2000
# 
# modified: Andreas Suter,   14/04/2004
# modified: Thomas Prokscha, 30/01/2007
# 
#
include Makefile.arch
#------------------------------------------------------------------------------

# TPsiRunHeader
TNAME        = TPsiRunHeader
TLRHO        = $(TNAME).$(ObjSuf) $(TNAME)Dict.$(ObjSuf)
TLRHS        = $(TNAME).$(SrcSuf) $(TNAME)Dict.$(SrcSuf)
TLRHSO       = lib$(TNAME).$(DllSuf)


ifeq ($(ARCH),win32)
TLRHLIB        = lib$(TNAME).lib
else
TLRHLIB         = $(TLRHSO)
endif

OBJS             = $(TLRHO)

# my one stuff

ifeq ($(ARCH),macosx)
	CXXFLAGS     += -I./ -I/usr/local/include
else
	CXXFLAGS     += -I./ -I/usr/local/include
endif

MYINCLUDES   += ./
MYLIBS       += ./

#------------------------------------------------------------------------------

.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)

#TLRH
$(TLRHSO):     $(TLRHO)
ifeq ($(ARCH),aix)
		/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(ARCH),aix5)
		/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(ARCH),macosx)
# We need to make both the .dylib and the .so
# SOFLAGS       = -dynamiclib -flat_namespace -undefined suppress
# 
		$(LD) $(SOFLAGS) $(EVENTO) $(EVENTSO) $^ 
		$(LD) -bundle -undefined suppress -Wl,-x $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@) $(EXPLLINKLIBS)
else
ifeq ($(ARCH),win32)
		bindexplib $* $^ > $*.def
		lib -nologo -MACHINE:IX86 $^ -def:$*.def \
		   $(OutPutOpt)$(EVENTLIB)
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \
		   $(OutPutOpt)$@ 
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $(MYLIBS)/$@ $(EXPLLINKLIBS)
endif
endif
endif
endif
		@echo
		@echo "$@ done $(TNAME)"


clean:
		@rm -f $(OBJS) core
		@rm -f *Dict*
		@rm -f *.*~

distclean:      clean
		@rm -f $(PROGRAMS) $(EVENTSO) $(EVENTLIB) *Dict.* *.def *.exp \
		   *.root *.ps *.so *.lib *.dll *.d .def so_locations
		@rm -rf cxx_repository
		-@cd RootShower && $(MAKE) distclean
		
install:
ifeq ($(ARCH),linux)
		cp -pv $(MYLIBS)/$(TLRHSO) $(ROOTSYS)/lib
		cp -pv $(MYINCLUDES)/$(TNAME).h $(ROOTSYS)/include
endif
ifeq ($(ARCH),win32gcc)
		cp -pv $(MYLIBS)/$(TLRHSO) $(ROOTSYS)/bin
		ln -sf $(ROOTSYS)/bin/$(TLRHSO) $(ROOTSYS)/lib/$(TLRHSO)
		cp -pv $(MYINCLUDES)/$(TNAME).h $(ROOTSYS)/include
endif

uninstall:
ifeq ($(ARCH),linux)
		rm $(ROOTSYS)/lib/$(TLRHSO)
		rm $(ROOTSYS)/include/$(TNAME).h
endif
ifeq ($(ARCH),win32gcc)
		rm $(ROOTSYS)/lib/$(TLRHSO)
		rm $(ROOTSYS)/include/$(TNAME).h
endif

.SUFFIXES: .$(SrcSuf)

###

#TLRH
$(TNAME).$(ObjSuf): $(MYINCLUDES)/$(TNAME).h

$(TNAME)Dict.$(SrcSuf): $(MYINCLUDES)/$(TNAME).h $(MYINCLUDES)/$(TNAME)LinkDef.h
	@echo "Generating dictionary $@..."
	rootcint -f $@ -c -p $^

.$(SrcSuf).$(ObjSuf):
	@echo "Generating object file $@..."
	$(CXX) $(CXXFLAGS) -c $<


