This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / nlist_pfx.U
1 ?RCS: $Id: nlist_pfx.U 1 2006-08-24 12:32:52Z rmanfredi $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, 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 4.0.
10 ?RCS:
11 ?RCS: $Log: nlist_pfx.U,v $
12 ?RCS: Revision 3.0.1.1  1994/10/29  16:26:18  ram
13 ?RCS: patch36: added ?F: line for metalint file checking
14 ?RCS:
15 ?RCS: Revision 3.0  1993/08/18  12:09:25  ram
16 ?RCS: Baseline for dist 3.0 netwide release.
17 ?RCS:
18 ?MAKE:nlist_pfx nlist_fnd: cat test Myread Oldconfig libnlist \
19         +cc +ccflags
20 ?MAKE:  -pick add $@ %<
21 ?S:nlist_pfx:
22 ?S:     This variable holds any characters which precede the symbol name
23 ?S:     when doing an nlist search.
24 ?S:.
25 ?S:nlist_fnd:
26 ?S:     This variable holds the member of the nlist structure which is
27 ?S:     nonzero if an nlist search succeeds.  Presently, it is always "n_value".
28 ?S:.
29 ?C:NLIST_PREFIX:
30 ?C:     This manifest constant holds the string of characters which should
31 ?C:     precede the symbol name when doing an nlist search.
32 ?C:.
33 ?C:NLIST_FOUND:
34 ?C:     This manifest constant holds the member of the nlist structure which
35 ?C:     is nonzero if an nlist search succeeds.
36 ?C:.
37 ?H:#define NLIST_PREFIX $nlist_pfx      /**/
38 ?H:#define NLIST_FOUND $nlist_fnd       /**/
39 ?H:.
40 ?F:!nlisttest
41 ?T:nlist_loc
42 : Nose around for nlist stuff
43 echo " "
44 echo "Checking out nlist stuff..." >&4
45 $cat >nlisttest.c <<'EOCP'
46 #include <stdio.h>
47 #include <nlist.h>
48
49 main(argc, argv)
50 int argc;
51 char **argv;
52 {
53         int (*loc)();
54         extern int hereIam();
55         static struct nlist nl[] = {
56                 { "IamNotFound", 0 },
57                 { "hereIam", 0 },
58                 { "_hereIam", 0 },
59                 { ".hereIam", 0 },
60                 { "", 0 }
61         };
62
63         loc = hereIam;
64
65         if(argc == 1) {
66                 printf("%ld\n", loc);}
67         else {
68                 int i;
69                 int rc;
70
71                 if(nlist("./nlisttest", nl) == -1) exit(-1);
72                 i = argv[1][0] - '0';
73                 printf("%d %d %d\n", nl[i].n_name, nl[i].n_type, nl[i].n_value);
74                 }
75         exit(0);}
76
77 int hereIam() {
78
79         return;}
80 EOCP
81 nlist_fnd=n_value
82 if $cc $ccflags -o nlisttest nlisttest.c $libnlist >/dev/null 2>&1 ; then
83         set `./nlisttest`
84         nlist_loc=$1
85
86         set `./nlisttest 0`
87         if $test "$3" = "0" ; then
88                 echo "$nlist_fnd is 0 if nlist() fails, as I expected."
89         else
90                 $cat <<EOM
91 Hello, Jim.  We have just discovered that $nlist_fnd was nonzero on an
92 nlist() lookup failure!  Your mission, should you choose to accept it, is to
93 edit either config.sh (to provide a Good value for nlist_fnd) or The Code
94 (to find an alternative to NLIST_FOUND), and reporting the full details of
95 your success to the MetaConfig Police.  Of course, should you fail...
96 EOM
97                 nlist_fnd="/* Bletch! */ */"
98         fi
99
100         set `./nlisttest 1`
101         if $test "$nlist_loc" = "$3" ; then
102                 echo "Symbols are stored with no initial characters."
103                 nlist_pfx=
104         else
105                 set `./nlisttest 2`
106                 if $test "$nlist_loc" = "$3" ; then
107                         echo "Symbols are stored with an initial underscore."
108                         nlist_pfx=_
109                 else
110                         set `./nlisttest 3`
111                         if $test "$nlist_loc" = "$3" ; then
112                                 echo "Symbols are stored with an initial dot."
113                                 nlist_pfx=.
114                         else
115                                 $cat <<EOM
116 I can't figure out the symbol prefix!
117 You get to edit config.sh and fix 'nlist_pfx' (Configure will let you do this
118 at the end of its configuration questions), or config.h and fix the value of
119 the NLIST_PREFIX symbol.
120 EOM
121                                 nlist_pfx="/* Bletch! */ */"
122                         fi
123                 fi
124         fi
125 else
126         $cat <<EOM
127 I can't get the nlist test program working!
128 You get to edit config.sh and fix 'nlist_pfx' (Configure will let you do this
129 at the end of its configuration questions) and 'nlist_fnd', or config.h and
130 fix the value of the NLIST_PREFIX and NLIST_FOUND symbols.
131 EOM
132         nlist_pfx="/* Bletch! */ */"
133         nlist_fnd="/* Bletch! */ */"
134 fi
135