diff mbox

Makefile: Set default locale C

Message ID 1332533128-24331-1-git-send-email-sw@weilnetz.de
State Superseded
Headers show

Commit Message

Stefan Weil March 23, 2012, 8:05 p.m. UTC
Some locale settings let make fail or create wrong results,
so set always the C locale.

* Conversion from lower to upper case with tr does not convert
  lower case 'i' to 'I' with locale tr_TR.UTF-8.

* The html files created from texi input contain non english
  titles like "Anhang" with locale de_DE.UTF-8.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 Makefile |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Comments

Peter Maydell March 24, 2012, 12:44 p.m. UTC | #1
On 23 March 2012 20:05, Stefan Weil <sw@weilnetz.de> wrote:
> +# Set default locale for commands like tr and others.
> +LANG=C
> +LC_ALL=C
> +LC_CTYPE=C

You don't export these, which leads to an obscure corner case:
if the user has no LANG variable set in their environment when
they run make then we will set LANG=C in the top level makefile
but it will not be set in a sub-makefile. Since the default
locale is the same as the C locale this doesn't make any
practical difference, but it's a little odd.

(Make automatically exports variables to submakes if they had
some value in its environment when it was started, but not if
they were only set in the makefile.)

Also, do we need to set these in configure too?

-- PMM
Emre Ersin March 24, 2012, 4:11 p.m. UTC | #2
It has to be set before configure. Because configure script creates wrong
.h file.

On Sat, Mar 24, 2012 at 2:44 PM, Peter Maydell <peter.maydell@linaro.org>wrote:

> On 23 March 2012 20:05, Stefan Weil <sw@weilnetz.de> wrote:
> > +# Set default locale for commands like tr and others.
> > +LANG=C
> > +LC_ALL=C
> > +LC_CTYPE=C
>
> You don't export these, which leads to an obscure corner case:
> if the user has no LANG variable set in their environment when
> they run make then we will set LANG=C in the top level makefile
> but it will not be set in a sub-makefile. Since the default
> locale is the same as the C locale this doesn't make any
> practical difference, but it's a little odd.
>
> (Make automatically exports variables to submakes if they had
> some value in its environment when it was started, but not if
> they were only set in the makefile.)
>
> Also, do we need to set these in configure too?
>
> -- PMM
>
Stefan Weil March 24, 2012, 5:56 p.m. UTC | #3
Am 24.03.2012 17:11, schrieb Emre Ersin:
> It has to be set before configure. Because configure script creates 
> wrong .h file.
>
> On Sat, Mar 24, 2012 at 2:44 PM, Peter Maydell 
> <peter.maydell@linaro.org <mailto:peter.maydell@linaro.org>> wrote:
>
>     On 23 March 2012 20:05, Stefan Weil <sw@weilnetz.de
>     <mailto:sw@weilnetz.de>> wrote:
>     > +# Set default locale for commands like tr and others.
>     > +LANG=C
>     > +LC_ALL=C
>     > +LC_CTYPE=C
>
>     You don't export these, which leads to an obscure corner case:
>     if the user has no LANG variable set in their environment when
>     they run make then we will set LANG=C in the top level makefile
>     but it will not be set in a sub-makefile. Since the default
>     locale is the same as the C locale this doesn't make any
>     practical difference, but it's a little odd.
>
>     (Make automatically exports variables to submakes if they had
>     some value in its environment when it was started, but not if
>     they were only set in the makefile.)
>
>     Also, do we need to set these in configure too?
>

Hi Peter,

yes, the same kind of patch is needed for configure, too.
I've already prepared one, but wanted to wait until this patch
was reviewed.

I intentionally did not add 'export' in the Makefile because up to now,
QEMU did not use this keyword in Makefiles, and I was not sure
whether it works on all build hosts with all variants of make.

I tested that my patch works. It's like you said: either the environment
variables are exported - then the settings in the Makefile override
the values and set the correct ones. Or they are not exported -
then the default setting is used which is also correct.

With my patch, configure creates a correct .h file.
There is no dependency on Makefile, so you have to remove the old
wrong .h file before running a new incremental build.

Regards,
Stefan W.
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 1bc3cb0..fef0d7f 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,11 @@  $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
 
 LIBS+=-lz $(LIBS_TOOLS)
 
+# Set default locale for commands like tr and others.
+LANG=C
+LC_ALL=C
+LC_CTYPE=C
+
 HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
 
 ifdef BUILD_DOCS