From a3d07eae11a4fa3a26a8c7bb926bda593430e5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Thu, 9 Dec 2021 13:01:01 +0100 Subject: [PATCH] Configure: Improved support for C99 with autoconf 2.59 and earlier. --- .gitattributes | 1 - src/aclocal.m4 | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index 706b29e438..8c33c46c12 100644 --- a/.gitattributes +++ b/.gitattributes @@ -310,7 +310,6 @@ testfont binary /refdoc/structure/traditional.xml foreign_ident /src/Makefile.in foreign_ident /src/acconfig.h foreign_ident -/src/aclocal.m4 foreign_ident /src/alloca.c foreign_ident /src/apply_low.h foreign_ident /src/array.c foreign_ident diff --git a/src/aclocal.m4 b/src/aclocal.m4 index bc0bb5a156..e4b436c37d 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -1,4 +1,4 @@ -dnl $Id: aclocal.m4,v 1.118 2006/05/20 14:05:35 marcus Exp $ +dnl $Id$ dnl Some compatibility with Autoconf 2.50+. Not complete. dnl newer Autoconf calls substr m4_substr @@ -17,6 +17,7 @@ dnl autoconf-wrapper if it is used. dnl can't be used since the wrapper dnl checks for it, so just store it in a dummy define. define([require_autoconf_2_50],[AC_PREREQ(2.50)]) +dnl major, minor, on_ge, on_lt define([if_autoconf], [ifelse(ifelse(index(AC_ACVERSION,.),-1,0,[m4_eval( translit(substr(AC_ACVERSION, 0, index(AC_ACVERSION,.)),[A-Za-z])-0 >= $1 && @@ -26,6 +27,21 @@ define([if_autoconf], ) )]),1,$3,$4)]) +dnl Autoconf 2.60 is the first version that supports C99. +dnl C99-compilers complain about implicit declarations. +dnl For autoconf 2.59 and earlier: Make sure at least +dnl exit(3C) is declared by always including <stdlib.h>. +if_autoconf(2,60,,[ + m4_copy([AC_LANG_SOURCE(C)], [ORIG_AC_LANG_SOURCE_C]) + m4_define([AC_LANG_SOURCE(C)], [ + ORIG_AC_LANG_SOURCE_C([ +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +]$1) + ]) +]) + pushdef([AC_PROG_CC_WORKS], [ popdef([AC_PROG_CC_WORKS]) @@ -378,7 +394,7 @@ define(PIKE_FEATURE_OK,[ define([AC_LOW_MODULE_INIT], [ - # $Id: aclocal.m4,v 1.118 2006/05/20 14:05:35 marcus Exp $ + # $Id$ MY_AC_PROG_CC -- GitLab