-############################### RICH Makefile #################################
+Module :=RICH
-# Include machine specific definitions
+include lib$(Module).pkg
-include $(ALICE_ROOT)/conf/GeneralDef
-include $(ALICE_ROOT)/conf/MachineDef.$(ALICE_TARGET)
+Sources :=$(SRCS)
-PACKAGE = RICH
+OutputDir :=$(KIR_DIR)/$(Module)
+SoLib :=$(KIR_DIR)/lib$(Module).so
-# C++ sources
+CxxFlags := -g -Wall -fPIC -pipe -I$(ROOTSYS)/include -I$(ALICE_ROOT)/include
-SRCS = AliRICH.cxx
+ifdef ALIVERBOSE
+ Mute :=
+else
+ Mute :=@
+endif
-# C++ Headers
+Headers := $(Sources:.cxx=.h) $(Module)LinkDef.h
-HDRS = $(SRCS:.cxx=.h) RICHLinkDef.h
+DictSource := $(OutputDir)/G__$(Module).cxx
+DictHeader := $(DictSource:.cxx=.h)
+DictObject := $(DictSource:.cxx=.o)
-# Library dictionary
-DICT = RICHCint.cxx
-DICTH = $(DICT:.cxx=.h)
-DICTO = $(patsubst %.cxx,tgt_$(ALICE_TARGET)/%.o,$(DICT))
+Objects := $(patsubst %.cxx,$(OutputDir)/%.o,$(Sources)) $(DictObject)
-# FORTRAN Objectrs
-FOBJS = $(patsubst %.f,tgt_$(ALICE_TARGET)/%.o,$(FSRCS))
-
-# C Objects
-
-COBJS = $(patsubst %.c,tgt_$(ALICE_TARGET)/%.o,$(CSRCS))
-
-# C++ Objects
-
-OBJS = $(patsubst %.cxx,tgt_$(ALICE_TARGET)/%.o,$(SRCS)) $(DICTO)
-
-# C++ compilation flags
-
-CXXFLAGS = $(CXXOPTS) -I$(ROOTSYS)/include -I. -I$(ALICE_ROOT)/include/
-
-CXXFLAGS += -I$(ALICE_ROOT)/TGeant3
-DEPINC += -I$(ALICE_ROOT)/TGeant3
-
-# FORTRAN compilation flags
-
-FFLAGS = $(FOPT)
+DepFile := $(OutputDir)/$(Module).d
##### TARGETS #####
-
-# Target
-
-SLIBRARY = $(LIBDIR)/libRICH.$(SL)
-ALIBRARY = $(LIBDIR)/libRICH.a
-
-default: $(SLIBRARY)
-
-$(LIBDIR)/libRICH.$(SL): $(OBJS)
-
-$(DICT): $(HDRS)
-
-depend: $(SRCS)
-
-TOCLEAN = $(OBJS) *Cint.cxx *Cint.h
-
-############################### General Macros ################################
-
-include $(ALICE_ROOT)/conf/GeneralMacros
+$(SoLib): $(Objects)
+ @echo "Creating $@"
+ $(Mute)g++ -Wl,-soname,lib$(Module).so -shared -O -g $^ -o $@
+
+$(DepFile): $(Headers)
+ @[ -d $(OutputDir) ] || mkdir -p $(OutputDir)
+ @touch $(DepFile)
+ @echo "Generating dependency $@"
+ $(Mute)rmkdepend -f$(DepFile) -p$(OutputDir)/ -- $(CxxFlags) -- $(Sources) 2>/dev/null
+
+$(DictSource): $(Headers)
+ @echo "Generating $@"
+ $(Mute)rootcint -f $@ -c $(filter -I%,$(CxxFlags)) $^
+
+$(DictObject) : $(DictSource)
+ @echo "Compiling $^"
+ $(Mute)g++ $(CxxFlags) -I. -c $^ -o $@
+
+show:
+ @echo "Headers: $(Headers)"
+ @echo "Sources: $(Sources)"
+ @echo "Depend : $(DepFile)"
+ @echo "Objects: $(Objects)"
+ @echo "Library: $(SoLib)"
+
+spec: $(Sources)
+ @echo $^
+ @echo $@
+
+clean:
+ @echo "Cleaning..."
+ $(Mute)rm -rf $(Objects) $(DictSource) $(DictHeader) $(SoLib) $(DepFile)
+
+############################ cxx rule #########################################
+$(OutputDir)/%.o : %.cxx
+ @echo $*.cxx
+ $(Mute)g++ $(CxxFlags) -c $*.cxx -o $(OutputDir)/$*.o
############################ Dependencies #####################################
--include Make-depend
+-include $(DepFile)