Skip to content

Commit

Permalink
add latest m4 files from gnulib
Browse files Browse the repository at this point in the history
gnulib git, rev 4084b3a git://git.sv.gnu.org/gnulib.git

gnulib git seems to be original source this stuff comes from.
had to update because the existing m4 files had some incompatibility
with latest gnu autotools when trying to build nano from git.
  • Loading branch information
rofl0r committed Mar 8, 2017
1 parent 9fc5563 commit 20c2491
Show file tree
Hide file tree
Showing 32 changed files with 953 additions and 500 deletions.
152 changes: 109 additions & 43 deletions m4/ansi-c++.m4
Original file line number Diff line number Diff line change
@@ -1,62 +1,128 @@
# ansi-c++.m4 serial 1 (gettext-0.12)
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
# ansi-c++.m4 serial 9
dnl Copyright (C) 2002-2003, 2005, 2010-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

dnl From Bruno Haible.

# Sets CXX to the name of a sufficiently ANSI C++ compliant compiler,
# or to ":" if none is found.
# Sets CXX_CHOICE to 'yes' or 'no', depending on the preferred use of C++.
# The default is 'yes'. If the configure.ac contains a definition of the
# macro gl_CXX_CHOICE_DEFAULT_NO, then the default is 'no'. In both cases,
# the user can change the value by passing the option --disable-cxx or
# --enable-cxx, respectively.

AC_DEFUN([gt_PROG_ANSI_CXX],
AC_DEFUN([gl_CXX_CHOICE],
[
AC_CHECK_PROGS(CXX, $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC, :)
if test "$CXX" != ":"; then
dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit
dnl upon failure.
AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
AC_LANG_PUSH(C++)
AC_ARG_VAR([CXX], [C++ compiler command])
AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])
echo 'int main () { return 0; }' > conftest.$ac_ext
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
ac_cv_prog_cxx_works=yes
if (./conftest; exit) 2>/dev/null; then
ac_cv_prog_cxx_cross=no
AC_MSG_CHECKING([whether to use C++])
dnl Plus signs are supported in AC_ARG_ENABLE starting with autoconf-2.66.
m4_version_prereq([2.66],
[m4_ifdef([gl_CXX_CHOICE_DEFAULT_NO],
[AC_ARG_ENABLE([c++],
[ --enable-c++ also build C++ sources],
[CXX_CHOICE="$enableval"],
[CXX_CHOICE=no])],
[AC_ARG_ENABLE([c++],
[ --disable-c++ do not build C++ sources],
[CXX_CHOICE="$enableval"],
[CXX_CHOICE=yes])])],
[m4_ifdef([gl_CXX_CHOICE_DEFAULT_NO],
[AC_ARG_ENABLE([cxx],
[ --enable-cxx also build C++ sources],
[CXX_CHOICE="$enableval"],
[CXX_CHOICE=no])],
[AC_ARG_ENABLE([cxx],
[ --disable-cxx do not build C++ sources],
[CXX_CHOICE="$enableval"],
[CXX_CHOICE=yes])])])
AC_MSG_RESULT([$CXX_CHOICE])
AC_SUBST([CXX_CHOICE])
])

# gl_PROG_ANSI_CXX([ANSICXX_VARIABLE], [ANSICXX_CONDITIONAL])
# Sets ANSICXX_VARIABLE to the name of a sufficiently ANSI C++ compliant
# compiler, or to "no" if none is found.
# Defines the Automake condition ANSICXX_CONDITIONAL to true if such a compiler
# was found, or to false if not.

