aboutsummaryrefslogtreecommitdiffstats
path: root/package/utils/ucode/Makefile
blob: 46112d31e88401ec5bcecb8133bbbb0201477f91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#
# Copyright (C) 2020-2021 Jo-Philipp Wich <jo@mein.io>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=ucode
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/jow-/ucode.git
PKG_SOURCE_DATE:=2023-10-19
PKG_SOURCE_VERSION:=07c03173d4e6a30953f92fa88ed29b0b956c9106
PKG_MIRROR_HASH:=fd770335f442ebfc0f4e28d94bb60d886c43aa239ab88e965be7c490b3283a82
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
  SUBMENU:=ucode
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=Tiny scripting and templating language
endef

define Package/ucode
  $(Package/ucode/default)
  DEPENDS:=+libucode
endef

define Package/ucode/description
 ucode is a tiny script interpreter featuring an ECMAScript oriented
 script language and Jinja-inspired templating.
endef


define Package/libucode
  $(Package/ucode/default)
  SUBMENU:=
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE+= (library)
  ABI_VERSION:=$(PKG_ABI_VERSION)
  DEPENDS:=+libjson-c
endef

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-$(strip $(1))
  $(Package/ucode/default)
  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 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/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(CP) $(PKG_INSTALL_DIR)/usr/bin/u* $(1)/usr/bin/
endef

define Package/libucode/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so.* $(1)/usr/lib/
endef


$(eval $(call UcodeModule, \
	debug, DEBUG_SUPPORT, +libubox +libucode, \
	The debug plugin module provides runtime debugging and introspection facilities.))

$(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.))

$(eval $(call UcodeModule, \
	math, MATH_SUPPORT, , \
	The math plugin provides access to various <math.h> procedures.))

$(eval $(call UcodeModule, \
	nl80211, NL80211_SUPPORT, +libnl-tiny +libubox, \
	The nl80211 plugin provides access to the Linux wireless 802.11 netlink API.))

$(eval $(call UcodeModule, \
	resolv, RESOLV_SUPPORT, , \
	The resolv plugin implements simple DNS resolving.))

$(eval $(call UcodeModule, \
	rtnl, RTNL_SUPPORT, +libnl-tiny +libubox, \
	The rtnl plugin provides access to the Linux routing netlink API.))

$(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))

$(foreach mod,$(UCODE_MODULES), \
	$(eval $(call BuildPackage,$(mod))))

$(eval $(call HostBuild))