# HG changeset patch # User Jan Nieuwenhuizen # Date 1296312528 -3600 # Node ID 344d21a6233d9f14a710013a23838734f4b8ad03 # Parent 2c2917119ce3a74454e8e66936b1ca534b2cbd06 guile: bump to 1.9.14. diff -r 2c2917119ce3 -r 344d21a6233d gub/build.py --- a/gub/build.py Sun Dec 06 11:09:57 2015 +0000 +++ b/gub/build.py Sat Jan 29 15:48:48 2011 +0100 @@ -337,6 +337,8 @@ return [ '%(tools_prefix)s/share/aclocal', '%(system_prefix)s/share/aclocal', + #'%(srcdir)s/m4', TODO + #'%(srcdir)s', ] @context.subst_method def job_spec (self): diff -r 2c2917119ce3 -r 344d21a6233d gub/specs/guile-config.py --- a/gub/specs/guile-config.py Sun Dec 06 11:09:57 2015 +0000 +++ b/gub/specs/guile-config.py Sat Jan 29 15:48:48 2011 +0100 @@ -3,6 +3,7 @@ class Guile_config (build.SdkBuild): source = 'url://host/guile-config-1.8.7.tar.gz' + source = 'url://host/guile-config-1.9.14.tar.gz' def install (self): build.SdkBuild.install (self) self.system ('mkdir -p %(cross_prefix)s%(prefix_dir)s/bin') diff -r 2c2917119ce3 -r 344d21a6233d gub/specs/guile.py --- a/gub/specs/guile.py Sun Dec 06 11:09:57 2015 +0000 +++ b/gub/specs/guile.py Sat Jan 29 15:48:48 2011 +0100 @@ -11,11 +11,25 @@ class Guile (target.AutoBuild): # source = 'git://git.sv.gnu.org/guile.git&branch=branch_release-1-8&revision=bba579611b3671c7e4c1515b100f01c048a07935' source = 'http://ftp.gnu.org/pub/gnu/guile/guile-1.8.7.tar.gz' - patches = ['guile-reloc-1.8.6.patch', - 'guile-cexp.patch', - 'guile-1.8.6-test-use-srfi.patch', - 'guile-1.8.7-doc-snarfing.patch'] - dependencies = ['gettext-devel', 'gmp-devel', 'libtool', 'tools::guile'] + source = 'http://alpha.gnu.org/gnu/guile/guile-1.9.14.tar.gz' + patches = [ + #'guile-reloc-1.8.6.patch', + 'guile-1.9.14-reloc.patch', + #'guile-cexp.patch', + 'guile-1.8.6-test-use-srfi.patch', + #'guile-1.8.7-doc-snarfing.patch', + 'guile-1.9.14-configure-cross.patch', + 'guile-1.9.14-cross.patch', + ] + force_autoupdate = True + dependencies = [ + 'gettext-devel', + 'gmp-devel', + 'libtool', + 'tools::guile', + 'libunistring', + 'libgc', + ] guile_configure_flags = misc.join_lines (''' --without-threads --with-gnu-ld @@ -24,6 +38,7 @@ --disable-error-on-warning --enable-relocation --enable-rpath +--with-pic ''') configure_variables = (target.AutoBuild.configure_variables + misc.join_lines (''' @@ -45,14 +60,21 @@ # without setting the proper LD_LIBRARY_PATH. compile_flags_native = (' LD_PRELOAD= ' + ' LD_LIBRARY_PATH=%(tools_prefix)s/lib:${LD_LIBRARY_PATH-/foe} ' + + ' CFLAGS="-I%(srcdir)s -I%(builddir)s -DHAVE_CONFIG_H=1"' + + ' LIBFFI_CFLAGS=' + + ' LDFLAGS=' + ' cross_compiling=yes ') # FIXME: guile runs gen_scmconfig [when not x-building also guile] # without setting the proper LD_LIBRARY_PATH. configure_command = ('GUILE_FOR_BUILD=%(tools_prefix)s/bin/guile ' + target.AutoBuild.configure_command + guile_configure_flags) - compile_command = ('preinstguile=%(tools_prefix)s/bin/guile ' + compile_command = ('export preinstguile=%(tools_prefix)s/bin/guile; ' + + 'export LIBRESTRICT_ALLOW=/proc/stat; ' + target.AutoBuild.compile_command) + install_command = ('export preinstguile=%(tools_prefix)s/bin/guile; ' + + 'export LIBRESTRICT_ALLOW=/proc/stat; ' + + target.AutoBuild.install_command) subpackage_names = ['doc', 'devel', 'runtime', ''] @staticmethod def version_from_VERSION (self): @@ -73,6 +95,12 @@ ''', "%(srcdir)s/pre-inst-guile.in") #self.autopatch () target.AutoBuild.patch (self) + self.system ('cp -pv %(sourcefiledir)s/fcntl-o.m4 %(srcdir)s/m4') + def autoupdate (self): + self.system ('cd %(srcdir)s && autoreconf') + # .libs/libguile_2.0_la-arbiters.o: In function `__gmpz_abs': + # arbiters.c:(.text+0x0): multiple definition of `__gmpz_abs' + self.file_sub ([('-std=gnu99', ''),('-std=c99', '')], '%(srcdir)s/configure') def autopatch (self): self.file_sub ([(r'AC_CONFIG_SUBDIRS\(guile-readline\)', '')], '%(srcdir)s/configure.in') @@ -129,15 +157,25 @@ Guile.__init__ (self, settings, source) # Configure (compile) without -mwindows for console self.target_gcc_flags = '-mms-bitfields' - dependencies = Guile.dependencies + ['regex-devel'] + patches = Guile.patches + [ + 'guile-1.9.14-mingw.patch', + ] + dependencies = (Guile.dependencies + + [ + 'regex-devel', + 'mingw-extras', + ]) configure_flags = (Guile.configure_flags + ' --without-threads') configure_variables = (Guile.configure_variables .replace ("':'", "';'") + misc.join_lines (''' CFLAGS='-O2 -DHAVE_CONFIG_H=1 -I%(builddir)s' +LIBS='-lgc -lmingw-extras' ''')) config_cache_overrides = Guile.config_cache_overrides + ''' +gl_cv_socket_ipv6=no +guile_cv_have_ipv6=no scm_cv_struct_timespec=${scm_cv_struct_timespec=no} guile_cv_func_usleep_declared=${guile_cv_func_usleep_declared=yes} guile_cv_exeext=${guile_cv_exeext=} @@ -149,6 +187,9 @@ Guile.configure (self) for libtool in ['%(builddir)s/libtool']: # readline patched-out: '%(builddir)s/guile-readline/libtool']: self.file_sub ([('-mwindows', '')], libtool) + def patch (self): + Guile.patch (self) + self.system ('cd %(srcdir)s && gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write func gendocs getaddrinfo git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile nproc putenv stat-time stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings accept bind close connect getpeername getsockname getsockopt listen malloc malloca recv recv recvfrom send sendto setsockopt shutdown socket sockets || :') def compile (self): ## Why the !?#@$ is .EXE only for guile_filter_doc_snarfage? self.system ('''cd %(builddir)s/libguile &&make %(compile_flags_native)sgen-scmconfig guile_filter_doc_snarfage.exe''') @@ -197,7 +238,13 @@ class Guile__tools (tools.AutoBuild, Guile): dependencies = (Guile.dependencies - + ['autoconf', 'automake', 'gettext', 'flex', 'libtool']) + + [ + 'autoconf', + 'automake', + 'gettext', + 'flex', + 'libtool' + ]) make_flags = Guile.make_flags # Doing make gen-scmconfig, guile starts a configure recheck: # cd .. && make am--refresh @@ -222,9 +269,15 @@ def patch (self): tools.AutoBuild.patch (self) #Guile.autopatch (self) + self.system ('cp -pv %(sourcefiledir)s/fcntl-o.m4 %(srcdir)s/m4') + def autoupdate (self): + self.system ('cd %(srcdir)s && autoreconf') + # .libs/libguile_2.0_la-arbiters.o: In function `__gmpz_abs': + # arbiters.c:(.text+0x0): multiple definition of `__gmpz_abs' + self.file_sub ([('-std=gnu99', ''),('-std=c99', '')], '%(srcdir)s/configure') def install (self): tools.AutoBuild.install (self) - self.system ('cd %(install_root)s%(packaging_suffix_dir)s%(prefix_dir)s/bin && cp guile guile-1.8') - self.file_sub ([('[(]string-join other-flags[)]', '(string-join (filter (lambda (x) (not (equal? x "-L/usr/lib"))) other-flags))')], - '%(install_root)s%(packaging_suffix_dir)s%(prefix_dir)s/bin/guile-config', - must_succeed=True) + self.system ('cd %(install_root)s%(packaging_suffix_dir)s%(prefix_dir)s/bin && cp guile guile-1.9') +# self.file_sub ([('[(]string-join other-flags[)]', '(string-join (filter (lambda (x) (not (equal? x "-L/usr/lib"))) other-flags))')], +# '%(install_root)s%(packaging_suffix_dir)s%(prefix_dir)s/bin/guile-config', +# must_succeed=True) diff -r 2c2917119ce3 -r 344d21a6233d patches/guile-1.9.14-configure-cross.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/guile-1.9.14-configure-cross.patch Sat Jan 29 15:48:48 2011 +0100 @@ -0,0 +1,39 @@ +--- guile-1.9.14/configure.ac~ 2011-01-27 18:33:17.300003072 +0100 ++++ guile-1.9.14/configure.ac 2011-01-27 19:29:42.191669551 +0100 +@@ -27,10 +27,7 @@ Floor, Boston, MA 02110-1301, USA. + + AC_PREREQ(2.61) + +-AC_INIT([GNU Guile], +- m4_esyscmd([build-aux/git-version-gen \ +- .tarball-version \ +- 's/^release_\([0-9][0-9]*\)-\([0-9][0-9]*\)-\([0-9][0-9]*\)/v\1.\2\.\3/g']), ++AC_INIT([GNU Guile], [1.9.14], + [bug-guile@gnu.org]) + AC_CONFIG_AUX_DIR([build-aux]) + AC_CONFIG_MACRO_DIR([m4]) +@@ -76,11 +76,7 @@ AC_LIBTOOL_DLOPEN + AC_PROG_LIBTOOL + + dnl Check for libltdl. +-AC_LIB_HAVE_LINKFLAGS([ltdl], [], [#include ], +- [lt_dlopenext ("foo");]) +-if test "x$HAVE_LIBLTDL" != "xyes"; then +- AC_MSG_ERROR([GNU libltdl (Libtool) not found, see README.]) +-fi ++AC_CHECK_LIB(ltdl, lt_dlopenext, [HAVE_LIBLTDL=yes AC_SUBST(HAVE_LIBLTDL) LTLIBLTDL="-lltdl" AC_SUBST(LTLIBLTDL)]) + + AC_CHECK_PROG(have_makeinfo, makeinfo, yes, no) + AM_CONDITIONAL(HAVE_MAKEINFO, test "$have_makeinfo" = yes) +@@ -854,10 +850,7 @@ fi + + + dnl GMP tests +-AC_LIB_HAVE_LINKFLAGS([gmp], +- [], +- [#include ], +- [mpz_import (0, 0, 0, 0, 0, 0, 0);]) ++AC_CHECK_LIB(gmp, main, [HAVE_LIBGMP=yes AC_SUBST(HAVE_LIBGMP) LTLIBGMP="-lgmp" AC_SUBST(LTLIBGMP)]) + + if test "x$HAVE_LIBGMP" != "xyes"; then + AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README]) diff -r 2c2917119ce3 -r 344d21a6233d patches/guile-1.9.14-cross.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/guile-1.9.14-cross.patch Sat Jan 29 15:48:48 2011 +0100 @@ -0,0 +1,23 @@ +--- guile-1.9.14/meta/guile.in~ 2010-12-14 19:15:17.000000000 +0100 ++++ guile-1.9.14/meta/guile.in 2011-01-29 13:31:24.227563342 +0100 +@@ -45,7 +45,8 @@ XDG_CACHE_HOME=${top_builddir}/cache + export XDG_CACHE_HOME + + # do it +-exec ${top_builddir}/meta/uninstalled-env $GUILE "$@" ++#exec ${top_builddir}/meta/uninstalled-env $GUILE "$@" ++exec @GUILE_FOR_BUILD@ "$@" + + # never reached + exit 1 +--- guile-1.9.14/Makefile.am~ 2010-12-14 19:15:16.000000000 +0100 ++++ guile-1.9.14/Makefile.am 2011-01-29 15:36:05.312047266 +0100 +@@ -32,8 +32,6 @@ SUBDIRS = \ + guile-readline \ + examples \ + emacs \ +- test-suite \ +- benchmark-suite \ + am \ + doc + diff -r 2c2917119ce3 -r 344d21a6233d patches/guile-1.9.14-mingw.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/guile-1.9.14-mingw.patch Sat Jan 29 15:48:48 2011 +0100 @@ -0,0 +1,82 @@ +--- guile-1.9.14/libguile/filesys.c~ 2010-12-14 19:15:17.000000000 +0100 ++++ guile-1.9.14/libguile/filesys.c 2011-01-28 16:10:57.884026263 +0100 +@@ -523,7 +523,7 @@ static int fstat_Win32 (int fdes, struct + /* Is this a socket ? */ + if (getsockopt (fdes, SOL_SOCKET, SO_ERROR, (void *) &error, &optlen) >= 0) + { +- buf->st_mode = _S_IFSOCK | _S_IREAD | _S_IWRITE | _S_IEXEC; ++ buf->st_mode = _S_IREAD | _S_IWRITE | _S_IEXEC; + buf->st_nlink = 1; + buf->st_atime = buf->st_ctime = buf->st_mtime = time (NULL); + return 0; +--- guile-1.9.14/libguile/net_db.c~ 2010-12-14 19:15:17.000000000 +0100 ++++ guile-1.9.14/libguile/net_db.c 2011-01-28 19:40:57.212601530 +0100 +@@ -456,6 +456,7 @@ SCM_DEFINE (scm_setserv, "setserv", 0, 1 + + SCM_SYMBOL (sym_getaddrinfo_error, "getaddrinfo-error"); + ++#ifndef __MINGW32__ + /* Make sure the `AI_*' flags can be stored as INUMs. */ + verify (SCM_I_INUM (SCM_I_MAKINUM (AI_ALL)) == AI_ALL); + +@@ -743,6 +741,8 @@ SCM_DEFINE (scm_gai_strerror, "gai-strer + } + #undef FUNC_NAME + ++#endif /* __MINGW32__ */ ++ + /* TODO: Add a getnameinfo(3) wrapper. */ + + +--- guile-1.9.14/libguile/socket.c~ 2010-12-14 19:15:17.000000000 +0100 ++++ guile-1.9.14/libguile/socket.c 2011-01-28 21:40:25.375025713 +0100 +@@ -40,6 +40,7 @@ + + #ifdef __MINGW32__ + #include "win32-socket.h" ++#include + #endif + + #ifdef HAVE_STDINT_H +--- guile-1.9.14/libguile/ports.h~ 2010-12-14 19:15:17.000000000 +0100 ++++ guile-1.9.14/libguile/ports.h 2011-01-29 11:59:46.356995940 +0100 +@@ -25,6 +25,7 @@ + + #include "libguile/__scm.h" + ++#include + #include "libguile/print.h" + #include "libguile/struct.h" + #include "libguile/threads.h" +--- guile-1.9.14/libguile/deprecated.c~ 2010-12-14 19:15:17.000000000 +0100 ++++ guile-1.9.14/libguile/deprecated.c 2011-01-29 12:10:02.504032975 +0100 +@@ -1639,7 +1639,7 @@ scm_i_fluidp (SCM x) + + /* Networking. */ + +-#ifdef HAVE_NETWORKING ++#ifdef HAVE_IPV6 + + SCM_DEFINE (scm_inet_aton, "inet-aton", 1, 0, 0, + (SCM address), +@@ -1674,7 +1674,7 @@ SCM_DEFINE (scm_inet_ntoa, "inet-ntoa", + } + #undef FUNC_NAME + +-#endif /* HAVE_NETWORKING */ ++#endif /* HAVE_IPV6 */ + + + void +--- guile-1.9.14/libguile/bdw-gc.h~ 2010-12-14 19:15:17.000000000 +0100 ++++ guile-1.9.14/libguile/bdw-gc.h 2011-01-29 12:35:43.485771038 +0100 +@@ -30,7 +30,9 @@ + allocation. */ + + # define GC_THREADS 1 ++#ifndef __MINGW32__ + # define GC_REDIRECT_TO_LOCAL 1 ++#endif /* __MINGW32__ */ + + #endif + diff -r 2c2917119ce3 -r 344d21a6233d patches/guile-1.9.14-reloc.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/guile-1.9.14-reloc.patch Sat Jan 29 15:48:48 2011 +0100 @@ -0,0 +1,161 @@ +From 73b081531e9191876105c1e16d62868eb1c43b8a Mon Sep 17 00:00:00 2001 +From: Han-Wen Nienhuys +Date: Sat, 22 Mar 2008 17:43:04 -0300 +Subject: [PATCH] Relocate patch + + + +2005-06-08 Jan Nieuwenhuizen + + * configure.in: Add --enable-relocation option. Default off. + +libguile/ ChangeLog + +2005-06-09 Jan Nieuwenhuizen + + Experimental relocation patch. + + * load.c (scm_init_argv0_relocation)[ARGV0_RELOCATION]: New + function. + + (scm_init_load_path)[ARGV0_RELOCATION]: Use it. + + * load.c (scm_c_argv0_relocation)[ARGV0_RELOCATION]: + + * guile.c (main)[ARGV0_RELOCATION]: Use it to append from + executable location derived scm library directory. + [__MINGW32__|__CYGWIN__]: Append directory of executable to PATH. + +--- + configure.in | 12 +++++++++++ + libguile/guile.c | 5 ++++ + libguile/load.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + libguile/load.h | 4 +++ + 4 files changed, 79 insertions(+), 0 deletions(-) + +diff --git a/configure.ac b/configure.ac +index dd0628f..41c5c96 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1196,6 +1196,18 @@ AC_MSG_RESULT($works) + fi # with_threads=pthreads + + ++## Dynamic relocation, based on argv[0]. ++reloc_p=no ++AC_ARG_ENABLE(relocation, ++ [ --enable-relocation compile with dynamic relocation. Default: off], ++ [reloc_p=$enableval]) ++ ++if test "$reloc_p" = "yes"; then ++ AC_DEFINE([ARGV0_RELOCATION], [1], [Dynamic relocation]) ++ AC_DEFINE_UNQUOTED([PATH_SEPARATOR], "$PATH_SEPARATOR", [Path separator]) ++ AC_DEFINE_UNQUOTED([GUILE_EFFECTIVE_VERSION], "$GUILE_EFFECTIVE_VERSION", [GUILE_EFFECTIVE_VERSION]) ++fi # $reloc_b ++ + ## Cross building + if test "$cross_compiling" = "yes"; then + AC_MSG_CHECKING(cc for build) +diff --git a/libguile/guile.c b/libguile/guile.c +index c8341c2..116aa2f 100644 +--- a/libguile/guile.c ++++ b/libguile/guile.c +@@ -66,6 +66,9 @@ inner_main (void *closure SCM_UNUSED, int argc, char **argv) + int + main (int argc, char **argv) + { ++#if ARGV0_RELOCATION ++ scm_c_argv0_relocation (argv[0]); ++#endif /* ARGV0_RELOCATION */ + scm_boot_guile (argc, argv, inner_main, 0); + return 0; /* never reached */ + } +diff --git a/libguile/load.c b/libguile/load.c +index 3e702c4..2341daf 100644 +--- a/libguile/load.c ++++ b/libguile/load.c +@@ -195,6 +195,59 @@ SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0, + } + #undef FUNC_NAME + ++#if ARGV0_RELOCATION ++#include "filesys.h" ++#if defined (__CYGWIN__) || defined (__MINGW32__) ++#include "posix.h" ++#endif ++ ++char const *global_argv0 = 0; ++ ++void ++scm_c_argv0_relocation (char const *argv0) ++{ ++ global_argv0 = argv0; ++} ++ ++SCM ++scm_init_argv0_relocation (char const* argv0) ++{ ++ SCM bindir = scm_dirname (scm_from_locale_string (argv0)); ++ SCM prefix = scm_dirname (bindir); ++ SCM datadir = scm_string_append (scm_list_2 (prefix, ++ scm_from_locale_string ("/share/guile/" GUILE_EFFECTIVE_VERSION))); ++ SCM libdir = scm_string_append (scm_list_2 (prefix, ++ scm_from_locale_string ("/lib"))); ++ ++#if 0 /* def SYSV */ ++ { ++ SCM path; ++ char *env = getenv ("LD_LIBRARY_PATH"); ++ if (env) ++ path = scm_string_append (scm_list_3 (scm_from_locale_string (env), ++ scm_from_locale_string (PATH_SEPARATOR), ++ datadir)); ++ else ++ path = libdir; ++ scm_putenv (scm_string_append (scm_list_2 (scm_from_locale_string ("LD_LIBRARY_PATH="), path))); ++ } ++#elif defined (__CYGWIN__) || defined (__MINGW32__) ++ { ++ SCM path; ++ char *env = getenv ("PATH"); ++ if (env) ++ path = scm_string_append (scm_list_3 (scm_from_locale_string (env), ++ scm_from_locale_string (PATH_SEPARATOR), ++ bindir)); ++ else ++ path = bindir; ++ scm_putenv (scm_string_append (scm_list_2 (scm_from_locale_string ("PATH="), path))); ++ } ++#endif /* __CYGWIN__ || __MINGW32__ */ ++ ++ return scm_list_1 (datadir); ++} ++#endif /* ARGV0_RELOCATION */ + + /* Initialize the global variable %load-path, given the value of the + SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the +@@ -215,6 +268,11 @@ scm_init_load_path () + if (env) + path = scm_parse_path (scm_from_locale_string (env), path); + ++#if ARGV0_RELOCATION ++ if (global_argv0) ++ path = scm_append (scm_list_2 (path, scm_init_argv0_relocation (global_argv0))); ++#endif /* __CYGWIN__ || __MINGW32__ */ ++ + *scm_loc_load_path = path; + } + +--- a/libguile/load.h~ 2010-12-14 19:15:17.000000000 +0100 ++++ a/libguile/load.h 2011-01-26 17:33:13.797510681 +0100 +@@ -27,6 +27,10 @@ + + + SCM_API SCM scm_parse_path (SCM path, SCM tail); ++#if ARGV0_RELOCATION ++SCM_API void scm_c_argv0_relocation (char const *argv0); ++SCM_API SCM scm_init_argv0_relocation (char const* argv0); ++#endif + SCM_API SCM scm_primitive_load (SCM filename); + SCM_API SCM scm_c_primitive_load (const char *filename); + SCM_API SCM scm_sys_package_data_dir (void); diff -r 2c2917119ce3 -r 344d21a6233d sourcefiles/fcntl-o.m4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sourcefiles/fcntl-o.m4 Sat Jan 29 15:48:48 2011 +0100 @@ -0,0 +1,81 @@ +# fcntl-o.m4 serial 1 +dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. +# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. +# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. +AC_DEFUN([gl_FCNTL_O_FLAGS], +[ + dnl Persuade glibc to define O_NOATIME and O_NOFOLLOW. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + #include + #ifndef O_NOATIME + #define O_NOATIME 0 + #endif + #ifndef O_NOFOLLOW + #define O_NOFOLLOW 0 + #endif + static int const constants[] = + { + O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, + O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY + }; + ]], + [[ + int status = !constants; + { + static char const sym[] = "conftest.sym"; + if (symlink (".", sym) != 0 + || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0) + status |= 32; + unlink (sym); + } + { + static char const file[] = "confdefs.h"; + int fd = open (file, O_RDONLY | O_NOATIME); + char c; + struct stat st0, st1; + if (fd < 0 + || fstat (fd, &st0) != 0 + || sleep (1) != 0 + || read (fd, &c, 1) != 1 + || close (fd) != 0 + || stat (file, &st1) != 0 + || st0.st_atime != st1.st_atime) + status |= 64; + } + return status;]])], + [gl_cv_header_working_fcntl_h=yes], + [case $? in #( + 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( + 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( + 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( + *) gl_cv_header_working_fcntl_h='no';; + esac], + [gl_cv_header_working_fcntl_h=cross-compiling])]) + + case $gl_cv_header_working_fcntl_h in #( + *O_NOATIME* | no | cross-compiling) ac_val=0;; #( + *) ac_val=1;; + esac + AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val], + [Define to 1 if O_NOATIME works.]) + + case $gl_cv_header_working_fcntl_h in #( + *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( + *) ac_val=1;; + esac + AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val], + [Define to 1 if O_NOFOLLOW works.]) +])