# =============================================================================
#  $Id$
#  $Name$
# =============================================================================
#MAKEFILEϤ
PREFIX			:= $(CCD_ROOT)
CC			:= $(CCD_CC)
MAKE			:= $(CCD_MAKE)
ARFLAGS			:= r
LIB_EX_NAME		:= examples
LIB_EX_FILE		:= lib$(LIB_EX_NAME).a
INC_EX_DIR		:= $(CCD_ROOT)/examples
LIB_EX_DIR		:= $(CCD_ROOT)/examples
INC_FLAGS		:= -I$(INC_EX_DIR)
LIB_FLAGS		:= -L$(LIB_EX_DIR)# -l$(LIB_EX_NAME)

INC_CCD_DIR		:= $(CCD_ROOT)
LIB_CCD_DIR		:= $(CCD_ROOT)

LIB_CCD_NAME		:= CCDdaq
LIB_CCD_FILE		:= lib$(LIB_CCD_NAME).a

INC_FLAGS		+= -I$(INC_CCD_DIR)
LIB_FLAGS		+= -L$(LIB_CCD_DIR) -l$(LIB_CCD_NAME)

INC_FLAGS		+= -I$(CCD_CLHEP_BASE_DIR)/include
LIB_FLAGS		+= -L$(CCD_CLHEP_BASE_DIR)/lib -l$(CCD_CLHEP_LIB_NAME)


ifeq ($(CCD_ZLIB_USE),1)
LIB_FLAGS		+= -lz
endif


ifeq ($(CCD_ROOT_USE),1)
INC_FLAGS		+= $(shell root-config --cflags)
LIB_FLAGS		+= $(shell root-config --glibs)
endif

ifeq ($(CCD_GTK_GUI_USE),1)
INC_FLAGS		+= $(shell gtk-config --cflags)
LIB_FLAGS		+= $(shell gtk-config --libs)
endif

COMPILE_FLAGS		:= -pipe -c -g -O2
#COMPILE_FLAGS		+= -Wall -ansi -pedantic
COMPILE_FLAGS		+= -Wall -pedantic
COMPILE_FLAGS		+= -DDEBUG
COMPILE_FLAGS		+= $(INC_FLAGS)
COMPILE			:= $(CC) $(COMPILE_FLAGS)

LINK_FLAGS		:= -pipe -g -O3
#LINK_FLAGS		+= -Wall -ansi -pedantic
LINK_FLAGS		+= -Wall -pedantic
LINK_FLAGS		+= -DDEBUG
LINK_FLAGS		+= $(INC_FLAGS)
LINK_FLAGS		+= $(LIB_FLAGS)
LINK                    := $(CC) -o


OBJ_FILES		:= AsoReadFileCommand.o
OBJ_FILES		+= AsoReadoutList.o
OBJ_FILES		+= AsoStartCommand.o
OBJ_FILES		+= ExGraphExtractor.o
OBJ_FILES		+= Ex1DHistogramExtractor.o
OBJ_FILES		+= DarkStartCommand.o
OBJ_FILES		+= DarkReadoutList.o
OBJ_FILES		+= DarkGraphExtractor.o
OBJ_FILES		+= Dark1DHistogramExtractor.o

#DEMOS			:= exTerminalUserInterface
#DEMOS			+= exOutputDataElement
#DEMOS			+= exInputDataElement
#DEMOS			+= exFindDataElement
#DEMOS			+= exOutputDataRecord
#DEMOS			+= exInputDataRecord
#DEMOS			+= exOutputSocket
#DEMOS			+= exInputSocket
#DEMOS			+= exOutputSharedMemory
#DEMOS			+= exInputSharedMemory
#DEMOS			+= exSoftwareModules
#DEMOS			+= exDataFileModule
#DEMOS			+= exVmeModules
#DEMOS			+= exRootAnalysis
DEMOS			:= exRun+Event
#DEMOS			:= dark-daq
#DEMOS			+= aso-daq
#DEMOS			+= aso-ana00
#DEMOS			+= aso-ana01

###############################################################################
all: $(DEMOS)
	@$(MAKE) $(DEMOS)

