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