From e767a2b99d2f5d53ecb0ac70cb1ed0e06b3e73d8 Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Thu, 30 Nov 2017 16:49:20 +0100 Subject: [PATCH] build process: Fix parallel build for libutil When building libutil in parallel, it can happen that the archive file is created twice: $ cd libutil $ make -j ... CC libutil/util_rec_example.o AR libutil/libutil.a AR libutil/libutil.a LINK libutil/util_base_example This can lead to the following build error: $ make -j OPT_FLAGS="-pipe" ..//libutil/libutil.a(util_path.o): In function `sys_mount_point': util_path.c:56: undefined reference to `util_proc_mnt_get_entry' util_path.c:60: undefined reference to `util_proc_mnt_free_entry' collect2: error: ld returned 1 exit status ../common.mak:232: recipe for target 'util_path_example' failed The problem is that the following rule from common.mak is triggered in the libutil directory: $(rootdir)/libutil/libutil.a: $(rootdir)/libutil $(MAKE) -C $(rootdir)/libutil/ libutil.a .PHONY: $(rootdir)/libutil To prevent this rule, use the local "libutil.a" as dependency for the example binaries. Reported-by: Heiko Carstens Signed-off-by: Michael Holzheu --- libutil/Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libutil/Makefile b/libutil/Makefile index adbbd63a..fd5e2138 100644 --- a/libutil/Makefile +++ b/libutil/Makefile @@ -28,17 +28,17 @@ objects = util_base.o \ util_proc.o \ util_rec.o -util_base_example: util_base_example.o $(rootdir)/libutil/libutil.a -util_panic_example: util_panic_example.o $(rootdir)/libutil/libutil.a -util_path_example: util_path_example.o $(rootdir)/libutil/libutil.a -util_scandir_example: util_scandir_example.o $(rootdir)/libutil/libutil.a -util_file_example: util_file_example.o $(rootdir)/libutil/libutil.a -util_libc_example: util_libc_example.o $(rootdir)/libutil/libutil.a -util_opt_example: util_opt_example.o $(rootdir)/libutil/libutil.a -util_opt_command_example: util_opt_command_example.o $(rootdir)/libutil/libutil.a -util_panic_example: util_panic_example.o $(rootdir)/libutil/libutil.a -util_prg_example: util_prg_example.o $(rootdir)/libutil/libutil.a -util_rec_example: util_rec_example.o $(rootdir)/libutil/libutil.a +util_base_example: util_base_example.o $(lib) +util_panic_example: util_panic_example.o $(lib) +util_path_example: util_path_example.o $(lib) +util_scandir_example: util_scandir_example.o $(lib) +util_file_example: util_file_example.o $(lib) +util_libc_example: util_libc_example.o $(lib) +util_opt_example: util_opt_example.o $(lib) +util_opt_command_example: util_opt_command_example.o $(lib) +util_panic_example: util_panic_example.o $(lib) +util_prg_example: util_prg_example.o $(lib) +util_rec_example: util_rec_example.o $(lib) $(lib): $(objects)