This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport #30919; remove \n; add $run
[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 29?MAKE:Csym mistrustnm: Options contains libc libs runnm test \
501cdb1e 30 +cc +optimize +ccflags +ldflags run rm _exe d_cplusplus
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 55?V:csym
501cdb1e 56?T:tval tx tlook tf tdc extern_C
959f3c4c
JH
57: is a C symbol defined?
58csym='tlook=$1;
59case "$3" in
15dfe1a4
JH
60-v) tf=libc.tmp; tdc="";;
61-a) tf=libc.tmp; tdc="[]";;
62*) tlook="^$1\$"; tf=libc.list; 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;
501cdb1e
MB
88 case "$d_cplusplus" in
89 $define) extern_C=\"C\";;
90 esac;
e3a6a689
JH
91 if $test "$runnm" = true; then
92 if $contains $tlook $tf >/dev/null 2>&1; then
868ab49f 93 tval=true;
e3a6a689 94 elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
501cdb1e 95 echo "extern $extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
e3a6a689 96 $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
15dfe1a4
JH
97 $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
98 $rm -f try$_exe try.c core core.* try.core;
959f3c4c 99 fi;
e3a6a689 100 else
501cdb1e 101 echo "extern $extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
e3a6a689 102 $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
15dfe1a4 103 $rm -f try$_exe try.c;
868ab49f
JH
104 fi;
105 ;;
959f3c4c
JH
106*)
107 case "$tval" in
108 $define) tval=true;;
109 *) tval=false;;
868ab49f
JH
110 esac;
111 ;;
959f3c4c
JH
112esac;
113eval "$2=$tval"'
114