2

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.

Juha
  • 2,053
  • 23
  • 44

2 Answers2

6

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

export CFLAGS="-m32"

wkl
  • 77,184
  • 16
  • 165
  • 176
  • +1 for suggesting the right way. I wonder if it will work with the broken Makefiles. – nmichaels Dec 06 '10 at 18:44
  • 1
    @Juha @Nathon - yeah, I thought about this problem more after Nathon commented. The `CFLAGS` environment variable is used by the various build tools (`configure`, `make`) but I think in Juha's case, his makefiles are unsetting flags or not using them at all at some point in the compilation. – wkl Dec 06 '10 at 19:01
5

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

#!/bin/bash
/usr/bin/gcc-4.whatever -m32 "$@"
nmichaels
  • 49,466
  • 12
  • 107
  • 135
  • +1, I was just about to suggest this. If this doesn't work, the OP will have to hack the `Makefile`s into shape. – Fred Foo Dec 06 '10 at 18:44
  • This is mostly running fine, but sometimes there is \-protected items. $* wraps them with "" which fails. Any ideas to fix this? – Juha Dec 06 '10 at 20:59
  • @Juha: Try with `"$@"` instead of `$*`? – nmichaels Dec 06 '10 at 21:06
  • @nmichaels wouldnt making an alias for gcc be better than messing with files? – chacham15 Feb 07 '12 at 20:14
  • @chacham15: In most situations, yes. However, in this one the Makefiles' environment appeared to be messed up so I'm not sure if it would work. – nmichaels Feb 08 '12 at 15:03