treewide: refactor to use PKG_BUILD_FLAGS:=no-mips16
[feed/packages.git] / lang / node-arduino-firmata / 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:=arduino-firmata
11 PKG_NAME:=node-$(PKG_NPM_NAME)
12 PKG_VERSION:=0.3.4
13 PKG_RELEASE:=4
14
15 PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
16 PKG_SOURCE_URL:=https://registry.npmjs.org/$(PKG_NPM_NAME)/-/
17 PKG_HASH:=d7157e02867eae82887cb5e17b90c963fe7489bacd464110bfd20c672b8d5a98
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.txt
25
26 include $(INCLUDE_DIR)/package.mk
27
28 define Package/node-arduino-firmata
29 SUBMENU:=Node.js
30 SECTION:=lang
31 CATEGORY:=Languages
32 TITLE:=Arduino Firmata implementation for Node.js
33 URL:=https://www.npmjs.com/package/arduino-firmata
34 DEPENDS:=+node +node-npm +node-serialport
35 endef
36
37 define Package/node-arduino-firmata/description
38 Arduino Firmata protocol (http://firmata.org) implementation on Node.js.
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:= \
51 $(MAKE_VARS) \
52 $(MAKE_FLAGS) \
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)
60
61 define Build/Compile
62 $(NPM_FLAGS) npm i -g --production $(PKG_BUILD_DIR)
63 $(NPM_FLAGS) npm i --production --prefix=$(PKG_BUILD_DIR) --target_arch=$(NODEJS_CPU) --prefer-dedupe
64 rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
65 rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
66 endef
67
68 define Package/node-arduino-firmata/install
69 $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)
70 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{package.json,README.md} \
71 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
72 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{tests,*.txt} \
73 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
74 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{node_modules,lib} \
75 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
76 $(CP) ./files/* $(1)/
77 endef
78
79 $(eval $(call BuildPackage,node-arduino-firmata))