nodejs.mk 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. ################################################################################
  2. #
  3. # nodejs
  4. #
  5. ################################################################################
  6. NODEJS_VERSION = 8.15.1
  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-libopenssl 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. (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-openssl \
  56. --shared-openssl-includes=$(HOST_DIR)/include/openssl \
  57. --shared-openssl-libpath=$(HOST_DIR)/lib \
  58. --shared-zlib \
  59. --with-intl=none \
  60. )
  61. endef
  62. define HOST_NODEJS_BUILD_CMDS
  63. $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/bin/python2 \
  64. $(MAKE) -C $(@D) \
  65. $(HOST_CONFIGURE_OPTS) \
  66. NO_LOAD=cctest.target.mk \
  67. PATH=$(@D)/bin:$(BR_PATH)
  68. endef
  69. define HOST_NODEJS_INSTALL_CMDS
  70. $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/bin/python2 \
  71. $(MAKE) -C $(@D) install \
  72. $(HOST_CONFIGURE_OPTS) \
  73. NO_LOAD=cctest.target.mk \
  74. PATH=$(@D)/bin:$(BR_PATH)
  75. endef
  76. ifeq ($(BR2_i386),y)
  77. NODEJS_CPU = ia32
  78. else ifeq ($(BR2_x86_64),y)
  79. NODEJS_CPU = x64
  80. else ifeq ($(BR2_mips),y)
  81. NODEJS_CPU = mips
  82. else ifeq ($(BR2_mipsel),y)
  83. NODEJS_CPU = mipsel
  84. else ifeq ($(BR2_arm),y)
  85. NODEJS_CPU = arm
  86. else ifeq ($(BR2_aarch64),y)
  87. NODEJS_CPU = arm64
  88. # V8 needs to know what floating point ABI the target is using.
  89. NODEJS_ARM_FP = $(GCC_TARGET_FLOAT_ABI)
  90. endif
  91. # MIPS architecture specific options
  92. ifeq ($(BR2_mips)$(BR2_mipsel),y)
  93. ifeq ($(BR2_MIPS_CPU_MIPS32R6),y)
  94. NODEJS_MIPS_ARCH_VARIANT = r6
  95. NODEJS_MIPS_FPU_MODE = fp64
  96. else ifeq ($(BR2_MIPS_CPU_MIPS32R2),y)
  97. NODEJS_MIPS_ARCH_VARIANT = r2
  98. else ifeq ($(BR2_MIPS_CPU_MIPS32),y)
  99. NODEJS_MIPS_ARCH_VARIANT = r1
  100. endif
  101. endif
  102. define NODEJS_CONFIGURE_CMDS
  103. mkdir -p $(@D)/bin
  104. ln -sf $(HOST_DIR)/bin/python2 $(@D)/bin/python
  105. (cd $(@D); \
  106. $(TARGET_CONFIGURE_OPTS) \
  107. PATH=$(@D)/bin:$(BR_PATH) \
  108. LD="$(TARGET_CXX)" \
  109. PYTHON=$(HOST_DIR)/bin/python2 \
  110. $(HOST_DIR)/bin/python2 ./configure \
  111. --prefix=/usr \
  112. --dest-cpu=$(NODEJS_CPU) \
  113. $(if $(NODEJS_ARM_FP),--with-arm-float-abi=$(NODEJS_ARM_FP)) \
  114. $(if $(NODEJS_MIPS_ARCH_VARIANT),--with-mips-arch-variant=$(NODEJS_MIPS_ARCH_VARIANT)) \
  115. $(if $(NODEJS_MIPS_FPU_MODE),--with-mips-fpu-mode=$(NODEJS_MIPS_FPU_MODE)) \
  116. $(NODEJS_CONF_OPTS) \
  117. )
  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. npm_config_cache=$(BUILD_DIR)/.npm-cache \
  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))