You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
4.5 KiB

  1. #
  2. # Copyright (C) 2006-2017 OpenWrt.org
  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:=node
  9. PKG_VERSION:=v14.17.0
  10. PKG_RELEASE:=2
  11. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  12. PKG_SOURCE_URL:=https://nodejs.org/dist/$(PKG_VERSION)
  13. PKG_HASH:=56e05bff9331039317db417f772e635e0cd1c55f733f7b1b079d71ab5842c9ed
  14. PKG_MAINTAINER:=Hirokazu MORIKAWA <morikw2@gmail.com>, Adrian Panella <ianchi74@outlook.com>
  15. PKG_LICENSE:=MIT
  16. PKG_LICENSE_FILES:=LICENSE
  17. PKG_CPE_ID:=cpe:/a:nodejs:node.js
  18. HOST_BUILD_DEPENDS:=python3/host
  19. HOST_BUILD_PARALLEL:=1
  20. PKG_BUILD_DEPENDS:=python3/host
  21. PKG_BUILD_PARALLEL:=1
  22. PKG_INSTALL:=1
  23. PKG_USE_MIPS16:=0
  24. PKG_ASLR_PIE:=0
  25. include $(INCLUDE_DIR)/host-build.mk
  26. include $(INCLUDE_DIR)/package.mk
  27. define Package/node
  28. SECTION:=lang
  29. CATEGORY:=Languages
  30. SUBMENU:=Node.js
  31. TITLE:=Node.js is a platform built on Chrome's JavaScript runtime
  32. URL:=https://nodejs.org/
  33. DEPENDS:=@HAS_FPU @(i386||x86_64||arm||aarch64||mipsel) \
  34. +libstdcpp +libopenssl +zlib +libnghttp2 +libuv \
  35. +libcares +libatomic +NODEJS_ICU_SYSTEM:icu +NODEJS_ICU_SYSTEM:icu-full-data
  36. endef
  37. define Package/node/description
  38. Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses
  39. an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js'
  40. package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
  41. *** The following preparations must be made on the host side. ***
  42. 1. gcc 6.3 or higher is required.
  43. 2. To build a 32-bit target, gcc-multilib, g++-multilib are required.
  44. 3. Requires libatomic package. (If necessary, install the 32-bit library at the same time.)
  45. ex) sudo apt-get install gcc-multilib g++-multilib
  46. endef
  47. define Package/node-npm
  48. SECTION:=lang
  49. CATEGORY:=Languages
  50. SUBMENU:=Node.js
  51. TITLE:=NPM stands for Node Package Manager
  52. URL:=https://www.npmjs.com/
  53. DEPENDS:=+node
  54. endef
  55. define Package/node-npm/description
  56. NPM is the package manager for NodeJS
  57. endef
  58. define Package/node/config
  59. if PACKAGE_node
  60. choice
  61. prompt "i18n features"
  62. default NODEJS_ICU_SMALL
  63. help
  64. Select i18n features
  65. config NODEJS_ICU_NONE
  66. bool "Disable"
  67. config NODEJS_ICU_SMALL
  68. bool "small-icu"
  69. config NODEJS_ICU_SYSTEM
  70. depends on ARCH_64BIT
  71. bool "system-icu"
  72. endchoice
  73. endif
  74. endef
  75. NODEJS_CPU:=$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH))))
  76. ifneq ($(CONFIG_ARCH_64BIT),y)
  77. FORCE_32BIT:=-m32
  78. endif
  79. MAKE_VARS+= \
  80. DESTCPU=$(NODEJS_CPU) \
  81. NO_LOAD='cctest.target.mk embedtest.target.mk node_mksnapshot.target.mk' \
  82. LD_LIBRARY_PATH=$(STAGING_DIR_HOSTPKG)/share/icu/current/lib
  83. HOST_MAKE_VARS+=NO_LOAD='cctest.target.mk embedtest.target.mk'
  84. CONFIGURE_VARS:= \
  85. CC="$(TARGET_CC) $(TARGET_OPTIMIZATION)" \
  86. CXX="$(TARGET_CXX) $(TARGET_OPTIMIZATION)" \
  87. CC_host="$(HOSTCC) $(FORCE_32BIT)" \
  88. CXX_host="$(HOSTCXX) $(FORCE_32BIT)"
  89. CONFIGURE_ARGS:= \
  90. --dest-cpu=$(NODEJS_CPU) \
  91. --dest-os=linux \
  92. --cross-compiling \
  93. --shared-zlib \
  94. --shared-openssl \
  95. --shared-nghttp2 \
  96. --shared-libuv \
  97. --shared-cares \
  98. --with-intl=$(if $(CONFIG_NODEJS_ICU_SMALL),small-icu,$(if $(CONFIG_NODEJS_ICU_SYSTEM),system-icu,none)) \
  99. $(if $(findstring +neon,$(CONFIG_CPU_TYPE)),--with-arm-fpu=neon) \
  100. $(if $(findstring +vfp",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfp) \
  101. $(if $(findstring +vfpv3",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3-d16) \
  102. $(if $(findstring +vfpv4",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3) \
  103. --prefix=/usr
  104. HOST_CONFIGURE_VARS:=
  105. HOST_CONFIGURE_ARGS:= \
  106. --dest-os=$(if $(findstring Darwin,$(HOST_OS)),mac,linux) \
  107. --with-intl=small-icu \
  108. --prefix=$(STAGING_DIR_HOSTPKG)
  109. define Build/InstallDev
  110. $(INSTALL_DIR) $(1)/usr/include
  111. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  112. endef
  113. define Package/node/install
  114. $(INSTALL_DIR) $(1)/usr/bin
  115. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/node $(1)/usr/bin/
  116. endef
  117. define Package/node-npm/install
  118. $(INSTALL_DIR) $(1)/usr/lib/node_modules/npm
  119. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/{package.json,LICENSE} \
  120. $(1)/usr/lib/node_modules/npm/
  121. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/{AUTHORS,*.md} \
  122. $(1)/usr/lib/node_modules/npm/
  123. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/{node_modules,bin,lib} \
  124. $(1)/usr/lib/node_modules/npm/
  125. $(INSTALL_DIR) $(1)/usr/bin
  126. $(LN) ../lib/node_modules/npm/bin/npm-cli.js $(1)/usr/bin/npm
  127. $(LN) ../lib/node_modules/npm/bin/npx-cli.js $(1)/usr/bin/npx
  128. endef
  129. $(eval $(call HostBuild))
  130. $(eval $(call BuildPackage,node))
  131. $(eval $(call BuildPackage,node-npm))