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.

155 lines
4.4 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:=v12.18.4
  10. PKG_RELEASE:=1
  11. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  12. PKG_SOURCE_URL:=https://nodejs.org/dist/$(PKG_VERSION)
  13. PKG_HASH:=25f03cb18e53b6d0959d0c219e701a85eb4693f526bdda7c72bc6199b364f609
  14. PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>, 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||KERNEL_MIPS_FPU_EMULATOR) @!arc @!armeb @!powerpc \
  34. +libstdcpp +libopenssl +zlib +libnghttp2 +libuv +libhttp-parser \
  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_NONE
  63. help
  64. Select i18n features
  65. config NODEJS_ICU_NONE
  66. bool "Disable"
  67. config NODEJS_ICU_SMALL
  68. depends on !BIG_ENDIAN
  69. bool "small-icu"
  70. config NODEJS_ICU_SYSTEM
  71. depends on ARCH_64BIT&&!BIG_ENDIAN
  72. bool "system-icu"
  73. endchoice
  74. endif
  75. endef
  76. NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))))
  77. ifneq ($(CONFIG_ARCH_64BIT),y)
  78. FORCE_32BIT:=-m32
  79. endif
  80. MAKE_VARS+= \
  81. DESTCPU=$(NODEJS_CPU) \
  82. LD_LIBRARY_PATH=$(STAGING_DIR_HOSTPKG)/share/icu/current/lib
  83. CONFIGURE_VARS:= \
  84. CC="$(TARGET_CC) $(TARGET_OPTIMIZATION)" \
  85. CXX="$(TARGET_CXX) $(TARGET_OPTIMIZATION)" \
  86. CC_host="$(HOSTCC) $(FORCE_32BIT)" \
  87. CXX_host="$(HOSTCXX) $(FORCE_32BIT)"
  88. CONFIGURE_ARGS:= \
  89. --dest-cpu=$(NODEJS_CPU) \
  90. --dest-os=linux \
  91. --cross-compiling \
  92. --shared-zlib \
  93. --shared-openssl \
  94. --shared-nghttp2 \
  95. --shared-libuv \
  96. --shared-http-parser \
  97. --shared-cares \
  98. $(if $(CONFIG_NODEJS_ICU_SMALL),, \
  99. --with-intl=$(if $(CONFIG_NODEJS_ICU_SYSTEM),system-icu,none)) \
  100. $(if $(findstring mips,$(NODEJS_CPU)), \
  101. $(if $(CONFIG_SOFT_FLOAT),--with-mips-float-abi=soft)) \
  102. $(if $(findstring +neon,$(CONFIG_CPU_TYPE)),--with-arm-fpu=neon) \
  103. $(if $(findstring +vfp",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfp) \
  104. $(if $(findstring +vfpv3",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3-d16) \
  105. $(if $(findstring +vfpv4",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3) \
  106. --prefix=/usr
  107. HOST_CONFIGURE_VARS:=
  108. HOST_CONFIGURE_ARGS:= \
  109. --dest-os=$(if $(findstring Darwin,$(HOST_OS)),mac,linux) \
  110. --with-intl=none \
  111. --prefix=$(STAGING_DIR_HOSTPKG)
  112. define Build/InstallDev
  113. $(INSTALL_DIR) $(1)/usr/include
  114. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  115. endef
  116. define Package/node/install
  117. $(INSTALL_DIR) $(1)/usr/bin
  118. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/node $(1)/usr/bin/
  119. endef
  120. define Package/node-npm/install
  121. $(INSTALL_DIR) $(1)/usr/lib/node_modules
  122. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/* $(1)/usr/lib/node_modules/
  123. $(INSTALL_DIR) $(1)/usr/bin
  124. $(LN) ../lib/node_modules/npm/bin/npm-cli.js $(1)/usr/bin/npm
  125. $(LN) ../lib/node_modules/npm/bin/npx-cli.js $(1)/usr/bin/npx
  126. endef
  127. $(eval $(call HostBuild))
  128. $(eval $(call BuildPackage,node))
  129. $(eval $(call BuildPackage,node-npm))