Makefile 4.9 KB

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