Skip to content

Commit 1e58dba

Browse files
Ralf Wildenhuesgitster
Ralf Wildenhues
authored andcommitted
configure: use AC_LANG_PROGRAM consistently
Avoid warnings from Autoconf 2.68 about missing use of AC_LANG_PROGRAM and friends. Quoting autoconf-2.68/NEWS: ** The macros AC_PREPROC_IFELSE, AC_COMPILE_IFELSE, AC_LINK_IFELSE, and AC_RUN_IFELSE now warn if the first argument failed to use AC_LANG_SOURCE or AC_LANG_PROGRAM to generate the conftest file contents. A new macro AC_LANG_DEFINES_PROVIDED exists if you have a compelling reason why you cannot use AC_LANG_SOURCE but must avoid the warning. The underlying reason for that change is that AC_LANG_{SOURCE,PROGRAM} take care to supply the previously computed set of #defines (and include standard headers if so desired) for preprocessed languages like C and C++. In some cases, AC_LANG_PROGRAM is already used but not sufficiently m4-quoted, so we just need to add another set of [quotes] to prevent the autoconf warning from being triggered bogusly. Quoting all arguments (except when calling special macros that need to be expanded before recursion) is better style, anyway. These and more rules are described in detail in 'info Autoconf "Programming in M4"'. No change in the resulting config.mak.autogen after running ./configure intended. Signed-off-by: Ralf Wildenhues <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 62b8102 commit 1e58dba

File tree

2 files changed

+21
-39
lines changed

2 files changed

+21
-39
lines changed

aclocal.m4

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ AC_DEFUN([TYPE_SOCKLEN_T],
1313
git_cv_socklen_t_equiv=
1414
for arg2 in "struct sockaddr" void; do
1515
for t in int size_t unsigned long "unsigned long"; do
16-
AC_TRY_COMPILE([
16+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1717
#include <sys/types.h>
1818
#include <sys/socket.h>
1919
2020
int getpeername (int, $arg2 *, $t *);
2121
],[
2222
$t len;
2323
getpeername(0,0,&len);
24-
],[
24+
])],[
2525
git_cv_socklen_t_equiv="$t"
2626
break 2
2727
])

configure.ac

+19-37
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ esac
345345
AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [
346346
SAVE_LDFLAGS="${LDFLAGS}"
347347
LDFLAGS="${SAVE_LDFLAGS} -R /"
348-
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
348+
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
349349
LDFLAGS="${SAVE_LDFLAGS}"
350350
])
351351
if test "$git_cv_ld_dashr" = "yes"; then
@@ -354,7 +354,7 @@ else
354354
AC_CACHE_CHECK([if linker supports -Wl,-rpath,], git_cv_ld_wl_rpath, [
355355
SAVE_LDFLAGS="${LDFLAGS}"
356356
LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
357-
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])
357+
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])
358358
LDFLAGS="${SAVE_LDFLAGS}"
359359
])
360360
if test "$git_cv_ld_wl_rpath" = "yes"; then
@@ -363,7 +363,7 @@ else
363363
AC_CACHE_CHECK([if linker supports -rpath], git_cv_ld_rpath, [
364364
SAVE_LDFLAGS="${LDFLAGS}"
365365
LDFLAGS="${SAVE_LDFLAGS} -rpath /"
366-
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_rpath=yes], [git_cv_ld_rpath=no])
366+
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_rpath=yes], [git_cv_ld_rpath=no])
367367
LDFLAGS="${SAVE_LDFLAGS}"
368368
])
369369
if test "$git_cv_ld_rpath" = "yes"; then
@@ -472,15 +472,9 @@ if test -z "$NO_ICONV"; then
472472

473473
GIT_STASH_FLAGS($ICONVDIR)
474474