.cc.o:
	@echo "Compiling $< ..."
	@$(COMPILE) $<
	@$(AR) $(ARFLAGS) $(LIB_EX_FILE) $@

.cc:
	@echo "Linking $@ ..."
	@$(LINK) $@ $< $(LINK_FLAGS)

clean:
	@echo "Cleaning ..."
	@-rm -f *~ *.o a.out core $(LIB_EX_FILE) $(DEMOS)
	@-rm -f test.obj test.dat test.ps
	@-rm -f last.kumac last.kumacold paw.metafile

$(LIB_EX_FILE): $(OBJ_FILES)

exOutputFile: exOutputFile.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exInputFile: exInputFile.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exOutputDataElement: exOutputDataElement.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exInputDataElement: exInputDataElement.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exSoftwareModules: exSoftwareModules.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exFindDataElement: exFindDataElement.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exInputSocket: exInputSocket.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exOutputSocket: exOutputSocket.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exTerminalUserInterface: exTerminalUserInterface.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exOutputSharedMemory: exOutputSharedMemory.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exInputSharedMemory: exInputSharedMemory.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exVmeModules: exVmeModules.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exDataFileModule: exDataFileModule.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
aso-ana00: aso-ana00.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
aso-ana01: aso-ana01.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)

exRootAnalysis: exRootAnalysis.cc $(LIB_EX_FILE) $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
exRun+Event: exRun+Event.cc $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
aso-daq: aso-daq.cc $(LIB_EX_FILE) $(LIB_CCD_DIR)/$(LIB_CCD_FILE)
dark-daq: dark-daq.cc $(LIB_EX_FILE) $(LIB_CCD_DIR)/$(LIB_CCD_FILE)

#############################################################
AsoReadFileCommand.o: AsoReadFileCommand.cc AsoReadFileCommand.hh \
  ../TGlobals.hh ../TTypes.hh ../TCommand.hh ../TInputObjectFile.hh \
  ../TObjectFile.hh ../TInputObjectStream.hh ../TObjectStream.hh \
  ../TDataRecord.hh ../TStreamableObject.hh ../TDataSectionList.hh \
  ../TDataSection.hh ../TDataSegmentList.hh ../TDataSegment.hh \
  ../TDataElementList.hh ../TDataElement.hh
AsoReadoutList.o: AsoReadoutList.cc AsoReadoutList.hh ../TGlobals.hh \
  ../TTypes.hh ../TReadoutList.hh ../TReadoutSectionList.hh \
  ../TReadoutSection.hh ../TReadoutSegmentList.hh ../TReadoutSegment.hh \
  ../TReadoutElementList.hh ../TReadoutElement.hh ../TDataRecord.hh \
  ../TStreamableObject.hh ../TDataSectionList.hh ../TDataSection.hh \
  ../TDataSegmentList.hh ../TDataSegment.hh ../TDataElementList.hh \
  ../TDataElement.hh ../TSoftwareScalerModule.hh ../TSoftwareModule.hh \
  ../TModule.hh ../TChannel.hh ../TSoftwareClockModule.hh \
  ../TVmeMpx201aModule.hh ../TVmeModule.hh
AsoStartCommand.o: AsoStartCommand.cc AsoStartCommand.hh ../TGlobals.hh \
  ../TTypes.hh ../TCommand.hh AsoReadoutList.hh ../TReadoutList.hh \
  ../TReadoutSectionList.hh ../TReadoutSection.hh \
  ../TReadoutSegmentList.hh ../TReadoutSegment.hh \
  ../TReadoutElementList.hh ../TReadoutElement.hh ../TDataRecord.hh \
  ../TStreamableObject.hh ../TDataSectionList.hh ../TDataSection.hh \
  ../TDataSegmentList.hh ../TDataSegment.hh ../TDataElementList.hh \
  ../TDataElement.hh ../TSoftwareScalerModule.hh ../TSoftwareModule.hh \
  ../TModule.hh ../TChannel.hh ../TSoftwareClockModule.hh \
  ../TVmeMpx201aModule.hh ../TVmeModule.hh ../TRunManager.hh \
  ../TUserInterface.hh ../TVmeRpv130Module.hh ../TOutputObjectFile.hh \
  ../TObjectFile.hh ../TOutputObjectStream.hh ../TObjectStream.hh
