Skip to content

PHPC-2194: Updates for autoconf 2.70+ #1476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ PHP_ARG_ENABLE([mongodb],
[Enable MongoDB support])])

if test "$PHP_MONGODB" != "no"; then
dnl Enable C99 (required for libmongoc 1.24+)
AC_PROG_CC_C99
dnl Enable C99 (required for libmongoc 1.24+). On Autoconf 2.70+, this will
dnl already have been done when AC_PROG_CC is called from configure.ac.
m4_version_prereq([2.70],,[AC_PROG_CC_C99])

if test "$ac_cv_prog_cc_c99" = no; then
AC_MSG_ERROR([Compiler does not support C99])
Expand Down Expand Up @@ -344,9 +345,9 @@ if test "$PHP_MONGODB" != "no"; then
])

dnl Avoid using AC_CONFIG_MACRO_DIR, which might conflict with PHP
_include([scripts/autotools/m4/as_var_copy.m4])
_include([scripts/autotools/m4/ax_check_compile_flag.m4])
_include([scripts/autotools/m4/ax_prototype.m4])
_include([scripts/autotools/m4/ax_prototype_accept.m4])
_include([scripts/autotools/m4/ax_pthread.m4])
_include([scripts/autotools/m4/php_mongodb.m4])
_include([scripts/autotools/m4/pkg.m4])
Expand Down
20 changes: 1 addition & 19 deletions scripts/autotools/CheckCompiler.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AC_PROG_CXX

dnl AC_PROG_CC_C99 is previously called in config.m4, but AC_PROG_CC resets CC
dnl so call it once more to ensure C99 remains enabled
AC_PROG_CC_C99
m4_version_prereq([2.70],,[AC_PROG_CC_C99])

# Check that an appropriate C compiler is available.
c_compiler="unknown"
Expand Down Expand Up @@ -62,24 +62,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#endif
])], [c_compiler="sun"], [])

# The type of parameters for accept, getpeername, getsockname, getsockopt
# all vary the same way by platform.
AX_PROTOTYPE(accept, [
#include <sys/types.h>
#include <sys/socket.h>
], [
int a = 0;
ARG2 *b = 0;
ARG3 *c = 0;
accept (a, b, c);],
ARG2, [struct sockaddr, void],
ARG3, [socklen_t, size_t, int])

MONGOC_SOCKET_ARG2="$ACCEPT_ARG2"
AC_SUBST(MONGOC_SOCKET_ARG2)
MONGOC_SOCKET_ARG3="$ACCEPT_ARG3"
AC_SUBST(MONGOC_SOCKET_ARG3)

AC_LANG_POP([C])

