a49b0616ea795939bc053d15ae91ff0e08a6c17c
[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:=3.18.0
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=http://kernel.org/pub/linux/utils/net/iproute2/
16 PKG_MD5SUM:=6f6ad51a00007880460e103367b16057
17 PKG_BUILD_PARALLEL:=1
18 PKG_LICENSE:=GPL-2.0
19
20 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
21
22 include $(INCLUDE_DIR)/package.mk
23
24 define Package/iproute2/Default
25 TITLE:=Routing control utility ($(2))
26 SECTION:=net
27 CATEGORY:=Network
28 URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
29 SUBMENU:=Routing and Redirection
30 MAINTAINER:=Russell Senior <russell@personaltelco.net>
31 DEPENDS:= +libnl-tiny
32 VARIANT:=$(1)
33 endef
34
35 define Package/ip
36 $(call Package/iproute2/Default,tiny,Minimal)
37 CONFLICTS:=ip-full
38 endef
39
40 Package/ip-full=$(call Package/iproute2/Default,full,Full)
41
42 define Package/ip/conffiles
43 /etc/iproute2/rt_tables
44 endef
45
46 define Package/ip-$(BUILD_VARIANT)/conffiles
47 $(Package/ip/conffiles)
48 endef
49
50 define Package/tc
51 $(call Package/iproute2/Default)
52 TITLE:=Traffic control utility
53 DEPENDS:=+kmod-sched-core
54 endef
55
56 define Package/genl
57 $(call Package/iproute2/Default)
58 TITLE:=General netlink utility frontend
59 endef
60
61 define Package/ss
62 $(call Package/iproute2/Default)
63 TITLE:=Socket statistics utility
64 endef
65
66 ifeq ($(BUILD_VARIANT),tiny)
67 IP_CONFIG_TINY:=y
68 endif
69
70 define Build/Configure
71 $(SED) "s,-I/usr/include/db3,," $(PKG_BUILD_DIR)/Makefile
72 $(SED) "s,^KERNEL_INCLUDE.*,KERNEL_INCLUDE=$(LINUX_DIR)/include," \
73 $(PKG_BUILD_DIR)/Makefile
74 $(SED) "s,^LIBC_INCLUDE.*,LIBC_INCLUDE=$(STAGING_DIR)/include," \
75 $(PKG_BUILD_DIR)/Makefile
76 echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
77 > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
78 endef
79
80 ifdef CONFIG_USE_EGLIBC
81 ifndef CONFIG_EGLIBC_VERSION_2_13
82 TARGET_CFLAGS += -DHAVE_SETNS
83 endif
84 endif
85 ifdef CONFIG_USE_MUSL
86 TARGET_CFLAGS += -DHAVE_SETNS
87 endif
88
89 TARGET_CFLAGS += -ffunction-sections -fdata-sections
90
91 MAKE_FLAGS += \
92 EXTRA_CCOPTS="$(TARGET_CFLAGS) -I../include -I$(STAGING_DIR)/usr/include/libnl-tiny" \
93 KERNEL_INCLUDE="$(LINUX_DIR)/include" \
94 SHARED_LIBS="" \
95 LDFLAGS="-Wl,--gc-sections" \
96 IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
97 FPIC="$(FPIC)"
98
99 define Build/Compile
100 +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
101 endef
102
103 define Build/InstallDev
104 $(INSTALL_DIR) $(1)/usr/include
105 $(CP) $(PKG_BUILD_DIR)/include/libnetlink.h $(1)/usr/include/
106 $(INSTALL_DIR) $(1)/usr/lib
107 $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
108 endef
109
110 define Package/ip/install
111 $(INSTALL_DIR) $(1)/usr/sbin
112 $(INSTALL_DIR) $(1)/etc/iproute2
113 $(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/iproute2/rt_tables $(1)/etc/iproute2
114 $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/sbin/
115 endef
116
117 define Package/ip-$(BUILD_VARIANT)/install
118 $(Package/ip/install)
119 endef
120
121 define Package/tc/install
122 $(INSTALL_DIR) $(1)/usr/sbin
123 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/sbin/
124 $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
125 $(INSTALL_BIN) ./files/15-teql $(1)/etc/hotplug.d/iface/
126 endef
127
128 define Package/genl/install
129 $(INSTALL_DIR) $(1)/usr/sbin
130 $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
131 endef
132
133 define Package/ss/install
134 $(INSTALL_DIR) $(1)/usr/sbin
135 $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
136 endef
137
138 $(eval $(call BuildPackage,ip))
139 $(eval $(call BuildPackage,ip-full))
140 $(eval $(call BuildPackage,tc))
141 $(eval $(call BuildPackage,genl))
142 $(eval $(call BuildPackage,ss))