Skip to content

Commit e5ccf5e

Browse files
committed
Merge branch 'sl/autoconf'
Updates our configure.ac to follow a better "autoconf" style. By Stefano Lattarini * sl/autoconf: configure: be more idiomatic configure: avoid some code repetitions thanks to m4_{push,pop}def configure: move definitions of private m4 macros before AC_INIT invocation
2 parents b3ba469 + 5b2d131 commit e5ccf5e

File tree

1 file changed

+99
-98
lines changed

1 file changed

+99
-98
lines changed

configure.ac

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

4-
AC_PREREQ(2.59)
5-
AC_INIT([git], [@@GIT_VERSION@@], [[email protected]])
6-
7-
AC_CONFIG_SRCDIR([git.c])
8-
9-
config_file=config.mak.autogen
10-
config_append=config.mak.append
11-
config_in=config.mak.in
12-
13-
echo "# ${config_append}. Generated by configure." > "${config_append}"
14-
4+
## Definitions of private macros.
155

16-
## Definitions of macros
176
# GIT_CONF_APPEND_LINE(LINE)
187
# --------------------------
198
# Append LINE to file ${config_append}
209
AC_DEFUN([GIT_CONF_APPEND_LINE],
21-
[echo "$1" >> "${config_append}"])# GIT_CONF_APPEND_LINE
22-
#
10+
[echo "$1" >> "${config_append}"])
11+
2312
# GIT_ARG_SET_PATH(PROGRAM)
2413
# -------------------------
2514
# Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
2615
# Optional second argument allows setting NO_PROGRAM=YesPlease if
2716
# --without-PROGRAM version used.
2817
AC_DEFUN([GIT_ARG_SET_PATH],
29-
[AC_ARG_WITH([$1],
30-
[AS_HELP_STRING([--with-$1=PATH],
31-
[provide PATH to $1])],
32-
[GIT_CONF_APPEND_PATH($1,$2)],[])
33-
])# GIT_ARG_SET_PATH
34-
#
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+
3524
# GIT_CONF_APPEND_PATH(PROGRAM)
36-
# ------------------------------
25+
# -----------------------------
3726
# Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
3827
# Used by GIT_ARG_SET_PATH(PROGRAM)
3928
# Optional second argument allows setting NO_PROGRAM=YesPlease if
4029
# --without-PROGRAM is used.
4130
AC_DEFUN([GIT_CONF_APPEND_PATH],
42-
[PROGRAM=m4_toupper($1); \
43-
if test "$withval" = "no"; then \
44-
if test -n "$2"; then \
45-
m4_toupper($1)_PATH=$withval; \
46-
AC_MSG_NOTICE([Disabling use of ${PROGRAM}]); \
47-
GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease); \
48-
GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=); \
49-
else \
50-
AC_MSG_ERROR([You cannot use git without $1]); \
51-
fi; \
52-
else \
53-
if test "$withval" = "yes"; then \
54-
AC_MSG_WARN([You should provide path for --with-$1=PATH]); \
55-
else \
56-
m4_toupper($1)_PATH=$withval; \
57-
AC_MSG_NOTICE([Setting m4_toupper($1)_PATH to $withval]); \
58-
GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval); \
59-
fi; \
60-
fi; \
61-
]) # GIT_CONF_APPEND_PATH
62-
#
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+
6353
# GIT_PARSE_WITH(PACKAGE)
6454
# -----------------------
6555
# For use in AC_ARG_WITH action-if-found, for packages default ON.
6656
# * Set NO_PACKAGE=YesPlease for --without-PACKAGE
6757
# * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
6858
# * Unset NO_PACKAGE for --with-PACKAGE without ARG
6959
AC_DEFUN([GIT_PARSE_WITH],
70-
[PACKAGE=m4_toupper($1); \
71-
if test "$withval" = "no"; then \
72-
m4_toupper(NO_$1)=YesPlease; \
73-
elif test "$withval" = "yes"; then \
74-
m4_toupper(NO_$1)=; \
75-
else \
76-
m4_toupper(NO_$1)=; \
77-
m4_toupper($1)DIR=$withval; \
78-
AC_MSG_NOTICE([Setting m4_toupper($1)DIR to $withval]); \
79-
GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
80-
fi \
81-
])# GIT_PARSE_WITH
82-
#
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+
8374
# GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
84-
# ---------------------
75+
# -----------------------------------------------------
8576
# Set VAR to the value specied by --with-WITHNAME.
8677
# No verification of arguments is performed, but warnings are issued
8778
# if either 'yes' or 'no' is specified.
@@ -90,33 +81,32 @@ fi \
9081
AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
9182
[AC_ARG_WITH([$1],
9283
[AS_HELP_STRING([--with-$1=VALUE], $3)],
93-
if test -n "$withval"; then \
94-
if test "$withval" = "yes" -o "$withval" = "no"; then \
84+
if test -n "$withval"; then
85+
if test "$withval" = "yes" -o "$withval" = "no"; then
9586
AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
96-
[a value for $1 ($2). Maybe you do...?]); \
97-
fi; \
98-
\
99-
AC_MSG_NOTICE([Setting $2 to $withval]); \
100-
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)
10191
fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
10292

