<p>Is there a way set flags on a per-file basis with automake?<br>
In particular, if I have a c++ project and want to compile with -WAll all the files except one for which I want to disable a particular warning, what could I do?</p>

<p>I tried something like:</p>

<pre><code>CXXFLAGS = -WAll ...
bin_PROGRAMS = test
test_SOURCES = main.cpp utility.cpp
utility_o_CXXFLAGS = $(CXXFLAGS) -Wno-unused-value
</code></pre>

<p>but it didn't work.</p>

<p>EDITED: removed reference to automake manual, which was actually misleading (thanks to Douglas Leeder).</p>

You've got confused - that section is referring to options to automake itself.
It's a way of setting the automake command-line options:
-W CATEGORY
  --warnings=category
      Output warnings falling in category. category can be one of:
```
```
gnu
    warnings related to the GNU Coding Standards (see Top).
obsolete
    obsolete features or constructions
override
    user redefinitions of Automake rules or variables
portability
    portability issues (e.g., use of make features that are known to be not portable)
syntax
    weird syntax, unused variables, typos
unsupported
    unsupported or incomplete features
all
    all the warnings
none
    turn off all the warnings
error
    treat warnings as errors
```
```
A category can be turned off by prefixing its name with ‘no-’.
  For instance, -Wno-syntax will hide the
  warnings about unused variables.
The categories output by default are ‘syntax’ and ‘unsupported’.
  Additionally, ‘gnu’ and ‘portability’
  are enabled in --gnu and --gnits
  strictness.
The environment variable WARNINGS can contain a comma separated list of
  categories to enable. It will be taken
  into account before the command-line
  switches, this way -Wnone will also
  ignore any warning category enabled by
  WARNINGS. This variable is also used
  by other tools like autoconf; unknown
  categories are ignored for this
  reason.
The per-file listed in section 17 refers to per-Makefile not source file.
I'm not aware of any per-source file flag setting, but you can set the option for each result binary with:
```
```
binaryname_CXXFLAGS
```
```