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