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