Skip to contentSkip to conversation

Config.in: add symbols for BR2_HOST_GCC_AT_LEAST_X_Y

PATCH New Thomas Petazzoni 2 participants 2 messages Dec 30, 2015 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Config.in: add symbols for BR2_HOST_GCC_AT_LEAST_X_Y

From: Arnout Vandecappelle <[email protected]>

Some host packages need a recent gcc version. Add symbols to Config.in to specify the HOSTCC version. The values are passed through the environment, and this environment is generated in a new support script.

Also update the documentation to mention the new symbols.

[Thomas: simplify by using only make logic instead of an external shell script.]

---
This is an alternate version, in which I've removed the shell script, and did everything in make. Contrary to what Arnout said, I don't find the sed expression to be more complicated, and the condition on gcc <= 4 or gcc >= 5 can easily be done in make.

 Config.in                                 | 24 ++++++++++++++++++++++++
 Makefile                                  | 12 ++++++++++++
 docs/manual/adding-packages-directory.txt |  7 +++++++
 3 files changed, 43 insertions(+)
Config.in +24 -0
index 9513cc1..bbbefb0 100644
@@ -18,6 +18,30 @@ config BR2_EXTERNAL
 	string
 	option env="BR2_EXTERNAL"
 
+# Hidden config symbols for packages to check system gcc version
+config BR2_HOST_GCC_VERSION
+	string
+	option env="HOST_GCC_VERSION"
+
+config BR2_HOST_GCC_AT_LEAST_4_7
+	bool
+	default y if BR2_HOST_GCC_VERSION = "47"
+
+config BR2_HOST_GCC_AT_LEAST_4_8
+	bool
+	default y if BR2_HOST_GCC_VERSION = "48"
+	select BR2_HOST_GCC_AT_LEAST_4_7
+
+config BR2_HOST_GCC_AT_LEAST_4_9
+	bool
+	default y if BR2_HOST_GCC_VERSION = "49"
+	select BR2_HOST_GCC_AT_LEAST_4_8
+
+config BR2_HOST_GCC_AT_LEAST_5
+	bool
+	default y if BR2_HOST_GCC_VERSION = "5"
+	select BR2_HOST_GCC_AT_LEAST_4_9
+
 # Hidden boolean selected by packages in need of Java in order to build
 # (example: xbmc)
 config BR2_NEEDS_HOST_JAVA
Makefile +12 -0
index 1d69192..0cfca6c 100644
@@ -293,6 +293,17 @@ HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranli
 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
 
+HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
+	sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*/\1 \2/')
+
+# For gcc 4.x, keep the second number around. For gcc >= 5.x, the
+# major version is enough.
+ifeq ($(firstword $(HOSTCC_VERSION)),4)
+HOSTCC_VERSION := $(subst $(space),,$(HOSTCC_VERSION))
+else
+HOSTCC_VERSION := $(firstword $(HOSTCC_VERSION))
+endif
+
 # Make sure pkg-config doesn't look outside the buildroot tree
 HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
 unexport PKG_CONFIG_PATH
@@ -724,6 +735,7 @@ COMMON_CONFIG_ENV = \
 	KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
 	BR2_CONFIG=$(BR2_CONFIG) \
 	BR2_EXTERNAL=$(BR2_EXTERNAL) \
+	HOST_GCC_VERSION=$(HOSTCC_VERSION) \
 	SKIP_LEGACY=
 
 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
docs/manual/adding-packages-directory.txt +7 -0
index 139123e..c2d9f75 100644
@@ -283,6 +283,13 @@ use in the comment.
 ** Comment string: +gcc >= X.Y+ and/or `gcc <= X.Y` (replace
    +X.Y+ with the proper version)
 
+* Host GCC version
+** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace
+   +X_Y+ with the proper version, see +Config.in+)
+** Comment string: no comment to be added
+** Note that it is usually not the package itself that has a minimum
+   host GCC version, but rather a host-package on which it depends.
+
 * C library
 ** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+,
    +BR2_TOOLCHAIN_USES_MUSL+, +BR2_TOOLCHAIN_USES_UCLIBC+
Signature · 1 line
2.6.4
#1 lore raw

