Skip to content

Commit 4177e66

Browse files
authored
PHPC-2194: Updates for autoconf 2.70+ (#1476)
* Do not call AC_PROG_CC_C99 on autoconf 2.70+ * Replace obsolete AC_TRY_COMPILE with AC_COMPILE_IFELSE * Update pkg.m4 to pkg-config-0.29 * Update ax_check_compile_flag.m4 * Update ax_pthread.m4 * Update ax_prototype.m4 and introduce ax_prototype_accept.m4 This also moves the accept() checking to libmongoc/FindDependencies.m4, since it is specific to libmongoc. * PHPC-2272: as_var_copy.m4 is obsolete PHP 7.4 requires autoconf 2.68+ and AS_VAR_COPY was introduced in 2.64
1 parent 1c533ff commit 4177e66

File tree

9 files changed

+608
-299
lines changed

9 files changed

+608
-299
lines changed

config.m4

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ PHP_ARG_ENABLE([mongodb],
55
[Enable MongoDB support])])
66

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

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

346347
dnl Avoid using AC_CONFIG_MACRO_DIR, which might conflict with PHP
347-
_include([scripts/autotools/m4/as_var_copy.m4])
348348
_include([scripts/autotools/m4/ax_check_compile_flag.m4])
349349
_include([scripts/autotools/m4/ax_prototype.m4])
350+
_include([scripts/autotools/m4/ax_prototype_accept.m4])
350351
_include([scripts/autotools/m4/ax_pthread.m4])
351352
_include([scripts/autotools/m4/php_mongodb.m4])
352353
_include([scripts/autotools/m4/pkg.m4])

scripts/autotools/CheckCompiler.m4

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ AC_PROG_CXX
1313

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

1818
# Check that an appropriate C compiler is available.
1919
c_compiler="unknown"
@@ -62,24 +62,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
6262
#endif
6363
])], [c_compiler="sun"], [])
6464

65-
# The type of parameters for accept, getpeername, getsockname, getsockopt
66-
# all vary the same way by platform.
67-
AX_PROTOTYPE(accept, [
68-
#include <sys/types.h>
69-
#include <sys/socket.h>
70-
], [
71-
int a = 0;
72-
ARG2 *b = 0;
73-
ARG3 *c = 0;
74-
accept (a, b, c);],
75-
ARG2, [struct sockaddr, void],
76-
ARG3, [socklen_t, size_t, int])
77-
78-
MONGOC_SOCKET_ARG2="$ACCEPT_ARG2"
79-
AC_SUBST(MONGOC_SOCKET_ARG2)
80-
MONGOC_SOCKET_ARG3="$ACCEPT_ARG3"
81-
AC_SUBST(MONGOC_SOCKET_ARG3)
82-
8365
AC_LANG_POP([C])
8466

8567
if test "$c_compiler" = "unknown"; then

scripts/autotools/libmongoc/FindDependencies.m4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],
2121
[AC_SUBST(MONGOC_HAVE_SS_FAMILY, 0)],
2222
[#include <sys/socket.h>])
2323

24+
AC_DEFINE([ACCEPT_ARG2], [], [Description])
25+
AC_DEFINE([ACCEPT_ARG3], [], [Description])
26+
AX_PROTOTYPE_ACCEPT
27+
AC_SUBST(MONGOC_SOCKET_ARG2, "$ACCEPT_ARG2")
28+
AC_SUBST(MONGOC_SOCKET_ARG3, "$ACCEPT_ARG3")
29+
2430
# Check for pthreads. libmongoc's original FindDependencies.m4 script did not
2531
# require pthreads, but it does appear to be necessary on non-Windows platforms
2632
# based on mongoc-openssl.c and mongoc-thread-private.h.

scripts/autotools/m4/as_var_copy.m4

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/autotools/m4/ax_check_compile_flag.m4

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

56-
#serial 2
37+
#serial 6
5738

5839
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
59-
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
40+
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
6041
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
6142
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
6243
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
6344
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
64-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
45+
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
6546
[AS_VAR_SET(CACHEVAR,[yes])],
6647
[AS_VAR_SET(CACHEVAR,[no])])
6748
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
68-
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
49+
AS_VAR_IF(CACHEVAR,yes,
6950
[m4_default([$2], :)],
7051
[m4_default([$3], :)])
7152
AS_VAR_POPDEF([CACHEVAR])dnl

