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.

82 lines
2.6 KiB

  1. #
  2. # Copyright (C) 2015 OpenWrt.org
  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:=node-hid
  9. PKG_NAME:=$(PKG_NPM_NAME)
  10. PKG_VERSION:=1.2.0
  11. PKG_RELEASE:=1
  12. PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
  13. PKG_SOURCE_URL:=https://registry.npmjs.org/$(PKG_NPM_NAME)/-/
  14. PKG_HASH:=b4a3e4c5a42dcdb4b6ef3ceeec18ed073322e8bca4160b95ef1671b062796bde
  15. PKG_BUILD_DEPENDS:=node/host
  16. PKG_USE_MIPS16:=0
  17. PKG_MAINTAINER:=Hirokazu MORIKAWA <morikw2@gmail.com>
  18. PKG_LICENSE:=MIT or X11
  19. PKG_LICENSE_FILES:=
  20. include $(INCLUDE_DIR)/package.mk
  21. include $(INCLUDE_DIR)/nls.mk
  22. define Package/node-hid
  23. SUBMENU:=Node.js
  24. SECTION:=lang
  25. CATEGORY:=Languages
  26. TITLE:=Node.js package to access HID devices
  27. URL:=https://github.com/node-hid/node-hid
  28. DEPENDS:=+node +node-npm +libusb-1.0 +hidapi +libudev-fbsd $(ICONV_DEPENDS)
  29. endef
  30. define Package/node-hid/description
  31. Node.js package to access HID devices
  32. endef
  33. TAR_OPTIONS+= --strip-components 1
  34. TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
  35. NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))))
  36. TMPNPM:=$(shell mktemp -u XXXXXXXXXX)
  37. TARGET_CFLAGS+=$(FPIC) -I$(STAGING_DIR)/usr/include/libusb-1.0
  38. TARGET_LDFLAGS+=$(if $(ICONV_FULL),-liconv)
  39. define Build/Compile
  40. git init $(PKG_BUILD_DIR)
  41. $(MAKE_VARS) \
  42. $(MAKE_FLAGS) \
  43. npm_config_arch=$(NODEJS_CPU) \
  44. npm_config_target_arch=$(NODEJS_CPU) \
  45. npm_config_build_from_source=true \
  46. npm_config_nodedir=$(STAGING_DIR)/usr/ \
  47. npm_config_prefix=$(PKG_INSTALL_DIR)/usr/ \
  48. npm_config_cache=$(TMP_DIR)/npm-cache-$(TMPNPM) \
  49. npm_config_tmp=$(TMP_DIR)/npm-tmp-$(TMPNPM) \
  50. npm install -g $(PKG_BUILD_DIR)
  51. rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
  52. rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
  53. endef
  54. define Package/node-hid/install
  55. $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)
  56. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{package.json,*.md} \
  57. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  58. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{binding.gyp,*.js} \
  59. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  60. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{node_modules,src} \
  61. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  62. $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)/build/Release
  63. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/build/Release/HID*.node \
  64. $(1)/usr/lib/node/$(PKG_NPM_NAME)/build/Release/
  65. $(INSTALL_DIR) $(1)/usr/bin
  66. $(LN) ../lib/node/node-hid/src/show-devices.js $(1)/usr/bin/hid-showdevices
  67. endef
  68. $(eval $(call BuildPackage,node-hid))