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