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 \
4    ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o \
5    iplink_vlan.o link_veth.o link_gre.o iplink_can.o \
6    iplink_macvlan.o iplink_macvtap.o ipl2tp.o
7
8RTMONOBJ=rtmon.o
9
10include ../Config
11
12ifeq ($(IP_CONFIG_SETNS),y)
13	CFLAGS += -DHAVE_SETNS
14endif
15
16ALLOBJ=$(IPOBJ) $(RTMONOBJ)
17SCRIPTS=ifcfg rtpr routel routef
18TARGETS=ip rtmon
19
20all: $(TARGETS) $(SCRIPTS)
21
22ip: $(IPOBJ) $(LIBNETLINK)
23
24
25rtmon: $(RTMONOBJ)
26
27install: all
28	install -m 0755 $(TARGETS) $(DESTDIR)$(SBINDIR)
29	install -m 0755 $(SCRIPTS) $(DESTDIR)$(SBINDIR)
30
31clean:
32	rm -f $(ALLOBJ) $(TARGETS)
33
34SHARED_LIBS ?= y
35ifeq ($(SHARED_LIBS),y)
36
37LDLIBS += -ldl
38LDFLAGS += -Wl,-export-dynamic
39
40else
41
42ip: static-syms.o
43static-syms.o: static-syms.h
44static-syms.h: $(wildcard *.c)
45	files="$^" ; \
46	for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
47		sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
48	done > $@
49
50endif
51