Ex1DHistogramExtractor.o: Ex1DHistogramExtractor.cc \
  Ex1DHistogramExtractor.hh ../TGlobals.hh ../TTypes.hh \
  ../TAnalysisDataExtractor.hh ../TMultipleData.hh ../TDataRecord.hh \
  ../TStreamableObject.hh ../TDataSectionList.hh ../TDataSection.hh \
  ../TDataSegmentList.hh ../TDataSegment.hh ../TDataElementList.hh \
  ../TDataElement.hh
ExGraphExtractor.o: ExGraphExtractor.cc ExGraphExtractor.hh \
  ../TGlobals.hh ../TTypes.hh ../TAnalysisDataExtractor.hh \
  ../TMultipleData.hh ../TDataRecord.hh ../TStreamableObject.hh \
  ../TDataSectionList.hh ../TDataSection.hh ../TDataSegmentList.hh \
  ../TDataSegment.hh ../TDataElementList.hh ../TDataElement.hh
Dark1DHistogramExtractor.o: Dark1DHistogramExtractor.cc \
  Dark1DHistogramExtractor.hh ../TGlobals.hh ../TTypes.hh \
  ../TAnalysisDataExtractor.hh ../TMultipleData.hh ../TDataRecord.hh \
  ../TStreamableObject.hh ../TDataSectionList.hh ../TDataSection.hh \
  ../TDataSegmentList.hh ../TDataSegment.hh ../TDataElementList.hh \
  ../TDataElement.hh
DarkGraphExtractor.o: DarkGraphExtractor.cc DarkGraphExtractor.hh \
  ../TGlobals.hh ../TTypes.hh ../TAnalysisDataExtractor.hh \
  ../TMultipleData.hh ../TDataRecord.hh ../TStreamableObject.hh \
  ../TDataSectionList.hh ../TDataSection.hh ../TDataSegmentList.hh \
  ../TDataSegment.hh ../TDataElementList.hh ../TDataElement.hh
DarkReadoutList.o: DarkReadoutList.cc DarkReadoutList.hh ../TGlobals.hh \
  ../TTypes.hh ../TReadoutList.hh ../TReadoutSectionList.hh \
  ../TReadoutSection.hh ../TReadoutSegmentList.hh ../TReadoutSegment.hh \
  ../TReadoutElementList.hh ../TReadoutElement.hh ../TDataRecord.hh \
  ../TStreamableObject.hh ../TDataSectionList.hh ../TDataSection.hh \
  ../TDataSegmentList.hh ../TDataSegment.hh ../TDataElementList.hh \
  ../TDataElement.hh ../TSoftwareScalerModule.hh ../TSoftwareModule.hh \
  ../TModule.hh ../TChannel.hh ../TSoftwareClockModule.hh \
  ../TVmeMpx201aModule.hh ../TVmeModule.hh
DarkStartCommand.o: DarkStartCommand.cc DarkStartCommand.hh \
  ../TGlobals.hh ../TTypes.hh ../TCommand.hh DarkReadoutList.hh \
  ../TReadoutList.hh ../TReadoutSectionList.hh ../TReadoutSection.hh \
  ../TReadoutSegmentList.hh ../TReadoutSegment.hh \
  ../TReadoutElementList.hh ../TReadoutElement.hh ../TDataRecord.hh \
  ../TStreamableObject.hh ../TDataSectionList.hh ../TDataSection.hh \
  ../TDataSegmentList.hh ../TDataSegment.hh ../TDataElementList.hh \
  ../TDataElement.hh ../TSoftwareScalerModule.hh ../TSoftwareModule.hh \
  ../TModule.hh ../TChannel.hh ../TSoftwareClockModule.hh \
  ../TVmeMpx201aModule.hh ../TVmeModule.hh Dark1DHistogramExtractor.hh \
  ../TAnalysisDataExtractor.hh ../TMultipleData.hh DarkGraphExtractor.hh \
  ../TAnalysisStation.hh ../TRoot1DHistogram.hh ../TRootGraph.hh \
  ../TRootAnalyser.hh ../TRootCanvas.hh ../TRunManager.hh \
  ../TUserInterface.hh ../TVmeRpv130Module.hh
