2

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?

James Miller
  • 25
  • 1
  • 4
  • 2
    Why haven't you fixed your code so that it compiles silently with `-Wall`? Is it safe to use, in fact, when there are warnings from `-Wall`? – Jonathan Leffler Sep 26 '15 at 01:49

2 Answers2

4

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.

RTLinuxSW
  • 822
  • 5
  • 9
  • 2
    The advice is generally the other way around. Rather than `CFLAGS=-O0 ./configure`, it's better to do `./configure CFLAGS=-O0`, because in that case the `./configure` script will record the fact that that variable was set, and ensure it's set again if you do `./config.status --recheck`. (It sounds as if this isn't the OP's problem, though) – Norman Gray Sep 27 '15 at 19:46
2

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.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621