iptables: bump to version 1.6.1
[buildroot-gz.git] / package / nodejs / nodejs.mk
blob042cc3fb07cb3bb287b161d8c3496f85f8e52ac4
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 \
66 $(if $(BR2_PACKAGE_NODEJS_V8_ARCH_SUPPORTS),--with-intl=none) \
68 endef
70 define HOST_NODEJS_BUILD_CMDS
71 $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
72 $(MAKE) -C $(@D) \
73 $(HOST_CONFIGURE_OPTS) \
74 PATH=$(@D)/bin:$(BR_PATH)
75 endef
77 define HOST_NODEJS_INSTALL_CMDS
78 $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
79 $(MAKE) -C $(@D) install \
80 $(HOST_CONFIGURE_OPTS) \
81 PATH=$(@D)/bin:$(BR_PATH)
82 endef
84 ifeq ($(BR2_i386),y)
85 NODEJS_CPU = ia32
86 else ifeq ($(BR2_x86_64),y)
87 NODEJS_CPU = x64
88 else ifeq ($(BR2_mips),y)
89 NODEJS_CPU = mips
90 else ifeq ($(BR2_mipsel),y)
91 NODEJS_CPU = mipsel
92 else ifeq ($(BR2_arm),y)
93 NODEJS_CPU = arm
94 else ifeq ($(BR2_aarch64),y)
95 NODEJS_CPU = arm64
96 # V8 needs to know what floating point ABI the target is using.
97 NODEJS_ARM_FP = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
98 endif
100 # MIPS architecture specific options
101 ifeq ($(BR2_mips)$(BR2_mipsel),y)
102 ifeq ($(BR2_MIPS_CPU_MIPS32R6),y)
103 NODEJS_MIPS_ARCH_VARIANT = r6
104 NODEJS_MIPS_FPU_MODE = fp64
105 else ifeq ($(BR2_MIPS_CPU_MIPS32R2),y)
106 NODEJS_MIPS_ARCH_VARIANT = r2
107 else ifeq ($(BR2_MIPS_CPU_MIPS32),y)
108 NODEJS_MIPS_ARCH_VARIANT = r1
109 endif
110 endif
112 define NODEJS_CONFIGURE_CMDS
113 mkdir -p $(@D)/bin
114 ln -sf $(HOST_DIR)/usr/bin/python2 $(@D)/bin/python
116 (cd $(@D); \
117 $(TARGET_CONFIGURE_OPTS) \
118 PATH=$(@D)/bin:$(BR_PATH) \
119 LD="$(TARGET_CXX)" \
120 PYTHON=$(HOST_DIR)/usr/bin/python2 \
121 $(HOST_DIR)/usr/bin/python2 ./configure \
122 --prefix=/usr \
123 --dest-cpu=$(NODEJS_CPU) \
124 $(if $(NODEJS_ARM_FP),--with-arm-float-abi=$(NODEJS_ARM_FP)) \
125 $(if $(NODEJS_MIPS_ARCH_VARIANT),--with-mips-arch-variant=$(NODEJS_MIPS_ARCH_VARIANT)) \
126 $(if $(NODEJS_MIPS_FPU_MODE),--with-mips-fpu-mode=$(NODEJS_MIPS_FPU_MODE)) \
127 $(NODEJS_CONF_OPTS) \
129 endef
131 define NODEJS_BUILD_CMDS
132 $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
133 $(MAKE) -C $(@D) \
134 $(TARGET_CONFIGURE_OPTS) \
135 PATH=$(@D)/bin:$(BR_PATH) \
136 LD="$(TARGET_CXX)"
137 endef
140 # Build the list of modules to install based on the booleans for
141 # popular modules, as well as the "additional modules" list.
143 NODEJS_MODULES_LIST= $(call qstrip,\
144 $(if $(BR2_PACKAGE_NODEJS_MODULES_EXPRESS),express) \
145 $(if $(BR2_PACKAGE_NODEJS_MODULES_COFFEESCRIPT),coffee-script) \
146 $(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL))
148 # Define NPM for other packages to use
149 NPM = $(TARGET_CONFIGURE_OPTS) \
150 LD="$(TARGET_CXX)" \
151 npm_config_arch=$(NODEJS_CPU) \
152 npm_config_target_arch=$(NODEJS_CPU) \
153 npm_config_build_from_source=true \
154 npm_config_nodedir=$(BUILD_DIR)/nodejs-$(NODEJS_VERSION) \
155 npm_config_prefix=$(TARGET_DIR)/usr \
156 $(HOST_DIR)/usr/bin/npm
159 # We can only call NPM if there's something to install.
161 ifneq ($(NODEJS_MODULES_LIST),)
162 define NODEJS_INSTALL_MODULES
163 # If you're having trouble with module installation, adding -d to the
164 # npm install call below and setting npm_config_rollback=false can both
165 # help in diagnosing the problem.
166 $(NPM) install -g $(NODEJS_MODULES_LIST)
167 endef
168 endif
170 define NODEJS_INSTALL_TARGET_CMDS
171 $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
172 $(MAKE) -C $(@D) install \
173 DESTDIR=$(TARGET_DIR) \
174 $(TARGET_CONFIGURE_OPTS) \
175 PATH=$(@D)/bin:$(BR_PATH) \
176 LD="$(TARGET_CXX)"
177 $(NODEJS_INSTALL_MODULES)
178 endef
180 # node.js configure is a Python script and does not use autotools
181 $(eval $(generic-package))
182 $(eval $(host-generic-package))