Patchwork [U-Boot] Move timestamp and version files into 'generated' subdir

login
register
mail settings
Submitter Simon Glass
Date Oct. 7, 2011, 11:19 p.m.
Message ID <1318029574-10895-1-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/118385/
State New, archived
Headers show

Comments

Simon Glass - Oct. 7, 2011, 11:19 p.m.
There is a rather subtle build problem where the build time stamp is not
updated for out-of-tree builds if there exists an in-tree build which
has a valid timestamp file. So if you do an in-tree build, then an
out-of-tree build your timestamp will not change.

The correct timestamp_autogenerated.h lives in the object tree, but it
is not always found there. The source still lives in the source tree and
when compiling version.h, it includes timestamp_autogenerated.h. Since
the current directory is always searched first, this will come from the
source tree rather than the object tree if it exists there. This affects
dependency generation also, which means that common/cmd_version.o will not
even be rebuilt if you have ever done an in-tree build.

A similar problem exists with the version file.

This change moves both files into the 'generated' subdir, which is already
used for asm-offsets.h. Then timestamp.h and version.h are updated to
include the files from there.

There are other places where these generated files are included, but I
cannot see why these don't just use the timestamp.h and version.h headers.
So this change also tidies that up.

I have tested this with in- and out-of-tree builds, but not SPL. I have
looked at various other options for fixing this, including sed on the dep
files, -I- and -include flags to gcc, but I don't think they can be made
to work. Comments welcome.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 Makefile                                  |    5 +++--
 arch/arm/cpu/armv7/omap-common/spl.c      |    3 +--
 arch/arm/cpu/armv7/omap-common/spl_mmc.c  |    3 +--
 arch/arm/cpu/armv7/omap-common/spl_nand.c |    3 +--
 drivers/serial/usbtty.h                   |    2 +-
 include/timestamp.h                       |    2 +-
 include/version.h                         |    2 +-
 7 files changed, 9 insertions(+), 11 deletions(-)
Mike Frysinger - Oct. 8, 2011, 1:05 a.m.
i like generated headers all being in the same place

however, you forgot to update include/.gitignore :)
-mike
Simon Glass - Oct. 10, 2011, 7:24 p.m.
Hi Mike,

On Fri, Oct 7, 2011 at 6:05 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> i like generated headers all being in the same place
>
> however, you forgot to update include/.gitignore :)
> -mike
>

OK I did this and sent a new patch set to remove those lines, and a
third (oops) since someone has already fixed the Makefile. Things move
quickly around here!

Regards,
Simon

Patch

diff --git a/Makefile b/Makefile
index cd6fc8c..f69ea25 100644
--- a/Makefile
+++ b/Makefile
@@ -30,8 +30,8 @@  U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 else
 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
 endif
-TIMESTAMP_FILE = $(obj)include/timestamp_autogenerated.h
-VERSION_FILE = $(obj)include/version_autogenerated.h
+TIMESTAMP_FILE = $(obj)include/generated/timestamp_autogenerated.h
+VERSION_FILE = $(obj)include/generated/version_autogenerated.h
 
 HOSTARCH := $(shell uname -m | \
 	sed -e s/i.86/x86/ \
@@ -456,6 +456,7 @@  $(obj)spl/u-boot-spl.bin:		depend
 		$(MAKE) -C spl all
 
 $(TIMESTAMP_FILE):
+		@mkdir -p $(dir $@)
 		@LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@
 		@LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@
 
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c
index c76fea6..01fd58a 100644
--- a/arch/arm/cpu/armv7/omap-common/spl.c
+++ b/arch/arm/cpu/armv7/omap-common/spl.c
@@ -29,8 +29,7 @@ 
 #include <nand.h>
 #include <mmc.h>
 #include <fat.h>
-#include <timestamp_autogenerated.h>
-#include <version_autogenerated.h>
+#include <version.h>
 #include <asm/omap_common.h>
 #include <asm/arch/mmc_host_def.h>
 #include <i2c.h>
diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c
index 1d1e50c..6f5b43e 100644
--- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c
+++ b/arch/arm/cpu/armv7/omap-common/spl_mmc.c
@@ -28,8 +28,7 @@ 
 #include <asm/arch/sys_proto.h>
 #include <mmc.h>
 #include <fat.h>
-#include <timestamp_autogenerated.h>
-#include <version_autogenerated.h>
+#include <version.h>
 #include <asm/omap_common.h>
 #include <asm/arch/mmc_host_def.h>
 
diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c
index af02a59..38d06b1 100644
--- a/arch/arm/cpu/armv7/omap-common/spl_nand.c
+++ b/arch/arm/cpu/armv7/omap-common/spl_nand.c
@@ -25,8 +25,7 @@ 
 #include <asm/utils.h>
 #include <asm/arch/sys_proto.h>
 #include <nand.h>
-#include <timestamp_autogenerated.h>
-#include <version_autogenerated.h>
+#include <version.h>
 #include <asm/omap_common.h>
 
 
diff --git a/drivers/serial/usbtty.h b/drivers/serial/usbtty.h
index a23169a..14961c1 100644
--- a/drivers/serial/usbtty.h
+++ b/drivers/serial/usbtty.h
@@ -37,7 +37,7 @@ 
 #include <usb/spr_udc.h>
 #endif
 
-#include <version_autogenerated.h>
+#include <version.h>
 
 /* If no VendorID/ProductID is defined in config.h, pretend to be Linux
  * DO NOT Reuse this Vendor/Product setup with protocol incompatible devices */
diff --git a/include/timestamp.h b/include/timestamp.h
index b2f4cf4..05a6658 100644
--- a/include/timestamp.h
+++ b/include/timestamp.h
@@ -24,7 +24,7 @@ 
 #define	__TIMESTAMP_H__
 
 #ifndef DO_DEPS_ONLY
-#include "timestamp_autogenerated.h"
+#include "generated/timestamp_autogenerated.h"
 #endif
 
 #endif	/* __TIMESTAMP_H__ */
diff --git a/include/version.h b/include/version.h
index 129acef..c908bd3 100644
--- a/include/version.h
+++ b/include/version.h
@@ -27,7 +27,7 @@ 
 #include <timestamp.h>
 
 #ifndef DO_DEPS_ONLY
-#include "version_autogenerated.h"
+#include "generated/version_autogenerated.h"
 #endif
 
 #ifndef CONFIG_IDENT_STRING