include $(TOPDIR)/rules.mk

PKG_NAME:=uniberg-ub-edge-api
PKG_VERSION:=$(shell git show -s --format=%cd --date=short)
PKG_RELEASE:=1

PKG_MAINTAINER:=Arthur Koch <arthur.koch@uniberg.com>

PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16

GO_PKG:=edge-api

include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	cp -R $(CURDIR)/../../* $(PKG_BUILD_DIR)/
endef

define Package/uniberg-ub-edge-api
  SECTION:=net
  CATEGORY:=Network
  TITLE:=uniberg-ub-edge-api
  DEPENDS:=$(GO_ARCH_DEPENDS)
endef

define Package/uniberg-ub-edge-api/install
	$(call GoPackage/Package/Install/Bin,$(1))
	$(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/uci-defaults $(1)/lib/upgrade/keep.d
	$(INSTALL_BIN) ./files/90-edge-api.sh $(1)/etc/uci-defaults/90-edge-api
	$(INSTALL_BIN) ./files/uniberg-ub-edge-api.init $(1)/etc/init.d/uniberg-ub-edge-api
	$(CP) ./files/keep-files $(1)/lib/upgrade/keep.d/uniberg-ub-edge-api
endef

$(eval $(call GoBinPackage,uniberg-ub-edge-api))
$(eval $(call BuildPackage,uniberg-ub-edge-api))