AC_DEFUN([gl_PROG_ANSI_CXX],
[
AC_REQUIRE([gl_CXX_CHOICE])
m4_if([$1], [CXX], [],
[gl_save_CXX="$CXX"])
if test "$CXX_CHOICE" = no; then
CXX=no
fi
if test -z "$CXX"; then
if test -n "$CCC"; then
CXX="$CCC"
else
ac_cv_prog_cxx_cross=yes
AC_CHECK_TOOLS([CXX],
[g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC],
[:])
fi
else
ac_cv_prog_cxx_works=no
fi
rm -fr conftest*
AC_LANG_POP(C++)
AC_MSG_RESULT($ac_cv_prog_cxx_works)
if test $ac_cv_prog_cxx_works = no; then
CXX=:
else
dnl Test for namespaces. Both libasprintf and tests/lang-c++ need it.
dnl We don't bother supporting pre-ANSI-C++ compilers.
AC_MSG_CHECKING([whether the C++ compiler supports namespaces])
AC_LANG_PUSH(C++)
cat <<EOF > conftest.$ac_ext
if test "$CXX" != no; then
dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit
dnl upon failure.
AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
AC_LANG_PUSH([C++])
AC_ARG_VAR([CXX], [C++ compiler command])
AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])
echo 'int main () { return 0; }' > conftest.$ac_ext
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
gl_cv_prog_ansicxx_works=yes
if (./conftest; exit) 2>/dev/null; then
gl_cv_prog_ansicxx_cross=no
else
gl_cv_prog_ansicxx_cross=yes
fi
else
gl_cv_prog_ansicxx_works=no
fi
rm -fr conftest*
AC_LANG_POP([C++])
AC_MSG_RESULT([$gl_cv_prog_ansicxx_works])
if test $gl_cv_prog_ansicxx_works = no; then
CXX=no
else
dnl Test for namespaces.
dnl We don't bother supporting pre-ANSI-C++ compilers.
AC_MSG_CHECKING([whether the C++ compiler supports namespaces])
AC_LANG_PUSH([C++])
cat <<EOF > conftest.$ac_ext
#include <iostream>
namespace test { using namespace std; }
std::ostream* ptr;
int main () { return 0; }
EOF
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
gt_cv_prog_cxx_namespaces=yes
else
gt_cv_prog_cxx_namespaces=no
fi
rm -fr conftest*
AC_LANG_POP(C++)
AC_MSG_RESULT($gt_cv_prog_cxx_namespaces)
if test $gt_cv_prog_cxx_namespaces = no; then
CXX=:
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
gl_cv_prog_ansicxx_namespaces=yes
else
gl_cv_prog_ansicxx_namespaces=no
fi
rm -fr conftest*
AC_LANG_POP([C++])
AC_MSG_RESULT([$gl_cv_prog_ansicxx_namespaces])
if test $gl_cv_prog_ansicxx_namespaces = no; then
CXX=no
fi
fi
fi
fi
m4_if([$1], [CXX], [],
[$1="$CXX"
CXX="$gl_save_CXX"])
AC_SUBST([$1])
AM_CONDITIONAL([$2], [test "$$1" != no])
if test "$$1" != no; then
dnl This macro invocation resolves an automake error:
dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in AM_CONDITIONAL
dnl /usr/local/share/automake-1.11/am/depend2.am: The usual way to define 'am__fastdepCXX' is to add 'AC_PROG_CXX'
dnl /usr/local/share/automake-1.11/am/depend2.am: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
_AM_DEPENDENCIES([CXX])
else
AM_CONDITIONAL([am__fastdepCXX], [false])
fi
])
15 changes: 9 additions & 6 deletions m4/codeset.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# codeset.m4 serial 4 (gettext-0.18)
dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc.
# codeset.m4 serial 5 (gettext-0.18.2)
dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
Expand All @@ -9,10 +10,12 @@ dnl From Bruno Haible.
AC_DEFUN([AM_LANGINFO_CODESET],
[
AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
[AC_TRY_LINK([#include <langinfo.h>],
[char* cs = nl_langinfo(CODESET); return !cs;],
[am_cv_langinfo_codeset=yes],
[am_cv_langinfo_codeset=no])
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <langinfo.h>]],
[[char* cs = nl_langinfo(CODESET); return !cs;]])],
[am_cv_langinfo_codeset=yes],
[am_cv_langinfo_codeset=no])
])
if test $am_cv_langinfo_codeset = yes; then
AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
Expand Down
95 changes: 74 additions & 21 deletions m4/fcntl-o.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fcntl-o.m4 serial 1
dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
# fcntl-o.m4 serial 4
dnl Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
Expand All @@ -12,13 +12,26 @@ dnl Written by Paul Eggert.
AC_DEFUN([gl_FCNTL_O_FLAGS],
[
dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
dnl AC_GNU_SOURCE.
m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
[AC_REQUIRE([AC_GNU_SOURCE])])
AC_CHECK_HEADERS_ONCE([unistd.h])
AC_CHECK_FUNCS_ONCE([symlink])
AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#else /* on Windows with MSVC */
# include <io.h>
# include <stdlib.h>
# defined sleep(n) _sleep ((n) * 1000)
#endif
#include <fcntl.h>
#ifndef O_NOATIME
#define O_NOATIME 0
Expand All @@ -33,34 +46,74 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
};
]],
[[
int status = !constants;
int result = !constants;
#if HAVE_SYMLINK
{
static char const sym[] = "conftest.sym";
if (symlink (".", sym) != 0
|| close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
status |= 32;
if (symlink ("/dev/null", sym) != 0)
result |= 2;
else
{
int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0);
if (fd >= 0)
{
close (fd);
result |= 4;
}
}
if (unlink (sym) != 0 || symlink (".", sym) != 0)
result |= 2;
else
{
int fd = open (sym, O_RDONLY | O_NOFOLLOW);
if (fd >= 0)
{
close (fd);
result |= 4;
}
}
unlink (sym);
}
#endif
{
static char const file[] = "confdefs.h";
int fd = open (file, O_RDONLY | O_NOATIME);
char c;
struct stat st0, st1;
if (fd < 0
|| fstat (fd, &st0) != 0
|| sleep (1) != 0
|| read (fd, &c, 1) != 1
|| close (fd) != 0
|| stat (file, &st1) != 0
|| st0.st_atime != st1.st_atime)
status |= 64;
if (fd < 0)
result |= 8;
else
{
struct stat st0;
if (fstat (fd, &st0) != 0)
result |= 16;
else
{
char c;
sleep (1);
if (read (fd, &c, 1) != 1)
result |= 24;
else
{
if (close (fd) != 0)
result |= 32;
else
{
struct stat st1;
if (stat (file, &st1) != 0)
result |= 40;
else
if (st0.st_atime != st1.st_atime)
result |= 64;
}
}
}
}
}
return status;]])],
return result;]])],
[gl_cv_header_working_fcntl_h=yes],
[case $? in #(
32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
*) gl_cv_header_working_fcntl_h='no';;
esac],
[gl_cv_header_working_fcntl_h=cross-compiling])])
Expand Down
Loading

0 comments on commit 20c2491

Please sign in to comment.