openthread-br: fix actually building
[feed/packages.git] / lang / node-homebridge / Makefile
1 # This is free software, licensed under the GNU General Public License v2.
2 # See /LICENSE for more information.
3 #
4
5 include $(TOPDIR)/rules.mk
6
7 PKG_NPM_NAME:=homebridge
8 PKG_NAME:=node-$(PKG_NPM_NAME)
9 PKG_VERSION:=1.2.4
10 PKG_RELEASE:=2
11
12 PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
13 PKG_SOURCE_URL:=https://registry.npmjs.org/$(PKG_NPM_NAME)/-/
14 PKG_HASH:=f91ab0058707a0498d97d87f45f19682065f80660fac942e0985caf9bb205f2a
15
16 PKG_BUILD_DEPENDS:=node/host
17 PKG_BUILD_FLAGS:=no-mips16
18
19 PKG_MAINTAINER:=Hirokazu MORIKAWA <morikw2@gmail.com>
20 PKG_LICENSE:=ISC Apache-2.0
21 PKG_LICENSE_FILES:=LICENSE
22
23 include $(INCLUDE_DIR)/package.mk
24
25 define Package/node-homebridge
26 SUBMENU:=Node.js
27 SECTION:=lang
28 CATEGORY:=Languages
29 TITLE:=Node.js HomeKit Server
30 URL:=https://www.npmjs.org/package/homebridge
31 DEPENDS:=+node +node-npm
32 USERID:=homebridge:homebridge
33 endef
34
35 define Package/node-homebridge/description
36 Homebridge is a lightweight Node.js server you can run on your home network that emulates the iOS HomeKit API
37 *** You need to install avahi-nodbus-daemon or avahi-dbus-daemon or umdns or mdnsd package. ***
38 endef
39
40 TAR_OPTIONS+= --strip-components 1
41 TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
42
43 NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))))
44 TMPNPM:=$(shell mktemp -u XXXXXXXXXX)
45
46 TARGET_CFLAGS+=$(FPIC)
47 TARGET_CPPFLAGS+=$(FPIC)
48
49 NPM_FLAGS=$(MAKE_VARS) \
50 $(MAKE_FLAGS) \
51 npm_config_arch=$(NODEJS_CPU) \
52 npm_config_target_arch=$(NODEJS_CPU) \
53 npm_config_build_from_source=true \
54 npm_config_nodedir=$(STAGING_DIR)/usr/ \
55 npm_config_prefix=$(PKG_INSTALL_DIR)/usr/ \
56 npm_config_cache=$(TMP_DIR)/npm-cache-$(TMPNPM) \
57 npm_config_tmp=$(TMP_DIR)/npm-tmp-$(TMPNPM)
58
59 define Build/Compile
60 $(NPM_FLAGS) npm i -g --production $(PKG_BUILD_DIR)
61 $(NPM_FLAGS) npm i --production --prefix=$(PKG_BUILD_DIR) --target_arch=$(NODEJS_CPU) --prefer-dedupe
62 npm install -g $(PKG_BUILD_DIR)
63 rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
64 rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
65 endef
66
67 define Package/node-homebridge/install
68 $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)
69 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{*.json,*.md} \
70 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
71 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{node_modules,lib} \
72 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
73 $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{LICENSE,bin} \
74 $(1)/usr/lib/node/$(PKG_NPM_NAME)/
75 $(INSTALL_DIR) $(1)/usr/bin
76 $(LN) ../lib/node/$(PKG_NPM_NAME)/bin/homebridge $(1)/usr/bin/homebridge
77 $(INSTALL_DIR) $(1)/etc/init.d
78 $(INSTALL_BIN) ./files/homebridge.init $(1)/etc/init.d/homebridge
79 endef
80
81 $(eval $(call BuildPackage,node-homebridge))