git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/2] Set Makefile variables from configure

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 3, 2009, 21:54 UTC
Message-ID
<20091103215408.GA13720@progeny.tock>
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
Previous: Ben WaltonNext: Jonathan Nieder
Message 5 of 15 in “Set Makefile variables from configure”
  1. 0/2 Set Makefile variables from configureBen Walton, Oct 31, 2009
  2. 1/2 configure: add function to directly set Makefile variablesBen Walton, Oct 31, 2009
  3. 2/2 configure: allow user to set gitconfig, pager and editorBen Walton, Oct 31, 2009
  4. Ben WaltonNov 3, 2009
  5. Jonathan NiederNov 3, 2009
  6. Jonathan NiederNov 3, 2009
  7. 0/2 Set Makefile variables from configureBen Walton, Nov 4, 2009
  8. 1/2 configure: add macro to set arbitrary make variablesBen Walton, Nov 4, 2009
  9. 2/2 configure: add settings for gitconfig, editor and pagerBen Walton, Nov 4, 2009
  10. Junio C HamanoNov 4, 2009
  11. Ben WaltonNov 4, 2009
  12. Junio C HamanoNov 4, 2009
  13. Ben WaltonNov 4, 2009
  14. Jonathan NiederNov 4, 2009
  15. Ben WaltonNov 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.