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

GSLCFLAGS   := $(shell gsl-config --cflags)
GSLLIBS     := $(shell gsl-config --libs)
GSLGLIBS    := $(shell gsl-config --glibs)


LDFLAGS       = -O
LIBS         += $(ROOTLIBS) $(GSLLIBS) -L/cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_95/tbb/2019_U1/x86_64-slc6-gcc8-opt/include
CFLAGS       += $(ROOTCFLAGS) $(GSLCFLAGS) -std=gnu++11

#  Not sure why Minuit isn't being included -- put in by hand
#
LIBS         += -lMinuit

OBJS = convert_clean.o init.o align_ethercat.o read_bpm.o

all: convert_clean


convert_clean: $(OBJS)
	g++ -o convert_clean  $(OBJS) $(LDFLAGS) $(LIBS)

%.o: %.c
	g++ ${CFLAGS} -c  -g $<

init.o: init.c init.h
	g++ ${CFLAGS} -c init.c

align_ethercat.o: align_ethercat.c align_ethercat.h
	g++ ${CFLAGS} -c align_ethercat.c

read_bpm.o: read_bpm.c read_bpm.h
	g++ ${CFLAGS} -c read_bpm.c	


test:
	@echo $(ROOTCFLAGS) 
	@echo $(LDFLAGS) 
	@echo $(LIBS)

clean:	
	-rm -f  *.o

