Message ID | 20240703131521.60284-4-przemyslaw.kitszel@intel.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | David Ahern |
Headers | show |
Series | minor improvements to makefile, devlink | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Wed, 3 Jul 2024 15:15:21 +0200 Przemek Kitszel <przemyslaw.kitszel@intel.com> wrote: > 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@intel.com> Not sure if this really needed, it impacts more than devlink.
On 7/3/24 17:16, Stephen Hemminger wrote: > On Wed, 3 Jul 2024 15:15:21 +0200 > Przemek Kitszel <przemyslaw.kitszel@intel.com> wrote: > >> 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. [1] This last "Note" could be fixed too to have proper dependencies (in example of devlink, lib should be build first for example), and it works now only thanks to serialized builds in terms of SUBDIRS in top level Makefile. >> >> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> > > Not sure if this really needed, it impacts more than devlink. devlink is just an example here This patch makes my development easier but it is not fixing [1] above, so it's just a shortcut. You could drop this patch, let me know if you will be interested in extending it to have [1] fixed.
On 7/3/24 7:15 AM, Przemek Kitszel wrote: > 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. > That is a very disruptive requirement - e.g., someone running git bisect. Even after a configure, I get build failures: LINK rtmon /usr/bin/ld: ../lib/libutil.a(utils.o): in function `drop_cap': utils.c:(.text+0x2c6a): undefined reference to `cap_get_proc' /usr/bin/ld: utils.c:(.text+0x2c89): undefined reference to `cap_get_flag' /usr/bin/ld: utils.c:(.text+0x2c9d): undefined reference to `cap_clear' /usr/bin/ld: utils.c:(.text+0x2ca9): undefined reference to `cap_set_proc' /usr/bin/ld: utils.c:(.text+0x2cb5): undefined reference to `cap_free' /usr/bin/ld: ../lib/libnetlink.a(libnetlink.o): in function `err_attr_cb': libnetlink.c:(.text+0x1a): undefined reference to `mnl_attr_type_valid' /usr/bin/ld: libnetlink.c:(.text+0x26): undefined reference to `mnl_attr_get_type' /usr/bin/ld: libnetlink.c:(.text+0x40): undefined reference to `mnl_attr_validate' /usr/bin/ld: ../lib/libnetlink.a(libnetlink.o): in function `nl_dump_ext_ack': libnetlink.c:(.text+0x2f5): undefined reference to `mnl_nlmsg_get_payload' /usr/bin/ld: libnetlink.c:(.text+0x323): undefined reference to `mnl_attr_parse' /usr/bin/ld: libnetlink.c:(.text+0x366): undefined reference to `mnl_attr_get_str' /usr/bin/ld: libnetlink.c:(.text+0x37e): undefined reference to `mnl_attr_get_u32' /usr/bin/ld: libnetlink.c:(.text+0x3a7): undefined reference to `mnl_attr_get_u32' /usr/bin/ld: libnetlink.c:(.text+0x3e5): undefined reference to `mnl_nlmsg_get_payload_len' /usr/bin/ld: ../lib/libnetlink.a(libnetlink.o): in function `nl_dump_ext_ack_done': libnetlink.c:(.text+0x8e4): undefined reference to `mnl_attr_parse' /usr/bin/ld: libnetlink.c:(.text+0x8f8): undefined reference to `mnl_attr_get_str' collect2: error: ld returned 1 exit status make[1]: *** [Makefile:32: rtmon] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:36: all] Error 2
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
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@intel.com> --- Makefile | 45 --------------------------------------------- common.mk | 43 +++++++++++++++++++++++++++++++++++++++++++ configure | 3 +++ 3 files changed, 46 insertions(+), 45 deletions(-) create mode 100644 common.mk