summaryrefslogtreecommitdiffstats
path: root/net/meshtasticd/Makefile
blob: 8e796bc40fa26d4fd5ee5fc12ba63f3f587df7ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# SPDX-License-Identifier: GPL-2.0-only

include $(TOPDIR)/rules.mk

PKG_NAME:=meshtasticd
PKG_VERSION:=2.7.15
PKG_SOURCE_VERSION:=v$(PKG_VERSION).567b8ea
PKG_RELEASE:=2

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/meshtastic/firmware.git
PKG_MIRROR_HASH:=07a85f6fb62103e841b88fbc38c2ed235b12dab8310fe4fe619c8a1754a9aa22

FRONTEND_VERSION:=2.6.7
FRONTEND_DEST:=$(PKG_NAME)-frontend-$(FRONTEND_VERSION).tar
FRONTEND_URL:=https://github.com/meshtastic/web/releases/download/v$(FRONTEND_VERSION)/
FRONTEND_HASH:=a34f4360a0486543a698de20de533557492e763ab459fc27fcea95d0495144ed

PKG_BUILD_DEPENDS:= \
	python3/host \
	python-platformio/host \
	python-pyelftools/host \
	!USE_GLIBC:argp-standalone

PKG_MAINTAINER:=Austin Lane <vidplace7@gmail.com>, George Sapkin <george@sapk.in>
PKG_LICENSE:=GPL-3.0-only
PKG_LICENSE_FILES:=LICENSE

include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/python/python3-host.mk
include $(INCLUDE_DIR)/nls.mk

define Package/meshtasticd/Default
  SECTION:=net
  CATEGORY:=Network
  SUBMENU:=Meshtastic
  TITLE:=Meshtastic daemon
  URL:=https://github.com/meshtastic/firmware
endef

# Leaving a possibility for adding a light variant without the web UI support if
# it's made configurable upstream. Currently headers are autodetected so it's
# not possible to add it.
define Package/meshtasticd-full
  $(call Package/meshtasticd/Default)
  TITLE+= (with web UI support)
  DEPENDS:= \
    +bluez-libs \
    +kmod-spi-dev \
    +libgpiod \
    +libi2c \
    +libopenssl \
    +liborcania \
    +libulfius-gnutls \
    +libusb-1.0 \
    +libuv \
    +libyaml-cpp \
    +libyder \
    +zlib \
    $(INTL_DEPENDS)
  PROVIDES:=meshtasticd
endef

define Package/meshtasticd-avahi-service
  $(call Package/meshtasticd/Default)
  TITLE+= (avahi service)
  DEPENDS:= \
    +avahi-daemon \
    +meshtasticd
endef

define Package/meshtasticd-web
  $(call Package/meshtasticd/Default)
  TITLE:=Meshtastic daemon web interface
  URL:=https://github.com/meshtastic/web
  DEPENDS:=+meshtasticd-full
  VERSION:=$(FRONTEND_VERSION)-r$(PKG_RELEASE)
endef

define Package/meshtasticd-full/description
  Meshtastic daemon with web interface support
endef

define Package/meshtasticd-avahi-service/description
  Service definition for announcing the Meshtastic daemon via mDNS
endef

define Package/meshtasticd-web/description
  The official Meshtastic web interface
endef

define Download/meshtasticd-web
  URL:=$(FRONTEND_URL)
  URL_FILE:=build.tar
  FILE:=$(FRONTEND_DEST)
  HASH:=$(FRONTEND_HASH)
endef

PLATFORMIO_BUILD_FLAGS := \
	-fdata-sections \
	-ffunction-sections \
	-Os \
	-Wl,--gc-sections \
	-lcrypto \
	-lorcania \
	-lssl \
	-lulfius \
	-lyder \
	$(if $(CONFIG_USE_GLIBC),,-largp) \
	$(if $(INTL_FULL),-lintl)

BUILD_FLAGS := \
	TARGET_AR="$(TARGET_AR)" \
	TARGET_AS="$(TARGET_CC) -c $(TARGET_ASFLAGS)" \
	TARGET_CC="$(TARGET_CC)" \
	TARGET_CFLAGS="$(TARGET_CFLAGS)" \
	TARGET_CXX="$(TARGET_CXX)" \
	TARGET_CXXFLAGS="$(TARGET_CXXFLAGS)" \
	TARGET_LD="$(TARGET_LD)" \
	TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
	TARGET_OBJCOPY="$(TARGET_CROSS)objcopy" \
	TARGET_RANLIB="$(TARGET_RANLIB)" \
	PLATFORMIO_BUILD_CACHE_DIR="$(PKG_BUILD_DIR)/.pio-build-cache" \
	PLATFORMIO_CACHE_DIR="$(DL_DIR)/platformio-cache"

define Build/Prepare/meshtasticd-web
	mkdir -p $(PKG_BUILD_DIR)/web
	$(HOST_TAR) -xf $(DL_DIR)/$(FRONTEND_DEST) -C $(PKG_BUILD_DIR)/web
	gzip -dr $(PKG_BUILD_DIR)/web/
endef

define Build/Prepare
	$(call Build/Prepare/Default)
	$(call Build/Prepare/meshtasticd-web)
endef

define Build/Compile/meshtasticd-full
	mkdir -p $(PKG_BUILD_DIR)/full

	$(BUILD_FLAGS) \
	PLATFORMIO_BUILD_DIR="$(PKG_BUILD_DIR)/full" \
	PLATFORMIO_BUILD_FLAGS="$(PLATFORMIO_BUILD_FLAGS)" \
	$(HOST_PYTHON3_BIN) -m platformio run \
		--environment buildroot \
		--project-dir $(PKG_BUILD_DIR)
endef

define Build/Compile
	$(call Build/Compile/meshtasticd-full)
endef

define Package/meshtasticd-full/install
	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_CONF) ./files/meshtasticd.conf $(1)/etc/config/meshtasticd

	$(INSTALL_DIR) $(1)/etc/meshtasticd
	$(INSTALL_CONF) $(PKG_BUILD_DIR)/bin/config-dist.yaml $(1)/etc/meshtasticd/config.yaml

	$(INSTALL_DIR) $(1)/etc/meshtasticd/available.d
	$(CP) -R $(PKG_BUILD_DIR)/bin/config.d/* $(1)/etc/meshtasticd/available.d

	$(INSTALL_DIR) $(1)/etc/meshtasticd/config.d

	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/meshtasticd.init $(1)/etc/init.d/meshtasticd

	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/full/buildroot/program $(1)/usr/bin/meshtasticd
endef

define Package/meshtasticd-avahi-service/install
	$(INSTALL_DIR) $(1)/etc/avahi/services
	$(INSTALL_CONF) ./files/meshtasticd.service $(1)/etc/avahi/services/
endef

define Package/meshtasticd-web/install
	$(INSTALL_DIR) $(1)/usr/share/meshtasticd/web
	$(CP) $(PKG_BUILD_DIR)/web/* $(1)/usr/share/meshtasticd/web

	$(INSTALL_DIR) $(1)/etc/meshtasticd/ssl
endef

define Package/meshtasticd-full/conffiles
/etc/config/meshtasticd
/etc/meshtasticd/config.d/
/etc/meshtasticd/config.yaml
/etc/meshtasticd/ssl
endef

define Package/meshtasticd-avahi-service/conffiles
/etc/avahi/services/meshtasticd.service
endef

$(eval $(call Download,meshtasticd-web))
$(eval $(call BuildPackage,meshtasticd-full))
$(eval $(call BuildPackage,meshtasticd-avahi-service))
$(eval $(call BuildPackage,meshtasticd-web))