* breakpoint.c (breakpoint_re_set): Avoid setting source symtab
[deliverable/binutils-gdb.git] / gdb / doc / pretex.m4
CommitLineData
07d021a6 1divert(-1) -*-Text-*-
9bcc06ef
RP
2` Copyright (c) 1991 Free Software Foundation, Inc.'
3` This file defines and documents the M4 macros used '
4` to preprocess some GNU manuals'
5` $Id$'
07d021a6
JG
6
7I. INTRODUCTION
8
9This collection of M4 macros is meant to help in pre-processing texinfo
10files to allow configuring them by hosts; for example, the reader of an
11as manual who only has access to a 386 may not really want to see crud about
12VAXen.
13
14A preprocessor is used, rather than extending texinfo, because this
15way we can hack the conditionals in only one place; otherwise we would
16have to write TeX macros, update makeinfo, and update the Emacs
17info-formatting functions.
18
19II. COMPATIBILITY
20
21These macros should work with GNU m4 and System V m4; they do not work
22with Sun or Berkeley M4.
23
24III. USAGE
25
26A. M4 INVOCATION
27Assume this file is called "pretex.m4". Then, to preprocess a
28document "mybook.texinfo" you might do something like the following:
29
30 m4 pretex.m4 none.m4 PARTIC.m4 mybook.texinfo >mybook-PARTIC.texinfo
31
32---where your path is set to find GNU or SysV "m4", and the other m4
33files mentioned are as follows:
34
35 none.m4: A file that defines, as 0, all the options you might
36 want to turn on using the conditionals defined below.
37 Unlike the C preprocessor, m4 does not default
38 undefined macros to 0. For example, here is a "none.m4"
39 I have been using:
40 _divert__(-1)
41
42 _define__(<_ALL_ARCH__>,<0>)
43 _define__(<_INTERNALS__>,<0>)
44
45 _define__(<_AMD29K__>,<0>)
46 _define__(<_I80386__>,<0>)
47 _define__(<_I960__>,<0>)
48 _define__(<_M680X0__>,<0>)
49 _define__(<_SPARC__>,<0>)
50 _define__(<_VAX__>,<0>)
51
52 _divert__<>
53
54 PARTIC.m4: A file that turns on whichever options you actually
55 want the manual configured for, in this particular
56 instance. Its contents are similar to one or more of
57 the lines in "none.m4", but of course the second
58 argument to _define__ is <1> rather than <0>.
59
92d30360 60 This is also a convenient place to _define__ any macros
07d021a6
JG
61 that you want to expand to different text for
62 different configurations---for example, the name of
63 the program being described.
64
65Naturally, these are just suggested conventions; you could put your macro
66definitions in any files or combinations of files you like.
67
68These macros use the characters < and > as m4 quotes; if you need
69these characters in your text, you will also want to use the macros
70_0__ and _1__ from this package---see the description of "Quote
71Handling" in the "Implementation" section below.
72
73B. WHAT GOES IN THE PRE-TEXINFO SOURCE
74
75For the most part, the text of your book. In addition, you can
92d30360 76have text that is included only conditionally, using the macros
07d021a6
JG
77_if__ and _fi__ defined below. They BOTH take an argument! This is
78primarily meant for readability (so a human can more easily see what
79conditional end matches what conditional beginning), but the argument
80is actually used in the _fi__ as well as the _if__ implementation.
81You should always give a _fi__ the same argument as its matching
82_if__. Other arguments may appear to work for a while, but are almost
83certain to produce the wrong output for some configurations.
84
85For example, here is an excerpt from the very beginning of the
86documentation for GNU as, to name the info file appropriately for
87different configurations:
88 _if__(_ALL_ARCH__)
89 @setfilename as.info
90 _fi__(_ALL_ARCH__)
91 _if__(_M680X0__ && !_ALL_ARCH__)
92 @setfilename as-m680x0.info
93 _fi__(_M680X0__ && !_ALL_ARCH__)
94 _if__(_AMD29K__ && !_ALL_ARCH__)
95 @setfilename as-29k.info
96 _fi__(_AMD29K__ && !_ALL_ARCH__)
97
98Note that you can use Boolean expressions in the arguments; the
92d30360 99expression language is that of the built-in m4 macro `eval', described
07d021a6
JG
100in the m4 manual.
101
102IV. IMPLEMENTATION
103
104A.PRIMITIVE RENAMING
105First, we redefine m4's built-ins to avoid conflict with plain text.
106The naming convention used is that our macros all begin with a single
107underbar and end with two underbars. The asymmetry is meant to avoid
108conflict with some other conventions (which we may want to document) that
109are intended to avoid conflict, like ANSI C predefined macros.
110
111define(`_undefine__',defn(`undefine'))
112define(`_define__',defn(`define'))
113define(`_defn__',defn(`defn'))
114define(`_ppf__',`_define__(`_$1__',_defn__(`$1'))_undefine__(`$1')')
115_ppf__(`builtin')
116_ppf__(`changecom')
117_ppf__(`changequote')
118_ppf__(`decr')
119_ppf__(`define')
120_ppf__(`defn')
121_ppf__(`divert')
9bcc06ef 122_ppf__(`divnum')
07d021a6
JG
123_ppf__(`dnl')
124_ppf__(`dumpdef')
125_ppf__(`errprint')
9bcc06ef 126_ppf__(`esyscmd')
07d021a6 127_ppf__(`eval')
9bcc06ef 128_ppf__(`format')
07d021a6
JG
129_ppf__(`ifdef')
130_ppf__(`ifelse')
131_ppf__(`include')
132_ppf__(`incr')
133_ppf__(`index')
134_ppf__(`len')
135_ppf__(`m4exit')
136_ppf__(`m4wrap')
137_ppf__(`maketemp')
9bcc06ef 138_ppf__(`patsubst')
07d021a6
JG
139_ppf__(`popdef')
140_ppf__(`pushdef')
92d30360 141_ppf__(`regexp')
07d021a6
JG
142_ppf__(`shift')
143_ppf__(`sinclude')
144_ppf__(`substr')
145_ppf__(`syscmd')
146_ppf__(`sysval')
147_ppf__(`traceoff')
148_ppf__(`traceon')
149_ppf__(`translit')
150_ppf__(`undefine')
151_ppf__(`undivert')
9bcc06ef 152_ppf__(`unix')
07d021a6
JG
153
154B. QUOTE HANDLING.
155
156The characters used as quotes by M4, by default, are unfortunately
157quite likely to occur in ordinary text. To avoid surprises, we will
158use the characters <> ---which are just as suggestive (more so to
159Francophones, perhaps) but a little less common in text (save for
160those poor Francophones. You win some, you lose some). Still, we
161expect also to have to set < and > occasionally in text; to do that,
162we define a macro to turn off quote handling (_0__) and a macro to
163turn it back on (_1__), according to our convention.
164
165 BEWARE: This seems to make < and > unusable as relational operations
166 in calls to the builtin "eval". So far I've gotten
167 along without; but a better choice may be possible.
168
169Note that we postponed this for a while, for convenience in discussing
170the issue and in the primitive renaming---not to mention in defining
171_0__ and _1__ themselves! However, the quote redefinitions MUST
172precede the _if__ / _fi__ definitions, because M4 will expand the text
173as given---if we use the wrong quotes here, we will get the wrong
174quotes when we use the conditionals.
175
176_define__(_0__,`_changequote__(\ 1,\ 2)')_define__(_1__,`_changequote__(<,>)')
177_1__
178
179C. CONDITIONALS
180
181We define two macros, _if__ and _fi__. BOTH take arguments! This is
182meant both to help the human reader match up a _fi__ with its
183corresponding _if__ and to aid in the implementation. You may use the
184full expression syntax supported by M4 (see docn of `eval' builtin in
185the m4 manual).
186
187The conditional macros are carefully defined to avoid introducing
188extra whitespace (i.e., blank lines or blank characters). One side
189effect exists---
190
191 BEWARE: text following an `_if__' on the same line is
192 DISCARDED even if the condition is true; text
193 following a `_fi__' on the same line is also
194 always discarded.
195
196The recommended convention is to always place _if__ and _fi__ on a
197line by themselves. This will also aid the human reader. TeX won't
198care about the line breaks; as for info, you may want to insert calls
199to `@refill' at the end of paragraphs containing conditionalized text,
200where you don't want line breaks separating unconditional from
201conditional text. info formatting will then give you nice looking
202paragraphs in the info file.
203
204Nesting: conditionals are designed to nest, in the following way:
205*nothing* is output between an outer pair of false conditionals, even
206if there are true conditionals inside. A false conditional "defeats"
207all conditionals within it. The counter _IF_FS__ is used to
208implement this; kindly avoid redefining it directly.
209
210_define__(<_IF_FS__>,<0>)
9bcc06ef
RP
211
212NOTE: The definitions for our "pushf" and "popf" macros use eval
213rather than incr and decr, because GNU m4 (0.75) tries to call eval
214for us when we say "incr" or "decr"---but doesn't notice we've changed
215eval's name.
216
07d021a6
JG
217_define__(
218 <_pushf__>,
219 <_define__(<_IF_FS__>,
9bcc06ef 220 _eval__((_IF_FS__)+1))>)
07d021a6
JG
221_define__(
222 <_popf__>,
223 <_ifelse__(0,_IF_FS__,
224 <<>_dnl__<>>,
9bcc06ef 225 <_define__(<_IF_FS__>,_eval__((_IF_FS__)-1))>)>)
07d021a6
JG
226
227_define__(
228 <_if__>,
229 <_ifelse__(1,_eval__( ($1) ),
230 <<>_dnl__<>>,
231 <_pushf__<>_divert__(-1)>)>)
232_define__(
233 <_fi__>,
234 <_ifelse__(1,_eval__( ($1) ),
235 <<>_dnl__<>>,
236 <_popf__<>_ifelse__(0,_IF_FS__,
237 <_divert__<>_dnl__<>>,<>)>)>)
238
239D. CHAPTER/SECTION MACRO
240In a parametrized manual, the heading level may need to be calculated;
241for example, a manual that has a chapter on machine dependencies
242should be conditionally structured as follows:
243 - IF the manual is configured for a SINGLE machine type, use
244the chapter heading for that machine type, and run headings down
245from there (top level for a particular machine is chapter, then within
246that we have section, subsection etc);
247 - ELSE, if MANY machine types are described in the chapter,
248use a generic chapter heading such as "@chapter Machine Dependencies",
249use "section" for the top level description of EACH machine, and run
250headings down from there (top level for a particular machine is
251section, then within that we have subsection, subsubsection etc).
252
253The macro <_CHAPSEC__> is for this purpose: its argument is evaluated (so
254you can construct expressions to express choices such as above), then
255expands as follows:
256 0: @chapter
257 1: @section
258 2: @subsection
259 3: @subsubsection
260 ...and so on.
261
262_define__(<_CHAPSEC__>,<@_cs__(_eval__($1))>)
263_define__(<_cs__>,<_ifelse__(
264 0, $1, <chapter>,
265 1, $1, <section>,
266 <sub<>_cs__(_eval__($1 - 1))>)>)
267
268_divert__<>_dnl__<>
This page took 0.068563 seconds and 4 git commands to generate.