Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

330 lines
15KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Environment Variables (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="Environment Variables (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="Environment Variables (Using the GNU Compiler Collection (GCC))">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Invoking-GCC.html#Invoking-GCC" rel="up" title="Invoking GCC">
  30. <link href="Precompiled-Headers.html#Precompiled-Headers" rel="next" title="Precompiled Headers">
  31. <link href="Spec-Files.html#Spec-Files" rel="prev" title="Spec Files">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Environment-Variables"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Precompiled-Headers.html#Precompiled-Headers" accesskey="n" rel="next">Precompiled Headers</a>, Previous: <a href="Spec-Files.html#Spec-Files" accesskey="p" rel="prev">Spec Files</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Environment-Variables-Affecting-GCC"></a>
  68. <h3 class="section">3.21 Environment Variables Affecting GCC</h3>
  69. <a name="index-environment-variables"></a>
  70. <p>This section describes several environment variables that affect how GCC
  71. operates. Some of them work by specifying directories or prefixes to use
  72. when searching for various kinds of files. Some are used to specify other
  73. aspects of the compilation environment.
  74. </p>
  75. <p>Note that you can also specify places to search using options such as
  76. <samp>-B</samp>, <samp>-I</samp> and <samp>-L</samp> (see <a href="Directory-Options.html#Directory-Options">Directory Options</a>). These
  77. take precedence over places specified using environment variables, which
  78. in turn take precedence over those specified by the configuration of GCC.
  79. See <a href="http://gcc.gnu.org/onlinedocs/gccint/Driver.html#Driver">Controlling the Compilation Driver <samp>gcc</samp></a> in <cite>GNU Compiler Collection (GCC) Internals</cite>.
  80. </p>
  81. <dl compact="compact">
  82. <dt><code>LANG</code></dt>
  83. <dt><code>LC_CTYPE</code></dt>
  84. <dt><code>LC_MESSAGES</code></dt>
  85. <dt><code>LC_ALL</code></dt>
  86. <dd><a name="index-LANG"></a>
  87. <a name="index-LC_005fCTYPE"></a>
  88. <a name="index-LC_005fMESSAGES"></a>
  89. <a name="index-LC_005fALL"></a>
  90. <a name="index-locale"></a>
  91. <p>These environment variables control the way that GCC uses
  92. localization information which allows GCC to work with different
  93. national conventions. GCC inspects the locale categories
  94. <code>LC_CTYPE</code> and <code>LC_MESSAGES</code> if it has been configured to do
  95. so. These locale categories can be set to any value supported by your
  96. installation. A typical value is &lsquo;<samp>en_GB.UTF-8</samp>&rsquo; for English in the United
  97. Kingdom encoded in UTF-8.
  98. </p>
  99. <p>The <code>LC_CTYPE</code> environment variable specifies character
  100. classification. GCC uses it to determine the character boundaries in
  101. a string; this is needed for some multibyte encodings that contain quote
  102. and escape characters that are otherwise interpreted as a string
  103. end or escape.
  104. </p>
  105. <p>The <code>LC_MESSAGES</code> environment variable specifies the language to
  106. use in diagnostic messages.
  107. </p>
  108. <p>If the <code>LC_ALL</code> environment variable is set, it overrides the value
  109. of <code>LC_CTYPE</code> and <code>LC_MESSAGES</code>; otherwise, <code>LC_CTYPE</code>
  110. and <code>LC_MESSAGES</code> default to the value of the <code>LANG</code>
  111. environment variable. If none of these variables are set, GCC
  112. defaults to traditional C English behavior.
  113. </p>
  114. </dd>
  115. <dt><code>TMPDIR</code></dt>
  116. <dd><a name="index-TMPDIR"></a>
  117. <p>If <code>TMPDIR</code> is set, it specifies the directory to use for temporary
  118. files. GCC uses temporary files to hold the output of one stage of
  119. compilation which is to be used as input to the next stage: for example,
  120. the output of the preprocessor, which is the input to the compiler
  121. proper.
  122. </p>
  123. </dd>
  124. <dt><code>GCC_COMPARE_DEBUG</code></dt>
  125. <dd><a name="index-GCC_005fCOMPARE_005fDEBUG"></a>
  126. <p>Setting <code>GCC_COMPARE_DEBUG</code> is nearly equivalent to passing
  127. <samp>-fcompare-debug</samp> to the compiler driver. See the documentation
  128. of this option for more details.
  129. </p>
  130. </dd>
  131. <dt><code>GCC_EXEC_PREFIX</code></dt>
  132. <dd><a name="index-GCC_005fEXEC_005fPREFIX"></a>
  133. <p>If <code>GCC_EXEC_PREFIX</code> is set, it specifies a prefix to use in the
  134. names of the subprograms executed by the compiler. No slash is added
  135. when this prefix is combined with the name of a subprogram, but you can
  136. specify a prefix that ends with a slash if you wish.
  137. </p>
  138. <p>If <code>GCC_EXEC_PREFIX</code> is not set, GCC attempts to figure out
  139. an appropriate prefix to use based on the pathname it is invoked with.
  140. </p>
  141. <p>If GCC cannot find the subprogram using the specified prefix, it
  142. tries looking in the usual places for the subprogram.
  143. </p>
  144. <p>The default value of <code>GCC_EXEC_PREFIX</code> is
  145. <samp><var>prefix</var>/lib/gcc/</samp> where <var>prefix</var> is the prefix to
  146. the installed compiler. In many cases <var>prefix</var> is the value
  147. of <code>prefix</code> when you ran the <samp>configure</samp> script.
  148. </p>
  149. <p>Other prefixes specified with <samp>-B</samp> take precedence over this prefix.
  150. </p>
  151. <p>This prefix is also used for finding files such as <samp>crt0.o</samp> that are
  152. used for linking.
  153. </p>
  154. <p>In addition, the prefix is used in an unusual way in finding the
  155. directories to search for header files. For each of the standard
  156. directories whose name normally begins with &lsquo;<samp>/usr/local/lib/gcc</samp>&rsquo;
  157. (more precisely, with the value of <code>GCC_INCLUDE_DIR</code>), GCC tries
  158. replacing that beginning with the specified prefix to produce an
  159. alternate directory name. Thus, with <samp>-Bfoo/</samp>, GCC searches
  160. <samp>foo/bar</samp> just before it searches the standard directory
  161. <samp>/usr/local/lib/bar</samp>.
  162. If a standard directory begins with the configured
  163. <var>prefix</var> then the value of <var>prefix</var> is replaced by
  164. <code>GCC_EXEC_PREFIX</code> when looking for header files.
  165. </p>
  166. </dd>
  167. <dt><code>COMPILER_PATH</code></dt>
  168. <dd><a name="index-COMPILER_005fPATH"></a>
  169. <p>The value of <code>COMPILER_PATH</code> is a colon-separated list of
  170. directories, much like <code>PATH</code>. GCC tries the directories thus
  171. specified when searching for subprograms, if it cannot find the
  172. subprograms using <code>GCC_EXEC_PREFIX</code>.
  173. </p>
  174. </dd>
  175. <dt><code>LIBRARY_PATH</code></dt>
  176. <dd><a name="index-LIBRARY_005fPATH"></a>
  177. <p>The value of <code>LIBRARY_PATH</code> is a colon-separated list of
  178. directories, much like <code>PATH</code>. When configured as a native compiler,
  179. GCC tries the directories thus specified when searching for special
  180. linker files, if it cannot find them using <code>GCC_EXEC_PREFIX</code>. Linking
  181. using GCC also uses these directories when searching for ordinary
  182. libraries for the <samp>-l</samp> option (but directories specified with
  183. <samp>-L</samp> come first).
  184. </p>
  185. </dd>
  186. <dt><code>LANG</code></dt>
  187. <dd><a name="index-LANG-1"></a>
  188. <a name="index-locale-definition"></a>
  189. <p>This variable is used to pass locale information to the compiler. One way in
  190. which this information is used is to determine the character set to be used
  191. when character literals, string literals and comments are parsed in C and C++.
  192. When the compiler is configured to allow multibyte characters,
  193. the following values for <code>LANG</code> are recognized:
  194. </p>
  195. <dl compact="compact">
  196. <dt>&lsquo;<samp>C-JIS</samp>&rsquo;</dt>
  197. <dd><p>Recognize JIS characters.
  198. </p></dd>
  199. <dt>&lsquo;<samp>C-SJIS</samp>&rsquo;</dt>
  200. <dd><p>Recognize SJIS characters.
  201. </p></dd>
  202. <dt>&lsquo;<samp>C-EUCJP</samp>&rsquo;</dt>
  203. <dd><p>Recognize EUCJP characters.
  204. </p></dd>
  205. </dl>
  206. <p>If <code>LANG</code> is not defined, or if it has some other value, then the
  207. compiler uses <code>mblen</code> and <code>mbtowc</code> as defined by the default locale to
  208. recognize and translate multibyte characters.
  209. </p></dd>
  210. </dl>
  211. <p>Some additional environment variables affect the behavior of the
  212. preprocessor.
  213. </p>
  214. <dl compact="compact">
  215. <dt><code>CPATH</code>
  216. <a name="index-CPATH"></a>
  217. </dt>
  218. <dt><code>C_INCLUDE_PATH</code>
  219. <a name="index-C_005fINCLUDE_005fPATH"></a>
  220. </dt>
  221. <dt><code>CPLUS_INCLUDE_PATH</code>
  222. <a name="index-CPLUS_005fINCLUDE_005fPATH"></a>
  223. </dt>
  224. <dt><code>OBJC_INCLUDE_PATH</code>
  225. <a name="index-OBJC_005fINCLUDE_005fPATH"></a>
  226. </dt>
  227. <dd><p>Each variable&rsquo;s value is a list of directories separated by a special
  228. character, much like <code>PATH</code>, in which to look for header files.
  229. The special character, <code>PATH_SEPARATOR</code>, is target-dependent and
  230. determined at GCC build time. For Microsoft Windows-based targets it is a
  231. semicolon, and for almost all other targets it is a colon.
  232. </p>
  233. <p><code>CPATH</code> specifies a list of directories to be searched as if
  234. specified with <samp>-I</samp>, but after any paths given with <samp>-I</samp>
  235. options on the command line. This environment variable is used
  236. regardless of which language is being preprocessed.
  237. </p>
  238. <p>The remaining environment variables apply only when preprocessing the
  239. particular language indicated. Each specifies a list of directories
  240. to be searched as if specified with <samp>-isystem</samp>, but after any
  241. paths given with <samp>-isystem</samp> options on the command line.
  242. </p>
  243. <p>In all these variables, an empty element instructs the compiler to
  244. search its current working directory. Empty elements can appear at the
  245. beginning or end of a path. For instance, if the value of
  246. <code>CPATH</code> is <code>:/special/include</code>, that has the same
  247. effect as &lsquo;<samp><span class="nolinebreak">-I.</span>&nbsp;<span class="nolinebreak">-I/special/include</span><!-- /@w --></samp>&rsquo;.
  248. </p>
  249. </dd>
  250. <dt><code>DEPENDENCIES_OUTPUT</code>
  251. <a name="index-DEPENDENCIES_005fOUTPUT"></a>
  252. </dt>
  253. <dd><a name="index-dependencies-for-make-as-output"></a>
  254. <p>If this variable is set, its value specifies how to output
  255. dependencies for Make based on the non-system header files processed
  256. by the compiler. System header files are ignored in the dependency
  257. output.
  258. </p>
  259. <p>The value of <code>DEPENDENCIES_OUTPUT</code> can be just a file name, in
  260. which case the Make rules are written to that file, guessing the target
  261. name from the source file name. Or the value can have the form
  262. &lsquo;<samp><var>file</var> <var>target</var></samp>&rsquo;, in which case the rules are written to
  263. file <var>file</var> using <var>target</var> as the target name.
  264. </p>
  265. <p>In other words, this environment variable is equivalent to combining
  266. the options <samp>-MM</samp> and <samp>-MF</samp>
  267. (see <a href="Preprocessor-Options.html#Preprocessor-Options">Preprocessor Options</a>),
  268. with an optional <samp>-MT</samp> switch too.
  269. </p>
  270. </dd>
  271. <dt><code>SUNPRO_DEPENDENCIES</code>
  272. <a name="index-SUNPRO_005fDEPENDENCIES"></a>
  273. </dt>
  274. <dd><a name="index-dependencies-for-make-as-output-1"></a>
  275. <p>This variable is the same as <code>DEPENDENCIES_OUTPUT</code> (see above),
  276. except that system header files are not ignored, so it implies
  277. <samp>-M</samp> rather than <samp>-MM</samp>. However, the dependence on the
  278. main input file is omitted.
  279. See <a href="Preprocessor-Options.html#Preprocessor-Options">Preprocessor Options</a>.
  280. </p>
  281. </dd>
  282. <dt><code>SOURCE_DATE_EPOCH</code>
  283. <a name="index-SOURCE_005fDATE_005fEPOCH"></a>
  284. </dt>
  285. <dd><p>If this variable is set, its value specifies a UNIX timestamp to be
  286. used in replacement of the current date and time in the <code>__DATE__</code>
  287. and <code>__TIME__</code> macros, so that the embedded timestamps become
  288. reproducible.
  289. </p>
  290. <p>The value of <code>SOURCE_DATE_EPOCH</code> must be a UNIX timestamp,
  291. defined as the number of seconds (excluding leap seconds) since
  292. 01 Jan 1970 00:00:00 represented in ASCII; identical to the output of
  293. &lsquo;<samp><code>date +%s</code></samp>&rsquo; on GNU/Linux and other systems that support the
  294. <code>%s</code> extension in the <code>date</code> command.
  295. </p>
  296. <p>The value should be a known timestamp such as the last modification
  297. time of the source or package and it should be set by the build
  298. process.
  299. </p>
  300. </dd>
  301. </dl>
  302. <hr>
  303. <div class="header">
  304. <p>
  305. Next: <a href="Precompiled-Headers.html#Precompiled-Headers" accesskey="n" rel="next">Precompiled Headers</a>, Previous: <a href="Spec-Files.html#Spec-Files" accesskey="p" rel="prev">Spec Files</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  306. </div>
  307. </body>
  308. </html>