This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / Typedef.U
1 ?RCS: $Id: Typedef.U 1 2006-08-24 12:32:52Z rmanfredi $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, 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 4.0.
10 ?RCS:
11 ?RCS: $Log: Typedef.U,v $
12 ?RCS: Revision 3.0.1.3  1995/07/25  13:42:07  ram
13 ?RCS: patch56: added backslash escapes within evals to prevent space problems
14 ?RCS:
15 ?RCS: Revision 3.0.1.2  1994/10/29  16:01:16  ram
16 ?RCS: patch36: don't clobber visible 'val' variable, use 'varval' instead
17 ?RCS:
18 ?RCS: Revision 3.0.1.1  1994/08/29  16:05:14  ram
19 ?RCS: patch32: created
20 ?RCS:
21 ?X:
22 ?X: This unit checks for the definition of a given typedef.
23 ?X:
24 ?X: To use it, say:
25 ?X: set typedef val_t default [includes]
26 ?X: eval $typedef
27 ?X:
28 ?MAKE:Typedef: cppstdin cppminus cppflags rm contains Oldconfig
29 ?MAKE:  -pick add $@ %<
30 ?F:!temp.c
31 ?LINT:define typedef
32 ?V:typedef
33 ?S:typedef:
34 ?S:     This shell variable is used internally by Configure to check
35 ?S:     wether a given typedef is defined or not. A typical use is:
36 ?S:             set typedef val_t default [includes]
37 ?S:             eval $typedef
38 ?S:     That will return val_t set to default if the typedef was not found,
39 ?S:     to typedef otherwise. If no includes are specified, look in sys/types.h.
40 ?S:.
41 ?T:type var def inclist varval inc
42 : define an is-a-typedef? function
43 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
44 case "$inclist" in
45 "") inclist="sys/types.h";;
46 esac;
47 eval "varval=\$$var";
48 case "$varval" in
49 "")
50         $rm -f temp.c;
51         for inc in $inclist; do
52                 echo "#include <$inc>" >>temp.c;
53         done;
54         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
55         if $contains $type temp.E >/dev/null 2>&1; then
56                 eval "$var=\$type";
57         else
58                 eval "$var=\$def";
59         fi;
60         $rm -f temp.?;;
61 *) eval "$var=\$varval";;
62 esac'
63