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_dni_ntpclient)),)
conditional_build: all
else
conditional_build:
	@echo "skipping $(CURR_DIR)"
endif


PKG_NAME:=ntpclient
PKG_RELEASE:=4
PKG_BUILD_DEPENDS:=datalib
PKG_BUILD_DIR := $(CURR_DIR)/$(PKG_NAME)

PKG_GIT_TREEISH=e1fcddfd4179947f230478e29e77526d44f2976c

include $(BUILD_DIR)/dni/make.dni

PKG_FIXUP:=autoreconf
PKG_INSTALL:=1

define Package/dni-ntpclient
  SECTION:=dni
  CATEGORY:=DNI Packages
  DEPENDS:= +datalib
  TITLE:=The CGI interface
endef

define Package/dni-ntpclient/description
	The CGI interface
endef

define Build/Prepare
endef

CONFIGURE_ARGS += --prefix="$(PKG_INSTALL_DIR)"
TARGET_CFLAGS += -Wall -Werror -Wunused -Wextra -Wundef -g -O2 -fPIC -fpie -pie -Wno-format-truncation
define Build/Configure
	$(call autoreconf_target)
	$(call Build/Configure/Default)
endef

LDFLAGS += -I$(BCM_FSBUILD_DIR)/private/include -L$(BCM_FSBUILD_DIR)/lib -L$(BCM_FSBUILD_DIR)/private/lib
define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR)/src CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(LDFLAGS)" $(TARGET_CONFIGURE_OPTS) all install PREFIX="$(PKG_INSTALL_DIR)"
endef

define Package/install
	install -d -m0755 $(1)/usr/sbin
	install -m0755 $(PKG_BUILD_DIR)/src/ntpclient $(1)/usr/sbin/
	install -m0755 $(PKG_BUILD_DIR)/files/ntp_updated.sh $(1)/usr/sbin/ntp_updated
	install -d -m0755 $(1)/etc/init.d
	install -m0755 $(PKG_BUILD_DIR)/files/ntpclient.init $(1)/etc/init.d/ntpclient
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

