This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[UTIL] Perl system does not default to $_
[metaconfig.git] / dist / U / Csym.U
CommitLineData
33a01fd2 1?RCS: $Id$
d8875586
MBT
2?RCS:
3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4?RCS:
33a01fd2 5?RCS: You may redistribute only under the terms of the Artistic License,
d8875586
MBT
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
33a01fd2 8?RCS: that same Artistic License; a copy of which may be found at the root
d8875586
MBT
9?RCS: of the source tree for dist 4.0.
10?RCS:
11?RCS: $Log: Csym.U,v $
12?RCS: Revision 3.0.1.4 1995/07/25 13:36:29 ram
13?RCS: patch56: re-arranged compile line to include ldflags before objects
14?RCS: patch56: added quotes for OS/2 support
15?RCS:
16?RCS: Revision 3.0.1.3 1995/05/12 12:00:33 ram
33a01fd2 17?RCS: patch54: fixed C test program to bypass gcc builtin type checks (ADO)
d8875586
MBT
18?RCS:
19?RCS: Revision 3.0.1.2 1994/10/31 09:34:13 ram
20?RCS: patch44: added Options to the MAKE line since it's no longer in Init.U
21?RCS:
22?RCS: Revision 3.0.1.1 1993/08/25 14:00:05 ram
23?RCS: patch6: added ldflags as a conditional dependency and to compile line
24?RCS: patch6: a final double quote was missing in csym variable after eval
25?RCS:
26?RCS: Revision 3.0 1993/08/18 12:04:50 ram
27?RCS: Baseline for dist 3.0 netwide release.
28?RCS:
29?MAKE:Csym: Options contains libc libs runnm +cc +ccflags +ldflags rm
30?MAKE: -pick add $@ %<
31?LINT:define csym
32?LINT:use libc
33?S:csym:
34?S: This shell variable is used internally by Configure to check
35?S: wether a given C symbol is defined or not. A typical use is:
36?S: set symbol result [-fva] [previous]
37?S: eval $csym
38?S: That will set result to 'true' if the function [-f], variable [-v]
39?S: or array [-a] is defined, 'false' otherwise. If a previous value is
40?S: given and the -r flag was provided on the command line, that value
41?S: is reused without questioning.
42?S:.
43?V:csym
44?T:tval tx tlook tf tdc tc
45: is a C symbol defined?
46csym='tlook=$1;
47case "$3" in
48-v) tf=libc.tmp; tc=""; tdc="";;
49-a) tf=libc.tmp; tc="[0]"; tdc="[]";;
50*) tlook="^$1\$"; tf=libc.list; tc=""; tdc="()";;
51esac;
52tx=yes;
53case "$reuseval-$4" in
54true-) ;;
55true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
56esac;
57case "$tx" in
58yes)
59 case "$runnm" in
60 true)
61 if $contains $tlook $tf >/dev/null 2>&1;
62 then tval=true;
63 else tval=false;
64 fi;;
65 *)
66?X:
67?X: We use 'char' instead of 'int' to try to circumvent overzealous
68?X: optimizing compilers using built-in prototypes for commonly used
69?X: routines to complain when seeing a different external declaration. For
70?X: instance, gcc 2.6.3 fails if we use 'int' and we attempt a test against
71?X: memcpy() on machines where sizeof(int) == sizeof(char *) (the usual return
72?X: type), the compiler assuming it's a built-in declaration given that the
73?X: returned size matches. At least with 'char' we are safe! -- RAM, for ADO
74?X:
75?X: Let's thank GNU cc for making our lifes so easy! :-)
76?X: (An alternative for the future would be to use our knowledge about gcc
77?X: to force a -fno-builtin option in the compile test, in case the 'char'
78?X: trick is obsoleted by future gcc releases). -- RAM
79?X:
80?X: Lastly, gcc 3.4 otimizes &missing == 0 away, so we use + 2 instead now.
81?X: The GNU folks like to do weird things, don't they? -- RAM, 2004-06-05
82?X:
83 echo "extern char $1$tdc; int main() { return &$1$tc + 2; }" > t.c;
84 if $cc $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
85 then tval=true;
86 else tval=false;
87 fi;
88 $rm -f t t.c;;
89 esac;;
90*)
91 case "$tval" in
92 $define) tval=true;;
93 *) tval=false;;
94 esac;;
95esac;
96eval "$2=$tval"'
97