Skip to contentSkip to conversation

Makefile problems

U-Boot-Users Detlef Vollmann 3 participants 7 messages May 13, 2005 – May 17, 2005

lore
Share & tools
lore
#0 lore raw

Hello,

as the command constants in cmd_confdefs.h are long longs, the programs in tools that include a board configuration file dont't compile with GCC 2.x. But on a number of workstations the 'gcc' command is still 2.95.x, while the 3.x version is named gcc3, gcc-3 or similar.
One way to solve this is to add a line to tools/Makefile like HOSTCC=gcc-3
But now I need a different makefile on different machines. To avoid this, I tried things like

 $ HOSTCC=gcc-3 make
or even
 $ HOSTCC=gcc-3 make -e
but none of these worked.
The most elegant version would be to give the HOSTCC at
configuration time, i.e.
 $ HOSTCC=gcc-3 make xyz_config
But I have no idea whether this is possible and if so how
to implement it.

Any ideas?

Detlef

Signature · 2 lines
Detlef Vollmann   vollmann engineering gmbh
Linux and C++ for Embedded Systems    http://www.vollmann.ch/
#1 lore raw
Quoted 21 lines · Detlef Vollmann

Hello,

as the command constants in cmd_confdefs.h are long longs, the programs in tools that include a board configuration file dont't compile with GCC 2.x. But on a number of workstations the 'gcc' command is still 2.95.x, while the 3.x version is named gcc3, gcc-3 or similar.
One way to solve this is to add a line to tools/Makefile like HOSTCC=gcc-3
But now I need a different makefile on different machines. To avoid this, I tried things like

 $ HOSTCC=gcc-3 make
or even
 $ HOSTCC=gcc-3 make -e
but none of these worked.
The most elegant version would be to give the HOSTCC at
configuration time, i.e.
 $ HOSTCC=gcc-3 make xyz_config
But I have no idea whether this is possible and if so how
to implement it.
Quoted 4 lines

Any ideas?

Detlef

I'm not sure why "HOSTCC=gcc-3 make -e" isn't working. This should override the declaration in config.mk.

However, you can always try the alternative (better) syntax:
make HOSTCC=gcc-3

make -e should be avoided because it causes *all* of your environment variables to override declarations in the Makefile. Using the format above you can explicity override individual variables.

--
Simon Poole
www.appliancestudio.com

#2 lore raw
Quoted 6 lines · Simon Poole

I'm not sure why "HOSTCC=gcc-3 make -e" isn't working. This should override the declaration in config.mk.

However, you can always try the alternative (better) syntax:
make HOSTCC=gcc-3

The problem with this is, that I have to remeber that every time I issue the command (and my customers as well).
If the first version would work, I could put the variable in the shell startup file.

Quoted 2 lines

make -e should be avoided because it causes *all* of your environment variables to override declarations in the Makefile.

I believe that is what I want.
The problem with it is that it works recursively: the definitions in the main makefile overide the ones from the sub-makefile. And that causes the sources in the tools directory to be compiled with the CC from the main makefile, which is the cross compiler :-(

Quoted 2 lines

Using the format
above you can explicity override individual variables.

On each single invocation. And that is what I want to avoid.

Detlef

Signature · 2 lines
Detlef Vollmann   vollmann engineering gmbh
Linux and C++ for Embedded Systems    http://www.vollmann.ch/
#3 lore raw
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 2 lines

make HOSTCC=gcc-3

The problem with this is, that I have to remeber that every time I issue the command (and my customers as well).

You better know exactly what you are doing, so having to remember the correct command is a Good Thing (TM).

Quoted 2 lines

If the first version would work, I could put the variable in the shell startup file.

... and run into trouble with other builds failing in "interesting" ways later. No, thanks.

Quoted 3 lines
Quoted 2 lines

make -e should be avoided because it causes *all* of your environment variables to override declarations in the Makefile.

I believe that is what I want.

You think you want it, but you don't. Really. You DO NOT.

Quoted 3 lines
Quoted 2 lines

Using the format
above you can explicity override individual variables.

On each single invocation. And that is what I want to avoid.

But each single invocation produces results. Maybe different results if you want. Or if you think you want ;-)

"UNIX was not designed to stop you from doing stupid things, because
that would also stop you from doing clever things." - Doug Gwyn

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A verbal contract isn't worth the paper it's written on.
                                                    -- Samuel Goldwyn
#4 lore raw
Quoted 7 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:
Quoted 1 line

make HOSTCC=gcc-3

The problem with this is, that I have to remeber that every time I issue the command (and my customers as well).

You better know exactly what you are doing, so having to remember the correct command is a Good Thing (TM).

Hmm, so if my host's C compiler happens to be named gcc, I don't have to remember, but if it happens to be named differently (ncc, como, gcc-3, acc, ...) I need to remember? Strange policy...

Quoted 5 lines
Quoted 2 lines

If the first version would work, I could put the variable in the shell startup file.

... and run into trouble with other builds failing in "interesting" ways later. No, thanks.

Well, that's the way all the packages using 'configure' work. They pick up whatever is defined in your environment at configure time.

And as I wrote, my most preferred solution would be something like 'HOSTCC=gcc-3 make xyz_config'. To achieve this, a simple line like '[ $HOSTCC ] && echo "HOSTCC = $HOSTCC" >> config.mk' in mkconfig would probably suffice. But maybe there's another (better) way.

Detlef

Signature · 2 lines
Detlef Vollmann   vollmann engineering gmbh
Linux and C++ for Embedded Systems    http://www.vollmann.ch/
#5 lore raw
Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 3 lines

You better know exactly what you are doing, so having to remember the correct command is a Good Thing (TM).

Hmm, so if my host's C compiler happens to be named gcc, I don't have to remember, but if it happens to be named differently (ncc, como, gcc-3, acc, ...) I need to remember? Strange policy...

What is strange about this? You will have to do the same whith about any Makefile I know.

Quoted 3 lines

Well, that's the way all the packages using 'configure' work. They pick up whatever is defined in your environment at configure time.

We don't use configure, though.

Quoted 5 lines

And as I wrote, my most preferred solution would be something like 'HOSTCC=gcc-3 make xyz_config'. To achieve this, a simple line like '[ $HOSTCC ] && echo "HOSTCC = $HOSTCC" >> config.mk' in mkconfig would probably suffice. But maybe there's another (better) way.

What makes it difficult for you to use

make HOSTCC=gcc-3 xyz_config
instead of
HOSTCC=gcc-3 make xyz_config
??

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Dealing with failure is easy: work hard to improve. Success  is  also
easy  to  handle:  you've  solved  the  wrong  problem.  Work hard to
improve.
#6 lore raw
Quoted 9 lines · Wolfgang Denk
Quoted 5 lines

And as I wrote, my most preferred solution would be something like 'HOSTCC=gcc-3 make xyz_config'. To achieve this, a simple line like '[ $HOSTCC ] && echo "HOSTCC = $HOSTCC" >> config.mk' in mkconfig would probably suffice. But maybe there's another (better) way.

What makes it difficult for you to use

Quoted 9 lines

make HOSTCC=gcc-3 xyz_config
instead of
HOSTCC=gcc-3 make xyz_config
??

Best regards,

Wolfgang Denk

or

MAKEARGS=
[ -n "$HOSTCC" ] && MAKEARGS="HOSTCC=$HOSTCC"
make $MAKEARGS xyz_config

--
Simon Poole
www.appliancestudio.com