AXIS_USABLE_LIBS = UCLIBC GLIBC
include $(AXIS_TOP_DIR)/tools/build/Rules.axis

SRCDIR   = $(AXIS_TOP_DIR)/apps/rrdtool
LDFLAGS  += -L$(prefix)/lib
CPPFLAGS += -I$(prefix)/include
CFLAGS += -I$(prefix)/include

PKG_INSTALL_DIR:=$(SRCDIR)/install_dir

#		--build=$(AXIS_HOSTTYPE) \

$(SRCDIR)/Makefile:
	cd $(SRCDIR) && \
	DESTDIR="$(PKG_INSTALL_DIR)" \
	RANLIB="$(RANLIB)" AR="$(AR)" STRIP="$(STRIP)" \
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
	CPPFLAGS="$(CPPFLAGS)" \
	ac_cv_path_PERL=no \
	rd_cv_ieee_works=yes \
	shrext_cmds=".so" \
	./configure --verbose \
		--target=$(AXIS_BUILDTYPE) \
		--host=$(AXIS_BUILDTYPE) \
		--program-prefix="" \
		--program-suffix="" \
		--prefix= \
		--bindir=/bin \
		--libdir=/lib \
		--includedir=/include \
		--oldincludedir=/include \
		--enable-shared=yes \
		--enable-static=yes \
		--disable-rpath \
		--with-gnu-ld

all: build

build: $(SRCDIR)/Makefile
	mkdir -p $(PKG_INSTALL_DIR)
	$(MAKE) -C $(SRCDIR) \
		DESTDIR="$(PKG_INSTALL_DIR)" \
		shrext_cmds=".so" \
		all install
	touch $@

install: all
	$(INSTALL) -d $(prefix)/lib
	$(INSTALL) -d $(prefix)/bin
	$(INSTALL) -d $(prefix)/include
#	$(STRIP) -g $(PKG_INSTALL_DIR)/bin/*
#	$(STRIP) -g $(PKG_INSTALL_DIR)/lib/librrd.so*
	$(INSTALL) $(INSTOWNER) -m 0755 $(PKG_INSTALL_DIR)/bin/* $(prefix)/bin/
	$(INSTALL) $(INSTOWNER) -m 0644 $(PKG_INSTALL_DIR)/include/rrd.h $(prefix)/include/
	$(INSTALL) $(INSTOWNER) -m 0755 $(PKG_INSTALL_DIR)/lib/librrd.so* $(prefix)/lib/

clean:
	$(RM) -r $(SRCDIR)/Makefile
