1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00

configure: add detection for O_NOFOLLOW flag to the open function

As discovered by Douglas Torrance, this flag is not really portable, so
this patch adds a check in the configure script to detect if any known
define could help. If no value works, we fall back to defining it with the
neutral value '0', so the compilation will not fail.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-12-17 17:54:38 +01:00
committed by Carlos R. Mafra
parent e1146e56e0
commit 9b67b36276
2 changed files with 40 additions and 0 deletions

View File

@@ -317,6 +317,9 @@ dnl case. One known example is Solaris which needs -lrt
AC_SEARCH_LIBS([nanosleep], [rt], [],
[AC_MSG_ERROR([function 'nanosleep' not found, please report to wmaker-dev@lists.windowmaker.org])])
dnl the flag 'O_NOFOLLOW' for 'open' is used in WINGs
WM_FUNC_OPEN_NOFOLLOW
dnl Check for strlcat/strlcpy
dnl =========================

View File

@@ -207,3 +207,40 @@ AS_IF([test "x$wm_cv_func_secure_getenv" != "xno"],
AC_DEFINE([HAVE_SECURE_GETENV], [1],
[defined when GNU's secure_getenv function is available])])
])
# WM_FUNC_OPEN_NOFOLLOW
# ---------------------
#
# Check if the flag 'O_NOFOLLOW' is supported, for the function 'open'
AC_DEFUN_ONCE([WM_FUNC_OPEN_NOFOLLOW],
[AC_CACHE_CHECK([for O_NOFOLLOW], [wm_cv_func_open_nofollow],
[wm_cv_func_open_nofollow=no
wm_save_CPPFLAGS="$CPPFLAGS"
for wm_arg in dnl
"yes" dnl natively supported, nothing to do
"-D_POSIX_C_SOURCE=200809L" dnl the flag was officially added in POSIX.1-2008
"-D_XOPEN_SOURCE=700" dnl for recent glibc
"-D_GNU_SOURCE" dnl for older glibc
; do
AS_IF([test "x$wm_arg" != "xyes"], [CPPFLAGS="$wm_save_CPPFLAGS $wm_arg"])
AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
@%:@include <sys/types.h>
@%:@include <sys/stat.h>
@%:@include <fcntl.h>], [dnl
int fd;
fd = open("/dev/null", O_RDONLY | O_NOFOLLOW);
return fd;])], [found=1], [found=0])
AS_IF([test $found = 1],
[wm_cv_func_open_nofollow="$wm_arg"
break])
done
CPPFLAGS="$wm_save_CPPFLAGS"])
AS_CASE([$wm_cv_func_open_nofollow],
[yes], [],
[no], [AC_DEFINE([O_NOFOLLOW], [0],
[defined by configure if the attribute is not defined on your platform])
AC_MSG_WARN([flag O_NOFOLLOW is not defined on your platform])],
[CPPFLAGS="$CPPFLAGS $wm_cv_func_open_nofollow"])
])