Commit e9b6611f authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Check for POSIX.1-2001 conformance.

* Since write, mmap and a number of other functions are not part of
  ISO C (i.e. strictly conforming programs must not use those), we need
  to ensure the build environment provides POSIX conformance.
* This mostly prevents unrelated bug reports later on.
* From POSIX 2008, CDI unconditionally only uses getline and has a
  work-around in case that is missing.
parent 1fa8e69b
......@@ -108,6 +108,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/m4/acx_lt_problems.m4 \
$(top_srcdir)/m4/acx_option_search_libs.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/acx_prog_cc_posix.m4 \
$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
......
......@@ -1196,6 +1196,7 @@ m4_include([m4/acx_lang_package.m4])
m4_include([m4/acx_lt_problems.m4])
m4_include([m4/acx_option_search_libs.m4])
m4_include([m4/acx_options.m4])
m4_include([m4/acx_prog_cc_posix.m4])
m4_include([m4/acx_sl_fc_mod_path_flag.m4])
m4_include([m4/acx_sl_mod_suffix.m4])
m4_include([m4/asx_tr_arg.m4])
......
......@@ -101,6 +101,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/m4/acx_lt_problems.m4 \
$(top_srcdir)/m4/acx_option_search_libs.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/acx_prog_cc_posix.m4 \
$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
......
......@@ -4949,6 +4949,54 @@ fi
 
 
 
acx_prog_cc_posix_version_value=200112
acx_prog_cc_posix_version_print="POSIX.1-2001"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking For conformance to ${acx_prog_cc_posix_version_print}." >&5
$as_echo_n "checking For conformance to ${acx_prog_cc_posix_version_print}.... " >&6; }
if ${acx_cv_cc_posix_support2001+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <unistd.h>
int
main ()
{
int n[(_POSIX_VERSION >= ${acx_prog_cc_posix_version_value}L) * 2 - 1];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
acx_cv_cc_posix_support2001=yes
else
acx_cv_cc_posix_support2001=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_cc_posix_support2001" >&5
$as_echo "$acx_cv_cc_posix_support2001" >&6; }
if test "x$acx_cv_cc_posix_support2001" = xno; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: It seems your system does not define _POSIX_VERSION to a value
greater-or-equal ${acx_prog_cc_posix_version_value}. This is typically the case when the
compiler is instructed to make ISO C features available only,
e.g. when using gcc -std=c99" >&5
$as_echo "$as_me: It seems your system does not define _POSIX_VERSION to a value
greater-or-equal ${acx_prog_cc_posix_version_value}. This is typically the case when the
compiler is instructed to make ISO C features available only,
e.g. when using gcc -std=c99" >&6;}
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "${acx_prog_cc_posix_version_print} profile required
See \`config.log' for more details" "$LINENO" 5; }
fi
 
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
......@@ -26,6 +26,8 @@ AM_MAINTAINER_MODE([disable])
# Check building environment
AC_CHECK_TOOL([CC],[gcc],[:])
AC_PROG_CC_C99
dnl verify the setup supports POSIX 2001
ACX_PROG_CC_POSIX([2001])
AM_PROG_CC_C_O
AC_C_RESTRICT
AC_PROG_FC
......
......@@ -101,6 +101,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/m4/acx_lt_problems.m4 \
$(top_srcdir)/m4/acx_option_search_libs.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/acx_prog_cc_posix.m4 \
$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
......
......@@ -102,6 +102,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/m4/acx_lt_problems.m4 \
$(top_srcdir)/m4/acx_option_search_libs.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/acx_prog_cc_posix.m4 \
$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
......
......@@ -108,6 +108,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/m4/acx_lt_problems.m4 \
$(top_srcdir)/m4/acx_option_search_libs.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/acx_prog_cc_posix.m4 \
$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
......
dnl acx_prog_cc_posix.m4 --- test whether _POSIX_VERSION is defined
dnl
dnl Copyright (C) 2017 Thomas Jahns <jahns@dkrz.de>
dnl
dnl Version: 1.0
dnl Keywords:
dnl Author: Thomas Jahns <jahns@dkrz.de>
dnl Maintainer: Thomas Jahns <jahns@dkrz.de>
dnl URL: https://www.dkrz.de/redmine/projects/show/scales-ppm
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions are
dnl met:
dnl
dnl Redistributions of source code must retain the above copyright notice,
dnl this list of conditions and the following disclaimer.
dnl
dnl Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl
dnl Neither the name of the DKRZ GmbH nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
dnl IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
dnl OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl ACX_PROG_CC_POSIX([VERSION])
dnl Test if compiler is defining _POSIX_VERSION correctly to at least
dnl the numeral corresponding to VERSION. Supported values for
dnl version:
dnl 1988, 1990, 1996, 2001, 2008
dnl
AC_DEFUN([ACX_PROG_CC_POSIX],
[m4_case([$1],
[1988],[acx_prog_cc_posix_version_value=198808
acx_prog_cc_posix_version_print="POSIX.1-1988"],
[1990],[acx_prog_cc_posix_version_value=199009
acx_prog_cc_posix_version_print="POSIX.1-1990"],
[1996],[acx_prog_cc_posix_version_value=199506L
acx_prog_cc_posix_version_print="POSIX.1-1996"],
[2001],[acx_prog_cc_posix_version_value=200112
acx_prog_cc_posix_version_print="POSIX.1-2001"],
[2008],[acx_prog_cc_posix_version_value=200809
acx_prog_cc_posix_version_print="POSIX.1-2008"],
[m4_fatal([Unexpected POSIX version argument])])
AC_LANG_PUSH([C])
AS_VAR_PUSHDEF([acx_cv_cc_posix_support],[acx_cv_cc_posix_support]$1)
AC_CACHE_CHECK([For conformance to ${acx_prog_cc_posix_version_print}.],
[acx_cv_cc_posix_support],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <unistd.h>],
[ int n@<:@(_POSIX_VERSION >= ${acx_prog_cc_posix_version_value}L) * 2 - 1@:>@;])],
[AS_VAR_SET([acx_cv_cc_posix_support],[yes])],
[AS_VAR_SET([acx_cv_cc_posix_support],[no])])])
AS_VAR_IF([acx_cv_cc_posix_support],[no],
[AC_MSG_NOTICE(
[It seems your system does not define _POSIX_VERSION to a value
greater-or-equal ${acx_prog_cc_posix_version_value}. This is typically the case when the
compiler is instructed to make ISO C features available only,
e.g. when using gcc -std=c99])
AC_MSG_FAILURE([${acx_prog_cc_posix_version_print} profile required])])])
......@@ -117,6 +117,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/m4/acx_lt_problems.m4 \
$(top_srcdir)/m4/acx_option_search_libs.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/acx_prog_cc_posix.m4 \
$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
......
......@@ -127,6 +127,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/m4/acx_lt_problems.m4 \
$(top_srcdir)/m4/acx_option_search_libs.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/acx_prog_cc_posix.m4 \
$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment