5ee7714de7ffbfa6096360615690b04592d60afc
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / nodejs / nodejs.mk
1 ################################################################################
2 #
3 # nodejs
4 #
5 ################################################################################
6
7 NODEJS_VERSION = 0.10.38
8 NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.gz
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 ifeq ($(BR2_PACKAGE_OPENSSL),y)
17 NODEJS_DEPENDENCIES += openssl
18 endif
19
20 # nodejs build system is based on python, but only support python-2.6 or
21 # python-2.7. So, we have to enforce PYTHON interpreter to be python2.
22 define HOST_NODEJS_CONFIGURE_CMDS
23         # Build with the static, built-in OpenSSL which is supplied as part of
24         # the nodejs source distribution.  This is needed on the host because
25         # NPM is non-functional without it, and host-openssl isn't part of
26         # buildroot.
27         (cd $(@D); \
28                 $(HOST_CONFIGURE_OPTS) \
29                 PYTHON=$(HOST_DIR)/usr/bin/python2 \
30                 $(HOST_DIR)/usr/bin/python2 ./configure \
31                 --prefix=$(HOST_DIR)/usr \
32                 --without-snapshot \
33                 --without-dtrace \
34                 --without-etw \
35                 --shared-zlib \
36         )
37 endef
38
39 define HOST_NODEJS_BUILD_CMDS
40         $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
41                 $(MAKE) -C $(@D) \
42                 $(HOST_CONFIGURE_OPTS)
43 endef
44
45 define HOST_NODEJS_INSTALL_CMDS
46         $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
47                 $(MAKE) -C $(@D) install \
48                 $(HOST_CONFIGURE_OPTS)
49 endef
50
51 ifeq ($(BR2_i386),y)
52 NODEJS_CPU = ia32
53 else ifeq ($(BR2_x86_64),y)
54 NODEJS_CPU = x64
55 else ifeq ($(BR2_mipsel),y)
56 NODEJS_CPU = mipsel
57 else ifeq ($(BR2_arm),y)
58 NODEJS_CPU = arm
59 # V8 needs to know what floating point ABI the target is using.
60 NODEJS_ARM_FP = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
61 endif
62
63 define NODEJS_CONFIGURE_CMDS
64         (cd $(@D); \
65                 $(TARGET_CONFIGURE_OPTS) \
66                 LD="$(TARGET_CXX)" \
67                 PYTHON=$(HOST_DIR)/usr/bin/python2 \
68                 $(HOST_DIR)/usr/bin/python2 ./configure \
69                 --prefix=/usr \
70                 --without-snapshot \
71                 --shared-zlib \
72                 $(if $(BR2_PACKAGE_OPENSSL),--shared-openssl,--without-ssl) \
73                 $(if $(BR2_PACKAGE_NODEJS_NPM),,--without-npm) \
74                 --without-dtrace \
75                 --without-etw \
76                 --dest-cpu=$(NODEJS_CPU) \
77                 $(if $(NODEJS_ARM_FP),--with-arm-float-abi=$(NODEJS_ARM_FP)) \
78                 --dest-os=linux \
79         )
80 endef
81
82 define NODEJS_BUILD_CMDS
83         $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
84                 $(MAKE) -C $(@D) \
85                 $(TARGET_CONFIGURE_OPTS) \
86                 LD="$(TARGET_CXX)"
87 endef
88
89 #
90 # Build the list of modules to install based on the booleans for
91 # popular modules, as well as the "additional modules" list.
92 #
93 NODEJS_MODULES_LIST= $(call qstrip,\
94         $(if $(BR2_PACKAGE_NODEJS_MODULES_EXPRESS),express) \
95         $(if $(BR2_PACKAGE_NODEJS_MODULES_COFFEESCRIPT),coffee-script) \
96         $(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL))
97
98 #
99 # We can only call NPM if there's something to install.
100 #
101 ifneq ($(NODEJS_MODULES_LIST),)
102 define NODEJS_INSTALL_MODULES
103         # If you're having trouble with module installation, adding -d to the
104         # npm install call below and setting npm_config_rollback=false can both
105         # help in diagnosing the problem.
106         (cd $(TARGET_DIR)/usr/lib && mkdir -p node_modules && \
107                 $(TARGET_CONFIGURE_OPTS) \
108                 LD="$(TARGET_CXX)" \
109                 npm_config_arch=$(NODEJS_CPU) \
110                 npm_config_nodedir=$(BUILD_DIR)/nodejs-$(NODEJS_VERSION) \
111                 $(HOST_DIR)/usr/bin/npm install \
112                 $(NODEJS_MODULES_LIST) \
113         )
114 endef
115 endif
116
117 define NODEJS_INSTALL_TARGET_CMDS
118         $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
119                 $(MAKE) -C $(@D) install \
120                 DESTDIR=$(TARGET_DIR) \
121                 $(TARGET_CONFIGURE_OPTS) \
122                 LD="$(TARGET_CXX)"
123         $(NODEJS_INSTALL_MODULES)
124 endef
125
126 # node.js configure is a Python script and does not use autotools
127 $(eval $(generic-package))
128 $(eval $(host-generic-package))