Skip to content

Commit 5b2d131

Browse files
slattarinigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 99cccef commit 5b2d131

File tree

1 file changed

+87
-89
lines changed

1 file changed

+87
-89
lines changed

configure.ac

Lines changed: 87 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,78 @@
11
# -*- Autoconf -*-
22
# Process this file with autoconf to produce a configure script.
33

4-
## Definitions of macros
4+
## Definitions of private macros.
5+
56
# GIT_CONF_APPEND_LINE(LINE)
67
# --------------------------
78
# Append LINE to file ${config_append}
89
AC_DEFUN([GIT_CONF_APPEND_LINE],
9-
[echo "$1" >> "${config_append}"])# GIT_CONF_APPEND_LINE
10-
#
10+
[echo "$1" >> "${config_append}"])
11+
1112
# GIT_ARG_SET_PATH(PROGRAM)
1213
# -------------------------
1314
# Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
1415
# Optional second argument allows setting NO_PROGRAM=YesPlease if
1516
# --without-PROGRAM version used.
1617
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+
2324
# GIT_CONF_APPEND_PATH(PROGRAM)
24-
# ------------------------------
25+
# -----------------------------
2526
# Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
2627
# Used by GIT_ARG_SET_PATH(PROGRAM)
2728
# Optional second argument allows setting NO_PROGRAM=YesPlease if
2829
# --without-PROGRAM is used.
2930
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+
5253
# GIT_PARSE_WITH(PACKAGE)
5354
# -----------------------
5455
# For use in AC_ARG_WITH action-if-found, for packages default ON.
5556
# * Set NO_PACKAGE=YesPlease for --without-PACKAGE
5657
# * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
5758
# * Unset NO_PACKAGE for --with-PACKAGE without ARG
5859
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+
7374
# GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
74-
# ---------------------
75+
# -----------------------------------------------------
7576
# Set VAR to the value specied by --with-WITHNAME.
7677
# No verification of arguments is performed, but warnings are issued
7778
# if either 'yes' or 'no' is specified.
@@ -80,33 +81,32 @@ m4_popdef([GIT_UC_PACKAGE])]) # GIT_PARSE_WITH
8081
AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
8182
[AC_ARG_WITH([$1],
8283
[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
8586
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)
9191
fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
9292

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.
100100
AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
101101
AC_SEARCH_LIBS([$1],,
102102
[$2],[$3])
103103
],[$3])])
104104

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.
110110
AC_DEFUN([GIT_STASH_FLAGS],[
111111
if test -n "$1"; then
112112
old_CPPFLAGS="$CPPFLAGS"
@@ -164,14 +164,13 @@ AC_ARG_WITH([sane-tool-path],
164164
AC_ARG_WITH([lib],
165165
[AS_HELP_STRING([--with-lib=ARG],
166166
[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])
175174

176175
if test -z "$lib"; then
177176
AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
@@ -237,9 +236,9 @@ AC_MSG_NOTICE([CHECKS for site configuration])
237236
# /foo/bar/include and /foo/bar/lib directories.
238237
AC_ARG_WITH(openssl,
239238
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+
243242
# Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
244243
# able to use Perl-compatible regular expressions.
245244
#
@@ -249,17 +248,16 @@ GIT_PARSE_WITH(openssl))
249248
AC_ARG_WITH(libpcre,
250249
AS_HELP_STRING([--with-libpcre],[support Perl-compatible regexes (default is NO)])
251250
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)
263261
#
264262
# Define NO_CURL if you do not have curl installed. git-http-pull and
265263
# git-http-push are not built, and you cannot use http:// and https://
@@ -367,7 +365,7 @@ AC_ARG_WITH(tcltk,
367365
AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
368366
AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
369367
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.]),
371369
GIT_PARSE_WITH(tcltk))
372370
#
373371

0 commit comments

Comments
 (0)