2 # Copyright (C) 2015 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR
)/rules.mk
10 PKG_NPM_NAME
:=node-hid
11 PKG_NAME
:=$(PKG_NPM_NAME
)
15 PKG_SOURCE
:=$(PKG_NPM_NAME
)-$(PKG_VERSION
).tgz
16 PKG_SOURCE_URL
:=https
://registry.npmjs.org
/$(PKG_NPM_NAME
)/-/
17 PKG_HASH
:=6c1f05935215feed4e8d2f4aecf31abbad8fa783d252b0bd6041ed2f2e96e9ba
19 PKG_BUILD_DEPENDS
:=node
/host
20 PKG_BUILD_FLAGS
:=no-mips16
22 PKG_MAINTAINER
:=Hirokazu MORIKAWA
<morikw2@gmail.com
>
23 PKG_LICENSE
:=MIT or X11
26 include $(INCLUDE_DIR
)/package.mk
27 include $(INCLUDE_DIR
)/nls.mk
29 define Package
/node-hid
33 TITLE
:=Node.js package to access HID devices
34 URL
:=https
://www.npmjs.com
/package
/node-hid
35 DEPENDS
:=+node
+node-npm
+libusb-1.0
+libudev
$(ICONV_DEPENDS
)
38 define Package
/node-hid
/description
39 Node.js package to access HID devices
42 TAR_OPTIONS
+= --strip-components
1
43 TAR_CMD
=$(HOST_TAR
) -C
$(1) $(TAR_OPTIONS
)
45 NODEJS_CPU
:=$(subst powerpc
,ppc
,$(subst aarch64
,arm64
,$(subst x86_64
,x64
,$(subst i386
,ia32
,$(ARCH
)))))
46 TMPNPM
:=$(shell mktemp
-u XXXXXXXXXX
)
48 TARGET_CFLAGS
+=$(FPIC
) -I
$(STAGING_DIR
)/usr
/include/libusb-1.0
49 TARGET_LDFLAGS
+=$(if
$(ICONV_FULL
),-liconv
)
51 NPM_FLAGS
=$(MAKE_VARS
) \
53 npm_config_arch
=$(NODEJS_CPU
) \
54 npm_config_target_arch
=$(NODEJS_CPU
) \
55 npm_config_build_from_source
=true \
56 npm_config_nodedir
=$(STAGING_DIR
)/usr
/ \
57 npm_config_prefix
=$(PKG_INSTALL_DIR
)/usr
/ \
58 npm_config_cache
=$(TMP_DIR
)/npm-cache-
$(TMPNPM
) \
59 npm_config_tmp
=$(TMP_DIR
)/npm-tmp-
$(TMPNPM
)
62 $(NPM_FLAGS
) npm i
-g
--production
$(PKG_BUILD_DIR
) --ignore-scripts
63 GYP_DEFINES
='driver="hidraw"' \
64 $(NPM_FLAGS
) npm i
--production
--prefix=$(PKG_BUILD_DIR
) --target_arch
=$(NODEJS_CPU
) --prefer-dedupe
65 rm -rf
$(TMP_DIR
)/npm-tmp-
$(TMPNPM
)
66 rm -rf
$(TMP_DIR
)/npm-cache-
$(TMPNPM
)
69 define Package
/node-hid
/install
70 $(INSTALL_DIR
) $(1)/usr
/lib
/node
/$(PKG_NPM_NAME
)
71 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/node_modules
/$(PKG_NPM_NAME
)/{package.json
,*.md
,*.js
} \
72 $(1)/usr
/lib
/node
/$(PKG_NPM_NAME
)/
73 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/node_modules
/$(PKG_NPM_NAME
)/{node_modules
,src
} \
74 $(1)/usr
/lib
/node
/$(PKG_NPM_NAME
)/
75 $(INSTALL_DIR
) $(1)/usr
/lib
/node
/$(PKG_NPM_NAME
)/build
/Release
76 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/node_modules
/$(PKG_NPM_NAME
)/build
/Release
/HID
*.node \
77 $(1)/usr
/lib
/node
/$(PKG_NPM_NAME
)/build
/Release
/
78 $(INSTALL_DIR
) $(1)/usr
/bin
79 $(LN
) ..
/lib
/node
/$(PKG_NPM_NAME
)/src
/show-devices.js
$(1)/usr
/bin
/hid-showdevices
82 $(eval
$(call BuildPackage
,node-hid
))