# Copyright 2019 University of Warsaw

include $(TOPDIR)/rules.mk

PKG_NAME:=config-uart
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=License

include $(INCLUDE_DIR)/package.mk

define Package/config-uart
	SECTION:=heni
	CATEGORY:=HENI
	TITLE:=UART config
endef

define Package/config-uart/description
  Configure uarts
endef

define Build/Compile
endef

define Package/config-uart/install
	$(INSTALL_DIR) $(1)/etc
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_DIR) $(1)/usr
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) ./files/etc/init.d/config-uart $(1)/etc/init.d/config-uart
	$(INSTALL_BIN) ./files/usr/bin/config-uart $(1)/usr/bin/config-uart
	$(INSTALL_DATA) ./files/etc/inittab $(1)/etc/inittab
endef

define Package/config-uart/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
        echo "Enabling rc.d symlink for config-uart"
        /etc/init.d/config-uart enable
fi
exit 0
endef

define Package/config-uart/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
        echo "Removing rc.d symlink for config-uart"
        /etc/init.d/config-uart disable
fi
exit 0
endef

$(eval $(call BuildPackage,config-uart))
