#
# sloppy, I know.  But I don't want anything in the build hidden
# or obscured  - J.Pretz
#

LD_FLAGS := `root-config --glibs`
CXX_FLAGS := -I`root-config --incdir`

all:  libClasses.so test ArraySyntax IteratorSyntax

libClasses.so: ClassA.o Dict.o
	g++ -shared $^ -o libClasses.so

Dict.o: Dict.cxx
	g++ -c ${CXX_FLAGS}  Dict.cxx

Dict.cxx: ClassA.h LinkDef.h
	rootcint -f Dict.cxx -c $^ 

ClassA.o: ClassA.cxx ClassA.h
	g++ -c ${CXX_FLAGS} ClassA.cxx

ArraySyntax: ClassA.o Dict.o 
	g++ ${CXX_FLAGS} $(LD_FLAGS) Dict.o ClassA.o ArraySyntax.cxx -o ArraySyntax

IteratorSyntax: ClassA.o Dict.o
	g++ ${CXX_FLAGS} $(LD_FLAGS) Dict.o ClassA.o IteratorSyntax.cxx -o IteratorSyntax

clean:
	rm -f *.o
	rm -f *Dict*
	rm -f *.so
	rm -f *~
	rm -f *core*
	rm -f ArraySyntax
	rm -f IteratorSyntax

test: libClasses.so ArraySyntax IteratorSyntax
	@echo ">>>>> If I use the 'array syntax' of the vector, then it works"
	@echo ">>>>>"
	@echo ">>>>>"
	root -l -q scripts/ArraySyntax.cxx
	@echo ">>>>> However if I use the 'iterator syntax' of the vector"
	@echo ">>>>> Then I get problems"
	@echo ">>>>>"
	@echo ">>>>>"
	root -l -q scripts/IteratorSyntax.cxx
	@echo ">>>>> Just to check that I'm not doing something bone-headed"
	@echo ">>>>> if I compile the 'IteratorSyntax' script into an"
	@echo ">>>>> executable, it runs as expected"
	@echo ">>>>>"
	@echo ">>>>>"
	./IteratorSyntax
