This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Spelling - megapatch
[metaconfig.git] / U / compline / Csym.U
... / ...
CommitLineData
1?RCS: $Id: Csym.U,v 3.0.1.4 1995/07/25 13:36:29 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 License,
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 License; 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: 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
17?RCS: patch54: fixed C test program to bypass gcc builtin type checks (ADO)
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 mistrustnm extern_C: Options contains libc libs runnm test \
30 +cc +optimize +ccflags +ldflags run rm_try _exe d_cplusplus
31?MAKE: -pick add $@ %<
32?LINT:define csym
33?LINT:use libc
34?LINT:extern mistrustnm
35?LINT:set mistrustnm
36?S:csym:
37?S: This shell variable is used internally by Configure to check
38?S: whether a given C symbol is defined or not. A typical use is:
39?S: set symbol result [-fva] [previous]
40?S: eval $csym
41?S: That will set result to 'true' if the function [-f], variable [-v]
42?S: or array [-a] is defined, 'false' otherwise. If a previous value is
43?S: given and the -r flag was provided on the command line, that value
44?S: is reused without questioning.
45?S:.
46?S:extern_C:
47?S: ANSI C requires 'extern' where C++ requires 'extern "C"'. This
48?S: variable can be used in Configure to do the right thing.
49?S:.
50?S:mistrustnm:
51?S: This variable can be used to establish a fallthrough for the cases
52?S: where nm fails to find a symbol. If usenm is false or usenm is true
53?S: and mistrustnm is false, this variable has no effect. If usenm is true
54?S: and mistrustnm is "compile", a test program will be compiled to try to
55?S: find any symbol that can't be located via nm lookup. If mistrustnm is
56?S: "run", the test program will be run as well as being compiled.
57?S:.
58?V:csym
59?T:tval tx tlook tf tdc
60?F:!try
61: is a C symbol defined?
62csym='tlook=$1;
63case "$3" in
64-v) tf=libc.tmp; tdc="";;
65-a) tf=libc.tmp; tdc="[]";;
66*) tlook="^$1\$"; tf=libc.list; tdc="()";;
67esac;
68case "$d_cplusplus" in
69 $define) extern_C="extern \"C\"" ;;
70 *) extern_C="extern" ;;
71esac;
72tx=yes;
73case "$reuseval-$4" in
74true-) ;;
75true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
76esac;
77case "$tx" in
78yes)
79?X:
80?X: Put symbol inside a printf to fool optimizing compilers...
81?X:
82?X: We use 'short' instead of 'int' to try to circumvent overzealous
83?X: optimizing compilers using built-in prototypes for commonly used
84?X: routines to complain when seeing a different external declaration. For
85?X: instance, gcc 2.6.3 fails if we use 'int' and we attempt a test against
86?X: memcpy() on machines where sizeof(int) == sizeof(char *) (the usual return
87?X: type), the compiler assuming it's a built-in declaration given that the
88?X: returned size matches. At least with 'short' we are safe! -- RAM, for ADO
89?X:
90?X: Let's thank GNU cc for making our lives so easy! :-)
91?X: (An alternative for the future would be to use our knowledge about gcc
92?X: to force a -fno-builtin option in the compile test, in case the 'short'
93?X: trick is obsoleted by future gcc releases). -- RAM
94?X:
95 tval=false;
96 if $test "$runnm" = true; then
97 if $contains $tlook $tf >/dev/null 2>&1; then
98 tval=true;
99 elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
100 echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
101 $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
102 $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
103 $rm_try;
104 fi;
105 else
106 echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
107 $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
108 $rm_try;
109 fi;
110 ;;
111*)
112 case "$tval" in
113 $define) tval=true;;
114 *) tval=false;;
115 esac;
116 ;;
117esac;
118eval "$2=$tval"'
119