Skip to contentSkip to conversation

allow CROSS_COMPILE override

PATCH In review Jun Sun 4 participants 9 messages Feb 20, 2003 – Feb 21, 2003 MIPS

lore
Share & tools
lore

Jun Sun

author
#0 lore raw

PATCH 1/1 allow CROSS_COMPILE override

Anybody would object this? It allows one to override CROSS_COMPILE from command line or top-level Makefile.

Jun

arch/mips/Makefile renamed from arch/mips/Makefile.orig +3 -1
diff -Nru linux/arch/mips/Makefile.orig linux/arch/mips/Makefile
@@ -23,7 +23,9 @@
 endif
 
 ifdef CONFIG_CROSSCOMPILE
-CROSS_COMPILE	= $(tool-prefix)
+  ifndef CROSS_COMPILE
+    CROSS_COMPILE	= $(tool-prefix)
+  endif
 endif
 
 #
#1 lore raw
Quoted 2 lines · Jun Sun

Anybody would object this? It allows one to override

Why not but this is less messy:

mips/Makefile 20 Feb 2003 21:10:30 -0000 renamed from mips/Makefile 13 Dec 2002 23:41:09 -0000 1.1.1.8 +0 -0
@@ -23,7 +23,7 @@

endif

ifdef CONFIG_CROSSCOMPILE
-CROSS_COMPILE = $(tool-prefix)
+CROSS_COMPILE ?= $(tool-prefix)
endif

#

/Brian

author
#2 lore raw

Is this allowed? Can't find any such usage in kernel other than the worrisome comment below:

arch/arm/Makefile:# Grr, ?= doesn't work as all the other assignment operators do. Make bug?

Jun

Quoted 20 lines · Brian Murphy
Quoted 2 lines · Jun Sun

Anybody would object this? It allows one to override

Why not but this is less messy:

mips/Makefile 20 Feb 2003 21:10:30 -0000 renamed from mips/Makefile 13 Dec 2002 23:41:09 -0000 1.1.1.8 +1 -1
@@ -23,7 +23,7 @@
 endif
 
 ifdef CONFIG_CROSSCOMPILE
-CROSS_COMPILE  = $(tool-prefix)
+CROSS_COMPILE ?= $(tool-prefix)
 endif
 
 #

/Brian

#3 lore raw
Quoted 8 lines · Jun Sun

Is this allowed? Can't find any such usage in kernel other than the worrisome comment below:

arch/arm/Makefile:# Grr, ?= doesn't work as all the other assignment operators do. Make bug?

It worked for me when I tested the patch, at least for this simple case. Might have something to do with the make version, when was the comment written?

brm@brian:~$ make -v
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.

/Brian

#4 lore raw
Quoted 10 lines · Brian Murphy
Quoted 8 lines · Jun Sun

Is this allowed? Can't find any such usage in kernel other than the worrisome comment below:

arch/arm/Makefile:# Grr, ?= doesn't work as all the other assignment operators do. Make bug?

Quoted 6 lines

It worked for me when I tested the patch, at least for this simple case. Might have something to do with the make version, when was the comment written?

brm@brian:~$ make -v
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.

I know for a fact that this syntax works for me on RH7.3 because we use it heavily in a bunch of tools makefiles.

Pete

#5 lore raw
In reply to Jun Sun
Quoted 8 lines · Jun Sun

Is this allowed? Can't find any such usage in kernel other than the worrisome comment below:

arch/arm/Makefile:# Grr, ?= doesn't work as all the other assignment operators do. Make bug?

The arm code does this:

# Only set INCDIR if its not already defined above
# Grr, ?= doesn't work as all the other assignment operators do. Make bug? ifeq ($(origin INCDIR), undefined)
INCDIR := $(MACHINE)
endif

where the make docs say:

INCDIR ?= $(MACHINE)

is the same as

ifeq ($(origin INCDIR), undefined)
INCDIR = $(MACHINE)
endif

which means INCDIR will reflect changes to MACHINE. The := form sets INCDIR once and for all. What do you want? I can't see that this should be a problem in the arm makefile. Perhaps I'm missing something.

/Brian

author
#6 lore raw
Quoted 22 lines · Brian Murphy
Quoted 8 lines · Jun Sun

Is this allowed? Can't find any such usage in kernel other than the worrisome comment below:

arch/arm/Makefile:# Grr, ?= doesn't work as all the other assignment operators do. Make bug?

The arm code does this:

# Only set INCDIR if its not already defined above
# Grr, ?= doesn't work as all the other assignment operators do. Make bug? ifeq ($(origin INCDIR), undefined)
INCDIR := $(MACHINE)
endif

where the make docs say:

INCDIR ?= $(MACHINE)

Quoted 8 lines

is the same as

ifeq ($(origin INCDIR), undefined)
INCDIR = $(MACHINE)
endif

which means INCDIR will reflect changes to MACHINE. The := form sets INCDIR once and for all. What do you want?

':=' is fine, as long as "?=" is deemed appropriate for kernel and hackers.

Jun

#7 lore raw
In reply to Jun Sun
Quoted 5 lines · Jun Sun

Anybody would object this? It allows one to override CROSS_COMPILE from command line or top-level Makefile.

Jun

Silly question: why does this matter if CROSS_COMPILE is on the command line? Command line definitions override anything in the makefile. Is it falling off the command line in a recursive make?

Quoted 14 lines

diff -Nru linux/arch/mips/Makefile.orig linux/arch/mips/Makefile

arch/mips/Makefile renamed from arch/mips/Makefile.orig +3 -1
@@ -23,7 +23,9 @@
 endif
 
 ifdef CONFIG_CROSSCOMPILE
-CROSS_COMPILE	= $(tool-prefix)
+  ifndef CROSS_COMPILE
+    CROSS_COMPILE	= $(tool-prefix)
+  endif
 endif
 
 #
Signature · 2 lines
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer
#8 lore raw
Quoted 5 lines · Daniel Jacobowitz

Silly question: why does this matter if CROSS_COMPILE is on the command line? Command line definitions override anything in the makefile. Is it falling off the command line in a recursive make?

You need ?= to allow the define in the top level makefile to override that in the sub-makefile. You also need it if you want to get the value from an environment variable and not from something like this:

make CROSS_COMPILE=xxx

which is the only case where it works now.

/Brian