[PATCH v4 02/12] Makefile: Provide numeric versions

Simon Glass sjg at chromium.org
Fri Feb 5 05:17:13 CET 2021


For SMBIOS we want to store the numeric version numbers in the tables. It
does not make sense to parse the strings. Instead, add new #defines with
the version and patchlevel.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---

(no changes since v3)

Changes in v3:
- Use .rst file instead of README

 Makefile                | 4 ++++
 doc/develop/version.rst | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/Makefile b/Makefile
index 23dd11f723a..ebbedb1fb1a 100644
--- a/Makefile
+++ b/Makefile
@@ -1853,9 +1853,13 @@ prepare: prepare0
 # Generate some files
 # ---------------------------------------------------------------------------
 
+# Use sed to remove leading zeros from PATCHLEVEL to avoid using octal numbers
 define filechk_version.h
 	(echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \
 	echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \
+	echo \#define U_BOOT_VERSION_NUM $(VERSION); \
+	echo \#define U_BOOT_VERSION_NUM_PATCH $$(echo $(PATCHLEVEL) | \
+		sed -e "s/^0*//"); \
 	echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head -n 1)\"; \
 	echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head -n 1)\"; )
 endef
diff --git a/doc/develop/version.rst b/doc/develop/version.rst
index 6da31a4a1e7..a7797db41bb 100644
--- a/doc/develop/version.rst
+++ b/doc/develop/version.rst
@@ -69,6 +69,14 @@ The following are available:
          U-Boot 2020.10 (Jan 06 2021 - 08:50:36 -0700)
          U-Boot 2021.01-rc5-00248-g60dd854f3ba-dirty (Jan 06 2021 - 08:50:36 -0700) for spring
 
+   U_BOOT_VERSION_NUM (integer #define)
+      Release year, e.g. 2021 for release 2021.01. Note
+      this is an integer, not a string.
+
+   U_BOOT_VERSION_NUM_PATCH (integer #define)
+      Patch number, e.g. 1 for release 2020.01. Note
+      this is an integer, not a string.
+
 Build date/time is also included. See the generated file
 include/generated/timestamp_autogenerated.h for the available
 fields. For example::
-- 
2.30.0.478.g8a0d178c01-goog



More information about the U-Boot mailing list