blob: 9eb721f2aa36103ee2616d65190bc10e01cac3cb [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#
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
8include $(TOPDIR)/rules.mk
9
10PKG_NAME:=ucode
11PKG_RELEASE:=1
12
13PKG_SOURCE_PROTO:=git
14PKG_SOURCE_URL=https://github.com/jow-/ucode.git
15PKG_SOURCE_DATE:=2025-02-10
16PKG_SOURCE_VERSION:=a8a11aea0c093d669bb3c45f604dab3c291c8d25
17PKG_MIRROR_HASH:=4de0094bc641fc13ff13516ca80d8265bf6eed6d9a9b90fdf84b7a558d505acc
18PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
19PKG_LICENSE:=ISC
20
21PKG_ABI_VERSION:=20230711
22PKG_BUILD_DEPENDS:=libmd
23HOST_BUILD_DEPENDS:=libjson-c/host
24
25include $(INCLUDE_DIR)/package.mk
26include $(INCLUDE_DIR)/host-build.mk
27include $(INCLUDE_DIR)/cmake.mk
28
29CMAKE_OPTIONS += \
30 -DSOVERSION=$(PKG_ABI_VERSION)
31
32CMAKE_HOST_OPTIONS += \
33 -DCMAKE_SKIP_RPATH=FALSE \
34 -DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOSTPKG}/lib"
35
36ifeq ($(HOST_OS),Darwin)
37 CMAKE_HOST_OPTIONS += \
38 -DCMAKE_MACOSX_RPATH=1
39else
40 CMAKE_HOST_OPTIONS += \
41 -DUSE_RPATH="${STAGING_DIR_HOSTPKG}/lib"
42endif
43
44CMAKE_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
59define Package/ucode/default
60 SUBMENU:=ucode
61 SECTION:=lang
62 CATEGORY:=Languages
63 TITLE:=Tiny scripting and templating language
64endef
65
66define Package/ucode
67 $(Package/ucode/default)
68 DEPENDS:=+libucode
69endef
70
71define Package/ucode/description
72 ucode is a tiny script interpreter featuring an ECMAScript oriented
73 script language and Jinja-inspired templating.
74endef
75
76
77define 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
85endef
86
87define Package/libucode/description
88 The libucode package provides the shared runtime library for the ucode interpreter.
89endef
90
91# 1: name
92# 2: cmake symbol
93# 3: depends
94# 4: description
95define 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
114endef
115
116
117define 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/
121endef
122
123
124define Package/ucode/install
125 $(INSTALL_DIR) $(1)/usr/bin
126 $(CP) $(PKG_INSTALL_DIR)/usr/bin/u* $(1)/usr/bin/
127endef
128
129define Package/libucode/install
130 $(INSTALL_DIR) $(1)/usr/lib
131 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so.* $(1)/usr/lib/
132endef
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))