PATCH v3 1/1 Config.in: add symbols for BR2_HOST_GCC_AT_LEAST_X_Y

THomas, Arnout, All,

On 2015-12-31 00:08 +0100, Thomas Petazzoni spake thusly:

Quoted 6 lines

From: Arnout Vandecappelle <[email protected]>

Some host packages need a recent gcc version. Add symbols to Config.in to specify the HOSTCC version. The values are passed through the environment, and this environment is generated in a new support script.

Quoted 7 lines

Also update the documentation to mention the new symbols.

[Thomas: simplify by using only make logic instead of an external shell script.]

Regards,
Yann E. MORIN.

Quoted 97 lines

---
This is an alternate version, in which I've removed the shell script, and did everything in make. Contrary to what Arnout said, I don't find the sed expression to be more complicated, and the condition on gcc <= 4 or gcc >= 5 can easily be done in make.

 Config.in                                 | 24 ++++++++++++++++++++++++
 Makefile                                  | 12 ++++++++++++
 docs/manual/adding-packages-directory.txt |  7 +++++++
 3 files changed, 43 insertions(+)
Config.in +24 -0
index 9513cc1..bbbefb0 100644
@@ -18,6 +18,30 @@ config BR2_EXTERNAL
 	string
 	option env="BR2_EXTERNAL"
 
+# Hidden config symbols for packages to check system gcc version
+config BR2_HOST_GCC_VERSION
+	string
+	option env="HOST_GCC_VERSION"
+
+config BR2_HOST_GCC_AT_LEAST_4_7
+	bool
+	default y if BR2_HOST_GCC_VERSION = "47"
+
+config BR2_HOST_GCC_AT_LEAST_4_8
+	bool
+	default y if BR2_HOST_GCC_VERSION = "48"
+	select BR2_HOST_GCC_AT_LEAST_4_7
+
+config BR2_HOST_GCC_AT_LEAST_4_9
+	bool
+	default y if BR2_HOST_GCC_VERSION = "49"
+	select BR2_HOST_GCC_AT_LEAST_4_8
+
+config BR2_HOST_GCC_AT_LEAST_5
+	bool
+	default y if BR2_HOST_GCC_VERSION = "5"
+	select BR2_HOST_GCC_AT_LEAST_4_9
+
 # Hidden boolean selected by packages in need of Java in order to build
 # (example: xbmc)
 config BR2_NEEDS_HOST_JAVA
Makefile +12 -0
index 1d69192..0cfca6c 100644
@@ -293,6 +293,17 @@ HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranli
 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
 
+HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
+	sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*/\1 \2/')
+
+# For gcc 4.x, keep the second number around. For gcc >= 5.x, the
+# major version is enough.
+ifeq ($(firstword $(HOSTCC_VERSION)),4)
+HOSTCC_VERSION := $(subst $(space),,$(HOSTCC_VERSION))
+else
+HOSTCC_VERSION := $(firstword $(HOSTCC_VERSION))
+endif
+
 # Make sure pkg-config doesn't look outside the buildroot tree
 HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
 unexport PKG_CONFIG_PATH
@@ -724,6 +735,7 @@ COMMON_CONFIG_ENV = \
 	KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
 	BR2_CONFIG=$(BR2_CONFIG) \
 	BR2_EXTERNAL=$(BR2_EXTERNAL) \
+	HOST_GCC_VERSION=$(HOSTCC_VERSION) \
 	SKIP_LEGACY=
 
 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
docs/manual/adding-packages-directory.txt +7 -0
index 139123e..c2d9f75 100644
@@ -283,6 +283,13 @@ use in the comment.
 ** Comment string: +gcc >= X.Y+ and/or `gcc <= X.Y` (replace
    +X.Y+ with the proper version)
 
+* Host GCC version
+** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace
+   +X_Y+ with the proper version, see +Config.in+)
+** Comment string: no comment to be added
+** Note that it is usually not the package itself that has a minimum
+   host GCC version, but rather a host-package on which it depends.
+
 * C library
 ** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+,
    +BR2_TOOLCHAIN_USES_MUSL+, +BR2_TOOLCHAIN_USES_UCLIBC+
Signature · 1 line
2.6.4
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'