From 16bb6580be39d8a3930f5c9860d4313e36c729a9 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Mon, 23 Feb 2009 23:20:19 +0200 Subject: build: shave it! http://damien.lespiau.name/blog/2009/02/18/shave-making-the-autotools-output-sane/ --- bootstrap.sh | 6 ++++- configure.ac | 5 ++++ m4/shave.m4 | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ shave-libtool.in | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ shave.in | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 m4/shave.m4 create mode 100644 shave-libtool.in create mode 100644 shave.in diff --git a/bootstrap.sh b/bootstrap.sh index e64f3426..4e223e32 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -49,6 +49,10 @@ if ! pkg-config --version &>/dev/null; then exit 1 fi +if type -p colorgcc > /dev/null ; then + export CC=colorgcc +fi + if [ "x$1" = "xam" ] ; then run_versioned automake "$VERSION" -a -c --foreign ./config.status @@ -73,7 +77,7 @@ else run_versioned automake "$VERSION" --copy --foreign --add-missing if test "x$NOCONFIGURE" = "x"; then - CFLAGS="-g -O0" ./configure --sysconfdir=/etc --localstatedir=/var --enable-force-preopen "$@" + CFLAGS="-g -O0" ./configure --sysconfdir=/etc --localstatedir=/var --enable-force-preopen --enable-shave "$@" make clean fi fi diff --git a/configure.ac b/configure.ac index 11b091bb..aab7e2d5 100644 --- a/configure.ac +++ b/configure.ac @@ -1261,6 +1261,8 @@ AM_CONDITIONAL([FORCE_PREOPEN], [test "x$FORCE_PREOPEN" = "xyes"]) AC_CONFIG_FILES([ Makefile +shave +shave-libtool src/Makefile man/Makefile libpulse.pc @@ -1272,7 +1274,10 @@ doxygen/doxygen.conf src/pulse/version.h po/Makefile.in ]) + +SHAVE_INIT AC_OUTPUT +SHAVE_OUTPUT # ========================================================================== ENABLE_X11=no diff --git a/m4/shave.m4 b/m4/shave.m4 new file mode 100644 index 00000000..44d3908b --- /dev/null +++ b/m4/shave.m4 @@ -0,0 +1,69 @@ +dnl Make automake/libtool output more friendly to humans +dnl +dnl SHAVE_INIT([shavedir]) +dnl +dnl shavedir: the directory where the shave scripts are, it defaults to +dnl $(top_builddir) +dnl +dnl * SHAVE_INIT should be called late in your configure.(ac|in) file (just +dnl before AC_CONFIG_FILE/AC_OUTPUT is perfect. This macro rewrites CC and +dnl LIBTOOL, you don't want the configure tests to have these variables +dnl re-defined. +dnl * This macro requires GNU make's -s option. + +AC_DEFUN([SHAVE_INIT], +[ + dnl enable/disable shave + AC_ARG_ENABLE([shave], + AS_HELP_STRING([--enable-shave], + [use shave to make the build pretty [[default=no]]]),, + [enable_shave=no]) + + if test x"$enable_shave" = xyes; then + dnl where can we find the shave scripts? + m4_if([$1],, + [shavedir='$(top_builddir)'], + [shavedir='$(top_builddir)'/$1]) + AC_SUBST(shavedir) + + dnl make is now quiet + AC_SUBST([MAKEFLAGS], [-s]) + AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`']) + + dnl we need sed + AC_CHECK_PROG(SED,sed,sed,false) + + dnl substitute libtool + SHAVE_SAVED_LIBTOOL=$LIBTOOL + AC_SUBST(SHAVE_SAVED_LIBTOOL) + LIBTOOL="\$(SHELL) \$(shavedir)/shave-libtool '\$(SHAVE_SAVED_LIBTOOL)'" + AC_SUBST(LIBTOOL) + + dnl substitute cc/cxx + SHAVE_SAVED_CC=$CC + SHAVE_SAVED_CXX=$CXX + AC_SUBST(SHAVE_SAVED_CC) + AC_SUBST(SHAVE_SAVED_CXX) + CC="\$(SHELL) \$(shavedir)/shave cc '\$(SHAVE_SAVED_CC)'" + CXX="\$(SHELL) \$(shavedir)/shave cxx '\$(SHAVE_SAVED_CXX)'" + AC_SUBST(CC) + AC_SUBST(CXX) + + V=@ + else + V=1 + fi + Q='$(V:1=)' + AC_SUBST(V) + AC_SUBST(Q) +]) + +AC_DEFUN([SHAVE_OUTPUT], +[ + if test x"$enable_shave" = xyes; then + dnl small workaround to fix libtool itself + dnl it's shokingly hard to find a better way, really! wtf... + test -f $srcdir/libtool && (tmpfile=`mktemp` && cat $srcdir/libtool | sed "s,^LTCC=.*$,LTCC=\"$SHELL $ac_pwd/shave cc $SHAVE_SAVED_CC\"," > $tmpfile && mv $tmpfile $srcdir/libtool) + fi + +]) diff --git a/shave-libtool.in b/shave-libtool.in new file mode 100644 index 00000000..30e6f138 --- /dev/null +++ b/shave-libtool.in @@ -0,0 +1,69 @@ +#!/bin/sh + +# we need sed +SED=@SED@ +if test -z "$SED" ; then +SED=sed +fi + +lt_unmangle () +{ + last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_]\*_la-##'` +} + +# the real libtool to use +LIBTOOL="$1" +shift + +# if 1, don't print anything, the underlaying wrapper will do it +pass_though=0 + +# scan the arguments, keep the right ones for libtool, and discover the mode +preserved_args= +while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --mode=*) + mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'` + preserved_args="$preserved_args $opt" + ;; + -o) + lt_output="$1" + preserved_args="$preserved_args $opt" + ;; + *) + preserved_args="$preserved_args $opt" + ;; + esac +done + +case "$mode" in +compile) + # shave will be called and print the actual CC/CXX/LINK line + preserved_args="$preserved_args --shave-mode=$mode" + pass_though=1 + ;; +link) + preserved_args="$preserved_args --shave-mode=$mode" + Q=" LINK " + ;; +*) + # let's u + # echo "*** libtool: Unimplemented mode: $mode, fill a bug report" + ;; +esac + +lt_unmangle "$lt_output" +output=$last_result + +if test -z $V; then + if test $pass_though -eq 0; then + echo "$Q$output" + fi + $LIBTOOL --silent $preserved_args +else + echo $LIBTOOL $preserved_args + $LIBTOOL $preserved_args +fi diff --git a/shave.in b/shave.in new file mode 100644 index 00000000..dc46ec96 --- /dev/null +++ b/shave.in @@ -0,0 +1,70 @@ +#!/bin/sh + +# we need sed +SED=@SED@ +if test -z "$SED" ; then +SED=sed +fi + +lt_unmangle () +{ + last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_]\*_la-##'` +} + +# the tool to wrap (cc, cxx, ar, ranlib, ..) +tool="$1" +shift + +# the reel tool (to call) +REEL_TOOL="$1" +shift + +pass_through=0 +preserved_args= +while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --shave-mode=*) + mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'` + ;; + -o) + lt_output="$1" + preserved_args="$preserved_args $opt" + ;; + *) + preserved_args="$preserved_args $opt" + ;; + esac +done + +# mode=link is handled in the libtool wrapper +case "$mode,$tool" in +link,*) + pass_through=1 + ;; +*,cxx) + Q=" CXX " + ;; +*,cc) + Q=" CC " + ;; +*,*) + # should not happen + Q=" CC " + ;; +esac + +lt_unmangle "$lt_output" +output=$last_result + +if test -z $V; then + if test $pass_through -eq 0; then + echo "$Q$output" + fi + $REEL_TOOL $preserved_args +else + echo $REEL_TOOL $preserved_args + $REEL_TOOL $preserved_args +fi -- cgit