iproute2/Makefile
<<
>>
Prefs
   1# SPDX-License-Identifier: GPL-2.0
   2# Top level Makefile for iproute2
   3
   4ifeq ("$(origin V)", "command line")
   5VERBOSE = $(V)
   6endif
   7ifndef VERBOSE
   8VERBOSE = 0
   9endif
  10
  11ifeq ($(VERBOSE),0)
  12MAKEFLAGS += --no-print-directory
  13endif
  14
  15PREFIX?=/usr
  16LIBDIR?=$(PREFIX)/lib
  17SBINDIR?=/sbin
  18CONFDIR?=/etc/iproute2
  19NETNS_RUN_DIR?=/var/run/netns
  20NETNS_ETC_DIR?=/etc/netns
  21DATADIR?=$(PREFIX)/share
  22HDRDIR?=$(PREFIX)/include/iproute2
  23DOCDIR?=$(DATADIR)/doc/iproute2
  24MANDIR?=$(DATADIR)/man
  25ARPDDIR?=/var/lib/arpd
  26KERNEL_INCLUDE?=/usr/include
  27BASH_COMPDIR?=$(DATADIR)/bash-completion/completions
  28
  29# Path to db_185.h include
  30DBM_INCLUDE:=$(DESTDIR)/usr/include
  31
  32SHARED_LIBS = y
  33
  34DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
  35ifneq ($(SHARED_LIBS),y)
  36DEFINES+= -DNO_SHARED_LIBS
  37endif
  38
  39DEFINES+=-DCONFDIR=\"$(CONFDIR)\" \
  40         -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \
  41         -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\"
  42
  43#options for mpls
  44ADDLIB+=mpls_ntop.o mpls_pton.o
  45
  46CC := gcc
  47HOSTCC ?= $(CC)
  48DEFINES += -D_GNU_SOURCE
  49# Turn on transparent support for LFS
  50DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  51CCOPTS = -O2 -pipe
  52WFLAGS := -Wall -Wstrict-prototypes  -Wmissing-prototypes
  53WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
  54
  55CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
  56YACCFLAGS = -d -t -v
  57
  58SUBDIRS=lib ip tc bridge misc netem genl tipc devlink rdma dcb man vdpa
  59
  60LIBNETLINK=../lib/libutil.a ../lib/libnetlink.a
  61LDLIBS += $(LIBNETLINK)
  62
  63all: config
  64        @set -e; \
  65        for i in $(SUBDIRS); \
  66        do echo; echo $$i; $(MAKE) -C $$i; done
  67
  68.PHONY: clean clobber distclean check cscope version
  69
  70help:
  71        @echo "Make Targets:"
  72        @echo " all                 - build binaries"
  73        @echo " clean               - remove products of build"
  74        @echo " distclean           - remove configuration and build"
  75        @echo " install             - install binaries on local machine"
  76        @echo " check               - run tests"
  77        @echo " cscope              - build cscope database"
  78        @echo " version             - update version"
  79        @echo ""
  80        @echo "Make Arguments:"
  81        @echo " V=[0|1]             - set build verbosity level"
  82
  83config:
  84        @if [ ! -f config.mk -o configure -nt config.mk ]; then \
  85                sh configure $(KERNEL_INCLUDE); \
  86        fi
  87
  88install: all
  89        install -m 0755 -d $(DESTDIR)$(SBINDIR)
  90        install -m 0755 -d $(DESTDIR)$(CONFDIR)
  91        install -m 0755 -d $(DESTDIR)$(ARPDDIR)
  92        install -m 0755 -d $(DESTDIR)$(HDRDIR)
  93        @for i in $(SUBDIRS);  do $(MAKE) -C $$i install; done
  94        install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
  95        install -m 0755 -d $(DESTDIR)$(BASH_COMPDIR)
  96        install -m 0644 bash-completion/tc $(DESTDIR)$(BASH_COMPDIR)
  97        install -m 0644 bash-completion/devlink $(DESTDIR)$(BASH_COMPDIR)
  98        install -m 0644 include/bpf_elf.h $(DESTDIR)$(HDRDIR)
  99
 100version:
 101        echo "static const char version[] = \""`git describe --tags --long`"\";" \
 102                > include/version.h
 103
 104clean:
 105        @for i in $(SUBDIRS) testsuite; \
 106        do $(MAKE) -C $$i clean; done
 107
 108clobber:
 109        touch config.mk
 110        $(MAKE) clean
 111        rm -f config.mk cscope.*
 112
 113distclean: clobber
 114
 115check: all
 116        $(MAKE) -C testsuite
 117        $(MAKE) -C testsuite alltests
 118        @if command -v man >/dev/null 2>&1; then \
 119                echo "Checking manpages for syntax errors..."; \
 120                $(MAKE) -C man check; \
 121        else \
 122                echo "man not installed, skipping checks for syntax errors."; \
 123        fi
 124
 125cscope:
 126        cscope -b -q -R -Iinclude -sip -slib -smisc -snetem -stc
 127
 128.EXPORT_ALL_VARIABLES:
 129