default: conditional_build 


CURR_DIR := $(shell pwd)
BUILD_DIR:=$(subst /userspace, /userspace,$(CURR_DIR))
BUILD_DIR:=$(word 1, $(BUILD_DIR))
include $(BUILD_DIR)/make.common


ifneq ($(strip $(CONFIG_PACKAGE_ethtool)),)
conditional_build: all
else
conditional_build:
	@echo "skipping $(CURR_DIR)"
endif

PKG_NAME:=ethtool
PKG_VERSION:=3.18
PKG_RELEASE:=1

PKG_MAINTAINER:=Matthias Schiffer <mschiffer@universe-factory.net>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/software/network/ethtool
PKG_MD5SUM:=fbf1a167b88a5966a2c56a2483af68c6

PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=COPYING

PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1

PKG_BUILD_DIR:=$(CURR_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(BUILD_DIR)/dni/make.dni
LDFLAGS += $(FPIE)
CFLAGS += $(FPIE)

define Package/ethtool
  SECTION:=net
  CATEGORY:=Network
  TITLE:=Display or change ethernet card settings
  URL:=http://www.kernel.org/pub/software/network/ethtool/
endef

define Package/ethtool/description
 ethtool is a small utility for examining and tuning your ethernet-based
 network interface
endef

define Build/Prepare
	rm -rf $(PKG_BUILD_DIR)
	mkdir -p $(PKG_BUILD_DIR)
	(tar xvJf $(DL_DIR)/$(PKG_SOURCE) || true)
	$(call Build/Patch/Default)
endef

define Build/Configure
	$(call Build/Configure/Default)
endef

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
endef

define Package/install
	$(INSTALL_BDIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ethtool $(1)/usr/sbin
endef

prepare:
	$(call Build/Prepare)

compile:
	$(call Build/Configure)
	$(call Build/Compile)
	$(call Build/InstallDev,$(BCM_FSBUILD_DIR))
	$(call Package/install,$(INSTALL_DIR))

all:
ifneq ($(HAVEBUILT),built)
	$(call Build/Prepare)
	$(call Build/Configure)
	$(call Build/Compile)
	$(call Build/InstallDev,$(BCM_FSBUILD_DIR))
	$(call Package/install,$(INSTALL_DIR))
	@touch $(STAMP_BUILT)
endif


clean:
	rm -rf $(PKG_BUILD_DIR)


shell:
	bash -i