scripts/autotools/m4/ax_prototype.m4

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# values found in <values1>, <values2>, ... respectively. <values1>,
1414
# <values2>, ... contain a list of possible values for each corresponding
1515
# tag and all combinations are tested. When AC_TRY_COMPILE(include, code)
16-
# is successfull for a given substitution, the macro stops and defines the
16+
# is successful for a given substitution, the macro stops and defines the
1717
# following macros: FUNCTION_TAG1, FUNCTION_TAG2, ... using AC_DEFINE()
1818
# with values set to the current values of <TAG1>, <TAG2>, ... If no
19-
# combination is successfull the configure script is aborted with a
19+
# combination is successful the configure script is aborted with a
2020
# message.
2121
#
2222
# Intended purpose is to find which combination of argument types is
@@ -26,13 +26,13 @@
2626
#
2727
# Generic usage pattern:
2828
#
29-
# 1) add a call in configure.in
29+
# 1) add a call in configure.ac
3030
#
3131
# AX_PROTOTYPE(...)
3232
#
3333
# 2) call autoheader to see which symbols are not covered
3434
#
35-
# 3) add the lines in acconfig.h
35+
# 3) add the lines in config.h
3636
#
3737
# /* Type of Nth argument of function */
3838
# #undef FUNCTION_ARGN
@@ -41,7 +41,7 @@
4141
#
4242
# Complete example:
4343
#
44-
# 1) configure.in
44+
# 1) configure.ac
4545
#
4646
# AX_PROTOTYPE(getpeername,
4747
# [
@@ -59,10 +59,10 @@
5959
#
6060
# 2) call autoheader
6161
#
62-
# autoheader: Symbol `GETPEERNAME_ARG2' is not covered by ./acconfig.h
63-
# autoheader: Symbol `GETPEERNAME_ARG3' is not covered by ./acconfig.h
62+
# autoheader: Symbol `GETPEERNAME_ARG2' is not covered by ./config.h
63+
# autoheader: Symbol `GETPEERNAME_ARG3' is not covered by ./config.h
6464
#
65-
# 3) acconfig.h
65+
# 3) config.h
6666
#
6767
# /* Type of second argument of getpeername */
6868
# #undef GETPEERNAME_ARG2
@@ -114,7 +114,7 @@
114114
# modified version of the Autoconf Macro, you may extend this special
115115
# exception to the GPL to apply to your modified version as well.
116116

117-
#serial 6
117+
#serial 11
118118

