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