#############################################################
#
#  ATM - User Space Program For Controlling ATM modules
#
#############################################################
#
ATM_VERSION=2.4.1
ATM_SOURCE_URL= http://keihanna.dl.sourceforge.net/sourceforge/sysutil-atm/
ATM_SOURCE=sysutil-atm-$(ATM_VERSION).tar.gz
ATM_BUILD_DIR=$(BASE_DIR)/../fusiv_src/user/sysutil-atm
#ATM_BUILD_DIR=.
#ATM_TARGET_BINARY:=usr/sbin/atmarpd
#ATM_TARGET_BINARY:=usr/sbin/
ATM_TARGET_BINARY_ATMARPD:=bin/
LN=ln

$(ATM_BUILD_DIR)/.configured:
	(cd $(ATM_BUILD_DIR); rm -rf config.cache .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  $(ATM_BUILD_DIR)/.configured

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

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

sysutil-atm: $(TARGET_DIR)/$(ATM_TARGET_BINARY)

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

sysutil-atm-clean:
	#$(MAKE) DESTDIR=$(TARGET_DIR) CC=$(TARGET_CC) -C $(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+=sysutil-atm
endif
