From 15db1443aeac81fc8587409ab9eafbbde8c093e1 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 7 Sep 2010 14:58:50 +0000 Subject: [PATCH] Merged revisions 84584 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ........ r84584 | antoine.pitrou | 2010-09-07 16:52:42 +0200 (mar., 07 sept. 2010) | 4 lines Issue #4026: Make the fcntl extension build under AIX. Patch by Sébastien Sablé. ........ --- Misc/NEWS | 3 ++ configure | 86 +++++++++++++++++++++++++++++++++++++++++++++++---- configure.in | 23 +++++++++++--- pyconfig.h.in | 3 ++ setup.py | 6 +++- 5 files changed, 110 insertions(+), 11 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index dcec2e96d12..2474dc6f895 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -535,6 +535,9 @@ Extension Modules Build ----- +- Issue #4026: Make the fcntl extension build under AIX. Patch by Sébastien + Sablé. + - Issue #3101: Helper functions _add_one_to_index_C() and _add_one_to_index_F() become _Py_add_one_to_index_C() and _Py_add_one_to_index_F(), respectively. diff --git a/configure b/configure index 50a44edd9e4..fa81592b502 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 82963 . +# From configure.in Revision: 84367 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65 for python 3.1. # @@ -9410,6 +9410,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flock" >&5 $as_echo_n "checking for flock... " >&6; } +have_flock=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -9426,16 +9427,89 @@ void* p = flock _ACEOF if ac_fn_c_try_compile "$LINENO"; then : + $as_echo "#define HAVE_FLOCK 1" >>confdefs.h - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + have_flock=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_flock" >&5 +$as_echo "$have_flock" >&6; } + +if test "$have_flock" = yes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if flock requires additional libraries." >&5 +$as_echo_n "checking if flock requires additional libraries.... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include "confdefs.h" + #include + +int +main () +{ +flock(0, 0) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flock in -lbsd" >&5 +$as_echo_n "checking for flock in -lbsd... " >&6; } +if test "${ac_cv_lib_bsd_flock+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbsd $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char flock (); +int +main () +{ +return flock (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_bsd_flock=yes +else + ac_cv_lib_bsd_flock=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_flock" >&5 +$as_echo "$ac_cv_lib_bsd_flock" >&6; } +if test "x$ac_cv_lib_bsd_flock" = x""yes; then : + + +$as_echo "#define FLOCK_NEEDS_LIBBSD 1" >>confdefs.h + + +fi + + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpagesize" >&5 $as_echo_n "checking for getpagesize... " >&6; } diff --git a/configure.in b/configure.in index 557be3ae9d4..99e8f9debba 100644 --- a/configure.in +++ b/configure.in @@ -2642,14 +2642,29 @@ AC_TRY_COMPILE([ ) AC_MSG_CHECKING(for flock) +have_flock=no AC_TRY_COMPILE([ #include "confdefs.h" #include -], void* p = flock, +], void* p = flock, [ AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.) - AC_MSG_RESULT(yes), - AC_MSG_RESULT(no) -) + have_flock=yes +]) +AC_MSG_RESULT($have_flock) + +if test "$have_flock" = yes ; then + AC_MSG_CHECKING(if flock requires additional libraries.) + AC_TRY_LINK([ + #include "confdefs.h" + #include + ], [flock(0, 0)], + AC_MSG_RESULT(no), [ + AC_MSG_RESULT(yes) + AC_CHECK_LIB(bsd,flock, [ + AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.) + ]) + ]) +fi AC_MSG_CHECKING(for getpagesize) AC_TRY_COMPILE([ diff --git a/pyconfig.h.in b/pyconfig.h.in index 079a22de629..c057b32177d 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -33,6 +33,9 @@ /* Define if --enable-ipv6 is specified */ #undef ENABLE_IPV6 +/* Define if flock needs to be linked with bsd library */ +#undef FLOCK_NEEDS_LIBBSD + /* Define if getpgrp() must be called as getpgrp(0). */ #undef GETPGRP_HAVE_ARG diff --git a/setup.py b/setup.py index 332033dd7fa..d45c59183c7 100644 --- a/setup.py +++ b/setup.py @@ -489,7 +489,11 @@ class PyBuildExt(build_ext): # supported...) # fcntl(2) and ioctl(2) - exts.append( Extension('fcntl', ['fcntlmodule.c']) ) + libs = [] + if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)): + # May be necessary on AIX for flock function + libs = ['bsd'] + exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) ) if platform not in ['mac']: # pwd(3) exts.append( Extension('pwd', ['pwdmodule.c']) )