nodejs.mk 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. ################################################################################
  2. #
  3. # nodejs
  4. #
  5. ################################################################################
  6. NODEJS_VERSION = $(call qstrip,$(BR2_PACKAGE_NODEJS_VERSION_STRING))
  7. ifeq ($(BR2_PACKAGE_NODEJS_5_X),y)
  8. NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.xz
  9. else
  10. NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.gz
  11. endif
  12. NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION)
  13. NODEJS_DEPENDENCIES = host-python host-nodejs zlib \
  14. $(call qstrip,$(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL_DEPS))
  15. HOST_NODEJS_DEPENDENCIES = host-python host-zlib
  16. NODEJS_LICENSE = MIT (core code); MIT, Apache and BSD family licenses (Bundled components)
  17. NODEJS_LICENSE_FILES = LICENSE
  18. ifeq ($(BR2_PACKAGE_OPENSSL),y)
  19. NODEJS_DEPENDENCIES += openssl
  20. endif
  21. # nodejs build system is based on python, but only support python-2.6 or
  22. # python-2.7. So, we have to enforce PYTHON interpreter to be python2.
  23. define HOST_NODEJS_CONFIGURE_CMDS
  24. # Build with the static, built-in OpenSSL which is supplied as part of
  25. # the nodejs source distribution. This is needed on the host because
  26. # NPM is non-functional without it, and host-openssl isn't part of
  27. # buildroot.
  28. (cd $(@D); \
  29. $(HOST_CONFIGURE_OPTS) \
  30. PYTHON=$(HOST_DIR)/usr/bin/python2 \
  31. $(HOST_DIR)/usr/bin/python2 ./configure \
  32. --prefix=$(HOST_DIR)/usr \
  33. --without-snapshot \
  34. --without-dtrace \
  35. --without-etw \
  36. --shared-zlib \
  37. )
  38. endef
  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. define HOST_NODEJS_INSTALL_CMDS
  45. $(HOST_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
  46. $(MAKE) -C $(@D) install \
  47. $(HOST_CONFIGURE_OPTS)
  48. endef
  49. ifeq ($(BR2_i386),y)
  50. NODEJS_CPU = ia32
  51. else ifeq ($(BR2_x86_64),y)
  52. NODEJS_CPU = x64
  53. else ifeq ($(BR2_mips),y)
  54. NODEJS_CPU = mips
  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. # MIPS architecture specific options
  63. ifeq ($(BR2_mips)$(BR2_mipsel),y)
  64. ifeq ($(BR2_mips_32r6),y)
  65. NODEJS_MIPS_ARCH_VARIANT = r6
  66. NODEJS_MIPS_FPU_MODE = fp64
  67. else ifeq ($(BR2_mips_32r2),y)
  68. NODEJS_MIPS_ARCH_VARIANT = r2
  69. else ifeq ($(BR2_mips_32),y)
  70. NODEJS_MIPS_ARCH_VARIANT = r1
  71. endif
  72. endif
  73. define NODEJS_CONFIGURE_CMDS
  74. (cd $(@D); \
  75. $(TARGET_CONFIGURE_OPTS) \
  76. LD="$(TARGET_CXX)" \
  77. PYTHON=$(HOST_DIR)/usr/bin/python2 \
  78. $(HOST_DIR)/usr/bin/python2 ./configure \
  79. --prefix=/usr \
  80. --without-snapshot \
  81. --shared-zlib \
  82. $(if $(BR2_PACKAGE_OPENSSL),--shared-openssl,--without-ssl) \
  83. $(if $(BR2_PACKAGE_NODEJS_NPM),,--without-npm) \
  84. --without-dtrace \
  85. --without-etw \
  86. --dest-cpu=$(NODEJS_CPU) \
  87. $(if $(NODEJS_ARM_FP),--with-arm-float-abi=$(NODEJS_ARM_FP)) \
  88. $(if $(NODEJS_MIPS_ARCH_VARIANT),--with-mips-arch-variant=$(NODEJS_MIPS_ARCH_VARIANT)) \
  89. $(if $(NODEJS_MIPS_FPU_MODE),--with-mips-fpu-mode=$(NODEJS_MIPS_FPU_MODE)) \
  90. --dest-os=linux \
  91. )
  92. endef
  93. define NODEJS_BUILD_CMDS
  94. $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
  95. $(MAKE) -C $(@D) \
  96. $(TARGET_CONFIGURE_OPTS) \
  97. LD="$(TARGET_CXX)"
  98. endef
  99. #
  100. # Build the list of modules to install based on the booleans for
  101. # popular modules, as well as the "additional modules" list.
  102. #
  103. NODEJS_MODULES_LIST= $(call qstrip,\
  104. $(if $(BR2_PACKAGE_NODEJS_MODULES_EXPRESS),express) \
  105. $(if $(BR2_PACKAGE_NODEJS_MODULES_COFFEESCRIPT),coffee-script) \
  106. $(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL))
  107. # Define NPM for other packages to use
  108. NPM = $(TARGET_CONFIGURE_OPTS) \
  109. LD="$(TARGET_CXX)" \
  110. npm_config_arch=$(NODEJS_CPU) \
  111. npm_config_target_arch=$(NODEJS_CPU) \
  112. npm_config_build_from_source=true \
  113. npm_config_nodedir=$(BUILD_DIR)/nodejs-$(NODEJS_VERSION) \
  114. npm_config_prefix=$(TARGET_DIR)/usr \
  115. $(HOST_DIR)/usr/bin/npm
  116. #
  117. # We can only call NPM if there's something to install.
  118. #
  119. ifneq ($(NODEJS_MODULES_LIST),)
  120. define NODEJS_INSTALL_MODULES
  121. # If you're having trouble with module installation, adding -d to the
  122. # npm install call below and setting npm_config_rollback=false can both
  123. # help in diagnosing the problem.
  124. $(NPM) install -g $(NODEJS_MODULES_LIST)
  125. endef
  126. endif
  127. define NODEJS_INSTALL_TARGET_CMDS
  128. $(TARGET_MAKE_ENV) PYTHON=$(HOST_DIR)/usr/bin/python2 \
  129. $(MAKE) -C $(@D) install \
  130. DESTDIR=$(TARGET_DIR) \
  131. $(TARGET_CONFIGURE_OPTS) \
  132. LD="$(TARGET_CXX)"
  133. $(NODEJS_INSTALL_MODULES)
  134. endef
  135. # node.js configure is a Python script and does not use autotools
  136. $(eval $(generic-package))
  137. $(eval $(host-generic-package))