James Miller
James Miller

Reputation: 25

CFLAGS in configure script

I usually use an IDE whenever I write my own code. I don't know very much about make, configure scripts, etc.

I'm working on a large and complicated existing project now, and the steps to build are:

./autogen.sh
./configure
make

I wrote my own C files and added them to Makefile.am. I then repeat this process to build.

Everything is fine, except for one thing. I want to build without any compiler options like -Wall. I was told that using CFLAGS like this would give me what I want:

./configure CFLAGS=-O0

It doesn't seem to work, because the compiler still uses the -Wall option. I can manually remove all occurances of -Wall from the CFLAGS="..." in the configure script. This is annoying but it works. But then when I execute

./autogen.sh

The configure script is reset with all of the -Walls (and other CLFAGS I don't want) back in their original places. (I'm not sure but I think I have to run autogen.sh every time I add new files to Makefile.am.)

Is there a better way deal with this?

Upvotes: 2

Views: 5885

Answers (2)

RTLinuxSW
RTLinuxSW

Reputation: 842

Doing a

./configure --help

shows

Some influential environment variables: ...
  CFLAGS      C compiler flags

The better approach is

env CFLAGS="-O0" ./configure

Then a simple

make

does as you expect. This is helpful to set other compile flags.

Upvotes: 4

Some programmer dude
Some programmer dude

Reputation: 409206

The simplest way might be to do it when actually building, using make:

make CFLAGS=-O0

That's only temporary for that build though, it won't be permanent.

Upvotes: 2

Related Questions