11

I recently learned how to use automake, and I'm somewhat annoyed that my compile commands went from a bunch of:

g++ -O2 -Wall -c fileName.cpp

To a bunch of:

depbase=`echo src/Unit.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
    g++ -DHAVE_CONFIG_H -I. -I./src     -g -O2 -MT src/Unit.o -MD -MP -MF $depbase.Tpo -c -o src/Unit.o src/Unit.cpp &&\
    mv -f $depbase.Tpo $depbase.Po

Is there any way to clean this up? I can usually easily pick out warning messages, but now the wall of text to read though is 3x bigger and much weirder.

I know what my flags are, so making it just says "Compiling xxx.cpp" for each file would be perfect.

Brendan Long
  • 53,280
  • 21
  • 146
  • 188

2 Answers2

18

As of automake 1.11, you can greatly clean up the output using the silent-rules option. For example:

$ # First, make without silent rules
$ make
make  all-am
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT foo.o -MD -MP -MF .deps/foo.Tpo -c -o foo.o foo.c
mv -f .deps/foo.Tpo .deps/foo.Po
/bin/sh ./libtool  --tag=CC   --mode=link gcc  -g -O2   -o foo foo.o
libtool: link: gcc -g -O2 -o foo foo.o
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT bar.o -MD -MP -MF .deps/bar.Tpo -c -o bar.o bar.c
mv -f .deps/bar.Tpo .deps/bar.Po
/bin/sh ./libtool  --tag=CC   --mode=link gcc  -g -O2   -o bar bar.o
libtool: link: gcc -g -O2 -o bar bar.o
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT baz.o -MD -MP -MF .deps/baz.Tpo -c -o baz.o baz.c
mv -f .deps/baz.Tpo .deps/baz.Po
/bin/sh ./libtool  --tag=CC   --mode=link gcc  -g -O2   -o baz baz.o
libtool: link: gcc -g -O2 -o baz baz.o
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT qux.o -MD -MP -MF .deps/qux.Tpo -c -o qux.o qux.c
mv -f .deps/qux.Tpo .deps/qux.Po
/bin/sh ./libtool  --tag=CC   --mode=link gcc  -g -O2   -o qux qux.o
libtool: link: gcc -g -O2 -o qux qux.o
$ # Now, use the silent rules
$ ./configure --enable-silent-rules > /dev/null
$ make clean all
 rm -f foo bar baz qux
rm -rf .libs _libs
rm -f *.o
rm -f *.lo
make  all-am
  CC       foo.o
  CCLD     foo
  CC       bar.o
  CCLD     bar
  CC       baz.o
  CCLD     baz
  CC       qux.o
  CCLD     qux

All that is needed is to add "silent-rules" to the invocation of AM_INIT_AUTOMAKE in configure.ac, and add the option --enable-silent-rules when you invoke configure. (There was much debate about requiring the option to be added at configure time when this feature was added, and there is an easy workaround to make it unnecessary.) Note that with silent-rules enabled, you can still get verbose output by running 'make V=1'

William Pursell
  • 204,365
  • 48
  • 270
  • 300
  • 6
    Looks like all it takes to make it the default is to add AM_SILENT_RULES([yes]). This is exactly what I was looking for. – Brendan Long May 23 '10 at 20:38
  • 1
    Thanks; adding `AM_SILENT_RULES([yes])` by itself to `configure.ac`, right after the `AM_INIT_AUTOMAKE` line, did the trick. Much nicer output. – Arto Bendiken Nov 29 '10 at 10:36
  • Sorry for necrocommenting here... I'm having the same issue as the original poster. To me, it would be fine if my make output looked like your initial "without silent rules" example. That seems to be pretty standard. But mine comes with all kinds of sed lines like OP's, especially dealling with the "depbase" variable. It's honestly quite hard on the eyes. Is there any way to just clean that part out and leave the compile commands? – Mortimer McMire Dec 23 '13 at 05:28
2

I did a bit of googling around as I am in the same boat, the autoconf tools do a nice job but it kind of wrecks your eyes when the text whizzes by and no way of knowing what was that about... here is a link to a blog that mentions a tool to do this and make it look like neater just like how you see a kernel build does the magic i.e.

Compiling foo.so
Linking foo.so

Here is another link to a tool that is called prettify automake.

t0mm13b
  • 34,087
  • 8
  • 78
  • 110