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