automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Implement AM_MAINTAINER_MODE([DEFAULT-MODE]).


From: Ralf Wildenhues
Subject: [PATCH] Implement AM_MAINTAINER_MODE([DEFAULT-MODE]).
Date: Sun, 31 Aug 2008 17:19:28 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

* m4/maintainer.m4 (AM_MAINTAINER_MODE): Allow for an optional
first argument of `enable' or `disable', setting the default.
* doc/automake.texi (Optional, maintainer-mode): Document.
* tests/mmode.test: New test.
* tests/Makefile.am: Adjust.
* NEWS: Update.
Suggestion by Vincent Lefevre.

Signed-off-by: Ralf Wildenhues <address@hidden>
---

[ moving from bug-automake ]

* Vincent Lefevre wrote on Sun, Aug 31, 2008 at 01:54:23PM CEST:
> On 2008-08-31 12:19:54 +0200, Ralf Wildenhues wrote:
> > * Vincent Lefevre wrote on Sun, Aug 31, 2008 at 12:11:04PM CEST:
> > > Allow the user to choose AM_MAINTAINER_MODE's default in a clean way.
> > 
> > Well, that's one of the already-mentioned workarounds, no?
> 
> I mean in a clean way (a bit like AC_DISABLE_SHARED), so that
> "configure --help" gives correct output.

Good idea.

Somebody please check what I'm currently not seeing in the m4 fu I
tried (the test fails, because there is something wrong in
m4/maintainer.m4).  Also a review of the rest would be nice as well.

Thanks,
Ralf

 NEWS              |    3 ++
 doc/automake.texi |   35 +++++++++++++++------------
 m4/maintainer.m4  |   31 ++++++++++++++++--------
 tests/Makefile.am |    1 +
 tests/Makefile.in |    1 +
 tests/mmode.test  |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 113 insertions(+), 25 deletions(-)
 create mode 100755 tests/mmode.test

diff --git a/NEWS b/NEWS
index 453769d..6003f98 100644
--- a/NEWS
+++ b/NEWS
@@ -85,6 +85,9 @@ New in 1.10a:
     remove the file in a non-VPATH build.  Such setups work with Autoconf
     2.62 or newer.
 
+  - AM_MAINTAINER_MODE now allows for an optional argument specifying
+    the default setting.
+
 Bugs fixed in 1.10a:
 
 * Long standing bugs:
diff --git a/doc/automake.texi b/doc/automake.texi
index b0e0ee8..0a40e6f 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -2917,14 +2917,16 @@ This macro specifies that the @file{intl/} subdirectory 
is to be built,
 even if the @code{AM_GNU_GETTEXT} macro was invoked with a first argument
 of @samp{external}.
 
address@hidden AM_MAINTAINER_MODE
address@hidden AM_MAINTAINER_MODE(@ovar{default-mode})
 @opindex --enable-maintainer-mode
-This macro adds a @option{--enable-maintainer-mode} option to
address@hidden --disable-maintainer-mode
+This macro adds an @option{--enable-maintainer-mode} option to
 @command{configure}.  If this is used, @command{automake} will cause
 ``maintainer-only'' rules to be turned off by default in the
-generated @file{Makefile.in}s.  This macro defines the
address@hidden conditional, which you can use in your own
address@hidden  @xref{maintainer-mode}.
+generated @file{Makefile.in}s, unless @var{default-mode} is
address@hidden  This macro defines the @code{MAINTAINER_MODE}
+conditional, which you can use in your own @file{Makefile.am}.
address@hidden
 
 @item m4_include
 Files included by @file{configure.ac} using this macro will be
@@ -9948,16 +9950,19 @@ the build continue is one of the arguments of the
 @cindex @code{AM_MAINTAINER_MODE}, purpose
 @acindex AM_MAINTAINER_MODE
 
address@hidden disables the so called "rebuild rules" by
-default.  If you have @code{AM_MAINTAINER_MODE} in
address@hidden, and run @samp{./configure && make}, then
address@hidden will *never* attempt to rebuilt @file{configure},
address@hidden, Lex or Yacc outputs, etc.  I.e., this disables
-build rules for files that are usually distributed and that users
-should normally not have to update.
-
-If you run @samp{./configure --enable-maintainer-mode}, then these
-rebuild rules will be active.
address@hidden allows to choose whether the so called
+"rebuild rules" should be enabled or disabled.  With
address@hidden([enable])}, they are enabled by default,
+otherwise they are disabled by default.  In the latter case, if
+you have @code{AM_MAINTAINER_MODE} in @file{configure.ac}, and run
address@hidden/configure && make}, then @command{make} will *never* attempt to
+rebuilt @file{configure}, @file{Makefile.in}s, Lex or Yacc outputs, etc.
+I.e., this disables build rules for files that are usually distributed
+and that users should normally not have to update.
+
+The user can override the default setting by either
address@hidden/configure --enable-maintainer-mode} or
address@hidden/configure --disable-maintainer-mode}.
 
 People use @code{AM_MAINTAINER_MODE} either because they do want their
 users (or themselves) annoyed by timestamps lossage (@pxref{CVS}), or
