nodejs.mk 5.2 KB

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