iproute2: add libcap support, enabled in ip-full
[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.1.0
12 PKG_RELEASE:=2
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
16 PKG_HASH:=dc5a980873eabf6b00c0be976b6e5562b1400d47d1d07d2ac35d5e5acbcf7bcf
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:=tiny
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:=full
48 PROVIDES:=ip
49 ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full
50 DEPENDS:=+libnl-tiny +libelf +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libcap
51 endef
52
53 define Package/tc
54 $(call Package/iproute2/Default)
55 TITLE:=Traffic control utility
56 VARIANT:=tc
57 PROVIDES:=tc
58 DEPENDS:=+kmod-sched-core +libxtables +libelf +(PACKAGE_devlink||PACKAGE_rdma):libmnl +PACKAGE_ip-full:libcap
59 endef
60
61 define Package/genl
62 $(call Package/iproute2/Default)
63 TITLE:=General netlink utility frontend
64 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf +PACKAGE_ip-full:libcap
65 endef
66
67 define Package/ip-bridge
68 $(call Package/iproute2/Default)
69 TITLE:=Bridge configuration utility from iproute2
70 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf +PACKAGE_ip-full:libcap
71 endef
72
73 define Package/ss
74 $(call Package/iproute2/Default)
75 TITLE:=Socket statistics utility
76 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf +PACKAGE_ip-full:libcap
77 endef
78
79 define Package/nstat
80 $(call Package/iproute2/Default)
81 TITLE:=Network statistics utility
82 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf +PACKAGE_ip-full:libcap
83 endef
84
85 define Package/devlink
86 $(call Package/iproute2/Default)
87 TITLE:=Network devlink utility
88 DEPENDS:=+libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf +PACKAGE_ip-full:libcap
89 endef
90
91 define Package/rdma
92 $(call Package/iproute2/Default)
93 TITLE:=Network rdma utility
94 DEPENDS:=+libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf +PACKAGE_ip-full:libcap
95 endef
96
97 ifeq ($(BUILD_VARIANT),tiny)
98 IP_CONFIG_TINY:=y
99 endif
100
101 ifeq ($(BUILD_VARIANT),full)
102 HAVE_ELF:=y
103 HAVE_CAP:=y
104 endif
105
106 ifeq ($(BUILD_VARIANT),tc)
107 HAVE_ELF:=y
108 SHARED_LIBS:=y
109 endif
110
111 ifdef CONFIG_PACKAGE_devlink
112 HAVE_MNL:=y
113 endif
114
115 ifdef CONFIG_PACKAGE_rdma
116 HAVE_MNL:=y
117 endif
118
119 define Build/Configure
120 echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
121 > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
122 endef
123
124 TARGET_CFLAGS += -ffunction-sections -fdata-sections
125 TARGET_LDFLAGS += -Wl,--gc-sections
126 TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
127
128 MAKE_FLAGS += \
129 KERNEL_INCLUDE="$(LINUX_DIR)/user_headers/include" \
130 SHARED_LIBS=$(SHARED_LIBS) \
131 IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
132 HAVE_ELF=$(HAVE_ELF) \
133 HAVE_MNL=$(HAVE_MNL) \
134 HAVE_CAP=$(HAVE_CAP) \
135 IPT_LIB_DIR=/usr/lib/iptables \
136 XT_LIB_DIR=/usr/lib/iptables \
137 FPIC="$(FPIC)"
138
139 define Build/Compile
140 +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
141 endef
142
143 define Build/InstallDev
144 $(INSTALL_DIR) $(1)/usr/include
145 $(CP) $(PKG_BUILD_DIR)/include/{libgenl,libnetlink}.h $(1)/usr/include/
146 $(INSTALL_DIR) $(1)/usr/lib
147 $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
148 endef
149
150 define Package/ip-tiny/install
151 $(INSTALL_DIR) $(1)/usr/libexec
152 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-tiny
153 endef
154
155 define Package/ip-full/install
156 $(INSTALL_DIR) $(1)/usr/libexec
157 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-full
158 endef
159
160 define Package/tc/install
161 $(INSTALL_DIR) $(1)/usr/sbin
162 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/sbin/
163 $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
164 $(INSTALL_BIN) ./files/15-teql $(1)/etc/hotplug.d/iface/
165 ifeq ($(SHARED_LIBS),y)
166 $(INSTALL_DIR) $(1)/usr/lib/tc
167 $(CP) $(PKG_BUILD_DIR)/tc/*.so $(1)/usr/lib/tc
168 endif
169 endef
170
171 define Package/genl/install
172 $(INSTALL_DIR) $(1)/usr/sbin
173 $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
174 endef
175
176 define Package/ip-bridge/install
177 $(INSTALL_DIR) $(1)/usr/sbin
178 $(INSTALL_BIN) $(PKG_BUILD_DIR)/bridge/bridge $(1)/usr/sbin/
179 endef
180
181 define Package/ss/install
182 $(INSTALL_DIR) $(1)/usr/sbin
183 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
184 endef
185
186 define Package/nstat/install
187 $(INSTALL_DIR) $(1)/usr/sbin
188 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/nstat $(1)/usr/sbin/
189 endef
190
191 define Package/devlink/install
192 $(INSTALL_DIR) $(1)/usr/sbin
193 $(INSTALL_BIN) $(PKG_BUILD_DIR)/devlink/devlink $(1)/usr/sbin/
194 endef
195
196 define Package/rdma/install
197 $(INSTALL_DIR) $(1)/usr/sbin
198 $(INSTALL_BIN) $(PKG_BUILD_DIR)/rdma/rdma $(1)/usr/sbin/
199 endef
200
201 $(eval $(call BuildPackage,ip-tiny))
202 $(eval $(call BuildPackage,ip-full))
203 $(eval $(call BuildPackage,tc))
204 $(eval $(call BuildPackage,genl))
205 $(eval $(call BuildPackage,ip-bridge))
206 $(eval $(call BuildPackage,ss))
207 $(eval $(call BuildPackage,nstat))
208 $(eval $(call BuildPackage,devlink))
209 $(eval $(call BuildPackage,rdma))