nodejs.mk 5.1 KB

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