diff --git a/m4/maintainer.m4 b/m4/maintainer.m4
index 1c15c98..0b23cfb 100644
--- a/m4/maintainer.m4
+++ b/m4/maintainer.m4
@@ -1,27 +1,38 @@
 # Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
 # From Jim Meyering
 
-# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 5
 
+# AM_MAINTAINER_MODE([DEFAULT-MODE])
+# ----------------------------------
+# Control maintainer-specific portions of Makefiles.
+# Default is to disable them, unless `enable' is passed literally.
+# For symmetry, `disable' may be passed as well.  Anyway, the user
+# can override the default with the --enable/--disable switch.
 AC_DEFUN([AM_MAINTAINER_MODE],
-[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
-  dnl maintainer-mode is disabled by default
-  AC_ARG_ENABLE(maintainer-mode,
-[  --enable-maintainer-mode  enable make rules and dependencies not useful
+[m4_if(m4_default([$1], [disable]),
+       [enable], [m4_define([am_maintainer_other], [disable])],
+       [disable], [m4_define([am_maintainer_other], [enable])],
+       [m4_define([am_maintainer_other], [enable])
+        m4_warning([unexpected argument to AM@&address@hidden: $1])])
+AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions 
of Makefiles])
+  dnl maintainer-mode's default is 'disable' unless 'enable' is passed
+  AC_ARG_ENABLE([maintainer-mode],
+[  --][am_maintainer_other][-maintainer-mode  am_maintainer_other make rules 
and dependencies not useful
                          (and sometimes confusing) to the casual installer],
-      USE_MAINTAINER_MODE=$enableval,
-      USE_MAINTAINER_MODE=no)
+      [USE_MAINTAINER_MODE=$enableval],
+      [USE_MAINTAINER_MODE=]m4_if([am_maintainer_other], [enable], [no], 
[yes]))
   AC_MSG_RESULT([$USE_MAINTAINER_MODE])
-  AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
+  AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
   MAINT=$MAINTAINER_MODE_TRUE
-  AC_SUBST(MAINT)dnl
+  AC_SUBST([MAINT])dnl
 ]
 )
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e5a5061..5df6402 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -396,6 +396,7 @@ missing6.test \
 mkinstall.test \
 mkinst2.test \
 mkinst3.test \
+mmode.test \
 mmodely.test \
 multlib.test \
 nobase.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index cc94422..8bfa1d0 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -547,6 +547,7 @@ missing6.test \
 mkinstall.test \
 mkinst2.test \
 mkinst3.test \
+mmode.test \
 mmodely.test \
 multlib.test \
 nobase.test \
diff --git a/tests/mmode.test b/tests/mmode.test
new file mode 100755
index 0000000..c067ccc
--- /dev/null
+++ b/tests/mmode.test
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2008  Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check for AM_MAINTAINER_MODE defaults.
+
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AM_MAINTAINER_MODE
+AC_OUTPUT
+END
+
+: >Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure --help | grep 'enable-maintainer-mode.*enable make rules'
+./configure
+grep '^MAINT.*#' Makefile
+
+./configure --disable-maintainer-mode
+grep '^MAINT.*#' Makefile
+
+./configure --enable-maintainer-mode
+grep '^MAINT.*#' Makefile && exit 1
+
+sed 's/\(AM_MAINTAINER_MODE\).*/\1([disable])/' configure.in > configure.int
+mv -f configure.int configure.in
+mv configure configure1
+$AUTOCONF --force
+diff configure configure1
+
+sed 's/\(AM_MAINTAINER_MODE\).*/\1([enable])/' configure.in > configure.int
+mv -f configure.int configure.in
+$AUTOCONF --force
+
+./configure --help | grep 'disable-maintainer-mode.*disable make rules'
+./configure
+grep '^MAINT.*#' Makefile && exit 1
+
+./configure --enable-maintainer-mode
+grep '^MAINT.*#' Makefile && exit 1
+
+./configure --disable-maintainer-mode
+grep '^MAINT.*#' Makefile
+
+sed 's/\(AM_MAINTAINER_MODE\).*/\1([foo])/' configure.in > configure.int
+mv -f configure.int configure.in
+$AUTOCONF --force -Werror && exit 1
+:
-- 
1.5.5.40.g4cdda





reply via email to

[Prev in Thread] Current Thread [Next in Thread]