Makefile 5.3 KB

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