This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Populate metaconfig branch.
[metaconfig.git] / dist-3.0at70b / mcon / U / cpp_stuff.U
1 ?RCS: $Id: cpp_stuff.U,v 3.0.1.2 1997/02/28 15:30:48 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: cpp_stuff.U,v $
12 ?RCS: Revision 3.0.1.2  1997/02/28  15:30:48  ram
13 ?RCS: patch61: added cute quoting trick for wild stringify support
14 ?RCS:
15 ?RCS: Revision 3.0.1.1  1994/10/29  16:08:24  ram
16 ?RCS: patch36: now uses cppstdin instead of plain cpp for consistency (ADO)
17 ?RCS: patch36: remove temporary files when done
18 ?RCS:
19 ?RCS: Revision 3.0  1993/08/18  12:05:36  ram
20 ?RCS: Baseline for dist 3.0 netwide release.
21 ?RCS:
22 ?MAKE:cpp_stuff: cat contains cppstdin cppflags cppminus rm
23 ?MAKE:  -pick add $@ %<
24 ?S:cpp_stuff:
25 ?S:     This variable contains an identification of the catenation mechanism
26 ?S:     used by the C preprocessor.
27 ?S:.
28 ?C:CAT2:
29 ?C:     This macro catenates 2 tokens together.
30 ?C:.
31 ?C:CAT3:
32 ?C:     This macro catenates 3 tokens together.
33 ?C:.
34 ?C:CAT4:
35 ?C:     This macro catenates 4 tokens together.
36 ?C:.
37 ?C:CAT5:
38 ?C:     This macro catenates 5 tokens together.
39 ?C:.
40 ?C:STRINGIFY:
41 ?C:     This macro surrounds its token with double quotes.
42 ?C:.
43 ?C:SCAT2:
44 ?C:     This macro catenates 2 tokens together and stringifies the result.
45 ?C:.
46 ?C:SCAT3:
47 ?C:     This macro catenates 3 tokens together and stringifies the result.
48 ?C:.
49 ?C:SCAT4:
50 ?C:     This macro catenates 4 tokens together and stringifies the result.
51 ?C:.
52 ?C:SCAT5:
53 ?C:     This macro catenates 5 tokens together and stringifies the result.
54 ?C:.
55 ?H:?%<:#if $cpp_stuff == 1
56 ?H:?CAT2:#define CAT2(a,b)a/**/b
57 ?H:?CAT3:#define CAT3(a,b,c)a/**/b/**/c
58 ?H:?CAT4:#define CAT4(a,b,c,d)a/**/b/**/c/**/d
59 ?H:?CAT5:#define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e
60 ?H:?STRINGIFY:#define STRINGIFY(a)"a"
61 ?H:?%<:#define SQuoTe(a)"a
62 ?H:?%<:#define EQuoTe(a)a"
63 ?H:?SCAT2:#define SCAT2(a,b)EQuoTe(SQuoTe(a)b)
64 ?H:?SCAT3:#define SCAT3(a,b,c)EQuoTe(SQuoTe(a)b/**/c)
65 ?H:?SCAT4:#define SCAT4(a,b,c,d)EQuoTe(SQuoTe(a)b/**/c/**/d)
66 ?H:?SCAT5:#define SCAT5(a,b,c,d,e)EQuoTe(SQuoTe(a)b/**/c/**/d/**/e)
67 ?H:?%<:#endif
68 ?H:?%<:#if $cpp_stuff == 42
69 ?H:?CAT2:#define CAT2(a,b)a ## b
70 ?H:?CAT3:#define CAT3(a,b,c)a ## b ## c
71 ?H:?CAT4:#define CAT4(a,b,c,d)a ## b ## c ## d
72 ?H:?CAT5:#define CAT5(a,b,c,d,e)a ## b ## c ## d ## e
73 ?H:?%<:#define StGiFy(a)# a
74 ?H:?STRINGIFY:#define STRINGIFY(a)StGiFy(a)
75 ?H:?SCAT2:#define SCAT2(a,b)StGiFy(a) StGiFy(b)
76 ?H:?SCAT3:#define SCAT3(a,b,c)StGiFy(a) StGiFy(b) StGiFy(c)
77 ?H:?SCAT4:#define SCAT4(a,b,c,d)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d)
78 ?H:?SCAT5:#define SCAT5(a,b,c,d,e)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) StGiFy(e)
79 ?H:?%<:#endif
80 ?H:?%<:#if $cpp_stuff != 1 && $cpp_stuff != 42
81 ?H:?%<:#include "Bletch: How does this C preprocessor catenate tokens?"
82 ?H:?%<:#endif
83 ?H:.
84 ?W:%<:CAT2 CAT3 CAT4 CAT5 STRINGIFY SCAT2 SCAT3 SCAT4 SCAT5
85 ?LINT:known StGiFy EQuoTe SQuoTe
86 : how do we catenate cpp tokens here?
87 echo " "
88 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
89 $cat >cpp_stuff.c <<'EOCP'
90 #define RCAT(a,b)a/**/b
91 #define ACAT(a,b)a ## b
92 RCAT(Rei,ser)
93 ACAT(Cir,cus)
94 EOCP
95 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
96 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
97         echo "Oh!  Smells like ANSI's been here."
98         echo "We can catify or stringify, separately or together!"
99         cpp_stuff=42
100 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
101         $cat <<EOM
102 Ah, yes!  The good old days!
103 However, in the good old days we don't know how to stringify and
104 catify at the same time...
105 Unless we have a cute trick...  which I have!
106 EOM
107         cpp_stuff=1
108 else
109         $cat >&4 <<EOM
110 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
111 to have to edit the values of CAT[2-5] and SCAT[2-5] in config.h...
112 EOM
113 ?X: It would be nice to have configure remind us at the end that some manual
114 ?X: intervention is needed -- FIXME
115         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
116 fi
117 $rm -f cpp_stuff.*
118