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 <heiko.carstens@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is contained in:
Michael Holzheu
2017-11-30 16:49:20 +01:00
parent 869f629746
commit e767a2b99d

View File

@@ -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)