1dnl Make automake/libtool output more friendly to humans
2dnl
3dnl SHAVE_INIT([shavedir],[default_mode])
4dnl
5dnl shavedir: the directory where the shave scripts are, it defaults to
6dnl           $(top_builddir)
7dnl default_mode: (enable|disable) default shave mode.  This parameter
8dnl               controls shave's behaviour when no option has been
9dnl               given to configure.  It defaults to disable.
10dnl
11dnl * SHAVE_INIT should be called late in your configure.(ac|in) file (just
12dnl   before AC_CONFIG_FILE/AC_OUTPUT is perfect.  This macro rewrites CC and
13dnl   LIBTOOL, you don't want the configure tests to have these variables
14dnl   re-defined.
15dnl * This macro requires GNU make's -s option.
16
17AC_DEFUN([_SHAVE_ARG_ENABLE],
18[
19  AC_ARG_ENABLE([shave],
20    AS_HELP_STRING(
21      [--enable-shave],
22      [use shave to make the build pretty [[default=$1]]]),,
23      [enable_shave=$1]
24    )
25])
26
27AC_DEFUN([SHAVE_INIT],
28[
29  dnl you can tweak the default value of enable_shave
30  m4_if([$2], [enable], [_SHAVE_ARG_ENABLE(yes)], [_SHAVE_ARG_ENABLE(no)])
31
32  if test x"$enable_shave" = xyes; then
33    dnl where can we find the shave scripts?
34    m4_if([$1],,
35      [shavedir="$ac_pwd"],
36      [shavedir="$ac_pwd/$1"])
37    AC_SUBST(shavedir)
38
39    dnl make is now quiet
40    AC_SUBST([MAKEFLAGS], [-s])
41    AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`'])
42
43    dnl we need sed
44    AC_CHECK_PROG(SED,sed,sed,false)
45
46    dnl substitute libtool
47    SHAVE_SAVED_LIBTOOL=$LIBTOOL
48    LIBTOOL="${SHELL} ${shavedir}/shave-libtool '${SHAVE_SAVED_LIBTOOL}'"
49    AC_SUBST(LIBTOOL)
50
51    dnl substitute cc/cxx
52    SHAVE_SAVED_CC=$CC
53    SHAVE_SAVED_CXX=$CXX
54    SHAVE_SAVED_FC=$FC
55    SHAVE_SAVED_F77=$F77
56    CC="${SHELL} ${shavedir}/shave cc ${SHAVE_SAVED_CC}"
57    CXX="${SHELL} ${shavedir}/shave cxx ${SHAVE_SAVED_CXX}"
58    FC="${SHELL} ${shavedir}/shave fc ${SHAVE_SAVED_FC}"
59    F77="${SHELL} ${shavedir}/shave f77 ${SHAVE_SAVED_F77}"
60    AC_SUBST(CC)
61    AC_SUBST(CXX)
62    AC_SUBST(FC)
63    AC_SUBST(F77)
64
65    V=@
66  else
67    V=1
68  fi
69  Q='$(V:1=)'
70  AC_SUBST(V)
71  AC_SUBST(Q)
72])
73
74