if test "$c_compiler" = "unknown"; then
Expand Down
6 changes: 6 additions & 0 deletions scripts/autotools/libmongoc/FindDependencies.m4
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],
[AC_SUBST(MONGOC_HAVE_SS_FAMILY, 0)],
[#include <sys/socket.h>])

AC_DEFINE([ACCEPT_ARG2], [], [Description])
AC_DEFINE([ACCEPT_ARG3], [], [Description])
AX_PROTOTYPE_ACCEPT
AC_SUBST(MONGOC_SOCKET_ARG2, "$ACCEPT_ARG2")
AC_SUBST(MONGOC_SOCKET_ARG3, "$ACCEPT_ARG3")

# Check for pthreads. libmongoc's original FindDependencies.m4 script did not
# require pthreads, but it does appear to be necessary on non-Windows platforms
# based on mongoc-openssl.c and mongoc-thread-private.h.
Expand Down
5 changes: 0 additions & 5 deletions scripts/autotools/m4/as_var_copy.m4

This file was deleted.

43 changes: 12 additions & 31 deletions scripts/autotools/m4/ax_check_compile_flag.m4
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
Expand All @@ -19,6 +19,8 @@
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
Expand All @@ -27,45 +29,24 @@
# Copyright (c) 2008 Guido U. Draheim <[email protected]>
# Copyright (c) 2011 Maarten Bosmans <[email protected]>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 2
#serial 6

AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
Expand Down
40 changes: 25 additions & 15 deletions scripts/autotools/m4/ax_prototype.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# values found in <values1>, <values2>, ... respectively. <values1>,
# <values2>, ... contain a list of possible values for each corresponding
# tag and all combinations are tested. When AC_TRY_COMPILE(include, code)
# is successfull for a given substitution, the macro stops and defines the
# is successful for a given substitution, the macro stops and defines the
# following macros: FUNCTION_TAG1, FUNCTION_TAG2, ... using AC_DEFINE()
# with values set to the current values of <TAG1>, <TAG2>, ... If no
# combination is successfull the configure script is aborted with a
# combination is successful the configure script is aborted with a
# message.
#
# Intended purpose is to find which combination of argument types is
Expand All @@ -26,13 +26,13 @@
#
# Generic usage pattern:
#
# 1) add a call in configure.in
# 1) add a call in configure.ac
#
# AX_PROTOTYPE(...)
#
# 2) call autoheader to see which symbols are not covered
#
# 3) add the lines in acconfig.h
# 3) add the lines in config.h
#
# /* Type of Nth argument of function */
# #undef FUNCTION_ARGN
Expand All @@ -41,7 +41,7 @@
#
# Complete example:
#
# 1) configure.in
# 1) configure.ac
#
# AX_PROTOTYPE(getpeername,
# [
Expand All @@ -59,10 +59,10 @@
#
# 2) call autoheader
#
# autoheader: Symbol `GETPEERNAME_ARG2' is not covered by ./acconfig.h
# autoheader: Symbol `GETPEERNAME_ARG3' is not covered by ./acconfig.h
# autoheader: Symbol `GETPEERNAME_ARG2' is not covered by ./config.h
# autoheader: Symbol `GETPEERNAME_ARG3' is not covered by ./config.h
#
# 3) acconfig.h
# 3) config.h
#
# /* Type of second argument of getpeername */
# #undef GETPEERNAME_ARG2
Expand Down Expand Up @@ -114,7 +114,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.

#serial 6
#serial 11

AU_ALIAS([AC_PROTOTYPE], [AX_PROTOTYPE])
AC_DEFUN([AX_PROTOTYPE],[
Expand Down Expand Up @@ -148,7 +148,7 @@ AC_DEFUN([AX_PROTOTYPE_REVERSE],[ifelse($#,0,,$#,1,[[$1]],[AX_PROTOTYPE_REVERSE(
dnl
dnl AX_PROTOTYPE_SUBST(string, tag)
dnl
dnl Substitute all occurence of <tag> in <string> with <tag>_VAL.
dnl Substitute all occurrence of <tag> in <string> with <tag>_VAL.
dnl Assumes that tag_VAL is a macro containing the value associated to tag.
dnl
AC_DEFUN([AX_PROTOTYPE_SUBST],[ifelse($2,,[$1],[AX_PROTOTYPE_SUBST(patsubst([$1],[$2],[$2[]_VAL]),builtin([shift],builtin([shift],$@)))])])
Expand All @@ -168,9 +168,9 @@ dnl Assumes that function is a macro containing the name of the function in uppe
dnl and that tag_VAL is a macro containing the value associated to tag.
dnl
AC_DEFUN([AX_PROTOTYPE_DEFINES],[ifelse($1,,[],
[AC_DEFINE(function[]_$1, $1_VAL, [ ])
AC_SUBST(function[]_$1, "$1_VAL")
AX_PROTOTYPE_DEFINES(builtin([shift],$@))])])
[AC_DEFINE(function[]_$1, $1_VAL)
AC_SUBST(function[]_$1, "$1_VAL")
AX_PROTOTYPE_DEFINES(builtin([shift],$@))])])

dnl
dnl AX_PROTOTYPE_STATUS(tags)
Expand Down Expand Up @@ -217,8 +217,18 @@ dnl
dnl Activate fatal warnings if possible, gives better guess
dnl
ac_save_CPPFLAGS="$CPPFLAGS"
if test "$GCC" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi
AC_TRY_COMPILE($2, $1, [
dnl ifelse(AC_LANG,CPLUSPLUS,if test "$GXX" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi)
dnl ifelse(AC_LANG,C,if test "$GCC" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi)
dnl
dnl Disable the 'unused-variable' warning in case e.g. -Wall was enabled,
dnl otherwise the test may always fail.
dnl
if (test "x$GCC" = "xyes" || test "x$GXX" = "xyes" ); then
CPPFLAGS="$CPPFLAGS -Werror -Wno-unused-variable" ;
fi

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2], [$1])],
[
CPPFLAGS="$ac_save_CPPFLAGS"
AC_MSG_RESULT(ok)
AX_PROTOTYPE_DEFINES(tags)
Expand Down
69 changes: 69 additions & 0 deletions scripts/autotools/m4/ax_prototype_accept.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_prototype_accept.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PROTOTYPE_ACCEPT
#
# DESCRIPTION
#
# Requires the AX_PROTOTYPE macro. FIXME: Put this in the code!
#
# Find the type of argument two and three of accept. User must include the
# following in acconfig.h:
#
# /* Type of second argument of accept */
# #undef ACCEPT_ARG2
#
# /* Type of third argument of accept */
# #undef ACCEPT_ARG3
#
# LICENSE
#
# Copyright (c) 2008 Loic Dachary <[email protected]>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.

#serial 6

AU_ALIAS([AC_PROTOTYPE_ACCEPT], [AX_PROTOTYPE_ACCEPT])
AC_DEFUN([AX_PROTOTYPE_ACCEPT],[
AX_PROTOTYPE(accept,
[
#include <sys/types.h>
#include <sys/socket.h>
],
[
int a = 0;
ARG2 * b = 0;
ARG3 * c = 0;
accept(a, b, c);
],
ARG2, [struct sockaddr, void],
ARG3, [socklen_t, size_t, int, unsigned int, long unsigned int])
])
Loading