iproute2: tc: backport canonical cake support
[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:=4.16.0
12 PKG_RELEASE:=4
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
16 PKG_HASH:=0c5c24020fd7349fe25728c5edee9fb6a1bc8a38f08e23be5c57a6301e55ee0a
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_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
23
24 include $(INCLUDE_DIR)/kernel.mk
25 include $(INCLUDE_DIR)/package.mk
26
27 define Package/iproute2/Default
28 SECTION:=net
29 CATEGORY:=Network
30 URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
31 SUBMENU:=Routing and Redirection
32 MAINTAINER:=Russell Senior <russell@personaltelco.net>
33 endef
34
35 define Package/ip-tiny
36 $(call Package/iproute2/Default)
37 TITLE:=Routing control utility (Minimal)
38 VARIANT:=tiny
39 PROVIDES:=ip
40 ALTERNATIVES:=200:/sbin/ip:/sbin/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:/sbin/ip-full
50 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
51 endef
52
53 define Package/tc
54 $(call Package/iproute2/Default)
55 TITLE:=Traffic control utility
56 DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl
57 endef
58
59 define Package/genl
60 $(call Package/iproute2/Default)
61 TITLE:=General netlink utility frontend
62 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
63 endef
64
65 define Package/ip-bridge
66 $(call Package/iproute2/Default)
67 TITLE:=Bridge configuration utility from iproute2
68 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
69 endef
70
71 define Package/ss
72 $(call Package/iproute2/Default)
73 TITLE:=Socket statistics utility
74 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
75 endef
76
77 define Package/nstat
78 $(call Package/iproute2/Default)
79 TITLE:=Network statistics utility
80 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
81 endef
82
83 define Package/devlink
84 $(call Package/iproute2/Default)
85 TITLE:=Network devlink utility
86 DEPENDS:=+libmnl
87 endef
88
89 define Package/rdma
90 $(call Package/iproute2/Default)
91 TITLE:=Network rdma utility
92 DEPENDS:=+libmnl
93 endef
94
95 ifeq ($(BUILD_VARIANT),tiny)
96 IP_CONFIG_TINY:=y
97 endif
98
99 ifdef CONFIG_PACKAGE_devlink
100 HAVE_MNL:=y
101 endif
102
103 ifdef CONFIG_PACKAGE_rdma
104 HAVE_MNL:=y
105 endif
106
107 define Build/Configure
108 $(SED) "s,-I/usr/include/db3,," $(PKG_BUILD_DIR)/Makefile
109 $(SED) "s,^KERNEL_INCLUDE.*,KERNEL_INCLUDE=$(LINUX_DIR)/include," \
110 $(PKG_BUILD_DIR)/Makefile
111 $(SED) "s,^LIBC_INCLUDE.*,LIBC_INCLUDE=$(STAGING_DIR)/include," \
112 $(PKG_BUILD_DIR)/Makefile
113 echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
114 > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
115 endef
116
117 TARGET_CFLAGS += -ffunction-sections -fdata-sections
118
119 MAKE_FLAGS += \
120 EXTRA_CCOPTS="-I$(STAGING_DIR)/usr/include/libnl-tiny" \
121 KERNEL_INCLUDE="$(LINUX_DIR)/include" \
122 SHARED_LIBS="" \
123 LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections" \
124 IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
125 HAVE_MNL=$(HAVE_MNL) \
126 IPT_LIB_DIR=/usr/lib/iptables \
127 FPIC="$(FPIC)"
128
129 define Build/Compile
130 +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
131 endef
132
133 define Build/InstallDev
134 $(INSTALL_DIR) $(1)/usr/include
135 $(CP) $(PKG_BUILD_DIR)/include/{libgenl,libnetlink,ll_map}.h $(1)/usr/include/
136 $(INSTALL_DIR) $(1)/usr/lib
137 $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
138 endef
139
140 define Package/ip-tiny/install
141 $(INSTALL_DIR) $(1)/sbin
142 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/sbin/ip-tiny
143 endef
144
145 define Package/ip-full/install
146 $(INSTALL_DIR) $(1)/sbin
147 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/sbin/ip-full
148 endef
149
150 define Package/tc/install
151 $(INSTALL_DIR) $(1)/usr/sbin
152 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/sbin/
153 $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
154 $(INSTALL_BIN) ./files/15-teql $(1)/etc/hotplug.d/iface/
155 endef
156
157 define Package/genl/install
158 $(INSTALL_DIR) $(1)/usr/sbin
159 $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
160 endef
161
162 define Package/ip-bridge/install
163 $(INSTALL_DIR) $(1)/usr/sbin
164 $(INSTALL_BIN) $(PKG_BUILD_DIR)/bridge/bridge $(1)/usr/sbin/
165 endef
166
167 define Package/ss/install
168 $(INSTALL_DIR) $(1)/usr/sbin
169 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
170 endef
171
172 define Package/nstat/install
173 $(INSTALL_DIR) $(1)/usr/sbin
174 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/nstat $(1)/usr/sbin/
175 endef
176
177 define Package/devlink/install
178 $(INSTALL_DIR) $(1)/usr/sbin
179 $(INSTALL_BIN) $(PKG_BUILD_DIR)/devlink/devlink $(1)/usr/sbin/
180 endef
181
182 define Package/rdma/install
183 $(INSTALL_DIR) $(1)/usr/sbin
184 $(INSTALL_BIN) $(PKG_BUILD_DIR)/rdma/rdma $(1)/usr/sbin/
185 endef
186
187 $(eval $(call BuildPackage,ip-tiny))
188 $(eval $(call BuildPackage,ip-full))
189 $(eval $(call BuildPackage,tc))
190 $(eval $(call BuildPackage,genl))
191 $(eval $(call BuildPackage,ip-bridge))
192 $(eval $(call BuildPackage,ss))
193 $(eval $(call BuildPackage,nstat))
194 $(eval $(call BuildPackage,devlink))
195 $(eval $(call BuildPackage,rdma))