CXX_FLAGS := `root-config --cflags`
LD_FLAGS := `root-config --libs`

all: build example

build: clean
	@echo
	@echo
	@echo "---------> Building the code"
	rootcint -f Dict.cxx -c -p Singleton.h LinkDef.h 
	g++ $(CXX_FLAGS) -c Dict.cxx;
	g++ $(CXX_FLAGS) -c instantiations.cxx
	g++ $(CXX_FlAGS) $(LD_FLAGS) -shared Dict.o instantiations.o -o libLib.so
	g++ main.cxx -o main-exe

example:
	@echo
	@echo
	@echo "---------> Running the root script"
	root -l -q main-rootscript.cxx 
	@echo
	@echo
	@echo "---------> Running the binary"
	./main-exe

clean:
	rm -f *.o
	rm -f *.so
	rm -f *Dict*
	rm -f main-exe
