git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Ben Walton <bwalton@artsci.utoronto.ca>
Cc: gitster <gitster@pobox.com>, git <git@vger.kernel.org>
Subject: Re: [PATCH 0/2] Set Makefile variables from configure
Date: Tue, 3 Nov 2009 15:54:08 -0600	[thread overview]
Message-ID: <20091103215408.GA13720@progeny.tock> (raw)
In-Reply-To: <1257269082-sup-5056@ntdws12.chass.utoronto.ca>

Ben Walton wrote:
> Excerpts from Ben Walton's message of Sat Oct 31 16:41:33 -0400 2009:
 
>> These patches add support for setting the newly created DEFAULT_EDITOR
>> and DEFAULT_PAGER from the configure script.  I also tacked in
>> ETC_GITCONFIG, since I can't currently toggle this without setting a
>> command line value when building, but have need to alter it.
[...]
> Ping?  Is this useful or should I drop it?

I am not sure these patches alone would make the configuration much
easier.  The --help text means one has to check the Makefile to learn
what these options do, anyway:

--with-editor=VALUE	provide value for DEFAULT_EDITOR
--with-pager=VALUE	provide value for DEFAULT_PAGER

But then, why not just set the value directly in the Makefile, 'make'
command line, or config.mak?

Maybe something like this could help.  The help text is not carefully
written; it’s just a placeholder to show the idea.

 configure.ac |   56 ++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index f8db034..aeef08c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,20 +68,25 @@ else \
 	GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
 fi \
 ])# GIT_PARSE_WITH
+
 dnl
-dnl GIT_WITH_MAKE_VAR(withname, VAR)
-dnl ---------------------
-dnl Set VAR to the value specied by --with-$withname if --with-$withname
-dnl is specified.  This is a direct way to allow setting variables in the
-dnl Makefile.
-AC_DEFUN([GIT_WITH_MAKE_VAR],
-[AC_ARG_WITH([$1],
- [AS_HELP_STRING([--with-$1=VALUE],
-		 [provide value for $2])],
- if test -n "$withval"; then \
-    AC_MSG_NOTICE([Setting $2 to $withval]); \
-    GIT_CONF_APPEND_LINE($2=$withval); \
- fi)])# GIT_WITH_MAKE_VAR
+dnl GIT_PARSE_VALUE(WITHNAME, VAR)
+dnl ------------------------------
+dnl For use in AC_ARG_WITH action-if-found, for tweakable values that
+dnl are not actually enabling or disabling anything.
+dnl  * Set VAR=ARG for --with-WITHNAME=ARG
+dnl  * Complain for --without-WITHNAME or --with-WITHNAME without ARG
+AC_DEFUN([GIT_PARSE_VALUE], [
+if test "$withval" = "no"; then
+	AC_MSG_ERROR([$1 cannot be disabled])
+fi
+if test "$withval" = "yes"; then
+	AC_MSG_WARN([You should provide a value for --with-$1])
+else
+	AC_MSG_NOTICE([Setting $2 to $withval])
+	GIT_CONF_APPEND_LINE($2=$withval)
+fi
+])
 
 dnl
 dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
@@ -242,13 +247,32 @@ GIT_PARSE_WITH(iconv))
 
 #
 # Allow user to set ETC_GITCONFIG variable
-GIT_WITH_MAKE_VAR(gitconfig, ETC_GITCONFIG)
+AC_ARG_WITH(gitconfig,
+  [AS_HELP_STRING([--with-gitconfig=PATH],
+                  [Use PATH instead of /etc/gitconfig.]
+                  [Interpreted by git as a path relative to the computed]
+                  [prefix at run-time.])],
+  [GIT_PARSE_VALUE(gitconfig, ETC_GITCONFIG)])
+
 #
 # Allow user to set the default pager
-GIT_WITH_MAKE_VAR(pager, DEFAULT_PAGER)
+AC_ARG_WITH(pager,
+  [AS_HELP_STRING([--with-pager=CMD],
+                  [Set fall-back pager to CMD instead of less.]
+                  [The fall-back pager will be used by commands such]
+                  [as git log if the user does not specify some]
+                  [preferred pager.])],
+  [GIT_PARSE_VALUE(pager, DEFAULT_PAGER)])
+
 #
 # Allow user to set the default editor
-GIT_WITH_MAKE_VAR(editor, DEFAULT_EDITOR)
+AC_ARG_WITH(editor,
+  [AS_HELP_STRING([--with-editor=CMD],
+                  [Set fall-back text editor to CMD instead of vi.]
+                  [The fall-back editor will be used by commands such]
+                  [as git commit if the user does not specify some]
+                  [preferred editor.])],
+  [GIT_PARSE_VALUE(editor, DEFAULT_EDITOR)])
 
 #
 # Define SHELL_PATH to provide path to shell.
-- 
1.6.5.2

  reply	other threads:[~2009-11-03 21:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-31 20:41 [PATCH 0/2] Set Makefile variables from configure Ben Walton
2009-10-31 20:41 ` [PATCH 1/2] configure: add function to directly set Makefile variables Ben Walton
2009-10-31 20:41   ` [PATCH 2/2] configure: allow user to set gitconfig, pager and editor Ben Walton
2009-11-03 17:25 ` [PATCH 0/2] Set Makefile variables from configure Ben Walton
2009-11-03 21:54   ` Jonathan Nieder [this message]
2009-11-03 22:21 ` Jonathan Nieder
2009-11-04 18:05   ` Ben Walton
2009-11-04 18:05     ` [PATCH 1/2] configure: add macro to set arbitrary make variables Ben Walton
2009-11-04 18:06       ` [PATCH 2/2] configure: add settings for gitconfig, editor and pager Ben Walton
2009-11-04 19:36     ` [PATCH 0/2] Set Makefile variables from configure Junio C Hamano
2009-11-04 19:47       ` Ben Walton
2009-11-04 19:56         ` Junio C Hamano
2009-11-04 20:16           ` Ben Walton
2009-11-04 20:16         ` Jonathan Nieder
2009-11-04 18:07   ` Ben Walton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091103215408.GA13720@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=bwalton@artsci.utoronto.ca \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).