Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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:=2025-07-18
  13. PKG_SOURCE_VERSION:=3f64c8089bf3ea4847c96b91df09fbfcaec19e1d
  14. PKG_MIRROR_HASH:=55fbff7c527e1fadbda2e038636f39419649841ee63a5f3cdb50b9714b13420c
  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. -DDIGEST_SUPPORT=OFF
  48. define Package/ucode/default
  49. SUBMENU:=ucode
  50. SECTION:=lang
  51. CATEGORY:=Languages
  52. TITLE:=Tiny scripting and templating language
  53. endef
  54. define Package/ucode
  55. $(Package/ucode/default)
  56. DEPENDS:=+libucode
  57. endef
  58. define Package/ucode/description
  59. ucode is a tiny script interpreter featuring an ECMAScript oriented
  60. script language and Jinja-inspired templating.
  61. endef
  62. define Package/libucode
  63. $(Package/ucode/default)
  64. SUBMENU:=
  65. SECTION:=libs
  66. CATEGORY:=Libraries
  67. TITLE+= (library)
  68. ABI_VERSION:=$(PKG_ABI_VERSION)
  69. DEPENDS:=+libjson-c
  70. endef
  71. define Package/libucode/description
  72. The libucode package provides the shared runtime library for the ucode interpreter.
  73. endef
  74. # 1: name
  75. # 2: cmake symbol
  76. # 3: depends
  77. # 4: description
  78. define UcodeModule
  79. UCODE_MODULES += ucode-mod-$(strip $(1))
  80. CMAKE_OPTIONS += -D$(strip $(2))=$(if $(CONFIG_PACKAGE_ucode-mod-$(strip $(1))),ON,OFF)
  81. PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_ucode-mod-$(strip $(1))
  82. define Package/ucode-mod-$(strip $(1))
  83. $(Package/ucode/default)
  84. TITLE+= ($(strip $(1)) module)
  85. DEPENDS:=+ucode $(3)
  86. endef
  87. define Package/ucode-mod-$(strip $(1))/description
  88. $(strip $(4))
  89. endef
  90. define Package/ucode-mod-$(strip $(1))/install
  91. $(INSTALL_DIR) $$(1)/usr/lib/ucode
  92. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/$(strip $(1)).so $$(1)/usr/lib/ucode/
  93. endef
  94. endef
  95. define Build/InstallDev
  96. $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include/ucode
  97. $(CP) $(PKG_INSTALL_DIR)/usr/include/ucode/*.h $(1)/usr/include/ucode/
  98. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so* $(1)/usr/lib/
  99. endef
  100. define Package/ucode/install
  101. $(INSTALL_DIR) $(1)/usr/bin
  102. $(CP) $(PKG_INSTALL_DIR)/usr/bin/u* $(1)/usr/bin/
  103. endef
  104. define Package/libucode/install
  105. $(INSTALL_DIR) $(1)/usr/lib
  106. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so.* $(1)/usr/lib/
  107. endef
  108. $(eval $(call UcodeModule, \
  109. debug, DEBUG_SUPPORT, +libubox +libucode, \
  110. The debug plugin module provides runtime debugging and introspection facilities.))
  111. $(eval $(call UcodeModule, \
  112. fs, FS_SUPPORT, , \
  113. The filesystem plugin module allows interaction with the local file system.))
  114. $(eval $(call UcodeModule, \
  115. log, LOG_SUPPORT, +libubox, \
  116. The log plugin module provides access to the syslog and libubox ulog APIs.))
  117. $(eval $(call UcodeModule, \
  118. math, MATH_SUPPORT, , \
  119. The math plugin provides access to various <math.h> procedures.))
  120. $(eval $(call UcodeModule, \
  121. nl80211, NL80211_SUPPORT, +libnl-tiny +libubox, \
  122. The nl80211 plugin provides access to the Linux wireless 802.11 netlink API.))
  123. $(eval $(call UcodeModule, \
  124. resolv, RESOLV_SUPPORT, , \
  125. The resolv plugin implements simple DNS resolving.))
  126. $(eval $(call UcodeModule, \
  127. rtnl, RTNL_SUPPORT, +libnl-tiny +libubox, \
  128. The rtnl plugin provides access to the Linux routing netlink API.))
  129. $(eval $(call UcodeModule, \
  130. socket, SOCKET_SUPPORT, , \
  131. The socket plugin provides access to IPv4, IPv6, Unix and packet socket APIs.))
  132. $(eval $(call UcodeModule, \
  133. struct, STRUCT_SUPPORT, , \
  134. The struct plugin implements Python 3 compatible struct.pack/unpack functionality.))
  135. $(eval $(call UcodeModule, \
  136. ubus, UBUS_SUPPORT, +libubus +libblobmsg-json, \
  137. The ubus module allows ucode template scripts to enumerate and invoke ubus procedures.))
  138. $(eval $(call UcodeModule, \
  139. uci, UCI_SUPPORT, +libuci, \
  140. The uci module allows templates to read and modify uci configuration.))
  141. $(eval $(call UcodeModule, \
  142. uloop, ULOOP_SUPPORT, +libubox, \
  143. The uloop module allows ucode scripts to interact with OpenWrt uloop event loop implementation.))
  144. $(eval $(call UcodeModule, \
  145. digest, DIGEST_SUPPORT, , \
  146. The digest module allows ucode scripts to use libmd digests.))
  147. $(eval $(call BuildPackage,libucode))
  148. $(eval $(call BuildPackage,ucode))
  149. $(foreach mod,$(UCODE_MODULES), \
  150. $(eval $(call BuildPackage,$(mod))))
  151. $(eval $(call HostBuild))