ucode: update to Git HEAD (2023-11-30)
[openwrt/staging/hauke.git] / package / utils / ucode / Makefile
index 8ecfef01c5dba02aa141fe4db07fd08d31c735d1..670b9343760e90a53da1c91c16a6131c5d20127b 100644 (file)
@@ -12,24 +12,54 @@ PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=https://github.com/jow-/ucode.git
-PKG_SOURCE_DATE:=2021-03-29
-PKG_SOURCE_VERSION:=aa9621db401e881ffcdea03be272c94149484ccf
-PKG_MIRROR_HASH:=11b7de10e6ab91742d8a633a0030dde86118ffe73031cdf9c192cb3fded97a20
+PKG_SOURCE_DATE:=2023-11-30
+PKG_SOURCE_VERSION:=6e89b89e95bbb140bbff5ab72b8c9632727bf6a6
+PKG_MIRROR_HASH:=20ba99f8c2591b581cdf0245dd40301e517659193cddaa3a3888125fcc85b2aa
 PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
 PKG_LICENSE:=ISC
 
+PKG_ABI_VERSION:=20230711
+
 include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/cmake.mk
 
+CMAKE_OPTIONS += -DSOVERSION=$(PKG_ABI_VERSION)
+
+ifeq ($(HOST_OS),Darwin)
+  CMAKE_HOST_OPTIONS += \
+       -DCMAKE_SKIP_RPATH=FALSE \
+       -DCMAKE_MACOSX_RPATH=1 \
+       -DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOSTPKG}/lib"
+else
+  CMAKE_HOST_OPTIONS += \
+       -DSOVERSION=$(PKG_ABI_VERSION)
+endif
+
+CMAKE_HOST_OPTIONS += \
+       -DFS_SUPPORT=ON \
+       -DMATH_SUPPORT=ON \
+       -DNL80211_SUPPORT=OFF \
+       -DRESOLV_SUPPORT=OFF \
+       -DRTNL_SUPPORT=OFF \
+       -DSTRUCT_SUPPORT=ON \
+       -DUBUS_SUPPORT=OFF \
+       -DUCI_SUPPORT=OFF \
+       -DULOOP_SUPPORT=OFF \
+       -DDEBUG_SUPPORT=ON \
+       -DLOG_SUPPORT=OFF
+
+
 define Package/ucode/default
-  SECTION:=utils
-  CATEGORY:=Utilities
-  TITLE:=ucode - Tiny scripting and templating language
+  SUBMENU:=ucode
+  SECTION:=lang
+  CATEGORY:=Languages
+  TITLE:=Tiny scripting and templating language
 endef
 
 define Package/ucode
   $(Package/ucode/default)
-  DEPENDS:=+libjson-c
+  DEPENDS:=+libucode
 endef
 
 define Package/ucode/description
@@ -38,79 +68,112 @@ define Package/ucode/description
 endef
 
 
-define Package/ucode-mod-fs
+define Package/libucode
   $(Package/ucode/default)
-  TITLE+= (filesystem module)
-  DEPENDS:=ucode
+  SUBMENU:=
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE+= (library)
+  ABI_VERSION:=$(PKG_ABI_VERSION)
+  DEPENDS:=+libjson-c
 endef
 
-define Package/ucode-mod-fs/description
- The filesystem plugin module allows interaction with the local file system.
+define Package/libucode/description
+ The libucode package provides the shared runtime library for the ucode interpreter.
 endef
 
+# 1: name
+# 2: cmake symbol
+# 3: depends
+# 4: description
+define UcodeModule
+  UCODE_MODULES += ucode-mod-$(strip $(1))
+  CMAKE_OPTIONS += -D$(strip $(2))=$(if $(CONFIG_PACKAGE_ucode-mod-$(strip $(1))),ON,OFF)
+  PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_ucode-mod-$(strip $(1))
 
-define Package/ucode-mod-math
+ define Package/ucode-mod-$(strip $(1))
   $(Package/ucode/default)
-  TITLE+= (math module)
-  DEPENDS:=ucode
+  TITLE+= ($(strip $(1)) module)
+  DEPENDS:=ucode $(3)
+ endef
+
+ define Package/ucode-mod-$(strip $(1))/description
+ $(strip $(4))
+ endef
+
+ define Package/ucode-mod-$(strip $(1))/install
+       $(INSTALL_DIR) $$(1)/usr/lib/ucode
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/$(strip $(1)).so $$(1)/usr/lib/ucode/
+ endef
 endef
 
