This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Part 4 of a big cleanup action based on the upcoming dist-4.0
[metaconfig.git] / U / modified / d_access.U
1 ?RCS: $Id: d_access.U,v 3.0 1993/08/18 12:05:42 ram Exp $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
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: $Log: d_access.U,v $
12 ?RCS: Revision 3.0  1993/08/18  12:05:42  ram
13 ?RCS: Baseline for dist 3.0 netwide release.
14 ?RCS:
15 ?MAKE:d_access: test +cc cat +cppflags h_fcntl h_sysfile i_stdlib rm Inlibc Findhdr
16 ?MAKE:  -pick add $@ %<
17 ?S:d_access:
18 ?S:     This variable conditionally defines HAS_ACCESS if the access() system
19 ?S:     call is available to check for access permissions using real IDs.
20 ?S:.
21 ?C:HAS_ACCESS:
22 ?C:     This manifest constant lets the C program know that the access()
23 ?C:     system call is available to check for accessibility using real UID/GID.
24 ?C:     (always present on UNIX.)
25 ?C:.
26 ?H:#$d_access HAS_ACCESS                /**/
27 ?H:.
28 ?W:%<:R_OK W_OK X_OK F_OK
29 ?LINT:set d_access
30 ?LINT:change h_fcntl h_sysfile
31 : access call always available on UNIX
32 set access d_access
33 eval $inlibc
34
35 : locate the flags for 'access()'
36 case "$d_access" in
37 "$define")
38         echo " "
39         $cat >access.c <<EOCP
40 #include <sys/types.h>
41 #ifdef I_FCNTL
42 #include <fcntl.h>
43 #endif
44 #ifdef I_SYS_FILE
45 #include <sys/file.h>
46 #endif
47 #ifdef I_UNISTD
48 #include <unistd.h>
49 #endif
50 #$i_stdlib I_STDLIB
51 #ifdef I_STDLIB
52 #include <stdlib.h>
53 #endif
54 int main() {
55         exit(R_OK);
56 }
57 EOCP
58         : check sys/file.h first, no particular reason here
59         if $test `./findhdr sys/file.h` && \
60                 $cc -o access $cppflags -DI_SYS_FILE access.c >/dev/null 2>&1 ; then
61                 h_sysfile=true;
62                 echo "<sys/file.h> defines the *_OK access constants." >&4
63         elif $test `./findhdr fcntl.h` && \
64                 $cc -o access $cppflags -DI_FCNTL access.c >/dev/null 2>&1 ; then
65                 h_fcntl=true;
66                 echo "<fcntl.h> defines the *_OK access constants." >&4
67 @if I_UNISTD
68         elif $test `./findhdr unistd.h` && \
69                 $cc -o access $cppflags -DI_UNISTD access.c >/dev/null 2>&1 ; then
70                 echo "<unistd.h> defines the *_OK access constants." >&4
71 @end
72         else
73                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
74         fi
75         ;;
76 esac
77 $rm -f access*
78