The question is a little XY.
You want to be able make the intermediate assembly file foo.s
, where
the source file foo.c
is one of the sources in an autotooled project, using
a makefile that is generated by the project's ./configure
script. You
assume that to do this you must do something to the automake inputs -
the Makefile.am
s? - that will cause ./configure
to generate Makefiles
that include assembly targets *.s
matching all object targets *.o
.
Well you could, but then your project would not be a regular autotooled
project as usually distributed, and there is no need to make it irregular
to get what you want.
The GCC option -save-temps
exists to let developers see the intermediate files of compilation - the preprocessor
output, the assembly.
$ gcc -c -o foo.o foo.c
outputs foo.o
$ gcc -save-temps -c -o foo.o foo.c
outputs:
foo.o
foo.i # preprocessed source
foo.s # assembly
As I expect you know, GNU Make receives compiler options from the make-variable
CFLAGS
, and automake respects this convention, independently of and in addition to any compiler
options prescribed by the project's autotooling. So, if you would otherwise generate
makefiles with:
$ ./configure ...
then, to add -save-temps
to the C compiler options, generate makefiles instead
with:
$ ./configure CFLAGS=-save-temps ...
And if you are already using CFLAGS
, e.g.
$ ./configure CFLAGS="-g -O0" ...
then append -save-temps
:
$ ./configure CFLAGS="-g -O0 -save-temps" ...
Then,
$ make main.o
will make main.o
, main.i
and main.s
up-to-date.
To disable -save-temps
, of course, rerun ./configure
, removing it from
the CFLAGS
.
If the project involves C++ compilation, then CXXFLAGS
affects the C++
compiler in the same way that CFLAGS
affects the C compiler. Note that
the generated preprocessed C++ sources will be called *.ii
, not *.i
.
With -save-temps
enabled, make clean
will not delete the *.i
and *.s
files. You may not care, since compilation will always clobber them. If you
do care, you may take advantage of automake's standard phony target clean-local
,
which is supported to let an autotooling maintainer extend the behaviour of
clean
. Add the following recipe to the Makefile.am
of each source directory
in the project:
clean-local:
$(RM) *.i *.ii *.s
Then update the autotooling and regenerate Makefiles:
$ autoreconf
$ ./configure ...