shave: making the autotools output sane

February 18th, 2009

updated: add some gtk-doc info

updated: CXX support thanks to Tommi Komulainen

shave

Fed up with endless screens of libtool/automake output? Fed up with having to resort to -Werror to see warnings in your code? Then shave might be for you. shave transforms the messy output of autotools into a pretty Kbuild-like one (Kbuild is the Linux build system). It’s composed of a m4 macro and 2 small shell scripts and it’s available in a git repository.

git clone git://git.lespiau.name/shave

Hopefully, in a few minutes, you should be able to see your project compile like this:

$ make
Making all in foo
Making all in internal
  CC    internal-file0.o
  LINK  libinternal.la
  CC    lib-file0.o
  CC    lib-file1.o
  LINK  libfoo.la
Making all in tools
  CC    tool0-tool0.o
  LINK  tool0

Just like Kbuild, shave supports outputting the underlying commands using:

$ make V=1

Setup

  • Put the two shell scripts shave.in and shave-libtool.in in the directory of your choice (it can be at the root of your autotooled project).
  • add shave and shave-libtool to AC_CONFIG_FILES
  • add shave.m4 either in acinclude.m4 or your macro directory
  • add a call to SHAVE_INIT just before AC_CONFIG_FILES/AC_OUTPUT. SHAVE_INIT takes one argument, the directory where shave and shave-libtool are.

custom rules

Sometimes you have custom Makefile rules, e.g. to generate a small header, run glib-mkenums or glib-genmarshal. It would be nice to output a pretty ‘GEN’ line. That’s quite easy actually, just add few (portable!) lines at the top of your Makefile.am:

V         = @
Q         = $(V:1=)
QUIET_GEN = $(Q:@=@echo '  GEN   '$@;)

and then it’s just a matter of prepending $(QUIET_GEN) to the rule creating the file:

lib-file2.h: Makefile
       $(QUIET_GEN)echo "#define FOO_DEFINE 0xbabe" > lib-file2.h

gtk-doc + shave

gtk-doc + shave + libtool 1.x (2.x is fine) is known to have a small issue, a patch is available. Meanwhile I suggest adding a few lines to your autogen.sh script.

sed -e 's#) --mode=compile#) --tag=CC --mode=compile#' gtk-doc.make > gtk-doc.temp \
        && mv gtk-doc.temp gtk-doc.make
sed -e 's#) --mode=link#) --tag=CC --mode=link#' gtk-doc.make > gtk-doc.temp \
        && mv gtk-doc.temp gtk-doc.make

dolt + shave

It’s possible to use dolt in conjunction with shave with a surprisingly small patch to dolt.

Real world example: Clutter

$ make
GEN   stamp-clutter-marshal.h
GEN   clutter-marshal.c
GEN   stamp-clutter-enum-types.h
Making all in cogl
Making all in common
CC    cogl-util.o
CC    cogl-bitmap.o
CC    cogl-bitmap-fallback.o
CC    cogl-primitives.o
CC    cogl-bitmap-pixbuf.o
CC    cogl-clip-stack.o
CC    cogl-fixed.o
CC    cogl-color.o
cogl-color.c: In function ‘cogl_set_source_color4ub’:
cogl-color.c:141: warning: implicit declaration of function ‘cogl_set_source_color’
CC    cogl-vertex-buffer.o
CC    cogl-matrix.o
CC    cogl-material.o
LINK  libclutter-cogl-common.la
[...]

Eh! now we can see a warning there!

TODO

This is a first release, shave has not been widely tested aka it may not work for you!

  • test it with a wider range of automake/libtool versions
  • shave won’t work without AC_CONFIG_HEADERS due to shell quoting problems
  • see what can be done for make install/dist (they are prettier thanks to make -s, but we probably miss a few actions)
  • there is a ‘-s’ hardcoded in MAKEFLAGS,  I have to find a way to make it more flexible

damien cool hacks

ADV: ADV is a Dependency Viewer

February 10th, 2009

A few months ago I wrote a small script to draw a dependency graph between the object files of a library (the original idea is from Lionel Landwerlin). You’ll need an archive of your library for the tool to be able to look for the needed pieces. Let’s have a look at a sample of its output to understand what it does. I ran it against the HEAD of clutter.

A view of the clutter library

A view of the clutter library

This graph was generated with the following (tred is part of graphviz to do transitive reductions on graphs):

$ adv.py clutter/.libs/libclutter-glx-0.9.a | tred | dot -Tsvg > clutter.svg

You can provide more than one library to the tool:

./adv.py ../clutter/clutter/.libs/libclutter-glx-0.9.a \
../glib-2.18.4/glib/.libs/libglib-2.0.a \
../glib-2.18.4/gobject/.libs/libgobject-2.0.a \
| tred | dot -Tsvg > clutter-glib-gobject-boxed.svg

clutter, glib and gobject

What you can do with this:

  • trim down your library by removing the object files you don’t need and that are leafs in the graph. This was actually the reason behind the script and it proved useful,
  • get an overview of a library,
  • make part of a library optional more easily.

To make the script work you’ll need graphviz, python, ar and nm (you can provide a cross compiler prefix with –cross-prefix).

Interested? clone it! (or look at the code)

$ git clone git://git.lespiau.name/misc/adv

damien cool hacks

Vim macro for change log entry in .spec files

February 10th, 2009

Tired of writing this kind of lines by hand ?

* Mon Feb 09 2009 Damien Lespiau <damien.lespiau@xxxx.com> 1.4.3

This vim macro does just this for you!

nmap ,mob-ts :r!date +'\%a \%b \%d \%Y'<CR>0i* <ESC>$a Damien Lespiau <damien.lespiau@xxxx.com> FIXME

damien misc

libpneu first import

September 27th, 2008

Waw, definitely hard to keep a decent pace at posting news in my blog. Nevertheless, a first import of libpneu has reached my public git repository. libpneu is an effort to make a tracing library that I could use in every single project I start. Basically, you put tracing points in your programs and libpneu prints them whenever you need to know what is happening. Different backends can be used to display traces and debug messages, from printing them to stdout, to sending them over an UDP socket. More about libpneu in a few days/weeks !

A small screenshot to better understand what it does:

libpneu printing a few debug and error messages

libpneu printing a few debug and error messages

damien Pneu

Poulpy 0.1 is out !

July 29th, 2008

Be sure to check its page.

damien Poulpy

Survival Kit

July 13th, 2008

It’s time to start putting something on the site. It’s just a bunch of dot files (.vimrc, .gitconfig, …) in a git repository. I’ve called it my Survival Kit as these are files I cannot work without. I hope to make the repository more useful over time, adding simple skeletons to start (DocBook, C, Java, C#, …) projects.

damien lespiau.name

Hello world!

July 5th, 2008

OK. Let’s try to blog a little about what I do. Nothing fancy and mostly computer-related stuff but I hope it can be of any help to someone, somewhere, someday.

damien lespiau.name