Makefile 4.7 KB

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