File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libiconv / srcm4 / readlink.m4
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 13:38:46 2021 UTC (3 years, 3 months ago) by misho
Branches: libiconv, MAIN
CVS tags: v1_16p0, HEAD
libiconv 1.16

    1: # readlink.m4 serial 14
    2: dnl Copyright (C) 2003, 2007, 2009-2019 Free Software Foundation, Inc.
    3: dnl This file is free software; the Free Software Foundation
    4: dnl gives unlimited permission to copy and/or distribute it,
    5: dnl with or without modifications, as long as this notice is preserved.
    6: 
    7: AC_DEFUN([gl_FUNC_READLINK],
    8: [
    9:   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   10:   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   11:   AC_CHECK_FUNCS_ONCE([readlink])
   12:   if test $ac_cv_func_readlink = no; then
   13:     HAVE_READLINK=0
   14:   else
   15:     AC_CACHE_CHECK([whether readlink signature is correct],
   16:       [gl_cv_decl_readlink_works],
   17:       [AC_COMPILE_IFELSE(
   18:          [AC_LANG_PROGRAM(
   19:            [[#include <unistd.h>
   20:       /* Cause compilation failure if original declaration has wrong type.  */
   21:       ssize_t readlink (const char *, char *, size_t);]])],
   22:          [gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])])
   23:     dnl Solaris 9 ignores trailing slash.
   24:     dnl FreeBSD 7.2 dereferences only one level of links with trailing slash.
   25:     AC_CACHE_CHECK([whether readlink handles trailing slash correctly],
   26:       [gl_cv_func_readlink_works],
   27:       [# We have readlink, so assume ln -s works.
   28:        ln -s conftest.no-such conftest.link
   29:        ln -s conftest.link conftest.lnk2
   30:        AC_RUN_IFELSE(
   31:          [AC_LANG_PROGRAM(
   32:            [[#include <unistd.h>
   33: ]], [[char buf[20];
   34:       return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;]])],
   35:          [gl_cv_func_readlink_works=yes], [gl_cv_func_readlink_works=no],
   36:          [case "$host_os" in
   37:                              # Guess yes on Linux systems.
   38:             linux-* | linux) gl_cv_func_readlink_works="guessing yes" ;;
   39:                              # Guess yes on glibc systems.
   40:             *-gnu* | gnu*)   gl_cv_func_readlink_works="guessing yes" ;;
   41:                              # If we don't know, assume the worst.
   42:             *)               gl_cv_func_readlink_works="guessing no" ;;
   43:           esac
   44:          ])
   45:       rm -f conftest.link conftest.lnk2])
   46:     case "$gl_cv_func_readlink_works" in
   47:       *yes)
   48:         if test "$gl_cv_decl_readlink_works" != yes; then
   49:           REPLACE_READLINK=1
   50:         fi
   51:         ;;
   52:       *)
   53:         AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink
   54:           fails to recognize a trailing slash.])
   55:         REPLACE_READLINK=1
   56:         ;;
   57:     esac
   58:   fi
   59: ])
   60: 
   61: # Like gl_FUNC_READLINK, except prepare for separate compilation
   62: # (no REPLACE_READLINK, no AC_LIBOBJ).
   63: AC_DEFUN([gl_FUNC_READLINK_SEPARATE],
   64: [
   65:   AC_CHECK_FUNCS_ONCE([readlink])
   66:   gl_PREREQ_READLINK
   67: ])
   68: 
   69: # Prerequisites of lib/readlink.c.
   70: AC_DEFUN([gl_PREREQ_READLINK],
   71: [
   72:   :
   73: ])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>