1IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
2    rtm_map.o iptunnel.o ip6tunnel.o tunnel.o ipneigh.o ipntable.o iplink.o \
3    ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o iptuntap.o iptoken.o \
4    ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o iplink_dummy.o \
5    iplink_ifb.o iplink_nlmon.o iplink_team.o iplink_vcan.o iplink_vxcan.o \
6    iplink_vlan.o link_veth.o link_gre.o iplink_can.o iplink_xdp.o \
7    iplink_macvlan.o ipl2tp.o link_vti.o link_vti6.o \
8    iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
9    link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \
10    iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \
11    iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \
12    ipvrf.o iplink_xstats.o ipseg6.o
13
14RTMONOBJ=rtmon.o
15
16include ../config.mk
17
18ALLOBJ=$(IPOBJ) $(RTMONOBJ)
19SCRIPTS=ifcfg rtpr routel routef
20TARGETS=ip rtmon
21
22all: $(TARGETS) $(SCRIPTS)
23
24ip: $(IPOBJ) $(LIBNETLINK)
25	$(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
26
27rtmon: $(RTMONOBJ)
28	$(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
29
30install: all
31	install -m 0755 $(TARGETS) $(DESTDIR)$(SBINDIR)
32	install -m 0755 $(SCRIPTS) $(DESTDIR)$(SBINDIR)
33
34clean:
35	rm -f $(ALLOBJ) $(TARGETS)
36
37SHARED_LIBS ?= y
38ifeq ($(SHARED_LIBS),y)
39
40LDLIBS += -ldl
41LDFLAGS += -Wl,-export-dynamic
42
43else
44
45ip: static-syms.o
46static-syms.o: static-syms.h
47static-syms.h: $(wildcard *.c)
48	files="$^" ; \
49	for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
50		sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
51	done > $@
52
53endif
54