]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/nodejs/nodejs.mk
Globally replace $(HOST_DIR)/usr/bin with $(HOST_DIR)/bin
[coffee/buildroot.git] / package / nodejs / nodejs.mk
1 ################################################################################
2 #
3 # nodejs
4 #
5 ################################################################################
6
7 NODEJS_VERSION = 8.1.2
8 NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.xz
9 NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION)
10 NODEJS_DEPENDENCIES = host-python host-nodejs zlib \
11         $(call qstrip,$(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL_DEPS))
12 HOST_NODEJS_DEPENDENCIES = host-python host-zlib
13 NODEJS_LICENSE = MIT (core code); MIT, Apache and BSD family licenses (Bundled components)
14 NODEJS_LICENSE_FILES = LICENSE
15
16 NODEJS_CONF_OPTS = \
17         --without-snapshot \
18         --shared-zlib \
19         --without-dtrace \
20         --without-etw \
21         --dest-os=linux
22
23 ifeq ($(BR2_PACKAGE_OPENSSL),y)
24 NODEJS_DEPENDENCIES += openssl
25 NODEJS_CONF_OPTS += --shared-openssl
26 else
27 NODEJS_CONF_OPTS += --without-ssl
28 endif
29
30 ifeq ($(BR2_PACKAGE_ICU),y)
31 NODEJS_DEPENDENCIES += icu
32 NODEJS_CONF_OPTS += --with-intl=system-icu
33 else
34 NODEJS_CONF_OPTS += --with-intl=none
35 endif
36
37 ifneq ($(BR2_PACKAGE_NODEJS_NPM),y)
38 NODEJS_CONF_OPTS += --without-npm
39 endif
40
41 # nodejs build system is based on python, but only support python-2.6 or
42 # python-2.7. So, we have to enforce PYTHON interpreter to be python2.
43 define HOST_NODEJS_CONFIGURE_CMDS
44         # The build system directly calls python. Work around this by forcing python2
45         # into PATH. See https://github.com/nodejs/node/issues/2735
46         mkdir -p $(@D)/bin
47         ln -sf $(HOST_DIR)/bin/python2 $(@D)/bin/python
48
49         # Build with the static, built-in OpenSSL which is supplied as part of
50         # the nodejs source distribution.  This is needed on the host because
51         # NPM is non-functional without it, and host-openssl isn't part of
52         # buildroot.
53         (cd $(@D); \
54                 $(HOST_CONFIGURE_OPTS) \
55                 PATH=$(@D)/bin:$(BR_PATH) \
56                 PYTHON=$(HOST_DIR)/bin/python2 \
57                 $(HOST_DIR)/bin/python2 ./configure \
58                 --prefix=$(HOST_DIR) \
59                 --without-snapshot \
60                 --without-dtrace \
61                 --without-etw \
62                 --shared-zlib \
63                 --with-intl=none \
64         )
65 endef
66
67 define HOST_NODEJS_BUILD_CMDS
68         $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/bin/python2 \
69                 $(MAKE) -C $(@D) \
70                 $(HOST_CONFIGURE_OPTS) \
71                 NO_LOAD=cctest.target.mk \
72                 PATH=$(@D)/bin:$(BR_PATH)
73 endef
74
75 define HOST_NODEJS_INSTALL_CMDS
76         $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/bin/python2 \
77                 $(MAKE) -C $(@D) install \
78                 $(HOST_CONFIGURE_OPTS) \
79                 NO_LOAD=cctest.target.mk \
80                 PATH=$(@D)/bin:$(BR_PATH)
81
82         $(INSTALL) -m755 -D $(@D)/out/Release/mkpeephole $(HOST_DIR)/bin/mkpeephole
83 endef
84
85 ifeq ($(BR2_i386),y)
86 NODEJS_CPU = ia32
87 else ifeq ($(BR2_x86_64),y)
88 NODEJS_CPU = x64
89 else ifeq ($(BR2_mips),y)
90 NODEJS_CPU = mips
91 else ifeq ($(BR2_mipsel),y)
92 NODEJS_CPU = mipsel
93 else ifeq ($(BR2_arm),y)
94 NODEJS_CPU = arm
95 else ifeq ($(BR2_aarch64),y)
96 NODEJS_CPU = arm64
97 # V8 needs to know what floating point ABI the target is using.
98 NODEJS_ARM_FP = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
99 endif
100
101 # MIPS architecture specific options
102 ifeq ($(BR2_mips)$(BR2_mipsel),y)
103 ifeq ($(BR2_MIPS_CPU_MIPS32R6),y)
104 NODEJS_MIPS_ARCH_VARIANT = r6
105 NODEJS_MIPS_FPU_MODE = fp64
106 else ifeq ($(BR2_MIPS_CPU_MIPS32R2),y)
107 NODEJS_MIPS_ARCH_VARIANT = r2
108 else ifeq ($(BR2_MIPS_CPU_MIPS32),y)
109 NODEJS_MIPS_ARCH_VARIANT = r1
110 endif
111 endif
112
113 define NODEJS_CONFIGURE_CMDS
114         mkdir -p $(@D)/bin
115         ln -sf $(HOST_DIR)/bin/python2 $(@D)/bin/python
116
117         (cd $(@D); \
118                 $(TARGET_CONFIGURE_OPTS) \
119                 PATH=$(@D)/bin:$(BR_PATH) \
120                 LD="$(TARGET_CXX)" \
121                 PYTHON=$(HOST_DIR)/bin/python2 \
122                 $(HOST_DIR)/bin/python2 ./configure \
123                 --prefix=/usr \
124                 --dest-cpu=$(NODEJS_CPU) \
125                 $(if $(NODEJS_ARM_FP),--with-arm-float-abi=$(NODEJS_ARM_FP)) \
126                 $(if $(NODEJS_MIPS_ARCH_VARIANT),--with-mips-arch-variant=$(NODEJS_MIPS_ARCH_VARIANT)) \
127                 $(if $(NODEJS_MIPS_FPU_MODE),--with-mips-fpu-mode=$(NODEJS_MIPS_FPU_MODE)) \
128                 $(NODEJS_CONF_OPTS) \
129         )
130
131         # use host version of mkpeephole
132         sed "s#<(mkpeephole_exec)#$(HOST_DIR)/bin/mkpeephole#g" -i $(@D)/deps/v8/src/v8.gyp
133 endef
134
135 define NODEJS_BUILD_CMDS
136         $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/bin/python2 \
137                 $(MAKE) -C $(@D) \
138                 $(TARGET_CONFIGURE_OPTS) \
139                 NO_LOAD=cctest.target.mk \
140                 PATH=$(@D)/bin:$(BR_PATH) \
141                 LD="$(TARGET_CXX)"
142 endef
143
144 #
145 # Build the list of modules to install.
146 #
147 NODEJS_MODULES_LIST= $(call qstrip,\
148         $(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL))
149
150 # Define NPM for other packages to use
151 NPM = $(TARGET_CONFIGURE_OPTS) \
152         LD="$(TARGET_CXX)" \
153         npm_config_arch=$(NODEJS_CPU) \
154         npm_config_target_arch=$(NODEJS_CPU) \
155         npm_config_build_from_source=true \
156         npm_config_nodedir=$(BUILD_DIR)/nodejs-$(NODEJS_VERSION) \
157         npm_config_prefix=$(TARGET_DIR)/usr \
158         $(HOST_DIR)/bin/npm
159
160 #
161 # We can only call NPM if there's something to install.
162 #
163 ifneq ($(NODEJS_MODULES_LIST),)
164 define NODEJS_INSTALL_MODULES
165         # If you're having trouble with module installation, adding -d to the
166         # npm install call below and setting npm_config_rollback=false can both
167         # help in diagnosing the problem.
168         $(NPM) install -g $(NODEJS_MODULES_LIST)
169 endef
170 endif
171
172 define NODEJS_INSTALL_TARGET_CMDS
173         $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/bin/python2 \
174                 $(MAKE) -C $(@D) install \
175                 DESTDIR=$(TARGET_DIR) \
176                 $(TARGET_CONFIGURE_OPTS) \
177                 NO_LOAD=cctest.target.mk \
178                 PATH=$(@D)/bin:$(BR_PATH) \
179                 LD="$(TARGET_CXX)"
180         $(NODEJS_INSTALL_MODULES)
181 endef
182
183 # node.js configure is a Python script and does not use autotools
184 $(eval $(generic-package))
185 $(eval $(host-generic-package))