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