1 ?RCS: $Id: Typedef.U,v 3.0.1.3 1995/07/25 13:42:07 ram Exp $
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
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.
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
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
18 ?RCS: Revision 3.0.1.1 1994/08/29 16:05:14 ram
19 ?RCS: patch32: created
22 ?X: This unit checks for the definition of a given typedef.
25 ?X: set typedef val_t default [includes]
28 ?MAKE:Typedef: cppstdin cppminus cppflags rm sed contains Oldconfig Myread
29 ?MAKE: -pick add $@ %<
31 ?LINT:define typedef_ask
32 ?V:typedef typedef_ask
34 ?S: This shell variable is used internally by Configure to check
35 ?S: whether a given typedef is defined or not. A typical use is:
36 ?S: set typedef val_t default [includes]
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.
42 ?S: This shell variable is used internally by Configure to check
43 ?S: whether a given typedef is defined or not. If it is not defined,
44 ?S: this will call the ./myread script to prompt for an answer.
45 ?S: It is intended to be used to avoid unnecessary prompts.
47 ?S: rp="What is the type for file position used by fsetpos()?"
48 ?S: set fpos_t fpostype long stdio.h sys/types.h
50 ?S: This will set fpostype=fpos_t, if fpos_t is available. Otherwise
51 ?S: it will call myread with a default of 'long', and a prompt of $rp.
53 ?T:type var def inclist varval inc
54 : define an is-a-typedef? function
55 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
57 "") inclist="sys/types.h";;
63 for inc in $inclist; do
64 echo "#include <$inc>" >>temp.c;
66 ?X: Maybe it's a #define instead of a typedef.
67 echo "#ifdef $type" >> temp.c;
68 echo "printf(\"We have $type\");" >> temp.c;
69 echo "#endif" >> temp.c;
70 $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
71 if $contains $type temp.E >/dev/null 2>&1; then
77 *) eval "$var=\$varval";;
80 ?X: Originally, I eval'd $typedef and then checked the results against
81 ?X: $type. Unfortunately, it then became complicated to check
82 ?X: whether you are re-using an old config.sh value, and the logic got
83 ?X: so convoluted it became easier to just copy the function above
84 ?X: and alter it slightly. A.D. 3/1998
85 : define an is-a-typedef? function that prompts if the type is not available.
86 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
88 "") inclist="sys/types.h";;
94 for inc in $inclist; do
95 echo "#include <$inc>" >>temp.c;
97 ?X: Maybe it's a #define instead of a typedef.
98 echo "#ifdef $type" >> temp.c;
99 echo "printf(\"We have $type\");" >> temp.c;
100 echo "#endif" >> temp.c;
101 $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
103 echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
104 if $contains $type temp.E >/dev/null 2>&1; then
105 echo "$type found." >&4;
108 echo "$type NOT found." >&4;
114 *) eval "$var=\$varval";;