tags:

views:

63

answers:

1

Is there a way to force '-m64' not overriding CXXFLAGS/CFLAGS. I want automatic x64 build environment like in Linux/BSD amd64.

Why do I need this?

The problem is complexity of the project I need to be buit as x64 on Solaris. It contains several parts and each may use specific C/C++ compiler flags. So, I can't just run:

CXXFLAGS=-m64 O2 ...
CFLAGS=-m64 -O2 ...
./configure

because there are no common C/C++ flags.

All I need is the way to transparently append '-m64' to every gcc/g++ call.

+2  A: 

You can write a wrapper (eg: ~/bin/gcc) that would add the required option(s) and put ~/bin first in your PATH. eg:

#!/bin/ksh
/usr/sfw/bin/gcc -m64 "$@"
jlliagre
Thank you for the answer! It's quite ugly workaround. Actually, I've found the simalar way - I override CC="gcc -m64" and CXX="g++ -m64". It works now. Unfortunately, it seems that such hacks are the only possibility to solve this problem. How reliable is this? Do we need to override LD or something else?
Shcheklein
No more (no less) an ugly workaround than an ugly requirement ...Anyway, as long as your building scripts/tools do not alter the PATH (resp CC/CXX) variables, the method should be reliable. No need to override LD or anything else.
jlliagre
Ok then. Since there are no other ways (it seems so at least) I accept your answer. Though, I don't understand why do you think that requirements are ugly.
Shcheklein
Blindingly build everything in 64 bit is questionable. In any case, that's not the way Solaris use to do things.
jlliagre
Yep. Solaris just proposes nothing at all )) And I described why do I need "blind" compilation. Anyway, something like alternatives on Linux, or gcc_select on Mac OS, or Visual Studio environment scripts (vsvars.bat) would be great I think.
Shcheklein