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