How to force /usr/bin/gcc -> /usr/bin/gcc -m32?

2019-01-23 22:36发布

问题:

I have bad Makefile(s) of a large bundled software distribution. In some point compiler always "forgets" that I want to compile in 32 bit program. This causes that part of the programs have 64 bit libraries and others have 32 bit libraries.

How can I force -m32 option every time that I run gcc?

br,
Juha

P.S. My environment is mixed 32/64 bit (macbook5.1, snow leopard). Alternatively: How can I make my system purely 32 or 64 bits?

edit: Emphasis on the bad Makefiles that override the global variables. Thats why I chosed the hack that works.

回答1:

If you want a crappy hack, you could replace /usr/bin/gcc with this shell script:

#!/bin/bash
/usr/bin/gcc-4.whatever -m32 "$@"


回答2:

Set your CFLAGS environment variable to have the -m32 flag.

export CFLAGS="-m32"