source: box/trunk/infrastructure/m4/ax_check_dirent_d_type.m4 @ 2494

Revision 2494, 1.5 KB checked in by chris, 3 years ago (diff)

Blind fix for autoconf problems introduced by earlier attempt to support
cross-compiling.

  • Property svn:eol-style set to native
Line 
1dnl @synopsis AX_CHECK_DIRENT_D_TYPE([ACTION-IF-TRUE], [ACTION-IF-FALSE])
2dnl
3dnl This macro will find out if struct dirent.d_type is present and supported.
4dnl
5dnl The following defines will be set as appropriate:
6dnl HAVE_STRUCT_DIRENT_D_TYPE
7dnl HAVE_VALID_DIRENT_D_TYPE
8dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
9dnl
10dnl @category C
11dnl @author Martin Ebourne
12dnl @version 2005/07/03
13dnl @license AllPermissive
14
15AC_DEFUN([AX_CHECK_DIRENT_D_TYPE], [
16  AC_CHECK_MEMBERS([struct dirent.d_type],,, [[#include <dirent.h>]])
17  if test "x$ac_cv_member_struct_dirent_d_type" = "xyes"; then
18    AC_CACHE_CHECK([[whether struct dirent.d_type is valid]], [box_cv_have_valid_dirent_d_type],
19      [AC_TRY_RUN(
20        [
21          $ac_includes_default
22          #include <dirent.h>
23          int main()
24          {
25          DIR* dir = opendir(".");
26          struct dirent* res = NULL;
27          if(dir) res = readdir(dir);
28          return res ? (res->d_type != DT_FILE && res->d_type != DT_DIR) : 1;
29          }
30        ],
31        [box_cv_have_valid_dirent_d_type=yes],
32        [box_cv_have_valid_dirent_d_type=no],
33        [box_cv_have_valid_dirent_d_type=cross]
34      )])
35    if test "x$box_cv_have_valid_dirent_d_type" = "xyes"; then
36      AC_DEFINE([HAVE_VALID_DIRENT_D_TYPE], 1, [Define to 1 if struct dirent.d_type is valid])
37    fi
38  fi
39  if test "x$ac_cv_member_struct_dirent_d_type" = "xyes" || \
40     test "x$box_cv_have_valid_dirent_d_type" = "xyes"
41  then
42    m4_ifvaln([$1],[$1],[:])dnl
43    m4_ifvaln([$2],[else $2])dnl
44  fi
45  ])dnl
Note: See TracBrowser for help on using the repository browser.