treewide: refactor to use PKG_BUILD_FLAGS:=no-mips16
[feed/packages.git] / lang / node-serialport / Makefile
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
8 include $(TOPDIR)/rules.mk
9
10 PKG_NPM_NAME:=serialport
11 PKG_NAME:=node-$(PKG_NPM_NAME)
12 PKG_VERSION:=9.0.4
13 PKG_RELEASE:=2
14
15 PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
16 PKG_SOURCE_URL:=https://registry.npmjs.org/$(PKG_NPM_NAME)/-/
17 PKG_HASH:=e19fe993ad16ae0e03fc42e24cfe4babf8fd90f8358e1885d5e216277dda1086
18
19 PKG_BUILD_DEPENDS:=node/host
20 PKG_BUILD_FLAGS:=no-mips16
21
22 PKG_MAINTAINER:=Hirokazu MORIKAWA <morikw2@gmail.com>
23 PKG_LICENSE:=MIT
24 PKG_LICENSE_FILES:=LICENSE
25
26 include $(INCLUDE_DIR)/package.mk
27
28 define Package/node-serialport
29 SUBMENU:=Node.js
30 SECTION:=lang
31 CATEGORY:=Languages
32 TITLE:=Node.js package to access serial ports
33 URL:=https://serialport.io/
34 DEPENDS:=+node +node-npm +node-serialport-bindings
35 endef
36
37 define Package/node-serialport/description
38 Node.js package to access serial ports for reading and writing OR Welcome your robotic JavaScript overlords. Better yet, program them!
39 endef
40
41 TAR_OPTIONS+= --strip-components 1
42 TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
43
44 NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))))
45 TMPNPM:=$(shell mktemp -u XXXXXXXXXX)
46
47 TARGET_CFLAGS+=$(FPIC)
48 TARGET_CPPFLAGS+=$(FPIC)
49
50 NPM_FLAGS=$(MAKE_VARS) \
51 $(MAKE_FLAGS) \
52 npm_config_arch=$(NODEJS_CPU) \
53 npm_config_target_arch=$(NODEJS_CPU) \
54 npm_config_build_from_source=true \
55 npm_config_nodedir=$(STAGING_DIR)/usr/ \
56 npm_config_prefix=$(PKG_INSTALL_DIR)/usr/ \
57 npm_config_cache=$(TMP_DIR)/npm-cache-$(TMPNPM) \
58 npm_config_tmp=$(TMP_DIR)/npm-tmp-$(TMPNPM)
59
60 define Build/Compile
61 $(NPM_FLAGS) npm i -g --production $(PKG_BUILD_DIR)
62 $(NPM_FLAGS) npm i --production --prefix=$(PKG_BUILD_DIR) --target_arch=$(NODEJS_CPU) --prefer-dedupe
63 rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
64 rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
65 endef
66
67 define Package/node-serialport/install
68 $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)
69 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{package.json,LICENSE,*.md} \
70 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
71 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/*.js \
72 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
73 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{node_modules,lib} \
74 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
75 endef
76
77 $(eval $(call BuildPackage,node-serialport))