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