b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2020-2021 Jo-Philipp Wich <jo@mein.io> |
| 3 | # |
| 4 | # This is free software, licensed under the GNU General Public License v2. |
| 5 | # See /LICENSE for more information. |
| 6 | # |
| 7 | |
| 8 | include $(TOPDIR)/rules.mk |
| 9 | |
| 10 | PKG_NAME:=ucode |
| 11 | PKG_RELEASE:=1 |
| 12 | |
| 13 | PKG_SOURCE_PROTO:=git |
| 14 | PKG_SOURCE_URL=https://github.com/jow-/ucode.git |
| 15 | PKG_SOURCE_DATE:=2025-02-10 |
| 16 | PKG_SOURCE_VERSION:=a8a11aea0c093d669bb3c45f604dab3c291c8d25 |
| 17 | PKG_MIRROR_HASH:=4de0094bc641fc13ff13516ca80d8265bf6eed6d9a9b90fdf84b7a558d505acc |
| 18 | PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> |
| 19 | PKG_LICENSE:=ISC |
| 20 | |
| 21 | PKG_ABI_VERSION:=20230711 |
| 22 | PKG_BUILD_DEPENDS:=libmd |
| 23 | HOST_BUILD_DEPENDS:=libjson-c/host |
| 24 | |
| 25 | include $(INCLUDE_DIR)/package.mk |
| 26 | include $(INCLUDE_DIR)/host-build.mk |
| 27 | include $(INCLUDE_DIR)/cmake.mk |
| 28 | |
| 29 | CMAKE_OPTIONS += \ |
| 30 | -DSOVERSION=$(PKG_ABI_VERSION) |
| 31 | |
| 32 | CMAKE_HOST_OPTIONS += \ |
| 33 | -DCMAKE_SKIP_RPATH=FALSE \ |
| 34 | -DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOSTPKG}/lib" |
| 35 | |
| 36 | ifeq ($(HOST_OS),Darwin) |
| 37 | CMAKE_HOST_OPTIONS += \ |
| 38 | -DCMAKE_MACOSX_RPATH=1 |
| 39 | else |
| 40 | CMAKE_HOST_OPTIONS += \ |
| 41 | -DUSE_RPATH="${STAGING_DIR_HOSTPKG}/lib" |
| 42 | endif |
| 43 | |
| 44 | CMAKE_HOST_OPTIONS += \ |
| 45 | -DFS_SUPPORT=ON \ |
| 46 | -DMATH_SUPPORT=ON \ |
| 47 | -DNL80211_SUPPORT=OFF \ |
| 48 | -DRESOLV_SUPPORT=OFF \ |
| 49 | -DRTNL_SUPPORT=OFF \ |
| 50 | -DSTRUCT_SUPPORT=ON \ |
| 51 | -DUBUS_SUPPORT=OFF \ |
| 52 | -DUCI_SUPPORT=OFF \ |
| 53 | -DULOOP_SUPPORT=OFF \ |
| 54 | -DDEBUG_SUPPORT=ON \ |
| 55 | -DLOG_SUPPORT=OFF \ |
| 56 | -DDIGEST_SUPPORT=OFF |
| 57 | |
| 58 | |
| 59 | define Package/ucode/default |
| 60 | SUBMENU:=ucode |
| 61 | SECTION:=lang |
| 62 | CATEGORY:=Languages |
| 63 | TITLE:=Tiny scripting and templating language |
| 64 | endef |
| 65 | |
| 66 | define Package/ucode |
| 67 | $(Package/ucode/default) |
| 68 | DEPENDS:=+libucode |
| 69 | endef |
| 70 | |
| 71 | define Package/ucode/description |
| 72 | ucode is a tiny script interpreter featuring an ECMAScript oriented |
| 73 | script language and Jinja-inspired templating. |
| 74 | endef |
| 75 | |
| 76 | |
| 77 | define Package/libucode |
| 78 | $(Package/ucode/default) |
| 79 | SUBMENU:= |
| 80 | SECTION:=libs |
| 81 | CATEGORY:=Libraries |
| 82 | TITLE+= (library) |
| 83 | ABI_VERSION:=$(PKG_ABI_VERSION) |
| 84 | DEPENDS:=+libjson-c |
| 85 | endef |
| 86 | |
| 87 | define Package/libucode/description |
| 88 | The libucode package provides the shared runtime library for the ucode interpreter. |
| 89 | endef |
| 90 | |
| 91 | # 1: name |
| 92 | # 2: cmake symbol |
| 93 | # 3: depends |
| 94 | # 4: description |
| 95 | define UcodeModule |
| 96 | UCODE_MODULES += ucode-mod-$(strip $(1)) |
| 97 | CMAKE_OPTIONS += -D$(strip $(2))=$(if $(CONFIG_PACKAGE_ucode-mod-$(strip $(1))),ON,OFF) |
| 98 | PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_ucode-mod-$(strip $(1)) |
| 99 | |
| 100 | define Package/ucode-mod-$(strip $(1)) |
| 101 | $(Package/ucode/default) |
| 102 | TITLE+= ($(strip $(1)) module) |
| 103 | DEPENDS:=+ucode $(3) |
| 104 | endef |
| 105 | |
| 106 | define Package/ucode-mod-$(strip $(1))/description |
| 107 | $(strip $(4)) |
| 108 | endef |
| 109 | |
| 110 | define Package/ucode-mod-$(strip $(1))/install |
| 111 | $(INSTALL_DIR) $$(1)/usr/lib/ucode |
| 112 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/$(strip $(1)).so $$(1)/usr/lib/ucode/ |
| 113 | endef |
| 114 | endef |
| 115 | |
| 116 | |
| 117 | define Build/InstallDev |
| 118 | $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include/ucode |
| 119 | $(CP) $(PKG_INSTALL_DIR)/usr/include/ucode/*.h $(1)/usr/include/ucode/ |
| 120 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so* $(1)/usr/lib/ |
| 121 | endef |
| 122 | |
| 123 | |
| 124 | define Package/ucode/install |
| 125 | $(INSTALL_DIR) $(1)/usr/bin |
| 126 | $(CP) $(PKG_INSTALL_DIR)/usr/bin/u* $(1)/usr/bin/ |
| 127 | endef |
| 128 | |
| 129 | define Package/libucode/install |
| 130 | $(INSTALL_DIR) $(1)/usr/lib |
| 131 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so.* $(1)/usr/lib/ |
| 132 | endef |
| 133 | |
| 134 | |
| 135 | $(eval $(call UcodeModule, \ |
| 136 | debug, DEBUG_SUPPORT, +libubox +libucode, \ |
| 137 | The debug plugin module provides runtime debugging and introspection facilities.)) |
| 138 | |
| 139 | $(eval $(call UcodeModule, \ |
| 140 | fs, FS_SUPPORT, , \ |
| 141 | The filesystem plugin module allows interaction with the local file system.)) |
| 142 | |
| 143 | $(eval $(call UcodeModule, \ |
| 144 | log, LOG_SUPPORT, +libubox, \ |
| 145 | The log plugin module provides access to the syslog and libubox ulog APIs.)) |
| 146 | |
| 147 | $(eval $(call UcodeModule, \ |
| 148 | math, MATH_SUPPORT, , \ |
| 149 | The math plugin provides access to various <math.h> procedures.)) |
| 150 | |
| 151 | $(eval $(call UcodeModule, \ |
| 152 | nl80211, NL80211_SUPPORT, +libnl-tiny +libubox, \ |
| 153 | The nl80211 plugin provides access to the Linux wireless 802.11 netlink API.)) |
| 154 | |
| 155 | $(eval $(call UcodeModule, \ |
| 156 | resolv, RESOLV_SUPPORT, , \ |
| 157 | The resolv plugin implements simple DNS resolving.)) |
| 158 | |
| 159 | $(eval $(call UcodeModule, \ |
| 160 | rtnl, RTNL_SUPPORT, +libnl-tiny +libubox, \ |
| 161 | The rtnl plugin provides access to the Linux routing netlink API.)) |
| 162 | |
| 163 | $(eval $(call UcodeModule, \ |
| 164 | socket, SOCKET_SUPPORT, , \ |
| 165 | The socket plugin provides access to IPv4, IPv6, Unix and packet socket APIs.)) |
| 166 | |
| 167 | $(eval $(call UcodeModule, \ |
| 168 | struct, STRUCT_SUPPORT, , \ |
| 169 | The struct plugin implements Python 3 compatible struct.pack/unpack functionality.)) |
| 170 | |
| 171 | $(eval $(call UcodeModule, \ |
| 172 | ubus, UBUS_SUPPORT, +libubus +libblobmsg-json, \ |
| 173 | The ubus module allows ucode template scripts to enumerate and invoke ubus procedures.)) |
| 174 | |
| 175 | $(eval $(call UcodeModule, \ |
| 176 | uci, UCI_SUPPORT, +libuci, \ |
| 177 | The uci module allows templates to read and modify uci configuration.)) |
| 178 | |
| 179 | $(eval $(call UcodeModule, \ |
| 180 | uloop, ULOOP_SUPPORT, +libubox, \ |
| 181 | The uloop module allows ucode scripts to interact with OpenWrt uloop event loop implementation.)) |
| 182 | |
| 183 | $(eval $(call UcodeModule, \ |
| 184 | digest, DIGEST_SUPPORT, , \ |
| 185 | The digest module allows ucode scripts to use libmd digests.)) |
| 186 | |
| 187 | $(eval $(call BuildPackage,libucode)) |
| 188 | $(eval $(call BuildPackage,ucode)) |
| 189 | |
| 190 | $(foreach mod,$(UCODE_MODULES), \ |
| 191 | $(eval $(call BuildPackage,$(mod)))) |
| 192 | |
| 193 | $(eval $(call HostBuild)) |