# Copyright (C) 2010 Thomas Müller

# Get the correct root configuration
ROOTCFLAGS	:= $(shell root-config --cflags)
ROOTLIBS	:= $(shell root-config --libs)
# -lMathCore -lThread
ROOTGLIBS	:= $(shell root-config --glibs)

# Set the compiler options
CXX			= g++							# use g++ as compiler
CXXFLAGS	= -g -O -Wall -fPIC				# set compiler options
											# -g compile with debug information
											# -O optimize
											# -Wall show warnings for everything
											# -fPIC compile source file as sharable object
# -pedantic

# Set the linker options
LD			= g++					# use g++ for linking
LDFLAGS		= -O
SOFLAGS		= #-fPIC -shared

#######################
CXXFLAGS	+= $(ROOTCFLAGS)
LIBS		= $(ROOTLIBS) -lGed
GLIBS		= $(ROOTGLIBS)



#======================================================================================================================================================
# link

RooFiLab:	CovarianceMatrix.o DistinguishedErrorsGraph.o DistinguishedErrorsMultiGraph.o DataManager.o English.o FitFunction.o German.o LabeledWidgetFrame.o RooFiLab.o RooFiLab_MainFrame.o UserInterface.o Value.o
			$(LD) $(LDFLAGS) $(SOFLAGS) CovarianceMatrix.o DistinguishedErrorsGraph.o DistinguishedErrorsMultiGraph.o DataManager.o English.o FitFunction.o German.o LabeledWidgetFrame.o RooFiLab.o RooFiLab_MainFrame.o UserInterface.o Value.o $(LIBS) $(GLIBS) $(SYSLIBS) -o RooFiLab



#======================================================================================================================================================
# compile

CovarianceMatrix.o:					header/CovarianceMatrix.h code/CovarianceMatrix.cxx header/DataManager.h header/DistinguishedErrorsGraph.h header/FitFunction.h header/UserInterface.h language/Language.h
									$(CXX) $(CXXFLAGS) -c code/CovarianceMatrix.cxx -o CovarianceMatrix.o $(LIBS) $(GLIBS) $(SYSLIBS)

DataManager.o:						header/DataManager.h code/DataManager.cxx header/DistinguishedErrorsGraph.h header/FitFunction.h header/UserInterface.h language/Language.h
									$(CXX) $(CXXFLAGS) -c code/DataManager.cxx -o DataManager.o $(LIBS) $(GLIBS) $(SYSLIBS)

DistinguishedErrorsGraph.o:			header/DistinguishedErrorsGraph.h code/DistinguishedErrorsGraph.cxx header/CovarianceMatrix.h header/DistinguishedErrorsMultiGraph.h header/FitFunction.h header/Value.h language/Language.h
									$(CXX) $(CXXFLAGS) -c code/DistinguishedErrorsGraph.cxx -o DistinguishedErrorsGraph.o $(LIBS) $(GLIBS) $(SYSLIBS)

DistinguishedErrorsMultiGraph.o:	header/DistinguishedErrorsMultiGraph.h code/DistinguishedErrorsMultiGraph.cxx header/DistinguishedErrorsGraph.h language/Language.h
									$(CXX) $(CXXFLAGS) -c code/DistinguishedErrorsMultiGraph.cxx -o DistinguishedErrorsMultiGraph.o $(LIBS) $(GLIBS) $(SYSLIBS)
									
English.o:							language/English.cxx
									$(CXX) $(CXXFLAGS) -c language/English.cxx -o English.o $(LIBS) $(GLIBS) $(SYSLIBS)

FitFunction.o:						header/FitFunction.h code/FitFunction.cxx header/DistinguishedErrorsMultiGraph.h header/UserInterface.h header/Value.h language/Language.h
									$(CXX) $(CXXFLAGS) -c code/FitFunction.cxx -o FitFunction.o $(LIBS) $(GLIBS) $(SYSLIBS)
									
German.o:							language/German.cxx
									$(CXX) $(CXXFLAGS) -c language/German.cxx -o German.o $(LIBS) $(GLIBS) $(SYSLIBS)

LabeledWidgetFrame.o:				header/LabeledWidgetFrame.h code/LabeledWidgetFrame.cxx language/Language.h
									$(CXX) $(CXXFLAGS) -c code/LabeledWidgetFrame.cxx -o LabeledWidgetFrame.o $(LIBS) $(GLIBS) $(SYSLIBS)
							
RooFiLab.o:							code/RooFiLab.cxx header/UserInterface.h language/Language.h
									$(CXX) $(CXXFLAGS) -c code/RooFiLab.cxx -o RooFiLab.o $(LIBS) $(GLIBS) $(SYSLIBS)

RooFiLab_MainFrame.o:				header/RooFiLab_MainFrame.h code/RooFiLab_MainFrame.cxx header/DistinguishedErrorsGraph.h header/DistinguishedErrorsMultiGraph.h header/LabeledWidgetFrame.h language/Language.h
									$(CXX) $(CXXFLAGS) -c code/RooFiLab_MainFrame.cxx -o RooFiLab_MainFrame.o $(LIBS) $(GLIBS) $(SYSLIBS)

UserInterface.o:					header/UserInterface.h code/UserInterface.cxx header/DistinguishedErrorsGraph.h header/DistinguishedErrorsMultiGraph.h header/DataManager.h header/RooFiLab_MainFrame.h language/Language.h
									$(CXX) $(CXXFLAGS) -c code/UserInterface.cxx -o UserInterface.o $(LIBS) $(GLIBS) $(SYSLIBS)

Value.o:							header/Value.h code/Value.cxx language/Language.h
									$(CXX) $(CXXFLAGS) -c code/Value.cxx -o Value.o $(LIBS) $(GLIBS) $(SYSLIBS)



#======================================================================================================================================================
#clean up

clean:
		@rm -f *.o core
