diff mbox series

[v2] Makefile: Search for distro-provided cross-compiler

Message ID 20200124230102.22984-1-bauerman@linux.ibm.com
State Accepted
Headers show
Series [v2] Makefile: Search for distro-provided cross-compiler | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d75e82dbfbb9443efeb3f9a5921ac23605aab469)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Thiago Jung Bauermann Jan. 24, 2020, 11:01 p.m. UTC
Search for different variations of cross-compiler prefixes that might be in
the PATH, in this order of preference:

1. powerpc64-linux-gcc
2. powerpc64le-linux-gcc
3. powerpc64-linux-gnu-gcc
4. powerpc64le-linux-gnu-gcc

The latter two are available as distro packages in at least Debian, Fedora
and Ubuntu.

Tested with GNU Make 3.82 (CentOS 7) and GNU make 4.2.1 (Fedora 30).

Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
---
 Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

Changes in v2:
- Also search for little-endian toolchains (suggested by Nick Piggin).
- Use "else if" statements to keep code clearer.

I didn't add Andrew Donnellan's Reviewed-by and Tested-by because the
patch changed somewhat from what he reviewed and tested.

Comments

Andrew Donnellan Jan. 28, 2020, 3:09 a.m. UTC | #1
On 25/1/20 10:01 am, Thiago Jung Bauermann wrote:
> Search for different variations of cross-compiler prefixes that might be in
> the PATH, in this order of preference:
> 
> 1. powerpc64-linux-gcc
> 2. powerpc64le-linux-gcc
> 3. powerpc64-linux-gnu-gcc
> 4. powerpc64le-linux-gnu-gcc
> 
> The latter two are available as distro packages in at least Debian, Fedora
> and Ubuntu.
> 
> Tested with GNU Make 3.82 (CentOS 7) and GNU make 4.2.1 (Fedora 30).
> 
> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>

Works fine on my Debian box.

Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
Tested-by: Andrew Donnellan <ajd@linux.ibm.com>
Thiago Jung Bauermann Jan. 28, 2020, 5:45 p.m. UTC | #2
Andrew Donnellan <ajd@linux.ibm.com> writes:

> On 25/1/20 10:01 am, Thiago Jung Bauermann wrote:
>> Search for different variations of cross-compiler prefixes that might be in
>> the PATH, in this order of preference:
>>
>> 1. powerpc64-linux-gcc
>> 2. powerpc64le-linux-gcc
>> 3. powerpc64-linux-gnu-gcc
>> 4. powerpc64le-linux-gnu-gcc
>>
>> The latter two are available as distro packages in at least Debian, Fedora
>> and Ubuntu.
>>
>> Tested with GNU Make 3.82 (CentOS 7) and GNU make 4.2.1 (Fedora 30).
>>
>> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
>
> Works fine on my Debian box.
>
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> Tested-by: Andrew Donnellan <ajd@linux.ibm.com>

Thanks for reviewing and testing!
Oliver O'Halloran Feb. 3, 2020, 1:46 a.m. UTC | #3
On Sat, Jan 25, 2020 at 10:01 AM Thiago Jung Bauermann
<bauerman@linux.ibm.com> wrote:
>
> Search for different variations of cross-compiler prefixes that might be in
> the PATH, in this order of preference:
>
> 1. powerpc64-linux-gcc
> 2. powerpc64le-linux-gcc
> 3. powerpc64-linux-gnu-gcc
> 4. powerpc64le-linux-gnu-gcc
>
> The latter two are available as distro packages in at least Debian, Fedora
> and Ubuntu.
>
> Tested with GNU Make 3.82 (CentOS 7) and GNU make 4.2.1 (Fedora 30).
>
> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>

Thanks, merged as 9cd556ca1e5f3371662b83388eda2c52fc3ea092
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index f938a062e..8122e0cc2 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,15 @@  ifdef CROSS_COMPILE
 endif
 ifneq ("$(ARCH)", "ppc64")
 ifneq ("$(ARCH)", "ppc64le")
+ifneq ($(shell which powerpc64-linux-gcc 2> /dev/null),)
 	CROSS ?= powerpc64-linux-
+else ifneq ($(shell which powerpc64le-linux-gcc 2> /dev/null),)
+	CROSS ?= powerpc64le-linux-
+else ifneq ($(shell which powerpc64-linux-gnu-gcc 2> /dev/null),)
+	CROSS ?= powerpc64-linux-gnu-
+else ifneq ($(shell which powerpc64le-linux-gnu-gcc 2> /dev/null),)
+	CROSS ?= powerpc64le-linux-gnu-
+endif
 endif
 endif