configure: be more idiomatic

Lots of code in Git's configure.ac doesn't follow the typical formatting, idioms and best practices for Autoconf input files. Improve the situation. There are probably many more similar improvements to be done, but trying to clump all of them in a single change would make it unreviewable, so we content ourselves with a partial improvement. This change is just cosmetic, and should cause no semantic change. The most relevant of the changes introduced by this patch are: - Do not add trailing '\' characters for line continuation where they are not truly needed. - In several (but not all) macro calls, properly quote the arguments. - Few cosmetic changes in spacing and comments. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefano Lattarini committed Mar 26, 2012 at 18:42 UTC 5b2d131419817c5f5996da0e284e906400c083ef
1 file changed +87 -89
configure.ac
+87 -89
@@ -1,54 +1,55 @@
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 -## Definitions of macros
4 +## Definitions of private macros.
5 +
6 # GIT_CONF_APPEND_LINE(LINE)
7 # --------------------------
8 # Append LINE to file ${config_append}
9 AC_DEFUN([GIT_CONF_APPEND_LINE],
9 -[echo "$1" >> "${config_append}"])# GIT_CONF_APPEND_LINE
10 -#
10 + [echo "$1" >> "${config_append}"])
11 +
12 # GIT_ARG_SET_PATH(PROGRAM)
13 # -------------------------
14 # Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
15 # Optional second argument allows setting NO_PROGRAM=YesPlease if
16 # --without-PROGRAM version used.
17 AC_DEFUN([GIT_ARG_SET_PATH],
17 -[AC_ARG_WITH([$1],
18 - [AS_HELP_STRING([--with-$1=PATH],
19 - [provide PATH to $1])],
20 - [GIT_CONF_APPEND_PATH($1,$2)],[])
21 -])# GIT_ARG_SET_PATH
22 -#
18 + [AC_ARG_WITH([$1],
19 + [AS_HELP_STRING([--with-$1=PATH],
20 + [provide PATH to $1])],
21 + [GIT_CONF_APPEND_PATH([$1], [$2])],
22 + [])])
23 +
24 # GIT_CONF_APPEND_PATH(PROGRAM)
24 -# ------------------------------
25 +# -----------------------------
26 # Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
27 # Used by GIT_ARG_SET_PATH(PROGRAM)
28 # Optional second argument allows setting NO_PROGRAM=YesPlease if
29 # --without-PROGRAM is used.
30 AC_DEFUN([GIT_CONF_APPEND_PATH],
30 -[m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
31 -PROGRAM=GIT_UC_PROGRAM; \
32 -if test "$withval" = "no"; then \
33 - if test -n "$2"; then \
34 - GIT_UC_PROGRAM[]_PATH=$withval; \
35 - AC_MSG_NOTICE([Disabling use of ${PROGRAM}]); \
36 - GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease); \
37 - GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=); \
38 - else \
39 - AC_MSG_ERROR([You cannot use git without $1]); \
40 - fi; \
41 -else \
42 - if test "$withval" = "yes"; then \
43 - AC_MSG_WARN([You should provide path for --with-$1=PATH]); \
44 - else \
45 - GIT_UC_PROGRAM[]_PATH=$withval; \
46 - AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval]); \
47 - GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval); \
48 - fi; \
49 -fi; \
50 -m4_popdef([GIT_UC_PROGRAM])]) # GIT_CONF_APPEND_PATH
51 -#
31 + [m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
32 + PROGRAM=GIT_UC_PROGRAM
33 + if test "$withval" = "no"; then
34 + if test -n "$2"; then
35 + GIT_UC_PROGRAM[]_PATH=$withval
36 + AC_MSG_NOTICE([Disabling use of ${PROGRAM}])
37 + GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease)
38 + GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=)
39 + else
40 + AC_MSG_ERROR([You cannot use git without $1])
41 + fi
42 + else
43 + if test "$withval" = "yes"; then
44 + AC_MSG_WARN([You should provide path for --with-$1=PATH])
45 + else
46 + GIT_UC_PROGRAM[]_PATH=$withval
47 + AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
48 + GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval)
49 + fi
50 + fi
51 + m4_popdef([GIT_UC_PROGRAM])])
52 +
53 # GIT_PARSE_WITH(PACKAGE)
54 # -----------------------
55 # For use in AC_ARG_WITH action-if-found, for packages default ON.
@@ -56,22 +57,22 @@ m4_popdef([GIT_UC_PROGRAM])]) # GIT_CONF_APPEND_PATH
57 # * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
58 # * Unset NO_PACKAGE for --with-PACKAGE without ARG
59 AC_DEFUN([GIT_PARSE_WITH],
59 -[m4_pushdef([GIT_UC_PACKAGE], m4_toupper([$1]))dnl
60 -PACKAGE=GIT_UC_PACKAGE; \
61 -if test "$withval" = "no"; then \
62 - NO_[]GIT_UC_PACKAGE=YesPlease; \
63 -elif test "$withval" = "yes"; then \
64 - NO_[]GIT_UC_PACKAGE=; \
65 -else \
66 - NO_[]GIT_UC_PACKAGE=; \
67 - GIT_UC_PACKAGE[]DIR=$withval; \
68 - AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval]); \
69 - GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
70 -fi \
71 -m4_popdef([GIT_UC_PACKAGE])]) # GIT_PARSE_WITH
72 -#
60 + [m4_pushdef([GIT_UC_PACKAGE], m4_toupper([$1]))dnl
61 + PACKAGE=GIT_UC_PACKAGE
62 + if test "$withval" = "no"; then
63 + NO_[]GIT_UC_PACKAGE=YesPlease
64 + elif test "$withval" = "yes"; then
65 + NO_[]GIT_UC_PACKAGE=
66 + else
67 + NO_[]GIT_UC_PACKAGE=
68 + GIT_UC_PACKAGE[]DIR=$withval
69 + AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
70 + GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval)
71 + fi
72 + m4_popdef([GIT_UC_PACKAGE])])
73 +
74 # GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
74 -# ---------------------
75 +# -----------------------------------------------------
76 # Set VAR to the value specied by --with-WITHNAME.
77 # No verification of arguments is performed, but warnings are issued
78 # if either 'yes' or 'no' is specified.
@@ -80,33 +81,32 @@ m4_popdef([GIT_UC_PACKAGE])]) # GIT_PARSE_WITH
81 AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
82 [AC_ARG_WITH([$1],
83 [AS_HELP_STRING([--with-$1=VALUE], $3)],
83 - if test -n "$withval"; then \
84 - if test "$withval" = "yes" -o "$withval" = "no"; then \
84 + if test -n "$withval"; then
85 + if test "$withval" = "yes" -o "$withval" = "no"; then
86 AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
86 - [a value for $1 ($2). Maybe you do...?]); \
87 - fi; \
88 - \
89 - AC_MSG_NOTICE([Setting $2 to $withval]); \
90 - GIT_CONF_APPEND_LINE($2=$withval); \
87 + [a value for $1 ($2). Maybe you do...?])
88 + fi
89 + AC_MSG_NOTICE([Setting $2 to $withval])
90 + GIT_CONF_APPEND_LINE($2=$withval)
91 fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
92
93 -dnl
94 -dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
95 -dnl -----------------------------------------
96 -dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
97 -dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
98 -dnl -Wall), it does not work. By looking for function definition in
99 -dnl libraries, this problem can be worked around.
93 +#
94 +# GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
95 +# -----------------------------------------
96 +# Similar to AC_CHECK_FUNC, but on systems that do not generate
97 +# warnings for missing prototypes (e.g. FreeBSD when compiling without
98 +# -Wall), it does not work. By looking for function definition in
99 +# libraries, this problem can be worked around.
100 AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
101 AC_SEARCH_LIBS([$1],,
102 [$2],[$3])
103 ],[$3])])
104
105 -dnl
106 -dnl GIT_STASH_FLAGS(BASEPATH_VAR)
107 -dnl -----------------------------
108 -dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
109 -dnl tests that may want to take user settings into account.
105 +#
106 +# GIT_STASH_FLAGS(BASEPATH_VAR)
107 +# -----------------------------
108 +# Allow for easy stashing of LDFLAGS and CPPFLAGS before running
109 +# tests that may want to take user settings into account.
110 AC_DEFUN([GIT_STASH_FLAGS],[
111 if test -n "$1"; then
112 old_CPPFLAGS="$CPPFLAGS"
@@ -164,14 +164,13 @@ AC_ARG_WITH([sane-tool-path],
164 AC_ARG_WITH([lib],
165 [AS_HELP_STRING([--with-lib=ARG],
166 [ARG specifies alternative name for lib directory])],
167 - [if test "$withval" = "no" || test "$withval" = "yes"; then \
168 - AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
169 -else \
170 - lib=$withval; \
171 - AC_MSG_NOTICE([Setting lib to '$lib']); \
172 - GIT_CONF_APPEND_LINE(lib=$withval); \
173 -fi; \
174 -],[])
167 + [if test "$withval" = "no" || test "$withval" = "yes"; then
168 + AC_MSG_WARN([You should provide name for --with-lib=ARG])
169 + else
170 + lib=$withval
171 + AC_MSG_NOTICE([Setting lib to '$lib'])
172 + GIT_CONF_APPEND_LINE(lib=$withval)
173 + fi])
174
175 if test -z "$lib"; then
176 AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
@@ -237,9 +236,9 @@ AC_MSG_NOTICE([CHECKS for site configuration])
236 # /foo/bar/include and /foo/bar/lib directories.
237 AC_ARG_WITH(openssl,
238 AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])
240 -AS_HELP_STRING([], [ARG can be prefix for openssl library and headers]),\
241 -GIT_PARSE_WITH(openssl))
242 -#
239 +AS_HELP_STRING([], [ARG can be prefix for openssl library and headers]),
240 +GIT_PARSE_WITH([openssl]))
241 +
242 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
243 # able to use Perl-compatible regular expressions.
244 #
@@ -249,17 +248,16 @@ GIT_PARSE_WITH(openssl))
248 AC_ARG_WITH(libpcre,
249 AS_HELP_STRING([--with-libpcre],[support Perl-compatible regexes (default is NO)])
250 AS_HELP_STRING([], [ARG can be also prefix for libpcre library and headers]),
252 -if test "$withval" = "no"; then \
253 - USE_LIBPCRE=; \
254 -elif test "$withval" = "yes"; then \
255 - USE_LIBPCRE=YesPlease; \
256 -else
257 - USE_LIBPCRE=YesPlease; \
258 - LIBPCREDIR=$withval; \
259 - AC_MSG_NOTICE([Setting LIBPCREDIR to $withval]); \
260 - GIT_CONF_APPEND_LINE(LIBPCREDIR=$withval); \
261 -fi \
262 -)
251 + if test "$withval" = "no"; then
252 + USE_LIBPCRE=
253 + elif test "$withval" = "yes"; then
254 + USE_LIBPCRE=YesPlease
255 + else
256 + USE_LIBPCRE=YesPlease
257 + LIBPCREDIR=$withval
258 + AC_MSG_NOTICE([Setting LIBPCREDIR to $withval])
259 + GIT_CONF_APPEND_LINE(LIBPCREDIR=$withval)
260 + fi)
261 #
262 # Define NO_CURL if you do not have curl installed. git-http-pull and
263 # git-http-push are not built, and you cannot use http:// and https://
@@ -367,7 +365,7 @@ AC_ARG_WITH(tcltk,
365 AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
366 AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
367 AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
370 -AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),\
368 +AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),
369 GIT_PARSE_WITH(tcltk))
370 #
371