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
This commit is contained in:
Junio C Hamano 2012-04-16 12:42:29 -07:00
commit e5ccf5e409

View File

@ -1,65 +1,55 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
## Definitions of private macros.
AC_CONFIG_SRCDIR([git.c])
config_file=config.mak.autogen
config_append=config.mak.append
config_in=config.mak.in
echo "# ${config_append}. Generated by configure." > "${config_append}"
## Definitions of macros
# GIT_CONF_APPEND_LINE(LINE)
# --------------------------
# Append LINE to file ${config_append}
AC_DEFUN([GIT_CONF_APPEND_LINE],
[echo "$1" >> "${config_append}"])# GIT_CONF_APPEND_LINE
#
[echo "$1" >> "${config_append}"])
# GIT_ARG_SET_PATH(PROGRAM)
# -------------------------
# Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
# Optional second argument allows setting NO_PROGRAM=YesPlease if
# --without-PROGRAM version used.
AC_DEFUN([GIT_ARG_SET_PATH],
[AC_ARG_WITH([$1],
[AS_HELP_STRING([--with-$1=PATH],
[provide PATH to $1])],
[GIT_CONF_APPEND_PATH($1,$2)],[])
])# GIT_ARG_SET_PATH
#
[AC_ARG_WITH([$1],
[AS_HELP_STRING([--with-$1=PATH],
[provide PATH to $1])],
[GIT_CONF_APPEND_PATH([$1], [$2])],
[])])
# GIT_CONF_APPEND_PATH(PROGRAM)
# ------------------------------
# -----------------------------
# Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
# Used by GIT_ARG_SET_PATH(PROGRAM)
# Optional second argument allows setting NO_PROGRAM=YesPlease if
# --without-PROGRAM is used.
AC_DEFUN([GIT_CONF_APPEND_PATH],
[PROGRAM=m4_toupper($1); \
if test "$withval" = "no"; then \
if test -n "$2"; then \
m4_toupper($1)_PATH=$withval; \
AC_MSG_NOTICE([Disabling use of ${PROGRAM}]); \
GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease); \
GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=); \
else \
AC_MSG_ERROR([You cannot use git without $1]); \
fi; \
else \
if test "$withval" = "yes"; then \
AC_MSG_WARN([You should provide path for --with-$1=PATH]); \
else \
m4_toupper($1)_PATH=$withval; \
AC_MSG_NOTICE([Setting m4_toupper($1)_PATH to $withval]); \
GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval); \
fi; \
fi; \
]) # GIT_CONF_APPEND_PATH
#
[m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
PROGRAM=GIT_UC_PROGRAM
if test "$withval" = "no"; then
if test -n "$2"; then
GIT_UC_PROGRAM[]_PATH=$withval
AC_MSG_NOTICE([Disabling use of ${PROGRAM}])
GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease)
GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=)
else
AC_MSG_ERROR([You cannot use git without $1])
fi
else
if test "$withval" = "yes"; then
AC_MSG_WARN([You should provide path for --with-$1=PATH])
else
GIT_UC_PROGRAM[]_PATH=$withval
AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval)
fi
fi
m4_popdef([GIT_UC_PROGRAM])])
# GIT_PARSE_WITH(PACKAGE)
# -----------------------
# For use in AC_ARG_WITH action-if-found, for packages default ON.
@ -67,21 +57,22 @@ fi; \
# * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
# * Unset NO_PACKAGE for --with-PACKAGE without ARG
AC_DEFUN([GIT_PARSE_WITH],
[PACKAGE=m4_toupper($1); \
if test "$withval" = "no"; then \
m4_toupper(NO_$1)=YesPlease; \
elif test "$withval" = "yes"; then \
m4_toupper(NO_$1)=; \
else \
m4_toupper(NO_$1)=; \
m4_toupper($1)DIR=$withval; \
AC_MSG_NOTICE([Setting m4_toupper($1)DIR to $withval]); \
GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
fi \
])# GIT_PARSE_WITH
#
[m4_pushdef([GIT_UC_PACKAGE], m4_toupper([$1]))dnl
PACKAGE=GIT_UC_PACKAGE
if test "$withval" = "no"; then
NO_[]GIT_UC_PACKAGE=YesPlease
elif test "$withval" = "yes"; then
NO_[]GIT_UC_PACKAGE=
else
NO_[]GIT_UC_PACKAGE=
GIT_UC_PACKAGE[]DIR=$withval
AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval)
fi
m4_popdef([GIT_UC_PACKAGE])])
# GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
# ---------------------
# -----------------------------------------------------
# Set VAR to the value specied by --with-WITHNAME.
# No verification of arguments is performed, but warnings are issued
# if either 'yes' or 'no' is specified.
@ -90,33 +81,32 @@ fi \
AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
[AC_ARG_WITH([$1],
[AS_HELP_STRING([--with-$1=VALUE], $3)],
if test -n "$withval"; then \
if test "$withval" = "yes" -o "$withval" = "no"; then \
if test -n "$withval"; then
if test "$withval" = "yes" -o "$withval" = "no"; then
AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
[a value for $1 ($2). Maybe you do...?]); \
fi; \
\
AC_MSG_NOTICE([Setting $2 to $withval]); \
GIT_CONF_APPEND_LINE($2=$withval); \
[a value for $1 ($2). Maybe you do...?])
fi
AC_MSG_NOTICE([Setting $2 to $withval])
GIT_CONF_APPEND_LINE($2=$withval)
fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
dnl
dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
dnl -----------------------------------------
dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
dnl -Wall), it does not work. By looking for function definition in
dnl libraries, this problem can be worked around.
#
# GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
# -----------------------------------------
# Similar to AC_CHECK_FUNC, but on systems that do not generate
# warnings for missing prototypes (e.g. FreeBSD when compiling without
# -Wall), it does not work. By looking for function definition in
# libraries, this problem can be worked around.
AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
AC_SEARCH_LIBS([$1],,
[$2],[$3])
],[$3])])
dnl
dnl GIT_STASH_FLAGS(BASEPATH_VAR)
dnl -----------------------------
dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
dnl tests that may want to take user settings into account.
#
# GIT_STASH_FLAGS(BASEPATH_VAR)
# -----------------------------
# Allow for easy stashing of LDFLAGS and CPPFLAGS before running
# tests that may want to take user settings into account.
AC_DEFUN([GIT_STASH_FLAGS],[
if test -n "$1"; then
old_CPPFLAGS="$CPPFLAGS"
@ -137,6 +127,19 @@ if test -n "$1"; then
fi
])
## Configure body starts here.
AC_PREREQ(2.59)
AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
AC_CONFIG_SRCDIR([git.c])
config_file=config.mak.autogen
config_append=config.mak.append
config_in=config.mak.in
echo "# ${config_append}. Generated by configure." > "${config_append}"
# Directories holding "saner" versions of common or POSIX binaries.
AC_ARG_WITH([sane-tool-path],
[AS_HELP_STRING(
@ -161,14 +164,13 @@ AC_ARG_WITH([sane-tool-path],
AC_ARG_WITH([lib],
[AS_HELP_STRING([--with-lib=ARG],
[ARG specifies alternative name for lib directory])],
[if test "$withval" = "no" || test "$withval" = "yes"; then \
AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
else \
lib=$withval; \
AC_MSG_NOTICE([Setting lib to '$lib']); \
GIT_CONF_APPEND_LINE(lib=$withval); \
fi; \
],[])
[if test "$withval" = "no" || test "$withval" = "yes"; then
AC_MSG_WARN([You should provide name for --with-lib=ARG])
else
lib=$withval
AC_MSG_NOTICE([Setting lib to '$lib'])
GIT_CONF_APPEND_LINE(lib=$withval)
fi])
if test -z "$lib"; then
AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
@ -234,9 +236,9 @@ AC_MSG_NOTICE([CHECKS for site configuration])
# /foo/bar/include and /foo/bar/lib directories.
AC_ARG_WITH(openssl,
AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])
AS_HELP_STRING([], [ARG can be prefix for openssl library and headers]),\
GIT_PARSE_WITH(openssl))
#
AS_HELP_STRING([], [ARG can be prefix for openssl library and headers]),
GIT_PARSE_WITH([openssl]))
# Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
# able to use Perl-compatible regular expressions.
#
@ -246,17 +248,16 @@ GIT_PARSE_WITH(openssl))
AC_ARG_WITH(libpcre,
AS_HELP_STRING([--with-libpcre],[support Perl-compatible regexes (default is NO)])
AS_HELP_STRING([], [ARG can be also prefix for libpcre library and headers]),
if test "$withval" = "no"; then \
USE_LIBPCRE=; \
elif test "$withval" = "yes"; then \
USE_LIBPCRE=YesPlease; \
else
USE_LIBPCRE=YesPlease; \
LIBPCREDIR=$withval; \
AC_MSG_NOTICE([Setting LIBPCREDIR to $withval]); \
GIT_CONF_APPEND_LINE(LIBPCREDIR=$withval); \
fi \
)
if test "$withval" = "no"; then
USE_LIBPCRE=
elif test "$withval" = "yes"; then
USE_LIBPCRE=YesPlease
else
USE_LIBPCRE=YesPlease
LIBPCREDIR=$withval
AC_MSG_NOTICE([Setting LIBPCREDIR to $withval])
GIT_CONF_APPEND_LINE(LIBPCREDIR=$withval)
fi)
#
# Define NO_CURL if you do not have curl installed. git-http-pull and
# git-http-push are not built, and you cannot use http:// and https://
@ -364,7 +365,7 @@ AC_ARG_WITH(tcltk,
AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),\
AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),
GIT_PARSE_WITH(tcltk))
#