SHELL = /bin/sh
# decide on compiler and flags depending on host
CC = g++ 
CFLAGS=-fPIC -pthread
ALL_CFLAGS = -Wall -O6 $(CFLAGS) -m32

LIBS = -L$(PAM_LIB)/ -lyoda -lDarthVader -lPamLevel2 -lCaloLevel2 -lTrkLevel2 -lTrkProcess -lTrkVerl2 -lPamCut -lCaloAxis -L$(PAM_PA_LIB)/ -lPa `root-config --cflags --glibs` -L$(ROOTSYS)/ -lTMVA -lMinuit -lXMLIO -lXMLParser -lMLP -lTreePlayer

INCS = -I `root-config --incdir`   -I$(PAM_INC)/ -I$(PAM_INC)/PamCut/ -I$(PAM_PA_INC)/ -I$(PAM_INC)/yoda/   -I./

CROOT= root -l -b -q 

# pattern rule to compile object files from C files
# might not work with make programs other than GNU make
#%.o : %.cpp Makefile
#	$(CC) $(ALL_CFLAGS) $(INCS) -c $< -o $@  

all: clean lib mask_profiler

mask_profiler:  mask_profiler.o  VKmask_cpp.so  Makefile
	$(CC) $(ALL_CFLAGS) $(INCS) mask_profiler.o $(LIBS) -L$(PAM_CUT)/  -lPamCut ./VKmask_cpp.so -o mask_profiler


mask_profiler.o : mask_profiler.cpp Makefile
	$(CC) $(ALL_CFLAGS) $(INCS) -c $< -o $@

lib: MakeLib.C VKmask.cpp VKmask.h
	$(CROOT) MakeLib.C
install:
	cp mask_profiler $(PAM_BIN)/
	cp VKmask.h $(PAM_INC)/
	cp VKmask_cpp.so $(PAM_LIB)/

.PHONY : clean
clean:
	rm -f *.o mask_profiler
	rm -f *.o 
	rm -f *~
	rm -f *.so
