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

CROOT= root -l -b -q 

LIBS = $(PAM_LIB)/libyoda.so $(PAM_LIB)/libDarthVader.so $(PAM_LIB)/libPamLevel2.so  `root-config --cflags --glibs`
INCS =-I `root-config --incdir`  -I$(PAM_INC) -I$(PAM_INC)/yoda/ -I./ 


#
# list of all exe to compile
#
EXE = GP.exe Trigger.exe
# 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: $(EXE)


#
# program to loop over a simulation file and retrieve GP variables
# (the file MUST contain both Digitizer and DarthVader output)
#
OBJS1 = Loop.o GP.o
GP.exe: $(OBJS1) Makefile
	$(CC) $(ALL_CFLAGS) $(INCS) $(OBJS1) $(LIBS) -o GP.exe

#
# program to compare trigger and tof-tdc variables
#
OBJS2 = Loop.o Trigger.o
Trigger.exe: $(OBJS2) Makefile
	$(CC) $(ALL_CFLAGS) $(INCS) $(OBJS2) $(LIBS) -o Trigger.exe

.PHONY : clean
clean:
	rm -f *.o *.exe