-define Package/ucode-mod-math/description
- The math plugin provides access to various <math.h> procedures.
+
+define Build/InstallDev
+       $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include/ucode
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/ucode/*.h $(1)/usr/include/ucode/
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so* $(1)/usr/lib/
 endef
 
 
-define Package/ucode-mod-ubus
-  $(Package/ucode/default)
-  TITLE+= (ubus module)
-  DEPENDS:=ucode +libubus +libblobmsg-json
+define Package/ucode/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(CP) $(PKG_INSTALL_DIR)/usr/bin/u* $(1)/usr/bin/
 endef
 
-define Package/ucode-mod-ubus/description
- The ubus module allows ucode template scripts to enumerate and invoke ubus
- procedures.
+define Package/libucode/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so.* $(1)/usr/lib/
 endef
 
 
-define Package/ucode-mod-uci
-  $(Package/ucode/default)
-  TITLE+= (uci module)
-  DEPENDS:=ucode +libuci
-endef
+$(eval $(call UcodeModule, \
+       debug, DEBUG_SUPPORT, +libubox +libucode, \
+       The debug plugin module provides runtime debugging and introspection facilities.))
 
-define Package/ucode-mod-uci/description
- The uci module allows templates to read and modify uci configuration.
-endef
+$(eval $(call UcodeModule, \
+       fs, FS_SUPPORT, , \
+       The filesystem plugin module allows interaction with the local file system.))
 
+$(eval $(call UcodeModule, \
+       log, LOG_SUPPORT, +libubox, \
+       The log plugin module provides access to the syslog and libubox ulog APIs.))
 
-define Package/ucode/install
-       $(INSTALL_DIR) $(1)/usr/bin
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ucode $(1)/usr/bin/ucode
-endef
+$(eval $(call UcodeModule, \
+       math, MATH_SUPPORT, , \
+       The math plugin provides access to various <math.h> procedures.))
 
-define Package/ucode-mod-fs/install
-       $(INSTALL_DIR) $(1)/usr/lib/ucode
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/fs.so $(1)/usr/lib/ucode/
-endef
+$(eval $(call UcodeModule, \
+       nl80211, NL80211_SUPPORT, +libnl-tiny +libubox, \
+       The nl80211 plugin provides access to the Linux wireless 802.11 netlink API.))
 
-define Package/ucode-mod-math/install
-       $(INSTALL_DIR) $(1)/usr/lib/ucode
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/math.so $(1)/usr/lib/ucode/
-endef
+$(eval $(call UcodeModule, \
+       resolv, RESOLV_SUPPORT, , \
+       The resolv plugin implements simple DNS resolving.))
 
-define Package/ucode-mod-ubus/install
-       $(INSTALL_DIR) $(1)/usr/lib/ucode
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/ubus.so $(1)/usr/lib/ucode/
-endef
+$(eval $(call UcodeModule, \
+       rtnl, RTNL_SUPPORT, +libnl-tiny +libubox, \
+       The rtnl plugin provides access to the Linux routing netlink API.))
 
-define Package/ucode-mod-uci/install
-       $(INSTALL_DIR) $(1)/usr/lib/ucode
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/uci.so $(1)/usr/lib/ucode/
-endef
+$(eval $(call UcodeModule, \
+       struct, STRUCT_SUPPORT, , \
+       The struct plugin implements Python 3 compatible struct.pack/unpack functionality.))
+
+$(eval $(call UcodeModule, \
+       ubus, UBUS_SUPPORT, +libubus +libblobmsg-json, \
+       The ubus module allows ucode template scripts to enumerate and invoke ubus procedures.))
 
+$(eval $(call UcodeModule, \
+       uci, UCI_SUPPORT, +libuci, \
+       The uci module allows templates to read and modify uci configuration.))
 
+$(eval $(call UcodeModule, \
+       uloop, ULOOP_SUPPORT, +libubox, \
+       The uloop module allows ucode scripts to interact with OpenWrt uloop event loop implementation.))
+
+$(eval $(call BuildPackage,libucode))
 $(eval $(call BuildPackage,ucode))
-$(eval $(call BuildPackage,ucode-mod-fs))
-$(eval $(call BuildPackage,ucode-mod-math))
-$(eval $(call BuildPackage,ucode-mod-ubus))
-$(eval $(call BuildPackage,ucode-mod-uci))
+
+$(foreach mod,$(UCODE_MODULES), \
+       $(eval $(call BuildPackage,$(mod))))
+
+$(eval $(call HostBuild))