119119
AU_ALIAS([AC_PROTOTYPE], [AX_PROTOTYPE])
120120
AC_DEFUN([AX_PROTOTYPE],[
@@ -148,7 +148,7 @@ AC_DEFUN([AX_PROTOTYPE_REVERSE],[ifelse($#,0,,$#,1,[[$1]],[AX_PROTOTYPE_REVERSE(
148148
dnl
149149
dnl AX_PROTOTYPE_SUBST(string, tag)
150150
dnl
151-
dnl Substitute all occurence of <tag> in <string> with <tag>_VAL.
151+
dnl Substitute all occurrence of <tag> in <string> with <tag>_VAL.
152152
dnl Assumes that tag_VAL is a macro containing the value associated to tag.
153153
dnl
154154
AC_DEFUN([AX_PROTOTYPE_SUBST],[ifelse($2,,[$1],[AX_PROTOTYPE_SUBST(patsubst([$1],[$2],[$2[]_VAL]),builtin([shift],builtin([shift],$@)))])])
@@ -168,9 +168,9 @@ dnl Assumes that function is a macro containing the name of the function in uppe
168168
dnl and that tag_VAL is a macro containing the value associated to tag.
169169
dnl
170170
AC_DEFUN([AX_PROTOTYPE_DEFINES],[ifelse($1,,[],
171-
[AC_DEFINE(function[]_$1, $1_VAL, [ ])
172-
AC_SUBST(function[]_$1, "$1_VAL")
173-
AX_PROTOTYPE_DEFINES(builtin([shift],$@))])])
171+
[AC_DEFINE(function[]_$1, $1_VAL)
172+
AC_SUBST(function[]_$1, "$1_VAL")
173+
AX_PROTOTYPE_DEFINES(builtin([shift],$@))])])
174174

175175
dnl
176176
dnl AX_PROTOTYPE_STATUS(tags)
@@ -217,8 +217,18 @@ dnl
217217
dnl Activate fatal warnings if possible, gives better guess
218218
dnl
219219
ac_save_CPPFLAGS="$CPPFLAGS"
220-
if test "$GCC" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi
221-
AC_TRY_COMPILE($2, $1, [
220+
dnl ifelse(AC_LANG,CPLUSPLUS,if test "$GXX" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi)
221+
dnl ifelse(AC_LANG,C,if test "$GCC" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi)
222+
dnl
223+
dnl Disable the 'unused-variable' warning in case e.g. -Wall was enabled,
224+
dnl otherwise the test may always fail.
225+
dnl
226+
if (test "x$GCC" = "xyes" || test "x$GXX" = "xyes" ); then
227+
CPPFLAGS="$CPPFLAGS -Werror -Wno-unused-variable" ;
228+
fi
229+
230+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2], [$1])],
231+
[
222232
CPPFLAGS="$ac_save_CPPFLAGS"
223233
AC_MSG_RESULT(ok)
224234
AX_PROTOTYPE_DEFINES(tags)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_prototype_accept.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_PROTOTYPE_ACCEPT
8+
#
9+
# DESCRIPTION
10+
#
11+
# Requires the AX_PROTOTYPE macro. FIXME: Put this in the code!
12+
#
13+
# Find the type of argument two and three of accept. User must include the
14+
# following in acconfig.h:
15+
#
16+
# /* Type of second argument of accept */
17+
# #undef ACCEPT_ARG2
18+
#
19+
# /* Type of third argument of accept */
20+
# #undef ACCEPT_ARG3
21+
#
22+
# LICENSE
23+
#
24+
# Copyright (c) 2008 Loic Dachary <[email protected]>
25+
#
26+
# This program is free software; you can redistribute it and/or modify it
27+
# under the terms of the GNU General Public License as published by the
28+
# Free Software Foundation; either version 2 of the License, or (at your
29+
# option) any later version.
30+
#
31+
# This program is distributed in the hope that it will be useful, but
32+
# WITHOUT ANY WARRANTY; without even the implied warranty of
33+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
34+
# Public License for more details.
35+
#
36+
# You should have received a copy of the GNU General Public License along
37+
# with this program. If not, see <https://www.gnu.org/licenses/>.
38+
#
39+
# As a special exception, the respective Autoconf Macro's copyright owner
40+
# gives unlimited permission to copy, distribute and modify the configure
41+
# scripts that are the output of Autoconf when processing the Macro. You
42+
# need not follow the terms of the GNU General Public License when using
43+
# or distributing such scripts, even though portions of the text of the
44+
# Macro appear in them. The GNU General Public License (GPL) does govern
45+
# all other use of the material that constitutes the Autoconf Macro.
46+
#
47+
# This special exception to the GPL applies to versions of the Autoconf
48+
# Macro released by the Autoconf Archive. When you make and distribute a
49+
# modified version of the Autoconf Macro, you may extend this special
50+
# exception to the GPL to apply to your modified version as well.
51+
52+
#serial 6
53+
54+
AU_ALIAS([AC_PROTOTYPE_ACCEPT], [AX_PROTOTYPE_ACCEPT])
55+
AC_DEFUN([AX_PROTOTYPE_ACCEPT],[
56+
AX_PROTOTYPE(accept,
57+
[
58+
#include <sys/types.h>
59+
#include <sys/socket.h>
60+
],
61+
[
62+
int a = 0;
63+
ARG2 * b = 0;
64+
ARG3 * c = 0;
65+
accept(a, b, c);
66+
],
67+
ARG2, [struct sockaddr, void],
68+
ARG3, [socklen_t, size_t, int, unsigned int, long unsigned int])
69+
])

0 commit comments

Comments
 (0)