]> code.delx.au - pulseaudio/blob - m4/shave.m4
build: shave it!
[pulseaudio] / m4 / shave.m4
1 dnl Make automake/libtool output more friendly to humans
2 dnl
3 dnl SHAVE_INIT([shavedir])
4 dnl
5 dnl shavedir: the directory where the shave scripts are, it defaults to
6 dnl $(top_builddir)
7 dnl
8 dnl * SHAVE_INIT should be called late in your configure.(ac|in) file (just
9 dnl before AC_CONFIG_FILE/AC_OUTPUT is perfect. This macro rewrites CC and
10 dnl LIBTOOL, you don't want the configure tests to have these variables
11 dnl re-defined.
12 dnl * This macro requires GNU make's -s option.
13
14 AC_DEFUN([SHAVE_INIT],
15 [
16 dnl enable/disable shave
17 AC_ARG_ENABLE([shave],
18 AS_HELP_STRING([--enable-shave],
19 [use shave to make the build pretty [[default=no]]]),,
20 [enable_shave=no])
21
22 if test x"$enable_shave" = xyes; then
23 dnl where can we find the shave scripts?
24 m4_if([$1],,
25 [shavedir='$(top_builddir)'],
26 [shavedir='$(top_builddir)'/$1])
27 AC_SUBST(shavedir)
28
29 dnl make is now quiet
30 AC_SUBST([MAKEFLAGS], [-s])
31 AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`'])
32
33 dnl we need sed
34 AC_CHECK_PROG(SED,sed,sed,false)
35
36 dnl substitute libtool
37 SHAVE_SAVED_LIBTOOL=$LIBTOOL
38 AC_SUBST(SHAVE_SAVED_LIBTOOL)
39 LIBTOOL="\$(SHELL) \$(shavedir)/shave-libtool '\$(SHAVE_SAVED_LIBTOOL)'"
40 AC_SUBST(LIBTOOL)
41
42 dnl substitute cc/cxx
43 SHAVE_SAVED_CC=$CC
44 SHAVE_SAVED_CXX=$CXX
45 AC_SUBST(SHAVE_SAVED_CC)
46 AC_SUBST(SHAVE_SAVED_CXX)
47 CC="\$(SHELL) \$(shavedir)/shave cc '\$(SHAVE_SAVED_CC)'"
48 CXX="\$(SHELL) \$(shavedir)/shave cxx '\$(SHAVE_SAVED_CXX)'"
49 AC_SUBST(CC)
50 AC_SUBST(CXX)
51
52 V=@
53 else
54 V=1
55 fi
56 Q='$(V:1=)'
57 AC_SUBST(V)
58 AC_SUBST(Q)
59 ])
60
61 AC_DEFUN([SHAVE_OUTPUT],
62 [
63 if test x"$enable_shave" = xyes; then
64 dnl small workaround to fix libtool itself
65 dnl it's shokingly hard to find a better way, really! wtf...
66 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)
67 fi
68
69 ])