iproute2: support eBFP/XDP object file loading, simplify linking libelf
[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.20.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:=c8adaa6a40f888476b23acb283cfa30c0dd55f07b5aa20663ed5ba2ef1f6fda8
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 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="" \
131 IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
132 HAVE_ELF=$(HAVE_ELF) \
133 HAVE_MNL=$(HAVE_MNL) \
134 IPT_LIB_DIR=/usr/lib/iptables \
135 XT_LIB_DIR=/usr/lib/iptables \
136 FPIC="$(FPIC)"
137
138 define Build/Compile
139 +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
140 endef
141
142 define Build/InstallDev
143 $(INSTALL_DIR) $(1)/usr/include
144 $(CP) $(PKG_BUILD_DIR)/include/{libgenl,libnetlink}.h $(1)/usr/include/
145 $(INSTALL_DIR) $(1)/usr/lib
146 $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
147 endef
148
149 define Package/ip-tiny/install
150 $(INSTALL_DIR) $(1)/usr/libexec
151 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-tiny
152 endef
153
154 define Package/ip-full/install
155 $(INSTALL_DIR) $(1)/usr/libexec
156 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-full
157 endef
158
159 define Package/tc/install
160 $(INSTALL_DIR) $(1)/usr/sbin
161 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/sbin/
162 $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
163 $(INSTALL_BIN) ./files/15-teql $(1)/etc/hotplug.d/iface/
164 endef
165
166 define Package/genl/install
167 $(INSTALL_DIR) $(1)/usr/sbin
168 $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
169 endef
170
171 define Package/ip-bridge/install
172 $(INSTALL_DIR) $(1)/usr/sbin
173 $(INSTALL_BIN) $(PKG_BUILD_DIR)/bridge/bridge $(1)/usr/sbin/
174 endef
175
176 define Package/ss/install
177 $(INSTALL_DIR) $(1)/usr/sbin
178 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
179 endef
180
181 define Package/nstat/install
182 $(INSTALL_DIR) $(1)/usr/sbin
183 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/nstat $(1)/usr/sbin/
184 endef
185
186 define Package/devlink/install
187 $(INSTALL_DIR) $(1)/usr/sbin
188 $(INSTALL_BIN) $(PKG_BUILD_DIR)/devlink/devlink $(1)/usr/sbin/
189 endef
190
191 define Package/rdma/install
192 $(INSTALL_DIR) $(1)/usr/sbin
193 $(INSTALL_BIN) $(PKG_BUILD_DIR)/rdma/rdma $(1)/usr/sbin/
194 endef
195
196 $(eval $(call BuildPackage,ip-tiny))
197 $(eval $(call BuildPackage,ip-full))
198 $(eval $(call BuildPackage,tc))
199 $(eval $(call BuildPackage,genl))
200 $(eval $(call BuildPackage,ip-bridge))
201 $(eval $(call BuildPackage,ss))
202 $(eval $(call BuildPackage,nstat))
203 $(eval $(call BuildPackage,devlink))
204 $(eval $(call BuildPackage,rdma))