[Ilugc] Changing default CFLAGS flags for gcc

  • From: a.kumar@xxxxxxxxxxxxxxxxx (Kumar Appaiah)
  • Date: Thu Sep 3 04:58:04 2009

On Thu, Sep 03, 2009 at 12:06:56AM +0530, narendra babu wrote:

I have lot of makefiles  , by default gcc geneartes 64 bit executable on 64 
machine  but i need to change to 32 bit , dont want to change the makefiles .

Instead is there anyway i can change default flags at command line for gcc

Can i set environment variable 
export CFLAGS=-m32 CXX=-m32  so that by gcc takes CFLAGS or CXX to generate 
32bit code instead of 64 bit code by default .

So in simple i want to chnage the gcc default flag settings
  
Like $CFLAGS=-m32 gcc hello.c should generate me 32 bit code on a 64 bit 
machine instead of 64 bit .

Note : As by default all my makefiles can take the default CFLAGS which is 
set as environment variable .

Well, why don't you try it?

Consider this Makefile:

all:
        echo CFLAGS are $(CFLAGS)

Now, this is the result of running it:

[$ /tmp] make
echo CFLAGS are
CFLAGS are

[$ /tmp] CFLAGS=-m32 make
echo CFLAGS are -m32
CFLAGS are -m32

HTH.

Kumar

Other related posts: