[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240703131521.60284-4-przemyslaw.kitszel@intel.com>
Date: Wed, 3 Jul 2024 15:15:21 +0200
From: Przemek Kitszel <przemyslaw.kitszel@...el.com>
To: Stephen Hemminger <stephen@...workplumber.org>,
David Ahern <dsahern@...nel.org>
Cc: netdev@...r.kernel.org,
Tony Nguyen <anthony.l.nguyen@...el.com>,
Lukasz Czapnik <lukasz.czapnik@...el.com>,
Przemek Kitszel <przemyslaw.kitszel@...el.com>
Subject: [PATCH iproute2-next 3/3] Makefile: support building from subdirectories
Support building also from subdirectories, like: `make -C devlink` or
`cd devlink; make`.
Extract common defines and include flags to a new file (common.mk) which
will be included from subdir makefiles via the generated config.mk file.
Note that the current, toplevel-issued, `make` still works as before.
Note that `./configure && make` is still required once after the fresh
checkout.
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
---
Makefile | 45 ---------------------------------------------
common.mk | 43 +++++++++++++++++++++++++++++++++++++++++++
configure | 3 +++
3 files changed, 46 insertions(+), 45 deletions(-)
create mode 100644 common.mk
diff --git a/Makefile b/Makefile
index 2b2c3dec927e..1915b8191d3e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# Top level Makefile for iproute2
--include config.mk
-
ifeq ("$(origin V)", "command line")
VERBOSE = $(V)
endif
@@ -14,37 +12,6 @@ ifeq ($(VERBOSE),0)
MAKEFLAGS += --no-print-directory
endif
-PREFIX?=/usr
-SBINDIR?=/sbin
-NETNS_RUN_DIR?=/var/run/netns
-NETNS_ETC_DIR?=/etc/netns
-DATADIR?=$(PREFIX)/share
-HDRDIR?=$(PREFIX)/include/iproute2
-CONF_ETC_DIR?=/etc/iproute2
-CONF_USR_DIR?=$(DATADIR)/iproute2
-DOCDIR?=$(DATADIR)/doc/iproute2
-MANDIR?=$(DATADIR)/man
-ARPDDIR?=/var/lib/arpd
-KERNEL_INCLUDE?=/usr/include
-BASH_COMPDIR?=$(DATADIR)/bash-completion/completions
-
-# Path to db_185.h include
-DBM_INCLUDE:=$(DESTDIR)/usr/include
-
-SHARED_LIBS = y
-
-DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
-ifneq ($(SHARED_LIBS),y)
-DEFINES+= -DNO_SHARED_LIBS
-endif
-
-DEFINES+=-DCONF_USR_DIR=\"$(CONF_USR_DIR)\" \
- -DCONF_ETC_DIR=\"$(CONF_ETC_DIR)\" \
- -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \
- -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\" \
- -DARPDDIR=\"$(ARPDDIR)\" \
- -DCONF_COLOR=$(CONF_COLOR)
-
#options for AX.25
ADDLIB+=ax25_ntop.o
@@ -59,24 +26,12 @@ ADDLIB+=netrom_ntop.o
CC := gcc
HOSTCC ?= $(CC)
-DEFINES += -D_GNU_SOURCE
-# Turn on transparent support for LFS
-DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-CCOPTS = -O2 -pipe
-WFLAGS := -Wall -Wstrict-prototypes -Wmissing-prototypes
-WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
-
-CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
-YACCFLAGS = -d -t -v
SUBDIRS=lib ip tc bridge misc netem genl man
ifeq ($(HAVE_MNL),y)
SUBDIRS += tipc devlink rdma dcb vdpa
endif
-LIBNETLINK=../lib/libutil.a ../lib/libnetlink.a
-LDLIBS += $(LIBNETLINK)
-
all: config.mk
@set -e; \
for i in $(SUBDIRS); \
diff --git a/common.mk b/common.mk
new file mode 100644
index 000000000000..de26322322d6
--- /dev/null
+++ b/common.mk
@@ -0,0 +1,43 @@
+PREFIX?=/usr
+SBINDIR?=/sbin
+NETNS_RUN_DIR?=/var/run/netns
+NETNS_ETC_DIR?=/etc/netns
+DATADIR?=$(PREFIX)/share
+HDRDIR?=$(PREFIX)/include/iproute2
+CONF_ETC_DIR?=/etc/iproute2
+CONF_USR_DIR?=$(DATADIR)/iproute2
+DOCDIR?=$(DATADIR)/doc/iproute2
+MANDIR?=$(DATADIR)/man
+ARPDDIR?=/var/lib/arpd
+KERNEL_INCLUDE?=/usr/include
+BASH_COMPDIR?=$(DATADIR)/bash-completion/completions
+
+# Path to db_185.h include
+DBM_INCLUDE:=$(DESTDIR)/usr/include
+
+SHARED_LIBS = y
+
+DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
+ifneq ($(SHARED_LIBS),y)
+DEFINES+= -DNO_SHARED_LIBS
+endif
+
+DEFINES+=-DCONF_USR_DIR=\"$(CONF_USR_DIR)\" \
+ -DCONF_ETC_DIR=\"$(CONF_ETC_DIR)\" \
+ -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \
+ -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\" \
+ -DARPDDIR=\"$(ARPDDIR)\" \
+ -DCONF_COLOR=$(CONF_COLOR)
+
+DEFINES += -D_GNU_SOURCE
+# Turn on transparent support for LFS
+DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+CCOPTS = -O2 -pipe
+WFLAGS := -Wall -Wstrict-prototypes -Wmissing-prototypes
+WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
+
+CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
+YACCFLAGS = -d -t -v
+
+LIBNETLINK=../lib/libutil.a ../lib/libnetlink.a
+LDLIBS += $(LIBNETLINK)
diff --git a/configure b/configure
index 928048b3d8c0..978f787ce4d3 100755
--- a/configure
+++ b/configure
@@ -615,6 +615,9 @@ check_cap
echo -n "color output: "
check_color
+# must be after check_color
+echo "include ../common.mk" >> $CONFIG
+
echo >> $CONFIG
echo "%.o: %.c" >> $CONFIG
echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -c -o $@ $<' >> $CONFIG
--
2.39.3
Powered by blists - more mailing lists