[Skiboot] [PATCH v2] external/pflash: Fix makefile dependencies

Joel Stanley joel at jms.id.au
Fri Dec 4 11:30:00 AEDT 2015


When building under buildroot, libflash was being built before the
links:

 make[2]: *** No rule to make target 'libflash/libflash.c', needed by
 'libflash-libflash.o'.  Stop.
 make[2]: *** Waiting for unfinished jobs....
     LN  ccan
     LN  common
     LN  libflash

To reproduce this outside of buildroot, set PFLASH_VERSION to anything.
This is another race that is only exposed in certain conditions. By
describing the dependencies on the source files the build works again.

I think it's almost time to stop using symlinks.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
V2:
 - followed up on Stewarts suggestion to move the arch rules into the
   commom/rules.mk where they should be

 external/common/rules.mk | 20 ++++++++++++--------
 external/pflash/rules.mk |  7 +++++--
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/external/common/rules.mk b/external/common/rules.mk
index 4d94fe8f96f7..356c2076de28 100644
--- a/external/common/rules.mk
+++ b/external/common/rules.mk
@@ -1,27 +1,29 @@
-ARCH = $(shell $(GET_ARCH) "$(CROSS_COMPILE)")
+ARCH := $(shell $(GET_ARCH) "$(CROSS_COMPILE)")
 
 ifeq ($(ARCH),ARCH_ARM)
-arch = arm
-ARCH_OBJS = common-arch_flash_common.o common-arch_flash_arm.o common-ast-sf-ctrl.o
+arch := arm
+ARCH_FILES := arch_flash_common.c arch_flash_arm.c ast-sf-ctrl.c
 else
 ifeq ($(ARCH),ARCH_POWERPC)
-arch = powerpc
-ARCH_OBJS = common-arch_flash_common.o common-arch_flash_powerpc.o
+arch := powerpc
+ARCH_FILES := arch_flash_common.c arch_flash_powerpc.c
 else
 ifeq ($(ARCH),ARCH_X86)
-arch = x86
-ARCH_OBJS = common-arch_flash_common.o common-arch_flash_x86.o
+arch := x86
+ARCH_FILES := arch_flash_common.c arch_flash_x86.c
 else
 $(error Unsupported architecture $(ARCH))
 endif
 endif
 endif
 
+ARCH_SRC := $(addprefix common/,$(ARCH_FILES))
+ARCH_OBJS := $(addprefix common-,$(ARCH_FILES:.c=.o))
 
 # Arch links are like this so we can have dependencies work (so that we don't
 # run the rule when the links exist), pretty build output (knowing the target
 # name) and a list of the files so we can clean them up.
-ARCH_LINKS = common/ast-sf-ctrl.c common/ast.h common/io.h
+ARCH_LINKS := common/ast-sf-ctrl.c common/ast.h common/io.h
 
 arch_links: $(ARCH_LINKS)
 common/ast.h : ../../include/ast.h | common
@@ -37,6 +39,8 @@ common/ast-sf-ctrl.c : ../../hw/ast-bmc/ast-sf-ctrl.c | common
 arch_clean:
 	rm -rf $(ARCH_OBJS) $(ARCH_LINKS)
 
+$(ARCH_SRC): | common
+
 $(ARCH_OBJS): common-%.o: common/%.c
 	$(Q_CC)$(CROSS_COMPILE)gcc $(CFLAGS) -c $< -o $@
 
diff --git a/external/pflash/rules.mk b/external/pflash/rules.mk
index f49e438cedf2..219e3d34a706 100644
--- a/external/pflash/rules.mk
+++ b/external/pflash/rules.mk
@@ -2,8 +2,9 @@
 
 override CFLAGS  += -O2 -Wall -I.
 OBJS    = pflash.o progress.o version.o
-LIBFLASH_OBJS += libflash-libflash.o libflash-libffs.o libflash-ecc.o \
-		 libflash-blocklevel.o libflash-file.o
+LIBFLASH_FILES := libflash.c libffs.c ecc.c blocklevel.c file.c
+LIBFLASH_OBJS := $(addprefix libflash-, $(LIBFLASH_FILES:.c=.o))
+LIBFLASH_SRC := $(addprefix libflash/,$(LIBFLASH_FILES))
 OBJS	+= $(LIBFLASH_OBJS)
 OBJS	+= common-arch_flash.o
 EXE     = pflash
@@ -22,6 +23,8 @@ version.c: .version
 %.o : %.c
 	$(Q_CC)$(CC) $(CFLAGS) -c $< -o $@
 
+$(LIBFLASH_SRC): | links
+
 $(LIBFLASH_OBJS): libflash-%.o : libflash/%.c
 	$(Q_CC)$(CC) $(CFLAGS) -c $< -o $@
 
-- 
2.6.2



More information about the Skiboot mailing list