475-
AC_DEFUN([ICONVTEST_SRC], [
476-
#include <iconv.h>
477-
478-
int main(void)
479-
{
480-
iconv_open("", "");
481-
return 0;
482-
}
483-
])
475+
AC_DEFUN([ICONVTEST_SRC],
476+
[AC_LANG_PROGRAM([#include <iconv.h>],
477+
[iconv_open("", "");])])
484478

485479
if test -n "$ICONVDIR"; then
486480
lib_order="-liconv -lc"
@@ -500,7 +494,7 @@ for l in $lib_order; do
500494
old_LIBS="$LIBS"
501495
LIBS="$LIBS $l"
502496
AC_MSG_CHECKING([for iconv in $l])
503-
AC_LINK_IFELSE(ICONVTEST_SRC,
497+
AC_LINK_IFELSE([ICONVTEST_SRC],
504498
[AC_MSG_RESULT([yes])
505499
NO_ICONV=
506500
break],
@@ -528,18 +522,12 @@ fi
528522
GIT_STASH_FLAGS($ZLIB_PATH)
529523

530524
AC_DEFUN([ZLIBTEST_SRC], [
531-
#include <zlib.h>
532-
533-
int main(void)
534-
{
535-
deflateBound(0, 0);
536-
return 0;
537-
}
538-
])
525+
AC_LANG_PROGRAM([#include <zlib.h>],
526+
[deflateBound(0, 0);])])
539527
AC_MSG_CHECKING([for deflateBound in -lz])
540528
old_LIBS="$LIBS"
541529
LIBS="$LIBS -lz"
542-
AC_LINK_IFELSE(ZLIBTEST_SRC,
530+
AC_LINK_IFELSE([ZLIBTEST_SRC],
543531
[AC_MSG_RESULT([yes])],
544532
[AC_MSG_RESULT([no])
545533
NO_DEFLATE_BOUND=yes])
@@ -631,23 +619,19 @@ AC_SUBST(NO_INTTYPES_H)
631619
#
632620
# Define OLD_ICONV if your library has an old iconv(), where the second
633621
# (input buffer pointer) parameter is declared with type (const char **).
634-
AC_DEFUN([OLDICONVTEST_SRC], [[
622+
AC_DEFUN([OLDICONVTEST_SRC], [
623+
AC_LANG_PROGRAM([[
635624
#include <iconv.h>
636625
637626
extern size_t iconv(iconv_t cd,
638627
char **inbuf, size_t *inbytesleft,
639628
char **outbuf, size_t *outbytesleft);
640-
641-
int main(void)
642-
{
643-
return 0;
644-
}
645-
]])
629+
]], [])])
646630

647631
GIT_STASH_FLAGS($ICONVDIR)
648632

649633
AC_MSG_CHECKING([for old iconv()])
650-
AC_COMPILE_IFELSE(OLDICONVTEST_SRC,
634+
AC_COMPILE_IFELSE([OLDICONVTEST_SRC],
651635
[AC_MSG_RESULT([no])],
652636
[AC_MSG_RESULT([yes])
653637
OLD_ICONV=UnfortunatelyYes])
@@ -931,18 +915,16 @@ AC_SUBST(NO_INITGROUPS)
931915
#
932916
# Define PTHREAD_LIBS to the linker flag used for Pthread support.
933917
AC_DEFUN([PTHREADTEST_SRC], [
918+
AC_LANG_PROGRAM([[
934919
#include <pthread.h>
935-
936-
int main(void)
937-
{
920+
]], [[
938921
pthread_mutex_t test_mutex;
939922
int retcode = 0;
940923
retcode |= pthread_mutex_init(&test_mutex,(void *)0);
941924
retcode |= pthread_mutex_lock(&test_mutex);
942925
retcode |= pthread_mutex_unlock(&test_mutex);
943926
return retcode;
944-
}
945-
])
927+
]])])
946928

947929
dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM(
948930
dnl [[#include <pthread.h>]],
@@ -962,7 +944,7 @@ elif test -z "$PTHREAD_CFLAGS"; then
962944
old_CFLAGS="$CFLAGS"
963945
CFLAGS="$opt $CFLAGS"
964946
AC_MSG_CHECKING([Checking for POSIX Threads with '$opt'])
965-
AC_LINK_IFELSE(PTHREADTEST_SRC,
947+
AC_LINK_IFELSE([PTHREADTEST_SRC],
966948
[AC_MSG_RESULT([yes])
967949
NO_PTHREADS=
968950
PTHREAD_LIBS="$opt"
@@ -982,7 +964,7 @@ else
982964
old_CFLAGS="$CFLAGS"
983965
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
984966
AC_MSG_CHECKING([Checking for POSIX Threads with '$PTHREAD_CFLAGS'])
985-
AC_LINK_IFELSE(PTHREADTEST_SRC,
967+
AC_LINK_IFELSE([PTHREADTEST_SRC],
986968
[AC_MSG_RESULT([yes])
987969
NO_PTHREADS=
988970
PTHREAD_LIBS="$PTHREAD_CFLAGS"

0 commit comments

Comments
 (0)