
I was looking at how U-Boot gets the date and time in the version string and I noticed that it doesn't get updated for each build. I'm using an arm-based board, and the code for building the version_string variable is in lib_arm/board.c. In other words, the date and time only get updated when that file (or anything it depends on) changes.
There's similar code in other lib*/board.c files.
I'm attaching a patch that builds the entire version string (including date and time) just before linking U-Boot so it's always up to date. Key features of the patch are:
1. Makefile generates version info in version_autogenerated.c, not include/version_autogenerated.h. I did this to avoid recompiling everything that depends on version.h since it changes every time.
2. There's no separate version recipe in Makefile since that caused a relink every time.
3. version.h now is C specific -- assembly files can no longer include it.
4. I deal with CONFIG_IDENT_STRING with a small program tools/identstr that I run from Makefile. I did this to avoid generating version_string at runtime with either a fixed size buffer that might not be big enough, or with malloc.
This patch is incomplete though. I'm sending it because I'm curious if this is interesting to other people (and they agree with the approach) and because I have some questions about how to proceed. They are:
- Lots of .S files include version.h but don't seem like they need to. I believe I can take them out without changing behavior.
- Lots of .S files have code like this: .globl version_string version_string: .ascii U_BOOT_VERSION .ascii " (", __DATE__, " - ", __TIME__, ")" .ascii CONFIG_IDENT_STRING, "\0"
I believe I can take these out as well.
I could use confirmation on both of these items.
- The blackfin board does something special with the version string. I'm sure I can come up with something equivalent but I wanted to get the above worked out first.
Thanks for your input.
-DB