package/xfont_font-cronyx-cyrillic: add hash file
[buildroot-gz.git] / package / nodejs / nodejs.mk
blobd6f115a51068cbfe1e532bbec2bebf54191f1816
1 ################################################################################
3 # nodejs
5 ################################################################################
7 NODEJS_VERSION = $(call qstrip,$(BR2_PACKAGE_NODEJS_VERSION_STRING))
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
16 NODEJS_CONF_OPTS = \
17 --without-snapshot \
18 --shared-zlib \
19 --without-dtrace \
20 --without-etw \
21 --dest-os=linux
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
30 # 0.10.x does not have icu support
31 ifeq ($(findstring 0.10.,$(NODEJS_VERSION)),)
32 ifeq ($(BR2_PACKAGE_ICU),y)
33 NODEJS_DEPENDENCIES += icu
34 NODEJS_CONF_OPTS += --with-intl=system-icu
35 else
36 NODEJS_CONF_OPTS += --with-intl=none
37 endif
38 endif
40 ifneq ($(BR2_PACKAGE_NODEJS_NPM),y)
41 NODEJS_CONF_OPTS += --without-npm
42 endif
44 # nodejs build system is based on python, but only support python-2.6 or
45 # python-2.7. So, we have to enforce PYTHON interpreter to be python2.
46 define HOST_NODEJS_CONFIGURE_CMDS
47 # The build system directly calls python. Work around this by forcing python2
48 # into PATH. See https://github.com/nodejs/node/issues/2735
49 mkdir -p $(@D)/bin
50 ln -sf $(HOST_DIR)/usr/bin/python2 $(@D)/bin/python
52 # Build with the static, built-in OpenSSL which is supplied as part of
53 # the nodejs source distribution. This is needed on the host because
54 # NPM is non-functional without it, and host-openssl isn't part of
55 # buildroot.
56 (cd $(@D); \
57 $(HOST_CONFIGURE_OPTS) \
58 PATH=$(@D)/bin:$(BR_PATH) \
59 PYTHON=$(HOST_DIR)/usr/bin/python2 \
60 $(HOST_DIR)/usr/bin/python2 ./configure \
61 --prefix=$(HOST_DIR)/usr \
62 --without-snapshot \
63 --without-dtrace \
64 --without-etw \
65 --shared-zlib \
67 endef
69 define HOST_NODEJS_BUILD_CMDS
70 $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
71 $(MAKE) -C $(@D) \
72 $(HOST_CONFIGURE_OPTS) \
73 PATH=$(@D)/bin:$(BR_PATH)
74 endef
76 define HOST_NODEJS_INSTALL_CMDS
77 $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
78 $(MAKE) -C $(@D) install \
79 $(HOST_CONFIGURE_OPTS) \
80 PATH=$(@D)/bin:$(BR_PATH)
81 endef
83 ifeq ($(BR2_i386),y)
84 NODEJS_CPU = ia32
85 else ifeq ($(BR2_x86_64),y)
86 NODEJS_CPU = x64
87 else ifeq ($(BR2_mips),y)
88 NODEJS_CPU = mips
89 else ifeq ($(BR2_mipsel),y)
90 NODEJS_CPU = mipsel
91 else ifeq ($(BR2_arm),y)
92 NODEJS_CPU = arm
93 # V8 needs to know what floating point ABI the target is using.
94 NODEJS_ARM_FP = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
95 endif
97 # MIPS architecture specific options
98 ifeq ($(BR2_mips)$(BR2_mipsel),y)
99 ifeq ($(BR2_mips_32r6),y)
100 NODEJS_MIPS_ARCH_VARIANT = r6
101 NODEJS_MIPS_FPU_MODE = fp64
102 else ifeq ($(BR2_mips_32r2),y)
103 NODEJS_MIPS_ARCH_VARIANT = r2
104 else ifeq ($(BR2_mips_32),y)
105 NODEJS_MIPS_ARCH_VARIANT = r1
106 endif
107 endif
109 define NODEJS_CONFIGURE_CMDS
110 mkdir -p $(@D)/bin
111 ln -sf $(HOST_DIR)/usr/bin/python2 $(@D)/bin/python
113 (cd $(@D); \
114 $(TARGET_CONFIGURE_OPTS) \
115 PATH=$(@D)/bin:$(BR_PATH) \
116 LD="$(TARGET_CXX)" \
117 PYTHON=$(HOST_DIR)/usr/bin/python2 \
118 $(HOST_DIR)/usr/bin/python2 ./configure \
119 --prefix=/usr \
120 --dest-cpu=$(NODEJS_CPU) \
121 $(if $(NODEJS_ARM_FP),--with-arm-float-abi=$(NODEJS_ARM_FP)) \
122 $(if $(NODEJS_MIPS_ARCH_VARIANT),--with-mips-arch-variant=$(NODEJS_MIPS_ARCH_VARIANT)) \
123 $(if $(NODEJS_MIPS_FPU_MODE),--with-mips-fpu-mode=$(NODEJS_MIPS_FPU_MODE)) \
124 $(NODEJS_CONF_OPTS) \
126 endef
128 define NODEJS_BUILD_CMDS
129 $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
130 $(MAKE) -C $(@D) \
131 $(TARGET_CONFIGURE_OPTS) \
132 PATH=$(@D)/bin:$(BR_PATH) \
133 LD="$(TARGET_CXX)"
134 endef
137 # Build the list of modules to install based on the booleans for
138 # popular modules, as well as the "additional modules" list.
140 NODEJS_MODULES_LIST= $(call qstrip,\
141 $(if $(BR2_PACKAGE_NODEJS_MODULES_EXPRESS),express) \
142 $(if $(BR2_PACKAGE_NODEJS_MODULES_COFFEESCRIPT),coffee-script) \
143 $(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL))
145 # Define NPM for other packages to use
146 NPM = $(TARGET_CONFIGURE_OPTS) \
147 LD="$(TARGET_CXX)" \
148 npm_config_arch=$(NODEJS_CPU) \
149 npm_config_target_arch=$(NODEJS_CPU) \
150 npm_config_build_from_source=true \
151 npm_config_nodedir=$(BUILD_DIR)/nodejs-$(NODEJS_VERSION) \
152 npm_config_prefix=$(TARGET_DIR)/usr \
153 $(HOST_DIR)/usr/bin/npm
156 # We can only call NPM if there's something to install.
158 ifneq ($(NODEJS_MODULES_LIST),)
159 define NODEJS_INSTALL_MODULES
160 # If you're having trouble with module installation, adding -d to the
161 # npm install call below and setting npm_config_rollback=false can both
162 # help in diagnosing the problem.
163 $(NPM) install -g $(NODEJS_MODULES_LIST)
164 endef
165 endif
167 define NODEJS_INSTALL_TARGET_CMDS
168 $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
169 $(MAKE) -C $(@D) install \
170 DESTDIR=$(TARGET_DIR) \
171 $(TARGET_CONFIGURE_OPTS) \
172 PATH=$(@D)/bin:$(BR_PATH) \
173 LD="$(TARGET_CXX)"
174 $(NODEJS_INSTALL_MODULES)
175 endef
177 # node.js configure is a Python script and does not use autotools
178 $(eval $(generic-package))
179 $(eval $(host-generic-package))