103-
dnl
104-
dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
105-
dnl -----------------------------------------
106-
dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
107-
dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
108-
dnl -Wall), it does not work. By looking for function definition in
109-
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.
110100
AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
111101
AC_SEARCH_LIBS([$1],,
112102
[$2],[$3])
113103
],[$3])])
114104

115-
dnl
116-
dnl GIT_STASH_FLAGS(BASEPATH_VAR)
117-
dnl -----------------------------
118-
dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
119-
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.
120110
AC_DEFUN([GIT_STASH_FLAGS],[
121111
if test -n "$1"; then
122112
old_CPPFLAGS="$CPPFLAGS"
@@ -137,6 +127,19 @@ if test -n "$1"; then
137127
fi
138128
])
139129

130+
## Configure body starts here.
131+
132+
AC_PREREQ(2.59)
133+
AC_INIT([git], [@@GIT_VERSION@@], [[email protected]])
134+
135+
AC_CONFIG_SRCDIR([git.c])
136+
137+
config_file=config.mak.autogen
138+
config_append=config.mak.append
139+
config_in=config.mak.in
140+
141+
echo "# ${config_append}. Generated by configure." > "${config_append}"
142+
140143
# Directories holding "saner" versions of common or POSIX binaries.
141144
AC_ARG_WITH([sane-tool-path],
142145
[AS_HELP_STRING(
@@ -161,14 +164,13 @@ AC_ARG_WITH([sane-tool-path],
161164
AC_ARG_WITH([lib],
162165
[AS_HELP_STRING([--with-lib=ARG],
163166
[ARG specifies alternative name for lib directory])],
164-
[if test "$withval" = "no" || test "$withval" = "yes"; then \
165-
AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
166-
else \
167-
lib=$withval; \
168-
AC_MSG_NOTICE([Setting lib to '$lib']); \
169-
GIT_CONF_APPEND_LINE(lib=$withval); \
170-
fi; \
171-
],[])
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])
172174

173175
if test -z "$lib"; then
174176
AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
@@ -234,9 +236,9 @@ AC_MSG_NOTICE([CHECKS for site configuration])
234236
# /foo/bar/include and /foo/bar/lib directories.
235237
AC_ARG_WITH(openssl,
236238
AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])
237-
AS_HELP_STRING([], [ARG can be prefix for openssl library and headers]),\
238-
GIT_PARSE_WITH(openssl))
239-
#
239+
AS_HELP_STRING([], [ARG can be prefix for openssl library and headers]),
240+
GIT_PARSE_WITH([openssl]))
241+
240242
# Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
241243
# able to use Perl-compatible regular expressions.
242244
#
@@ -246,17 +248,16 @@ GIT_PARSE_WITH(openssl))
246248
AC_ARG_WITH(libpcre,
247249
AS_HELP_STRING([--with-libpcre],[support Perl-compatible regexes (default is NO)])
248250
AS_HELP_STRING([], [ARG can be also prefix for libpcre library and headers]),
249-
if test "$withval" = "no"; then \
250-
USE_LIBPCRE=; \
251-
elif test "$withval" = "yes"; then \
252-
USE_LIBPCRE=YesPlease; \
253-
else
254-
USE_LIBPCRE=YesPlease; \
255-
LIBPCREDIR=$withval; \
256-
AC_MSG_NOTICE([Setting LIBPCREDIR to $withval]); \
257-
GIT_CONF_APPEND_LINE(LIBPCREDIR=$withval); \
258-
fi \
259-
)
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)
260261
#
261262
# Define NO_CURL if you do not have curl installed. git-http-pull and
262263
# git-http-push are not built, and you cannot use http:// and https://
@@ -364,7 +365,7 @@ AC_ARG_WITH(tcltk,
364365
AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
365366
AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
366367
AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
367-
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.]),
368369
GIT_PARSE_WITH(tcltk))
369370
#
370371

0 commit comments

Comments
 (0)