1PREFIX?=/usr
2LIBDIR?=$(PREFIX)/lib
3SBINDIR?=/sbin
4CONFDIR?=/etc/iproute2
5DATADIR?=$(PREFIX)/share
6DOCDIR?=$(DATADIR)/doc/iproute2
7MANDIR?=$(DATADIR)/man
8ARPDDIR?=/var/lib/arpd
9KERNEL_INCLUDE?=/usr/include
10
11# Path to db_185.h include
12DBM_INCLUDE:=$(DESTDIR)/usr/include
13
14SHARED_LIBS = y
15
16DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
17ifneq ($(SHARED_LIBS),y)
18DEFINES+= -DNO_SHARED_LIBS
19endif
20
21DEFINES+=-DCONFDIR=\"$(CONFDIR)\"
22
23#options for decnet
24ADDLIB+=dnet_ntop.o dnet_pton.o
25
26#options for ipx
27ADDLIB+=ipx_ntop.o ipx_pton.o
28
29#options for mpls
30ADDLIB+=mpls_ntop.o mpls_pton.o
31
32CC = gcc
33HOSTCC = gcc
34DEFINES += -D_GNU_SOURCE
35# Turn on transparent support for LFS
36DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
37CCOPTS = -O2
38WFLAGS := -Wall -Wstrict-prototypes  -Wmissing-prototypes
39WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
40
41CFLAGS := $(WFLAGS) $(CCOPTS) -I../include $(DEFINES) $(CFLAGS)
42YACCFLAGS = -d -t -v
43
44SUBDIRS=lib ip tc bridge misc netem genl tipc man
45
46LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
47LDLIBS += $(LIBNETLINK)
48
49all: Config
50	@set -e; \
51	for i in $(SUBDIRS); \
52	do $(MAKE) $(MFLAGS) -C $$i; done
53
54Config:
55	sh configure $(KERNEL_INCLUDE)
56
57install: all
58	install -m 0755 -d $(DESTDIR)$(SBINDIR)
59	install -m 0755 -d $(DESTDIR)$(CONFDIR)
60	install -m 0755 -d $(DESTDIR)$(ARPDDIR)
61	install -m 0755 -d $(DESTDIR)$(DOCDIR)/examples
62	install -m 0755 -d $(DESTDIR)$(DOCDIR)/examples/diffserv
63	install -m 0644 README.iproute2+tc $(shell find examples -maxdepth 1 -type f) \
64		$(DESTDIR)$(DOCDIR)/examples
65	install -m 0644 $(shell find examples/diffserv -maxdepth 1 -type f) \
66		$(DESTDIR)$(DOCDIR)/examples/diffserv
67	@for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
68	install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
69
70snapshot:
71	echo "static const char SNAPSHOT[] = \""`date +%y%m%d`"\";" \
72		> include/SNAPSHOT.h
73
74clean:
75	@for i in $(SUBDIRS) doc; \
76	do $(MAKE) $(MFLAGS) -C $$i clean; done
77
78clobber:
79	touch Config
80	$(MAKE) $(MFLAGS) clean
81	rm -f Config cscope.*
82
83distclean: clobber
84
85cscope:
86	cscope -b -q -R -Iinclude -sip -slib -smisc -snetem -stc
87
88.EXPORT_ALL_VARIABLES:
89