55c00a0d6d941abb614dd4e69adf8a7802f05589
[openwrt/staging/chunkeey.git] / package / network / utils / iproute2 / Makefile
1 #
2 # Copyright (C) 2006-2015 OpenWrt.org
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_NAME:=iproute2
11 PKG_VERSION:=5.15.0
12 PKG_RELEASE:=$(AUTORELEASE)
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
16 PKG_HASH:=38e3e4a5f9a7f5575c015027a10df097c149111eeb739993128e5b2b35b291ff
17 PKG_BUILD_PARALLEL:=1
18 PKG_BUILD_DEPENDS:=iptables
19 PKG_LICENSE:=GPL-2.0
20 PKG_CPE_ID:=cpe:/a:iproute2_project:iproute2
21
22 include $(INCLUDE_DIR)/kernel.mk
23 include $(INCLUDE_DIR)/package.mk
24 include $(INCLUDE_DIR)/nls.mk
25
26 define Package/iproute2/Default
27 SECTION:=net
28 CATEGORY:=Network
29 URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
30 SUBMENU:=Routing and Redirection
31 MAINTAINER:=Russell Senior <russell@personaltelco.net>
32 endef
33
34 define Package/ip-tiny
35 $(call Package/iproute2/Default)
36 TITLE:=Routing control utility (minimal)
37 VARIANT:=iptiny
38 DEFAULT_VARIANT:=1
39 PROVIDES:=ip
40 ALTERNATIVES:=200:/sbin/ip:/usr/libexec/ip-tiny
41 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
42 endef
43
44 define Package/ip-full
45 $(call Package/iproute2/Default)
46 TITLE:=Routing control utility (full)
47 VARIANT:=ipfull
48 PROVIDES:=ip
49 ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full
50 DEPENDS:=+libnl-tiny +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
51 endef
52
53 define Package/tc-tiny
54 $(call Package/iproute2/Default)
55 TITLE:=Traffic control utility (minimal)
56 VARIANT:=tctiny
57 DEFAULT_VARIANT:=1
58 PROVIDES:=tc
59 ALTERNATIVES:=200:/sbin/tc:/usr/libexec/tc-tiny
60 DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl
61 endef
62
63 define Package/tc-bpf
64 $(call Package/iproute2/Default)
65 TITLE:=Traffic control utility (bpf)
66 VARIANT:=tcbpf
67 PROVIDES:=tc
68 ALTERNATIVES:=300:/sbin/tc:/usr/libexec/tc-bpf
69 DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf
70 endef
71
72 define Package/tc-full
73 $(call Package/iproute2/Default)
74 TITLE:=Traffic control utility (full)
75 VARIANT:=tcfull
76 PROVIDES:=tc
77 ALTERNATIVES:=400:/sbin/tc:/usr/libexec/tc-full
78 DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf +libxtables +tc-mod-iptables
79 endef
80
81 define Package/tc-mod-iptables
82 $(call Package/iproute2/Default)
83 TITLE:=Traffic control module - iptables action
84 VARIANT:=tcfull
85 DEPENDS:=+libxtables
86 endef
87
88 define Package/genl
89 $(call Package/iproute2/Default)
90 TITLE:=General netlink utility frontend
91 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
92 endef
93
94 define Package/ip-bridge
95 $(call Package/iproute2/Default)
96 TITLE:=Bridge configuration utility from iproute2
97 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
98 endef
99
100 define Package/ss
101 $(call Package/iproute2/Default)
102 TITLE:=Socket statistics utility
103 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +kmod-netlink-diag
104 endef
105
106 define Package/nstat
107 $(call Package/iproute2/Default)
108 TITLE:=Network statistics utility
109 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
110 endef
111
112 define Package/devlink
113 $(call Package/iproute2/Default)
114 TITLE:=Network devlink utility
115 DEPENDS:=+libmnl
116 endef
117
118 define Package/rdma
119 $(call Package/iproute2/Default)
120 TITLE:=Network rdma utility
121 DEPENDS:=+libmnl
122 endef
123
124 ifeq ($(BUILD_VARIANT),iptiny)
125 IP_CONFIG_TINY:=y
126 LIBBPF_FORCE:=off
127 endif
128
129 ifeq ($(BUILD_VARIANT),ipfull)
130 HAVE_ELF:=y
131 LIBBPF_FORCE:=on
132 endif
133
134 ifeq ($(BUILD_VARIANT),tctiny)
135 LIBBPF_FORCE:=off
136 endif
137
138 ifeq ($(BUILD_VARIANT),tcbpf)
139 HAVE_ELF:=y
140 LIBBPF_FORCE:=on
141 SHARED_LIBS:=y
142 endif
143
144 ifeq ($(BUILD_VARIANT),tcfull)
145 #enable iptables/xtables requirement only if tciptables variant is selected
146 TC_CONFIG_XT:=y
147 TC_CONFIG_XT_OLD:=y
148 TC_CONFIG_XT_OLD_H:=y
149 TC_CONFIG_IPSET:=y
150 HAVE_ELF:=y
151 LIBBPF_FORCE:=on
152 SHARED_LIBS:=y
153 else
154 #disable iptables requirement by default
155 TC_CONFIG_XT:=n
156 TC_CONFIG_XT_OLD:=n
157 TC_CONFIG_XT_OLD_H:=n
158 TC_CONFIG_IPSET:=n
159 endif
160
161 ifdef CONFIG_PACKAGE_devlink
162 HAVE_MNL:=y
163 endif
164
165 ifdef CONFIG_PACKAGE_rdma
166 HAVE_MNL:=y
167 endif
168
169 define Build/Configure
170 echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
171 > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
172 endef
173
174 TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
175 TARGET_LDFLAGS += -Wl,--gc-sections -Wl,--as-needed
176 TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
177
178 MAKE_FLAGS += \
179 KERNEL_INCLUDE="$(LINUX_DIR)/user_headers/include" \
180 SHARED_LIBS=$(SHARED_LIBS) \
181 IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
182 BUILD_VARIANT=$(BUILD_VARIANT) \
183 LIBBPF_FORCE=$(LIBBPF_FORCE) \
184 HAVE_ELF=$(HAVE_ELF) \
185 HAVE_MNL=$(HAVE_MNL) \
186 HAVE_CAP=$(HAVE_CAP) \
187 IPT_LIB_DIR=/usr/lib/iptables \
188 XT_LIB_DIR=/usr/lib/iptables \
189 TC_CONFIG_XT=$(TC_CONFIG_XT) \
190 TC_CONFIG_XT_OLD=$(TC_CONFIG_XT_OLD) \
191 TC_CONFIG_XT_OLD_H=$(TC_CONFIG_XT_OLD_H) \
192 TC_CONFIG_IPSET=$(TC_CONFIG_IPSET) \
193 FPIC="$(FPIC)" \
194 $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
195
196 define Build/Compile
197 +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
198 endef
199
200 define Build/InstallDev
201 $(INSTALL_DIR) $(1)/usr/include/iproute2
202 $(CP) $(PKG_BUILD_DIR)/include/bpf_elf.h $(1)/usr/include/iproute2
203 $(CP) $(PKG_BUILD_DIR)/include/{libgenl,libnetlink}.h $(1)/usr/include/
204 $(INSTALL_DIR) $(1)/usr/lib
205 $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
206 endef
207
208 define Package/ip-tiny/install
209 $(INSTALL_DIR) $(1)/usr/libexec
210 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-tiny
211 endef
212
213 define Package/ip-full/install
214 $(INSTALL_DIR) $(1)/usr/libexec
215 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-full
216 endef
217
218 define Package/tc-tiny/install
219 $(INSTALL_DIR) $(1)/usr/libexec
220 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-tiny
221 endef
222
223 define Package/tc-bpf/install
224 $(INSTALL_DIR) $(1)/usr/libexec
225 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-bpf
226 endef
227
228 define Package/tc-full/install
229 $(INSTALL_DIR) $(1)/usr/libexec
230 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-full
231 endef
232
233 define Package/tc-mod-iptables/install
234 $(INSTALL_DIR) $(1)/usr/lib/tc
235 $(CP) $(PKG_BUILD_DIR)/tc/m_xt.so $(1)/usr/lib/tc
236 endef
237
238 define Package/genl/install
239 $(INSTALL_DIR) $(1)/usr/sbin
240 $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
241 endef
242
243 define Package/ip-bridge/install
244 $(INSTALL_DIR) $(1)/usr/sbin
245 $(INSTALL_BIN) $(PKG_BUILD_DIR)/bridge/bridge $(1)/usr/sbin/
246 endef
247
248 define Package/ss/install
249 $(INSTALL_DIR) $(1)/usr/sbin
250 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
251 endef
252
253 define Package/nstat/install
254 $(INSTALL_DIR) $(1)/usr/sbin
255 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/nstat $(1)/usr/sbin/
256 endef
257
258 define Package/devlink/install
259 $(INSTALL_DIR) $(1)/usr/sbin
260 $(INSTALL_BIN) $(PKG_BUILD_DIR)/devlink/devlink $(1)/usr/sbin/
261 endef
262
263 define Package/rdma/install
264 $(INSTALL_DIR) $(1)/usr/sbin
265 $(INSTALL_BIN) $(PKG_BUILD_DIR)/rdma/rdma $(1)/usr/sbin/
266 endef
267
268 $(eval $(call BuildPackage,ip-tiny))
269 $(eval $(call BuildPackage,ip-full))
270 # build tc-mod-iptables before its dependents, to avoid
271 # spurious rebuilds when building multiple variants.
272 $(eval $(call BuildPackage,tc-mod-iptables))
273 $(eval $(call BuildPackage,tc-tiny))
274 $(eval $(call BuildPackage,tc-bpf))
275 $(eval $(call BuildPackage,tc-full))
276 $(eval $(call BuildPackage,genl))
277 $(eval $(call BuildPackage,ip-bridge))
278 $(eval $(call BuildPackage,ss))
279 $(eval $(call BuildPackage,nstat))
280 $(eval $(call BuildPackage,devlink))
281 $(eval $(call BuildPackage,rdma))