From 76aa8e4a520a7bcf1a769555d7659b39be730744 Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Mon, 12 Jul 2021 11:06:57 +0200 Subject: [PATCH] Makefile: Fix order of build of libraries for parallel builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some libraries depend on other libraries, so split the libraries into two groups: base libraries that do not depend on any others, and the remaining libraries, that may depend on the base libraries. Ensure that the base libraries are built first, before starting to build the remaining libraries. The tools are only built once the base libraries and the remaining libraries have been built. This fixes a possible build problem with libseckey when parallel build is used. The libseckey library is used by libekmfweb and the zkey KMIP plugin (zkey-kmip). With parallel build both are built in parallel, and thus both trigger the build of libseckey. This can lead to the situation that libseckey is built twice at the same time, which can lead to build failures (corrupted archive, etc). Signed-off-by: Ingo Franzki Reviewed-by: Jan Höppner Signed-off-by: Jan Höppner --- Makefile | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index cad67e79..d34c0eb8 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,14 @@ ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/ar # Include common definitions include common.mak -LIB_DIRS = libvtoc libutil libzds libdasd libvmdump libccw libvmcp libekmfweb \ - libseckey libkmipclient +# +# BASELIBS: Libraries that have no dependency to other libraries in s390-tools +# LIBS: Libraries that can have a dependency to base libraries +# TOOLS: Tools that can have a dependency to base libraries or libraries +# +BASELIB_DIRS = libutil libseckey +LIB_DIRS = libvtoc libzds libdasd libvmdump libccw libvmcp libekmfweb \ + libkmipclient TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \ tape390 osasnmpd qetharp ip_watcher qethconf scripts zconf \ vmconvert vmcp man mon_tools dasdinfo vmur cpuplugd ipl_tools \ @@ -12,7 +18,7 @@ TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \ systemd hmcdrvfs cpacfstats zdev dump2tar zkey netboot etc zpcictl \ genprotimg lsstp hsci hsavmcore -SUB_DIRS = $(LIB_DIRS) $(TOOL_DIRS) +SUB_DIRS = $(BASELIB_DIRS) $(LIB_DIRS) $(TOOL_DIRS) all: $(TOOL_DIRS) clean: $(TOOL_DIRS) @@ -26,9 +32,10 @@ MAKECMDGOALS = all endif # -# We have to build the libraries before the tools are built. Otherwise -# the tools would trigger parallel "make -C" builds for libraries in -# case of "make -j". +# We have to build the base libraries before the other libraries are built, +# and then build the other libraries before the tools are built. Otherwise the +# other libraries and tools would trigger parallel "make -C" builds for the +# base libraries and the other libraries in case of "make -j". # # MAKECMDGOALS contains the list of goals, e.g. "clean all". We use # "foreach" to generate a ";" separated list of "make -C ". @@ -45,7 +52,12 @@ $(TOOL_DIRS): $(LIB_DIRS) $(MAKE) -C $@ TOPDIR=$(TOPDIR) ARCH=$(ARCH) $(goal) ;) .PHONY: $(TOOL_DIRS) -$(LIB_DIRS): +$(LIB_DIRS): $(BASELIB_DIRS) $(foreach goal,$(MAKECMDGOALS), \ $(MAKE) -C $@ TOPDIR=$(TOPDIR) ARCH=$(ARCH) $(goal) ;) .PHONY: $(LIB_DIRS) + +$(BASELIB_DIRS): + $(foreach goal,$(MAKECMDGOALS), \ + $(MAKE) -C $@ TOPDIR=$(TOPDIR) ARCH=$(ARCH) $(goal) ;) +.PHONY: $(BASELIB_DIRS)