You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.3 KiB

  1. #
  2. # Copyright (C) 2014 Arduino LLC
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NPM_NAME:=serialport
  9. PKG_NAME:=node-$(PKG_NPM_NAME)
  10. PKG_VERSION:=6.1.1
  11. PKG_RELEASE:=2
  12. PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
  13. PKG_SOURCE_URL:=http://registry.npmjs.org/$(PKG_NPM_NAME)/-/
  14. PKG_HASH:=b58c326d217fb0af1639e4ea834d9fca4be16934c486499e2ddac6e52b8dd560
  15. PKG_BUILD_DEPENDS:=node/host
  16. PKG_NODE_VERSION:=`$(STAGING_DIR_HOSTPKG)/bin/node --version`
  17. PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
  18. PKG_LICENSE:=Custom
  19. PKG_LICENSE_FILES:=LICENSE
  20. include $(INCLUDE_DIR)/package.mk
  21. define Package/node-serialport
  22. SUBMENU:=Node.js
  23. SECTION:=lang
  24. CATEGORY:=Languages
  25. TITLE:=Node.js package to access serial ports for reading and writing
  26. URL:=https://www.npmjs.org/package/serialport
  27. DEPENDS:=+node +node-npm
  28. endef
  29. define Package/node-serialport/description
  30. Node.js package to access serial ports for reading and writing OR Welcome your robotic JavaScript overlords. Better yet, program them!
  31. endef
  32. define Build/Prepare
  33. /bin/tar xzf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) --strip-components 1
  34. $(Build/Patch)
  35. endef
  36. CPU:=$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))
  37. EXTRA_LDFLAGS="-L$(TOOLCHAIN_DIR)/lib/ -Wl,-rpath-link $(TOOLCHAIN_DIR)/lib/" \
  38. define Build/Compile
  39. cd $(PKG_BUILD_DIR) ; \
  40. $(MAKE_FLAGS) \
  41. npm_config_arch=$(CONFIG_ARCH) \
  42. npm_config_nodedir=$(BUILD_DIR)/node-$(PKG_NODE_VERSION)/ \
  43. npm_config_cache=$(BUILD_DIR)/node-$(PKG_NODE_VERSION)/npm-cache \
  44. PREFIX="$(PKG_INSTALL_DIR)/usr/" \
  45. npm install --build-from-source --target_arch=$(CPU) -g \
  46. `npm pack $(PKG_BUILD_DIR) | tail -n 1`
  47. endef
  48. define Package/node-serialport/install
  49. mkdir -p $(1)/usr/lib/node/
  50. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/* $(1)/usr/lib/node/
  51. $(RM) -rf $(1)/usr/lib/node/node-hid/patches \
  52. $(1)/usr/lib/node/node-hid/.p* \
  53. $(1)/usr/lib/node/node-hid/.quilt* \
  54. $(1)/usr/lib/node/node-hid/.built* \
  55. $(1)/usr/lib/node/node-hid/.config*
  56. # Strip PKG_BUILD_DIR from useless metadata inserted by npm install
  57. # https://github.com/npm/npm/issues/10393
  58. # https://github.com/npm/npm/issues/12110
  59. find $(1)/usr/lib/node -name package.json -exec sed -i -e 's,$(PKG_BUILD_DIR),,g' {} +
  60. endef
  61. $(eval $(call BuildPackage,node-serialport))