#
# Copyright (C) 2006-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

VERSION_YEAR=$(shell date +%Y)
VERSION_MAJOR=$(shell expr $(VERSION_YEAR) - 2018)
VERSION_MINOR=$(shell date +%V%u)
#VERSION_REVISION=$(shell date +%H%M)
VERSION_REVISION=0000
PKG_VERSION:=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)

PKG_NAME:=libdyutils

PKG_LICENSE:=LGPL-2.1
PKG_MAINTAINER:=Xianpeng Zhao

ifneq ($(CONFIG_SUPPORT_LED),)
  PKG_MFLAGS+= SUPPORT_LED=1
endif

include $(INCLUDE_DIR)/package.mk

define Package/libdyutils/config
  source "$(SOURCE)/Config.in"
endef

define Package/libdyutils
  SECTION:=DYIOT
  CATEGORY:=DYIOT Software
  TITLE:=dayun iot utils library
  DEPENDS:=+libmosquitto-ssl +libopenssl +libsqlite3 +libipc_session +libubox +ubuslog
endef

define Package/libdyutils/description
 This package contains the util lib for dayun iot gateway
endef

TARGET_CFLAGS += $(FPIC)

define Build/Compile
	CC="$(TARGET_CC)" \
	CFLAGS="$(TARGET_CFLAGS)" \
	LDFLAGS="$(TARGET_LDFLAGS)" \
	$(MAKE) $(PKG_MFLAGS) -C $(PKG_BUILD_DIR) \
		$(TARGET_CONFIGURE_OPTS) \
		all
endef

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/lib
	$(INSTALL_DIR) $(1)/usr/include/dy_utils
	$(CP) $(PKG_BUILD_DIR)/include/* $(1)/usr/include/dy_utils/
	$(CP) $(PKG_BUILD_DIR)/libdyutils.so $(1)/usr/lib/
endef

define Package/libdyutils/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_BUILD_DIR)/libdyutils.so $(1)/usr/lib/
endef

$(eval $(call BuildPackage,libdyutils))
