• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/gcc/
1<html lang="en">
2<head>
3<title>Spec Files - Using the GNU Compiler Collection (GCC)</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Using the GNU Compiler Collection (GCC)">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC">
9<link rel="prev" href="Directory-Options.html#Directory-Options" title="Directory Options">
10<link rel="next" href="Target-Options.html#Target-Options" title="Target Options">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988-2013 Free Software Foundation, Inc.
14
15Permission is granted to copy, distribute and/or modify this document
16under the terms of the GNU Free Documentation License, Version 1.3 or
17any later version published by the Free Software Foundation; with the
18Invariant Sections being ``Funding Free Software'', the Front-Cover
19Texts being (a) (see below), and with the Back-Cover Texts being (b)
20(see below).  A copy of the license is included in the section entitled
21``GNU Free Documentation License''.
22
23(a) The FSF's Front-Cover Text is:
24
25     A GNU Manual
26
27(b) The FSF's Back-Cover Text is:
28
29     You have freedom to copy and modify this GNU Manual, like GNU
30     software.  Copies published by the Free Software Foundation raise
31     funds for GNU development.-->
32<meta http-equiv="Content-Style-Type" content="text/css">
33<style type="text/css"><!--
34  pre.display { font-family:inherit }
35  pre.format  { font-family:inherit }
36  pre.smalldisplay { font-family:inherit; font-size:smaller }
37  pre.smallformat  { font-family:inherit; font-size:smaller }
38  pre.smallexample { font-size:smaller }
39  pre.smalllisp    { font-size:smaller }
40  span.sc    { font-variant:small-caps }
41  span.roman { font-family:serif; font-weight:normal; } 
42  span.sansserif { font-family:sans-serif; font-weight:normal; } 
43--></style>
44<link rel="stylesheet" type="text/css" href="../cs.css">
45</head>
46<body>
47<div class="node">
48<a name="Spec-Files"></a>
49<p>
50Next:&nbsp;<a rel="next" accesskey="n" href="Target-Options.html#Target-Options">Target Options</a>,
51Previous:&nbsp;<a rel="previous" accesskey="p" href="Directory-Options.html#Directory-Options">Directory Options</a>,
52Up:&nbsp;<a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a>
53<hr>
54</div>
55
56<h3 class="section">3.15 Specifying subprocesses and the switches to pass to them</h3>
57
58<p><a name="index-Spec-Files-1066"></a>
59<samp><span class="command">gcc</span></samp> is a driver program.  It performs its job by invoking a
60sequence of other programs to do the work of compiling, assembling and
61linking.  GCC interprets its command-line parameters and uses these to
62deduce which programs it should invoke, and which command-line options
63it ought to place on their command lines.  This behavior is controlled
64by <dfn>spec strings</dfn>.  In most cases there is one spec string for each
65program that GCC can invoke, but a few programs have multiple spec
66strings to control their behavior.  The spec strings built into GCC can
67be overridden by using the <samp><span class="option">-specs=</span></samp> command-line switch to specify
68a spec file.
69
70 <p><dfn>Spec files</dfn> are plaintext files that are used to construct spec
71strings.  They consist of a sequence of directives separated by blank
72lines.  The type of directive is determined by the first non-whitespace
73character on the line, which can be one of the following:
74
75     <dl>
76<dt><code>%</code><var>command</var><dd>Issues a <var>command</var> to the spec file processor.  The commands that can
77appear here are:
78
79          <dl>
80<dt><code>%include &lt;</code><var>file</var><code>&gt;</code><dd><a name="index-g_t_0040code_007b_0025include_007d-1067"></a>Search for <var>file</var> and insert its text at the current point in the
81specs file.
82
83          <br><dt><code>%include_noerr &lt;</code><var>file</var><code>&gt;</code><dd><a name="index-g_t_0040code_007b_0025include_005fnoerr_007d-1068"></a>Just like &lsquo;<samp><span class="samp">%include</span></samp>&rsquo;, but do not generate an error message if the include
84file cannot be found.
85
86          <br><dt><code>%rename </code><var>old_name</var> <var>new_name</var><dd><a name="index-g_t_0040code_007b_0025rename_007d-1069"></a>Rename the spec string <var>old_name</var> to <var>new_name</var>.
87
88     </dl>
89
90     <br><dt><code>*[</code><var>spec_name</var><code>]:</code><dd>This tells the compiler to create, override or delete the named spec
91string.  All lines after this directive up to the next directive or
92blank line are considered to be the text for the spec string.  If this
93results in an empty string then the spec is deleted.  (Or, if the
94spec did not exist, then nothing happens.)  Otherwise, if the spec
95does not currently exist a new spec is created.  If the spec does
96exist then its contents are overridden by the text of this
97directive, unless the first character of that text is the &lsquo;<samp><span class="samp">+</span></samp>&rsquo;
98character, in which case the text is appended to the spec.
99
100     <br><dt><code>[</code><var>suffix</var><code>]:</code><dd>Creates a new &lsquo;<samp><span class="samp">[</span><var>suffix</var><span class="samp">] spec</span></samp>&rsquo; pair.  All lines after this directive
101and up to the next directive or blank line are considered to make up the
102spec string for the indicated suffix.  When the compiler encounters an
103input file with the named suffix, it processes the spec string in
104order to work out how to compile that file.  For example:
105
106     <pre class="smallexample">          .ZZ:
107          z-compile -input %i
108</pre>
109     <p>This says that any input file whose name ends in &lsquo;<samp><span class="samp">.ZZ</span></samp>&rsquo; should be
110passed to the program &lsquo;<samp><span class="samp">z-compile</span></samp>&rsquo;, which should be invoked with the
111command-line switch <samp><span class="option">-input</span></samp> and with the result of performing the
112&lsquo;<samp><span class="samp">%i</span></samp>&rsquo; substitution.  (See below.)
113
114     <p>As an alternative to providing a spec string, the text following a
115suffix directive can be one of the following:
116
117          <dl>
118<dt><code>@</code><var>language</var><dd>This says that the suffix is an alias for a known <var>language</var>.  This is
119similar to using the <samp><span class="option">-x</span></samp> command-line switch to GCC to specify a
120language explicitly.  For example:
121
122          <pre class="smallexample">               .ZZ:
123               @c++
124</pre>
125          <p>Says that .ZZ files are, in fact, C++ source files.
126
127          <br><dt><code>#</code><var>name</var><dd>This causes an error messages saying:
128
129          <pre class="smallexample">               <var>name</var> compiler not installed on this system.
130</pre>
131          </dl>
132
133     <p>GCC already has an extensive list of suffixes built into it. 
134This directive adds an entry to the end of the list of suffixes, but
135since the list is searched from the end backwards, it is effectively
136possible to override earlier entries using this technique.
137
138 </dl>
139
140 <p>GCC has the following spec strings built into it.  Spec files can
141override these strings or create their own.  Note that individual
142targets can also add their own spec strings to this list.
143
144<pre class="smallexample">     asm          Options to pass to the assembler
145     asm_final    Options to pass to the assembler post-processor
146     cpp          Options to pass to the C preprocessor
147     cc1          Options to pass to the C compiler
148     cc1plus      Options to pass to the C++ compiler
149     endfile      Object files to include at the end of the link
150     link         Options to pass to the linker
151     lib          Libraries to include on the command line to the linker
152     libgcc       Decides which GCC support library to pass to the linker
153     linker       Sets the name of the linker
154     predefines   Defines to be passed to the C preprocessor
155     signed_char  Defines to pass to CPP to say whether <code>char</code> is signed
156                  by default
157     startfile    Object files to include at the start of the link
158</pre>
159 <p>Here is a small example of a spec file:
160
161<pre class="smallexample">     %rename lib                 old_lib
162     
163     *lib:
164     --start-group -lgcc -lc -leval1 --end-group %(old_lib)
165</pre>
166 <p>This example renames the spec called &lsquo;<samp><span class="samp">lib</span></samp>&rsquo; to &lsquo;<samp><span class="samp">old_lib</span></samp>&rsquo; and
167then overrides the previous definition of &lsquo;<samp><span class="samp">lib</span></samp>&rsquo; with a new one. 
168The new definition adds in some extra command-line options before
169including the text of the old definition.
170
171 <p><dfn>Spec strings</dfn> are a list of command-line options to be passed to their
172corresponding program.  In addition, the spec strings can contain
173&lsquo;<samp><span class="samp">%</span></samp>&rsquo;-prefixed sequences to substitute variable text or to
174conditionally insert text into the command line.  Using these constructs
175it is possible to generate quite complex command lines.
176
177 <p>Here is a table of all defined &lsquo;<samp><span class="samp">%</span></samp>&rsquo;-sequences for spec
178strings.  Note that spaces are not generated automatically around the
179results of expanding these sequences.  Therefore you can concatenate them
180together or combine them with constant text in a single argument.
181
182     <dl>
183<dt><code>%%</code><dd>Substitute one &lsquo;<samp><span class="samp">%</span></samp>&rsquo; into the program name or argument.
184
185     <br><dt><code>%i</code><dd>Substitute the name of the input file being processed.
186
187     <br><dt><code>%b</code><dd>Substitute the basename of the input file being processed. 
188This is the substring up to (and not including) the last period
189and not including the directory.
190
191     <br><dt><code>%B</code><dd>This is the same as &lsquo;<samp><span class="samp">%b</span></samp>&rsquo;, but include the file suffix (text after
192the last period).
193
194     <br><dt><code>%d</code><dd>Marks the argument containing or following the &lsquo;<samp><span class="samp">%d</span></samp>&rsquo; as a
195temporary file name, so that that file is deleted if GCC exits
196successfully.  Unlike &lsquo;<samp><span class="samp">%g</span></samp>&rsquo;, this contributes no text to the
197argument.
198
199     <br><dt><code>%g</code><var>suffix</var><dd>Substitute a file name that has suffix <var>suffix</var> and is chosen
200once per compilation, and mark the argument in the same way as
201&lsquo;<samp><span class="samp">%d</span></samp>&rsquo;.  To reduce exposure to denial-of-service attacks, the file
202name is now chosen in a way that is hard to predict even when previously
203chosen file names are known.  For example, &lsquo;<samp><span class="samp">%g.s ... %g.o ... %g.s</span></samp>&rsquo;
204might turn into &lsquo;<samp><span class="samp">ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s</span></samp>&rsquo;.  <var>suffix</var> matches
205the regexp &lsquo;<samp><span class="samp">[.A-Za-z]*</span></samp>&rsquo; or the special string &lsquo;<samp><span class="samp">%O</span></samp>&rsquo;, which is
206treated exactly as if &lsquo;<samp><span class="samp">%O</span></samp>&rsquo; had been preprocessed.  Previously, &lsquo;<samp><span class="samp">%g</span></samp>&rsquo;
207was simply substituted with a file name chosen once per compilation,
208without regard to any appended suffix (which was therefore treated
209just like ordinary text), making such attacks more likely to succeed.
210
211     <br><dt><code>%u</code><var>suffix</var><dd>Like &lsquo;<samp><span class="samp">%g</span></samp>&rsquo;, but generates a new temporary file name
212each time it appears instead of once per compilation.
213
214     <br><dt><code>%U</code><var>suffix</var><dd>Substitutes the last file name generated with &lsquo;<samp><span class="samp">%u</span><var>suffix</var></samp>&rsquo;, generating a
215new one if there is no such last file name.  In the absence of any
216&lsquo;<samp><span class="samp">%u</span><var>suffix</var></samp>&rsquo;, this is just like &lsquo;<samp><span class="samp">%g</span><var>suffix</var></samp>&rsquo;, except they don't share
217the same suffix <em>space</em>, so &lsquo;<samp><span class="samp">%g.s ... %U.s ... %g.s ... %U.s</span></samp>&rsquo;
218involves the generation of two distinct file names, one
219for each &lsquo;<samp><span class="samp">%g.s</span></samp>&rsquo; and another for each &lsquo;<samp><span class="samp">%U.s</span></samp>&rsquo;.  Previously, &lsquo;<samp><span class="samp">%U</span></samp>&rsquo; was
220simply substituted with a file name chosen for the previous &lsquo;<samp><span class="samp">%u</span></samp>&rsquo;,
221without regard to any appended suffix.
222
223     <br><dt><code>%j</code><var>suffix</var><dd>Substitutes the name of the <code>HOST_BIT_BUCKET</code>, if any, and if it is
224writable, and if <samp><span class="option">-save-temps</span></samp> is not used;
225otherwise, substitute the name
226of a temporary file, just like &lsquo;<samp><span class="samp">%u</span></samp>&rsquo;.  This temporary file is not
227meant for communication between processes, but rather as a junk
228disposal mechanism.
229
230     <br><dt><code>%|</code><var>suffix</var><dt><code>%m</code><var>suffix</var><dd>Like &lsquo;<samp><span class="samp">%g</span></samp>&rsquo;, except if <samp><span class="option">-pipe</span></samp> is in effect.  In that case
231&lsquo;<samp><span class="samp">%|</span></samp>&rsquo; substitutes a single dash and &lsquo;<samp><span class="samp">%m</span></samp>&rsquo; substitutes nothing at
232all.  These are the two most common ways to instruct a program that it
233should read from standard input or write to standard output.  If you
234need something more elaborate you can use an &lsquo;<samp><span class="samp">%{pipe:</span><code>X</code><span class="samp">}</span></samp>&rsquo;
235construct: see for example <samp><span class="file">f/lang-specs.h</span></samp>.
236
237     <br><dt><code>%.</code><var>SUFFIX</var><dd>Substitutes <var>.SUFFIX</var> for the suffixes of a matched switch's args
238when it is subsequently output with &lsquo;<samp><span class="samp">%*</span></samp>&rsquo;.  <var>SUFFIX</var> is
239terminated by the next space or %.
240
241     <br><dt><code>%w</code><dd>Marks the argument containing or following the &lsquo;<samp><span class="samp">%w</span></samp>&rsquo; as the
242designated output file of this compilation.  This puts the argument
243into the sequence of arguments that &lsquo;<samp><span class="samp">%o</span></samp>&rsquo; substitutes.
244
245     <br><dt><code>%o</code><dd>Substitutes the names of all the output files, with spaces
246automatically placed around them.  You should write spaces
247around the &lsquo;<samp><span class="samp">%o</span></samp>&rsquo; as well or the results are undefined. 
248&lsquo;<samp><span class="samp">%o</span></samp>&rsquo; is for use in the specs for running the linker. 
249Input files whose names have no recognized suffix are not compiled
250at all, but they are included among the output files, so they are
251linked.
252
253     <br><dt><code>%O</code><dd>Substitutes the suffix for object files.  Note that this is
254handled specially when it immediately follows &lsquo;<samp><span class="samp">%g, %u, or %U</span></samp>&rsquo;,
255because of the need for those to form complete file names.  The
256handling is such that &lsquo;<samp><span class="samp">%O</span></samp>&rsquo; is treated exactly as if it had already
257been substituted, except that &lsquo;<samp><span class="samp">%g, %u, and %U</span></samp>&rsquo; do not currently
258support additional <var>suffix</var> characters following &lsquo;<samp><span class="samp">%O</span></samp>&rsquo; as they do
259following, for example, &lsquo;<samp><span class="samp">.o</span></samp>&rsquo;.
260
261     <br><dt><code>%p</code><dd>Substitutes the standard macro predefinitions for the
262current target machine.  Use this when running <code>cpp</code>.
263
264     <br><dt><code>%P</code><dd>Like &lsquo;<samp><span class="samp">%p</span></samp>&rsquo;, but puts &lsquo;<samp><span class="samp">__</span></samp>&rsquo; before and after the name of each
265predefined macro, except for macros that start with &lsquo;<samp><span class="samp">__</span></samp>&rsquo; or with
266&lsquo;<samp><span class="samp">_</span><var>L</var></samp>&rsquo;, where <var>L</var> is an uppercase letter.  This is for ISO
267C.
268
269     <br><dt><code>%I</code><dd>Substitute any of <samp><span class="option">-iprefix</span></samp> (made from <samp><span class="env">GCC_EXEC_PREFIX</span></samp>),
270<samp><span class="option">-isysroot</span></samp> (made from <samp><span class="env">TARGET_SYSTEM_ROOT</span></samp>),
271<samp><span class="option">-isystem</span></samp> (made from <samp><span class="env">COMPILER_PATH</span></samp> and <samp><span class="option">-B</span></samp> options)
272and <samp><span class="option">-imultilib</span></samp> as necessary.
273
274     <br><dt><code>%s</code><dd>Current argument is the name of a library or startup file of some sort. 
275Search for that file in a standard list of directories and substitute
276the full name found.  The current working directory is included in the
277list of directories scanned.
278
279     <br><dt><code>%T</code><dd>Current argument is the name of a linker script.  Search for that file
280in the current list of directories to scan for libraries. If the file
281is located insert a <samp><span class="option">--script</span></samp> option into the command line
282followed by the full path name found.  If the file is not found then
283generate an error message.  Note: the current working directory is not
284searched.
285
286     <br><dt><code>%e</code><var>str</var><dd>Print <var>str</var> as an error message.  <var>str</var> is terminated by a newline. 
287Use this when inconsistent options are detected.
288
289     <br><dt><code>%(</code><var>name</var><code>)</code><dd>Substitute the contents of spec string <var>name</var> at this point.
290
291     <br><dt><code>%x{</code><var>option</var><code>}</code><dd>Accumulate an option for &lsquo;<samp><span class="samp">%X</span></samp>&rsquo;.
292
293     <br><dt><code>%X</code><dd>Output the accumulated linker options specified by <samp><span class="option">-Wl</span></samp> or a &lsquo;<samp><span class="samp">%x</span></samp>&rsquo;
294spec string.
295
296     <br><dt><code>%Y</code><dd>Output the accumulated assembler options specified by <samp><span class="option">-Wa</span></samp>.
297
298     <br><dt><code>%Z</code><dd>Output the accumulated preprocessor options specified by <samp><span class="option">-Wp</span></samp>.
299
300     <br><dt><code>%a</code><dd>Process the <code>asm</code> spec.  This is used to compute the
301switches to be passed to the assembler.
302
303     <br><dt><code>%A</code><dd>Process the <code>asm_final</code> spec.  This is a spec string for
304passing switches to an assembler post-processor, if such a program is
305needed.
306
307     <br><dt><code>%l</code><dd>Process the <code>link</code> spec.  This is the spec for computing the
308command line passed to the linker.  Typically it makes use of the
309&lsquo;<samp><span class="samp">%L %G %S %D and %E</span></samp>&rsquo; sequences.
310
311     <br><dt><code>%D</code><dd>Dump out a <samp><span class="option">-L</span></samp> option for each directory that GCC believes might
312contain startup files.  If the target supports multilibs then the
313current multilib directory is prepended to each of these paths.
314
315     <br><dt><code>%L</code><dd>Process the <code>lib</code> spec.  This is a spec string for deciding which
316libraries are included on the command line to the linker.
317
318     <br><dt><code>%G</code><dd>Process the <code>libgcc</code> spec.  This is a spec string for deciding
319which GCC support library is included on the command line to the linker.
320
321     <br><dt><code>%S</code><dd>Process the <code>startfile</code> spec.  This is a spec for deciding which
322object files are the first ones passed to the linker.  Typically
323this might be a file named <samp><span class="file">crt0.o</span></samp>.
324
325     <br><dt><code>%E</code><dd>Process the <code>endfile</code> spec.  This is a spec string that specifies
326the last object files that are passed to the linker.
327
328     <br><dt><code>%C</code><dd>Process the <code>cpp</code> spec.  This is used to construct the arguments
329to be passed to the C preprocessor.
330
331     <br><dt><code>%1</code><dd>Process the <code>cc1</code> spec.  This is used to construct the options to be
332passed to the actual C compiler (&lsquo;<samp><span class="samp">cc1</span></samp>&rsquo;).
333
334     <br><dt><code>%2</code><dd>Process the <code>cc1plus</code> spec.  This is used to construct the options to be
335passed to the actual C++ compiler (&lsquo;<samp><span class="samp">cc1plus</span></samp>&rsquo;).
336
337     <br><dt><code>%*</code><dd>Substitute the variable part of a matched option.  See below. 
338Note that each comma in the substituted string is replaced by
339a single space.
340
341     <br><dt><code>%&lt;S</code><dd>Remove all occurrences of <code>-S</code> from the command line.  Note&mdash;this
342command is position dependent.  &lsquo;<samp><span class="samp">%</span></samp>&rsquo; commands in the spec string
343before this one see <code>-S</code>, &lsquo;<samp><span class="samp">%</span></samp>&rsquo; commands in the spec string
344after this one do not.
345
346     <br><dt><code>%:</code><var>function</var><code>(</code><var>args</var><code>)</code><dd>Call the named function <var>function</var>, passing it <var>args</var>. 
347<var>args</var> is first processed as a nested spec string, then split
348into an argument vector in the usual fashion.  The function returns
349a string which is processed as if it had appeared literally as part
350of the current spec.
351
352     <p>The following built-in spec functions are provided:
353
354          <dl>
355<dt><code>getenv</code><dd>The <code>getenv</code> spec function takes two arguments: an environment
356variable name and a string.  If the environment variable is not
357defined, a fatal error is issued.  Otherwise, the return value is the
358value of the environment variable concatenated with the string.  For
359example, if <samp><span class="env">TOPDIR</span></samp> is defined as <samp><span class="file">/path/to/top</span></samp>, then:
360
361          <pre class="smallexample">               %:getenv(TOPDIR /include)
362</pre>
363          <p>expands to <samp><span class="file">/path/to/top/include</span></samp>.
364
365          <br><dt><code>if-exists</code><dd>The <code>if-exists</code> spec function takes one argument, an absolute
366pathname to a file.  If the file exists, <code>if-exists</code> returns the
367pathname.  Here is a small example of its usage:
368
369          <pre class="smallexample">               *startfile:
370               crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
371</pre>
372          <br><dt><code>if-exists-else</code><dd>The <code>if-exists-else</code> spec function is similar to the <code>if-exists</code>
373spec function, except that it takes two arguments.  The first argument is
374an absolute pathname to a file.  If the file exists, <code>if-exists-else</code>
375returns the pathname.  If it does not exist, it returns the second argument. 
376This way, <code>if-exists-else</code> can be used to select one file or another,
377based on the existence of the first.  Here is a small example of its usage:
378
379          <pre class="smallexample">               *startfile:
380               crt0%O%s %:if-exists(crti%O%s) \
381               %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
382</pre>
383          <br><dt><code>replace-outfile</code><dd>The <code>replace-outfile</code> spec function takes two arguments.  It looks for the
384first argument in the outfiles array and replaces it with the second argument.  Here
385is a small example of its usage:
386
387          <pre class="smallexample">               %{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)}
388</pre>
389          <br><dt><code>remove-outfile</code><dd>The <code>remove-outfile</code> spec function takes one argument.  It looks for the
390first argument in the outfiles array and removes it.  Here is a small example
391its usage:
392
393          <pre class="smallexample">               %:remove-outfile(-lm)
394</pre>
395          <br><dt><code>pass-through-libs</code><dd>The <code>pass-through-libs</code> spec function takes any number of arguments.  It
396finds any <samp><span class="option">-l</span></samp> options and any non-options ending in <samp><span class="file">.a</span></samp> (which it
397assumes are the names of linker input library archive files) and returns a
398result containing all the found arguments each prepended by
399<samp><span class="option">-plugin-opt=-pass-through=</span></samp> and joined by spaces.  This list is
400intended to be passed to the LTO linker plugin.
401
402          <pre class="smallexample">               %:pass-through-libs(%G %L %G)
403</pre>
404          <br><dt><code>print-asm-header</code><dd>The <code>print-asm-header</code> function takes no arguments and simply
405prints a banner like:
406
407          <pre class="smallexample">               Assembler options
408               =================
409               
410               Use "-Wa,OPTION" to pass "OPTION" to the assembler.
411</pre>
412          <p>It is used to separate compiler options from assembler options
413in the <samp><span class="option">--target-help</span></samp> output. 
414</dl>
415
416     <br><dt><code>%{S}</code><dd>Substitutes the <code>-S</code> switch, if that switch is given to GCC. 
417If that switch is not specified, this substitutes nothing.  Note that
418the leading dash is omitted when specifying this option, and it is
419automatically inserted if the substitution is performed.  Thus the spec
420string &lsquo;<samp><span class="samp">%{foo}</span></samp>&rsquo; matches the command-line option <samp><span class="option">-foo</span></samp>
421and outputs the command-line option <samp><span class="option">-foo</span></samp>.
422
423     <br><dt><code>%W{S}</code><dd>Like %{<code>S</code>} but mark last argument supplied within as a file to be
424deleted on failure.
425
426     <br><dt><code>%{S*}</code><dd>Substitutes all the switches specified to GCC whose names start
427with <code>-S</code>, but which also take an argument.  This is used for
428switches like <samp><span class="option">-o</span></samp>, <samp><span class="option">-D</span></samp>, <samp><span class="option">-I</span></samp>, etc. 
429GCC considers <samp><span class="option">-o foo</span></samp> as being
430one switch whose name starts with &lsquo;<samp><span class="samp">o</span></samp>&rsquo;.  %{o*} substitutes this
431text, including the space.  Thus two arguments are generated.
432
433     <br><dt><code>%{S*&amp;T*}</code><dd>Like %{<code>S</code>*}, but preserve order of <code>S</code> and <code>T</code> options
434(the order of <code>S</code> and <code>T</code> in the spec is not significant). 
435There can be any number of ampersand-separated variables; for each the
436wild card is optional.  Useful for CPP as &lsquo;<samp><span class="samp">%{D*&amp;U*&amp;A*}</span></samp>&rsquo;.
437
438     <br><dt><code>%{S:X}</code><dd>Substitutes <code>X</code>, if the <samp><span class="option">-S</span></samp> switch is given to GCC.
439
440     <br><dt><code>%{!S:X}</code><dd>Substitutes <code>X</code>, if the <samp><span class="option">-S</span></samp> switch is <em>not</em> given to GCC.
441
442     <br><dt><code>%{S*:X}</code><dd>Substitutes <code>X</code> if one or more switches whose names start with
443<code>-S</code> are specified to GCC.  Normally <code>X</code> is substituted only
444once, no matter how many such switches appeared.  However, if <code>%*</code>
445appears somewhere in <code>X</code>, then <code>X</code> is substituted once
446for each matching switch, with the <code>%*</code> replaced by the part of
447that switch matching the <code>*</code>.
448
449     <br><dt><code>%{.S:X}</code><dd>Substitutes <code>X</code>, if processing a file with suffix <code>S</code>.
450
451     <br><dt><code>%{!.S:X}</code><dd>Substitutes <code>X</code>, if <em>not</em> processing a file with suffix <code>S</code>.
452
453     <br><dt><code>%{,S:X}</code><dd>Substitutes <code>X</code>, if processing a file for language <code>S</code>.
454
455     <br><dt><code>%{!,S:X}</code><dd>Substitutes <code>X</code>, if not processing a file for language <code>S</code>.
456
457     <br><dt><code>%{S|P:X}</code><dd>Substitutes <code>X</code> if either <code>-S</code> or <code>-P</code> is given to
458GCC.  This may be combined with &lsquo;<samp><span class="samp">!</span></samp>&rsquo;, &lsquo;<samp><span class="samp">.</span></samp>&rsquo;, &lsquo;<samp><span class="samp">,</span></samp>&rsquo;, and
459<code>*</code> sequences as well, although they have a stronger binding than
460the &lsquo;<samp><span class="samp">|</span></samp>&rsquo;.  If <code>%*</code> appears in <code>X</code>, all of the
461alternatives must be starred, and only the first matching alternative
462is substituted.
463
464     <p>For example, a spec string like this:
465
466     <pre class="smallexample">          %{.c:-foo} %{!.c:-bar} %{.c|d:-baz} %{!.c|d:-boggle}
467</pre>
468     <p class="noindent">outputs the following command-line options from the following input
469command-line options:
470
471     <pre class="smallexample">          fred.c        -foo -baz
472          jim.d         -bar -boggle
473          -d fred.c     -foo -baz -boggle
474          -d jim.d      -bar -baz -boggle
475</pre>
476     <br><dt><code>%{S:X; T:Y; :D}</code><dd>
477If <code>S</code> is given to GCC, substitutes <code>X</code>; else if <code>T</code> is
478given to GCC, substitutes <code>Y</code>; else substitutes <code>D</code>.  There can
479be as many clauses as you need.  This may be combined with <code>.</code>,
480<code>,</code>, <code>!</code>, <code>|</code>, and <code>*</code> as needed.
481
482 </dl>
483
484 <p>The conditional text <code>X</code> in a %{<code>S</code>:<code>X</code>} or similar
485construct may contain other nested &lsquo;<samp><span class="samp">%</span></samp>&rsquo; constructs or spaces, or
486even newlines.  They are processed as usual, as described above. 
487Trailing white space in <code>X</code> is ignored.  White space may also
488appear anywhere on the left side of the colon in these constructs,
489except between <code>.</code> or <code>*</code> and the corresponding word.
490
491 <p>The <samp><span class="option">-O</span></samp>, <samp><span class="option">-f</span></samp>, <samp><span class="option">-m</span></samp>, and <samp><span class="option">-W</span></samp> switches are
492handled specifically in these constructs.  If another value of
493<samp><span class="option">-O</span></samp> or the negated form of a <samp><span class="option">-f</span></samp>, <samp><span class="option">-m</span></samp>, or
494<samp><span class="option">-W</span></samp> switch is found later in the command line, the earlier
495switch value is ignored, except with {<code>S</code>*} where <code>S</code> is
496just one letter, which passes all matching options.
497
498 <p>The character &lsquo;<samp><span class="samp">|</span></samp>&rsquo; at the beginning of the predicate text is used to
499indicate that a command should be piped to the following command, but
500only if <samp><span class="option">-pipe</span></samp> is specified.
501
502 <p>It is built into GCC which switches take arguments and which do not. 
503(You might think it would be useful to generalize this to allow each
504compiler's spec to say which switches take arguments.  But this cannot
505be done in a consistent fashion.  GCC cannot even decide which input
506files have been specified without knowing which switches take arguments,
507and it must know which input files to compile in order to tell which
508compilers to run).
509
510 <p>GCC also knows implicitly that arguments starting in <samp><span class="option">-l</span></samp> are to be
511treated as compiler output files, and passed to the linker in their
512proper position among the other output files.
513
514<!-- man begin OPTIONS -->
515 </body></html>
516
517