| 1 | dnl @synopsis AX_CHECK_DIRENT_D_TYPE([ACTION-IF-TRUE], [ACTION-IF-FALSE]) |
|---|
| 2 | dnl |
|---|
| 3 | dnl This macro will find out if struct dirent.d_type is present and supported. |
|---|
| 4 | dnl |
|---|
| 5 | dnl The following defines will be set as appropriate: |
|---|
| 6 | dnl HAVE_STRUCT_DIRENT_D_TYPE |
|---|
| 7 | dnl HAVE_VALID_DIRENT_D_TYPE |
|---|
| 8 | dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate |
|---|
| 9 | dnl |
|---|
| 10 | dnl @category C |
|---|
| 11 | dnl @author Martin Ebourne |
|---|
| 12 | dnl @version 2005/07/03 |
|---|
| 13 | dnl @license AllPermissive |
|---|
| 14 | |
|---|
| 15 | AC_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 |
|---|