# ESAF : Euso Simulation and Analysis Framework
# $Id: GNUmakefile,v 1.21 2004/06/29 14:27:02 naumov Exp $
# D. De Marco created Jan, 23 2002

CPP = g++
CXX = g++
CXXFLAGS += -I include -Wall

ifdef ROOTSYS
ROOTCFLAGS   := $(shell root-config --cflags)
ROOTLIBS     := $(shell root-config --libs)
ROOTGLIBS    := $(shell root-config --glibs)

CXXFLAGS += -fPIC
CXXFLAGS += $(ROOTCFLAGS)
LDFLAGS += $(ROOTGLIBS) $(patsubst %,-l%)
else
$(error root not configured properly)
endif

SHARED := test

LIBTARGET := lib$(SHARED).so
linkdef := LinkDef
dict := G___Dict

libclasses := MyClass

dicts := $(patsubst %,%.cc,$(dict))
dicth := $(dicts:.cc=.h)
libheaders := $(patsubst %,%.hh,$(libclasses) $(linkdef))
libsources := $(patsubst %,%.cc,$(libclasses)) $(dicts) 

libldflags := -L$(shell root-config --libdir)

$(LIBTARGET): 
	@echo Building $(shared) dictionary...
	@rootcint -f $(dicts) -c $(libheaders)
	@echo Building $(LIBTARGET)...
	@$(CXX) --shared $(CXXFLAGS) $(dicts) $(libobjects) -L$(LIBDIR) $(libldflags) -o $@ 
	@echo Cleaning temporary files...
	@rm -r $(dicts) $(dicth) 

rootlib: $(LIBDIR)/$(LIBTARGET)

