OSDN Git Service

8a2d43126ac0cf0446015be0e18fe12bff9fa279
[immortalwrt/packages.git] / lang / node / Makefile
1 # This is free software, licensed under the GNU General Public License v2.
2 # See /LICENSE for more information.
3 #
4
5 include $(TOPDIR)/rules.mk
6
7 PKG_NAME:=node
8
9 ifeq ($(CONFIG_NODEJS_16),y)
10 PKG_VERSION:=v16.15.0
11 PKG_RELEASE:=1
12 PKG_HASH:=a0f812efc43f78321eca08957960a48f5e6bf97004d5058c8dd3b03c646ea4f7
13 PATCH_DIR:=./patches/v16.x
14 else
15 ifeq ($(CONFIG_NODEJS_14),y)
16 PKG_VERSION:=v14.19.3
17 PKG_RELEASE:=1
18 PKG_HASH:=5cf45b1f1aca77523acf36240c1d53a999279070a7711eabf23346f88b0cc994
19 PATCH_DIR:=./patches/v14.x
20 else
21 PKG_VERSION:=v18.2.0
22 PKG_RELEASE:=1
23 PKG_HASH:=2305b15ebf5547474e905b5002f9ba99c7eeef01d7394dfe6f3846cc6bcad66d
24 PATCH_DIR:=./patches/v18.x
25 endif
26 endif
27
28 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
29 PKG_SOURCE_URL:=https://mirrors.tencent.com/nodejs-release/$(PKG_VERSION) \
30                 https://nodejs.org/dist/$(PKG_VERSION)
31
32 PKG_MAINTAINER:=Hirokazu MORIKAWA <morikw2@gmail.com>
33 PKG_LICENSE:=MIT
34 PKG_LICENSE_FILES:=LICENSE
35 PKG_CPE_ID:=cpe:/a:nodejs:node.js
36
37 HOST_BUILD_DEPENDS:=python3/host
38 HOST_BUILD_PARALLEL:=1
39
40 PKG_BUILD_DEPENDS:=python3/host
41 PKG_BUILD_PARALLEL:=1
42 PKG_INSTALL:=1
43 PKG_USE_MIPS16:=0
44 PKG_ASLR_PIE:=0
45
46 include $(INCLUDE_DIR)/host-build.mk
47 include $(INCLUDE_DIR)/package.mk
48
49 define Package/node
50   SECTION:=lang
51   CATEGORY:=Languages
52   SUBMENU:=Node.js
53   TITLE:=Node.js is a platform built on Chrome's JavaScript runtime
54   URL:=https://nodejs.org/
55   DEPENDS:=@HAS_FPU @(i386||x86_64||arm||aarch64||mipsel) \
56            +libstdcpp +libopenssl +zlib +libnghttp2 +libuv \
57            +libcares +libatomic +NODEJS_ICU_SYSTEM:icu +NODEJS_ICU_SYSTEM:icu-full-data
58 endef
59
60 define Package/node/description
61   Node.jsĀ® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses
62   an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js'
63    package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
64
65   *** The following preparations must be made on the host side. ***
66       1. gcc 8.3 or higher is required.
67       2. To build a 32-bit target, gcc-multilib, g++-multilib are required.
68       3. Requires libatomic package. (If necessary, install the 32-bit library at the same time.)
69      ex) sudo apt-get install gcc-multilib g++-multilib
70 endef
71
72 define Package/node-npm
73   SECTION:=lang
74   CATEGORY:=Languages
75   SUBMENU:=Node.js
76   TITLE:=NPM stands for Node Package Manager
77   URL:=https://www.npmjs.com/
78   DEPENDS:=+node
79 endef
80
81 define Package/node-npm/description
82         NPM is the package manager for NodeJS
83 endef
84
85 define Package/node/config
86         menu "Configuration"
87                 depends on PACKAGE_node
88
89         choice
90                 prompt "Version Selection"
91                 default NODEJS_16
92                 help
93                  Select node.js version.
94
95                 config NODEJS_14
96                         bool "14.x Maintenance LTS"
97
98                 config NODEJS_16
99                         bool "16.x Active LTS"
100
101                 config NODEJS_18
102                         bool "18.x Current"
103         endchoice
104
105         choice
106                 prompt "i18n features"
107                 default NODEJS_ICU_SMALL
108                 help
109                  Select i18n features
110
111                 config NODEJS_ICU_NONE
112                         bool "Disable"
113
114                 config NODEJS_ICU_SMALL
115                         bool "small-icu"
116
117                 config NODEJS_ICU_SYSTEM
118                         depends on ARCH_64BIT
119                         bool "system-icu"
120         endchoice
121
122         endmenu
123 endef
124
125 NODEJS_CPU:=$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH))))
126
127 ifneq ($(CONFIG_ARCH_64BIT),y)
128 FORCE_32BIT:=-m32
129 endif
130
131 MAKE_VARS+= \
132         DESTCPU=$(NODEJS_CPU) \
133         NO_LOAD='cctest.target.mk embedtest.target.mk node_mksnapshot.target.mk overlapped-checker.target.mk mkcodecache.target.mk' \
134         LD_LIBRARY_PATH=$(STAGING_DIR_HOSTPKG)/share/icu/current/lib
135
136 HOST_MAKE_VARS+=NO_LOAD='cctest.target.mk embedtest.target.mk overlapped-checker.target.mk'
137
138 CONFIGURE_VARS:= \
139         CC="$(TARGET_CC) $(TARGET_OPTIMIZATION)" \
140         CXX="$(TARGET_CXX) $(TARGET_OPTIMIZATION)" \
141         CC_host="$(HOSTCC) $(FORCE_32BIT)" \
142         CXX_host="$(HOSTCXX) $(FORCE_32BIT)"
143
144 CONFIGURE_ARGS:= \
145         --dest-cpu=$(NODEJS_CPU) \
146         --dest-os=linux \
147         --cross-compiling \
148         --shared-zlib \
149         --shared-openssl \
150         --shared-nghttp2 \
151         --shared-libuv \
152         --shared-cares \
153         --with-intl=$(if $(CONFIG_NODEJS_ICU_SMALL),small-icu,$(if $(CONFIG_NODEJS_ICU_SYSTEM),system-icu,none)) \
154         $(if $(findstring +neon,$(CONFIG_CPU_TYPE)),--with-arm-fpu=neon) \
155         $(if $(findstring +vfp",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfp) \
156         $(if $(findstring +vfpv3",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3-d16) \
157         $(if $(findstring +vfpv4",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3) \
158         --prefix=/usr
159
160 HOST_CONFIGURE_VARS:=
161 HOST_CONFIGURE_ARGS:= \
162         --dest-os=$(if $(findstring Darwin,$(HOST_OS)),mac,linux) \
163         --with-intl=small-icu \
164         --prefix=$(STAGING_DIR_HOSTPKG)
165
166 define Build/InstallDev
167         $(INSTALL_DIR) $(1)/usr/include
168         $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
169 endef
170
171 define Package/node/install
172         $(INSTALL_DIR) $(1)/usr/bin
173         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/node $(1)/usr/bin/
174 endef
175
176 define Package/node-npm/install
177         $(INSTALL_DIR) $(1)/usr/lib/node_modules/npm
178         $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/{package.json,LICENSE} \
179                 $(1)/usr/lib/node_modules/npm/
180         $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/README.md \
181                 $(1)/usr/lib/node_modules/npm/
182         $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/{node_modules,bin,lib} \
183                 $(1)/usr/lib/node_modules/npm/
184         $(INSTALL_DIR) $(1)/usr/bin
185         $(LN) ../lib/node_modules/npm/bin/npm-cli.js $(1)/usr/bin/npm
186         $(LN) ../lib/node_modules/npm/bin/npx-cli.js $(1)/usr/bin/npx
187 endef
188
189 define Package/node-npm/postrm
190 #!/bin/sh
191 rm -rf /usr/lib/node_modules/npm || true
192 endef
193
194 define Host/Install
195         $(RM) -rf $(1)/lib/node_modules/npm
196         $(call Host/Install/Default)
197 endef
198
199 $(eval $(call HostBuild))
200 $(eval $(call BuildPackage,node))
201 $(eval $(call BuildPackage,node-npm))