diff mbox

[v2] external/pflash: Fix makefile dependencies

Message ID 1449189000-17764-1-git-send-email-joel@jms.id.au
State Accepted
Headers show

Commit Message

Joel Stanley Dec. 4, 2015, 12:30 a.m. UTC
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@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(-)

Comments

Stewart Smith Dec. 4, 2015, 3:41 a.m. UTC | #1
Joel Stanley <joel@jms.id.au> writes:
> 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@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 +++++--

Looks good - merged to master as of
6c21c4ffaf825b7a1bd130ff5b21c6349e772b68

Unfortunately, doesn't directly apply to stable as our makefiles are a
bit older there. Want something like this there?
Joel Stanley Dec. 4, 2015, 3:43 a.m. UTC | #2
On Fri, Dec 4, 2015 at 2:11 PM, Stewart Smith
<stewart@linux.vnet.ibm.com> wrote:
> Looks good - merged to master as of
> 6c21c4ffaf825b7a1bd130ff5b21c6349e772b68
>
> Unfortunately, doesn't directly apply to stable as our makefiles are a
> bit older there. Want something like this there?

I don't think we have anyone building pflash from stable that need this fix.

This relates to work on the Barreleye, so I think just master is fine.

Cheers,

Joel
diff mbox

Patch

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