1f8592b60eb1fb66164decf7823e06e79a516f52
[feed/routing.git] / cjdns / Makefile
1 #
2 # Copyright (C) 2014,2015 Hyperboria.net
3 #
4 # You may redistribute this program and/or modify it under the terms of
5 # the GNU General Public License as published by the Free Software Foundation,
6 # either version 3 of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 #
16
17 include $(TOPDIR)/rules.mk
18
19 PKG_NAME:=cjdns
20 PKG_VERSION:=v21.1
21 PKG_RELEASE:=4
22
23 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
24 PKG_SOURCE_URL:=https://codeload.github.com/cjdelisle/cjdns/tar.gz/$(PKG_NAME)-$(PKG_VERSION)?
25 PKG_HASH:=a6158ce7847159aa44e86f74ccc7b6ded6910a230ed8f3830db53cda5838f0b0
26 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_NAME)-$(PKG_VERSION)
27
28 PKG_MAINTAINER:=William Fleurant <meshnet@protonmail.com>
29 PKG_LICENSE:=GPL-3.0-or-later
30 PKG_LICENSE_FILES:=LICENSE
31
32 include $(INCLUDE_DIR)/package.mk
33
34 define Package/cjdns
35 SECTION:=net
36 CATEGORY:=Network
37 SUBMENU:=Routing and Redirection
38 TITLE:=Encrypted near-zero-conf mesh routing protocol
39 URL:=https://github.com/cjdelisle/cjdns
40 DEPENDS:=@!arc @IPV6 +kmod-tun +libnl-tiny +libpthread +librt \
41 +libuci-lua +lua-bencode +dkjson +luasocket +lua-sha2
42 endef
43
44 define Package/cjdns/description
45 Cjdns implements an encrypted IPv6 network using public-key cryptography \
46 for address allocation and a distributed hash table for routing. \
47 This provides near-zero-configuration networking, and prevents many \
48 of the security and scalability issues that plague existing networks.
49 endef
50
51 define Package/cjdns-tests
52 SECTION:=net
53 CATEGORY:=Network
54 SUBMENU:=Routing and Redirection
55 TITLE:=cjdns test cases
56 URL:=https://github.com/cjdelisle/cjdns
57 DEPENDS:=+libpthread +librt @!arc
58 endef
59
60 define Package/cjdns-test/description
61 Builds cjdns test cases binary test_testcjdroute_c
62 endef
63
64 define Build/Configure
65 endef
66
67 PKG_DO_VARS:=CJDNS_RELEASE_VERSION=$(PKG_SOURCE_VERSION)
68
69 ifneq ($(CONFIG_KERNEL_SECCOMP_FILTER),y)
70 PKG_DO_VARS+= Seccomp_NO=1
71 endif
72
73 ifneq ($(CONFIG_USE_UCLIBC),)
74 PKG_DO_VARS+= UCLIBC=1
75 endif
76
77 define Build/Compile
78 $(INSTALL_DIR) $(PKG_BUILD_DIR)/tmp
79 (cd $(PKG_BUILD_DIR) && \
80 CROSS="true" \
81 CC="$(TARGET_CC)" \
82 AR="$(TARGET_AR)" \
83 RANLIB="$(TARGET_RANLIB)" \
84 CFLAGS="$(TARGET_CFLAGS) -U_FORTIFY_SOURCE -Wno-error=array-bounds -Wno-error=stringop-overflow -Wno-error=stringop-overread" \
85 LDFLAGS="$(TARGET_LDFLAGS)" \
86 SYSTEM="linux" \
87 TARGET_ARCH="$(CONFIG_ARCH)" \
88 SSP_SUPPORT="$(CONFIG_SSP_SUPPORT)" \
89 GYP_ADDITIONAL_ARGS="-f make-linux" \
90 CJDNS_BUILD_TMPDIR="$(PKG_BUILD_DIR)/tmp" \
91 $(PKG_DO_VARS) \
92 exec ./do)
93 endef
94
95 define Package/cjdns/install
96 $(INSTALL_DIR) \
97 $(1)/usr/sbin \
98 $(1)/usr/bin \
99 $(1)/etc/config \
100 $(1)/etc/init.d \
101 $(1)/etc/uci-defaults \
102 $(1)/usr/lib/lua/cjdns
103
104 $(INSTALL_BIN) \
105 ./files/cjdrouteconf \
106 $(1)/usr/bin
107
108 $(INSTALL_BIN) \
109 $(PKG_BUILD_DIR)/cjdroute \
110 $(1)/usr/sbin
111
112 $(INSTALL_BIN) \
113 $(PKG_BUILD_DIR)/publictoip6 \
114 $(1)/usr/bin
115
116 $(INSTALL_BIN) \
117 ./files/cjdns.init \
118 $(1)/etc/init.d/cjdns
119
120 $(INSTALL_BIN) \
121 ./files/cjdns.defaults \
122 $(1)/etc/uci-defaults/cjdns
123
124 $(CP) \
125 ./lua/cjdns/* \
126 $(1)/usr/lib/lua/cjdns
127 endef
128
129 define Package/cjdns/postinst
130 #!/bin/sh
131 if [ -z $${IPKG_INSTROOT} ] ; then
132 ( . /etc/uci-defaults/cjdns ) && rm -f /etc/uci-defaults/cjdns
133 /etc/init.d/cjdns enabled || /etc/init.d/cjdns enable
134 exit 0
135 fi
136 endef
137
138 define Package/cjdns-tests/install
139 $(INSTALL_DIR) $(1)/usr/bin
140 $(INSTALL_BIN) \
141 $(PKG_BUILD_DIR)/build_linux/test_testcjdroute_c \
142 $(1)/usr/bin
143 endef
144
145 $(eval $(call BuildPackage,cjdns))
146 $(eval $(call BuildPackage,cjdns-tests))