
include $(AWARE_HOME)/config/Makefile.config

ifdef CONFIG_RRDTOOL


RRD_TARBALL=rrdtool-1.2.0.tar.gz
RRD_DIR=rrdtool-1.2.0
RRD_BUILD_DIR=$(AWARE_HOME)/src/pkg/$(RRD_DIR)

CGILIB_TARBALL=cgilib-0.5.tar.gz
CGILIB_DIR=cgilib-0.5

RRD_BUILT_DIRS=bin contrib doc examples html include lib man share

all: configure
	@(cd $(RRD_DIR) ; make);

configure: unpack cgilib
	@ if [ ! -s $(RRD_DIR)/config.log ] ; then \
		(cd $(RRD_DIR) ; \
		 export CPPFLAGS=-I$(INCLUDEDIR) ; \
		 export LDFLAGS=-L$(LIBDIR) ; \
		 ./configure --prefix=$(RRD_BUILD_DIR) \
		); \
	fi ;

cgilib:
	@if [ ! -d $(CGILIB_DIR) ] ; then tar xzf $(CGILIB_TARBALL) ; fi;
	@cp Makefile.cgilib $(CGILIB_DIR)/Makefile
	@(cd $(CGILIB_DIR); make install)

unpack::
	@if [ ! -d $(RRD_DIR) ] ; then tar xzf $(RRD_TARBALL) ; fi;

install: all
	@(cd $(RRD_DIR) ; make install);
	@ # copy the libs we want
	@cp ./lib/*.* $(LIBDIR)
	@ # copy the headers we want
	@cp ./include/*.h $(INCLUDEDIR)
	@ # copy the apps we want
	@cp ./bin/rrdcgi $(BINDIR) ;

clean::
	$(RM) $(RMFILES) 
	$(RM) -r $(CGILIB_DIR) $(RRD_DIR) $(RRD_BUILT_DIRS)



else



all: msg

install: msg


clean: msg
	$(RM) $(RMFILES) $(APPS)

msg::
	@echo "rrdtool not configured"


endif
