#############################################################
#
#  ATM - User Space Program For Controlling ATM modules
#
#############################################################
#
SYSUTIL_ATM_VERSION=2.4.1
SYSUTIL_ATM_SOURCE_URL= http://keihanna.dl.sourceforge.net/sourceforge/sysutil-atm/
SYSUTIL_ATM_SOURCE=sysutil-atm-$(ATM_VERSION).tar.gz
SYSUTIL_ATM_BUILD_DIR=$(BASE_DIR)/../fusiv_src/user/atm-linux-2.4.1
SYSUTIL_ATM_TARGET_BINARY_ATMARPD:=bin

$(DL_DIR)/$(SYSUTIL_ATM_SOURCE):
	$(WGET) -P $(DL_DIR) $(SYSUTIL_ATM_SOURCE_URL)/$(SYSUTIL_ATM_SOURCE)

$(SYSUTIL_ATM_BUILD_DIR)/.configured:
	(cd $(SYSUTIL_ATM_BUILD_DIR); rm -rf config.cache .configure; \
		cp -pf  configure.script configure; chmod 777 configure; \
		$(TARGET_CONFIGURE_OPTS) \
		CFLAGS="$(TARGET_CFLAGS)" \
		./configure \
		--target=$(GNU_TARGET_NAME) \
		--host=$(GNU_TARGET_NAME) \
		--build=$(GNU_HOST_NAME) \
		--prefix=/usr \
		--exec-prefix=/usr \
		--bindir=/usr/bin \
		--sbindir=/usr/sbin \
		--libexecdir=/usr/lib \
		--sysconfdir=/etc \
		--datadir=/usr/share \
		--localstatedir=/var \
		--mandir=/usr/man \
		--infodir=/usr/info \
		$(DISABLE_NLS) \
		--with-linux-headers=$(LINUX_HEADERS_DIR) \
	);
	touch  $(SYSUTIL_ATM_BUILD_DIR)/.configured

$(SYSUTIL_ATM_BUILD_DIR)/src/arpd/atmarpd: $(SYSUTIL_ATM_BUILD_DIR)/.configured
	$(MAKE) -C $(SYSUTIL_ATM_BUILD_DIR)

$(TARGET_DIR)/$(SYSUTIL_ATM_TARGET_BINARY_ATMARPD): $(SYSUTIL_ATM_BUILD_DIR)/src/arpd/atmarpd
	cp -af $(SYSUTIL_ATM_BUILD_DIR)/src/arpd/.libs/atmarpd $(TARGET_DIR)/$(SYSUTIL_ATM_TARGET_BINARY_ATMARPD)
	cp -af $(SYSUTIL_ATM_BUILD_DIR)/src/arpd/.libs/atmarp $(TARGET_DIR)/$(SYSUTIL_ATM_TARGET_BINARY_ATMARPD)
	cp -af $(SYSUTIL_ATM_BUILD_DIR)/src/lib/.libs/libatm.1.0.0  $(SYSUTIL_ATM_BUILD_DIR)/src/lib/.libs/libatm.so.1.0.0
	cp -af $(SYSUTIL_ATM_BUILD_DIR)/src/lib/.libs/libatm.so.1.0.0 $(TARGET_DIR)/lib
	cp -af $(SYSUTIL_ATM_BUILD_DIR)/src/lib/.libs/libatm.so.1.0.0 $(TARGET_DIR)/lib/libatm.so.1
	#$(STRIP) $(TARGET_DIR)/$(SYSUTIL_ATM_TARGET_BINARY_ATMARPD)
	$(STRIP) $(TARGET_DIR)/bin/atmarpd
	$(STRIP) $(TARGET_DIR)/bin/atmarp
#	$(STRIP) $(TARGET_DIR)/$(SYSUTIL_ATM_TARGET_BINARY_ATMARPD)
	#$(STRIP) $(TARGET_DIR)/usr/sbin/brctld

atm-linux-2.4.1: $(TARGET_DIR)/$(SYSUTIL_ATM_TARGET_BINARY_ATMARPD)

sysutil-atm-source: $(DL_DIR)/$(SYSUTIL_ATM_SOURCE)

sysutil-atm-clean:
	#$(MAKE) DESTDIR=$(TARGET_DIR) CC=$(TARGET_CC) -C $(SYSUTIL_ATM_BUILD_DIR) uninstall
	-$(MAKE) -C $(ATM_BUILD_DIR) clean

sysutil-atm-dirclean:
	rm -rf $(ATM_BUILD_DIR)
#############################################################
#
# Toplevel Makefile options
#
#############################################################
ifeq ($(strip $(CONFIG_FUSIV_USER_LINUXATM2_4_1)),y)
TARGETS+=atm-linux-2.4.1
endif
