This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
5d75d83b70a567d0f33f413045da40deac622848
[metaconfig.git] / U / perl / d_dirfd.U
1 ?RCS: $Id$
2 ?RCS:
3 ?RCS: Copyright (c) 2001, Jarkko Hietaniemi
4 ?RCS: 
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
10 ?RCS:
11 ?RCS:
12 ?MAKE:d_dirfd: Compile cat rm Setvar i_dirent i_sysdir i_sysndir i_systypes i_stdlib
13 ?MAKE:  -pick add $@ %<
14 ?S:d_dirfd:
15 ?S:     This variable conditionally defines the HAS_DIRFD constant,
16 ?S:     which indicates to the C program that dirfd() is available
17 ?S:     to return the file descriptor of a directory stream.
18 ?S:.
19 ?C:HAS_DIRFD:
20 ?C:     This manifest constant lets the C program know that dirfd
21 ?C:     is available.
22 ?C:.
23 ?H:#$d_dirfd HAS_DIRFD          /**/
24 ?H:.
25 ?LINT:set d_dirfd
26 ?X: Can't use Inlibc because dirfd() might be a macro.
27 : Look for dirfd
28 echo " "
29 $cat >dirfd.c <<EOM
30 #include <stdio.h>
31 #$i_stdlib I_STDLIB
32 #ifdef I_STDLIB
33 #include <stdlib.h>
34 #endif
35 #$i_dirent I_DIRENT             /**/
36 #$i_sysdir I_SYS_DIR            /**/
37 #$i_sysndir I_SYS_NDIR          /**/
38 #$i_systypes I_SYS_TYPES        /**/
39 #if defined(I_SYS_TYPES)
40 #include <sys/types.h>
41 #endif
42 #if defined(I_DIRENT)
43 #include <dirent.h>
44 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
45 #include <sys/dir.h>
46 #endif
47 #else
48 #ifdef I_SYS_NDIR
49 #include <sys/ndir.h>
50 #else
51 #ifdef I_SYS_DIR
52 #ifdef hp9000s500
53 #include <ndir.h>       /* may be wrong in the future */
54 #else
55 #include <sys/dir.h>
56 #endif
57 #endif
58 #endif
59 #endif 
60 int main() {
61         DIR *dirp = opendir(".");
62         if (dirfd(dirp) >= 0)
63                 exit(0);
64         else
65                 exit(1);
66 }
67 EOM
68 set dirfd
69 if eval $compile; then
70         val="$define"
71 fi
72 case "$val" in
73 $define)        echo "dirfd() found." >&4       ;;
74 *)              echo "dirfd() NOT found." >&4   ;;
75 esac
76 set d_dirfd
77 eval $setvar
78 $rm -f dirfd*
79