mt76: update to the latest version
[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:=5.0.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:=df047302a39650ef832c07e8dab5df7a23218cd398bd310c8628e386161d20ba
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 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:=tiny
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:=full
50 PROVIDES:=ip
51 ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full
52 DEPENDS:=+libnl-tiny +libelf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
53 endef
54
55 define Package/tc
56 $(call Package/iproute2/Default)
57 TITLE:=Traffic control utility
58 VARIANT:=tc
59 PROVIDES:=tc
60 DEPENDS:=+kmod-sched-core +libxtables +libelf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
61 endef
62
63 define Package/genl
64 $(call Package/iproute2/Default)
65 TITLE:=General netlink utility frontend
66 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
67 endef
68
69 define Package/ip-bridge
70 $(call Package/iproute2/Default)
71 TITLE:=Bridge configuration utility from iproute2
72 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
73 endef
74
75 define Package/ss
76 $(call Package/iproute2/Default)
77 TITLE:=Socket statistics utility
78 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
79 endef
80
81 define Package/nstat
82 $(call Package/iproute2/Default)
83 TITLE:=Network statistics utility
84 DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
85 endef
86
87 define Package/devlink
88 $(call Package/iproute2/Default)
89 TITLE:=Network devlink utility
90 DEPENDS:=+libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
91 endef
92
93 define Package/rdma
94 $(call Package/iproute2/Default)
95 TITLE:=Network rdma utility
96 DEPENDS:=+libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
97 endef
98
99 ifeq ($(BUILD_VARIANT),tiny)
100 IP_CONFIG_TINY:=y
101 endif
102
103 ifeq ($(BUILD_VARIANT),full)
104 HAVE_ELF:=y
105 endif
106
107 ifeq ($(BUILD_VARIANT),tc)
108 HAVE_ELF:=y
109 SHARED_LIBS:=y
110 endif
111
112 ifdef CONFIG_PACKAGE_devlink
113 HAVE_MNL:=y
114 endif
115
116 ifdef CONFIG_PACKAGE_rdma
117 HAVE_MNL:=y
118 endif
119
120 define Build/Configure
121 echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
122 > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
123 endef
124
125 TARGET_CFLAGS += -ffunction-sections -fdata-sections
126 TARGET_LDFLAGS += -Wl,--gc-sections
127 TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
128
129 MAKE_FLAGS += \
130 KERNEL_INCLUDE="$(LINUX_DIR)/user_headers/include" \
131 SHARED_LIBS=$(SHARED_LIBS) \
132 IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
133 HAVE_ELF=$(HAVE_ELF) \
134 HAVE_MNL=$(HAVE_MNL) \
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))