aboutsummaryrefslogtreecommitdiffstats
path: root/erts/doc/src/erlc.xml
blob: 2df026aef59705a24e8a4e91b76c066192e019bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE comref SYSTEM "comref.dtd">

<comref>
  <header>
    <copyright>
      <year>1997</year><year>2013</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.

      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.

    </legalnotice>

    <title>erlc</title>
    <prepared>Bj&ouml;rn Gustavsson</prepared>
    <responsible>Bjarne D&auml;cker</responsible>
    <docno>1</docno>
    <approved>Bjarne D&auml;cker</approved>
    <checked></checked>
    <date>97-03-24</date>
    <rev>A</rev>
    <file>erlc.xml</file>
  </header>
  <com>erlc</com>
  <comsummary>Compiler</comsummary>
  <description>
    <p>The <c><![CDATA[erlc]]></c> program provides a common way to run
      all compilers in the Erlang system.
      Depending on the extension of each input file, <c><![CDATA[erlc]]></c>
      will invoke the appropriate compiler.
      Regardless of which compiler is used, the same flags are used to provide parameters such as include paths and output directory.</p>
    <p>The current working directory, <c>"."</c>, will not be included
    in the code path when running the compiler (to avoid loading
    Beam files from the current working directory that could potentially
    be in conflict with the compiler or Erlang/OTP system used by the
    compiler).</p>
  </description>
  <funcs>
    <func>
      <name>erlc flags file1.ext file2.ext...</name>
      <fsummary>Compile files</fsummary>
      <desc>
        <p><c><![CDATA[Erlc]]></c> compiles one or more files.
          The files must include the extension, for example <c><![CDATA[.erl]]></c>
          for Erlang source code, or <c><![CDATA[.yrl]]></c> for Yecc source code.
          <c><![CDATA[Erlc]]></c> uses the extension to invoke the correct compiler.</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>Generally Useful Flags</title>
    <p>The following flags are supported:
      </p>
    <taglist>
      <tag>-I <em>directory</em></tag>
      <item>
        <p>Instructs the compiler to search for include files in
          the specified directory. When encountering an
          <c><![CDATA[-include]]></c> or <c><![CDATA[-include_lib]]></c> directive, the
          compiler searches for header files in the following
          directories:</p>
        <list type="ordered">
          <item>
            <p><c><![CDATA["."]]></c>, the current working directory of the
              file server;</p>
          </item>
          <item>
            <p>the base name of the compiled file;</p>
          </item>
          <item>
            <p>the directories specified using the <c><![CDATA[-I]]></c> option.
              The directory specified last is searched first.</p>
          </item>
        </list>
      </item>
      <tag>-o <em>directory</em></tag>
      <item>
        <p>The directory where the compiler should place the output files.
          If not specified, output files will be placed in the current working
          directory.</p>
      </item>
      <tag>-D<em>name</em></tag>
      <item>
        <p>Defines a macro.</p>
      </item>
      <tag>-D<em>name</em>=<em>value</em></tag>
      <item>
        <p>Defines a macro with the given value.
          The value can be any Erlang term.
          Depending on the platform, the value may need to be
          quoted if the shell itself interprets certain characters.
          On Unix, terms which contain tuples and list
          must be quoted. Terms which contain spaces
          must be quoted on all platforms.</p>
      </item>
      <tag>-W<em>error</em></tag>
      <item>
        <p>Makes all warnings into errors.</p>
      </item>
      <tag>-W<em>number</em></tag>
      <item>
        <p>Sets warning level to <em>number</em>. Default is <c><![CDATA[1]]></c>.
          Use <c><![CDATA[-W0]]></c> to turn off warnings.</p>
      </item>
      <tag>-W</tag>
      <item>
        <p>Same as <c><![CDATA[-W1]]></c>. Default.</p>
      </item>
      <tag>-v</tag>
      <item>
        <p>Enables verbose output.</p>
      </item>
      <tag>-b <em>output-type</em></tag>
      <item>
        <p>Specifies the type of output file.
          Generally, <em>output-type</em> is the same as the file extension
          of the output file but without the period.
          This option will be ignored by compilers that have a
          a single output format.</p>
      </item>
      <tag>-smp</tag>
      <item>
        <p>Compile using the SMP emulator. This is mainly useful
          for compiling native code, which needs to be compiled with the same
          run-time system that it should be run on.</p>
      </item>
      <tag>-M</tag>
      <item>
        <p>Produces a Makefile rule to track headers dependencies. The
          rule is sent to stdout. No object file is produced.
        </p>
      </item>
      <tag>-MF <em>Makefile</em></tag>
      <item>
        <p>Like the <c><![CDATA[-M]]></c> option above, except that the
          Makefile is written to <em>Makefile</em>. No object
          file is produced.
        </p>
      </item>
      <tag>-MD</tag>
      <item>
        <p>Same as <c><![CDATA[-M -MF <File>.Pbeam]]></c>.
        </p>
      </item>
      <tag>-MT <em>Target</em></tag>
      <item>
        <p>In conjunction with <c><![CDATA[-M]]></c> or
          <c><![CDATA[-MF]]></c>, change the name of the rule emitted
          to <em>Target</em>.
        </p>
      </item>
      <tag>-MQ <em>Target</em></tag>
      <item>
        <p>Like the <c><![CDATA[-MT]]></c> option above, except that
          characters special to make(1) are quoted.
        </p>
      </item>
      <tag>-MP</tag>
      <item>
        <p>In conjunction with <c><![CDATA[-M]]></c> or
          <c><![CDATA[-MF]]></c>, add a phony target for each dependency.
        </p>
      </item>
      <tag>-MG</tag>
      <item>
        <p>In conjunction with <c><![CDATA[-M]]></c> or
          <c><![CDATA[-MF]]></c>, consider missing headers as generated
          files and add them to the dependencies.
        </p>
      </item>
      <tag>--</tag>
      <item>
        <p>Signals that no more options will follow.
          The rest of the arguments will be treated as file names,
          even if they start with hyphens.</p>
      </item>
      <tag>+<em>term</em></tag>
      <item>
        <p>A flag starting with a plus ('<em>+</em>') rather than a hyphen
          will be converted to an Erlang term and passed unchanged to
          the compiler.
          For instance, the <c><![CDATA[export_all]]></c> option for the Erlang
          compiler can be specified as follows:</p>
        <pre>
erlc +export_all file.erl</pre>
        <p>Depending on the platform, the value may need to be
          quoted if the shell itself interprets certain characters.
          On Unix, terms which contain tuples and list
          must be quoted. Terms which contain spaces
          must be quoted on all platforms.</p>
      </item>
    </taglist>
  </section>

  <section>
    <title>Special Flags</title>
    <p>The flags in this section are useful in special situations
      such as re-building the OTP system.</p>
    <taglist>
      <tag>-pa <em>directory</em></tag>
      <item>
        <p>Appends <em>directory</em> to the front of the code path in
          the invoked Erlang emulator.
          This can be used to invoke another
          compiler than the default one.</p>
      </item>
      <tag>-pz <em>directory</em></tag>
      <item>
        <p>Appends <em>directory</em> to the code path in
          the invoked Erlang emulator.</p>
      </item>
    </taglist>
  </section>

  <section>
    <title>Supported Compilers</title>
    <taglist>
      <tag>.erl</tag>
      <item>
        <p>Erlang source code. It generates a <c><![CDATA[.beam]]></c> file.</p>
        <p>The options -P, -E, and -S are equivalent to +'P',
          +'E', and +'S', except that it is not necessary to include the single quotes to protect them
          from the shell.</p>
        <p>Supported options: -I, -o, -D, -v, -W, -b.</p>
      </item>
      <tag>.S</tag>
      <item>
        <p>Erlang assembler source code. It generates a <c><![CDATA[.beam]]></c> file.</p>
        <p>Supported options: same as for .erl.</p>
      </item>
      <tag>.yrl</tag>
      <item>
        <p>Yecc source code. It generates an <c><![CDATA[.erl]]></c> file.</p>
        <p>Use the -I option with the name of a file to use that file
          as a customized prologue file (the <c><![CDATA[includefile]]></c> option).</p>
        <p>Supported options: -o, -v, -I, -W (see above).</p>
      </item>
      <tag>.mib</tag>
      <item>
        <p>MIB for SNMP. It generates a <c><![CDATA[.bin]]></c> file.</p>
        <p>Supported options: -I, -o, -W.</p>
      </item>
      <tag>.bin</tag>
      <item>
        <p>A compiled MIB for SNMP. It generates a <c><![CDATA[.hrl]]></c> file.</p>
        <p>Supported options: -o, -v.</p>
      </item>
      <tag>.rel</tag>
      <item>
        <p>Script file. It generates a boot file.</p>
        <p>Use the -I to name directories to be searched for application
          files (equivalent to the <c><![CDATA[path]]></c> in the option list for
          <c><![CDATA[systools:make_script/2]]></c>).</p>
        <p>Supported options: -o.</p>
      </item>
      <tag>.asn1</tag>
      <item>
        <p>ASN1 file.</p>
        <p>Creates an <c><![CDATA[.erl]]></c>, <c><![CDATA[.hrl]]></c>, and <c><![CDATA[.asn1db]]></c> file from
          an <c><![CDATA[.asn1]]></c> file. Also compiles the <c><![CDATA[.erl]]></c> using the Erlang
          compiler unless the <c><![CDATA[+noobj]]></c> options is given.</p>
        <p>Supported options: -I, -o, -b, -W.</p>
      </item>
      <tag>.idl</tag>
      <item>
        <p>IC file.</p>
        <p>Runs the IDL compiler.</p>
        <p>Supported options: -I, -o.</p>
      </item>
    </taglist>
  </section>

  <section>
    <title>Environment Variables</title>
    <taglist>
      <tag>ERLC_EMULATOR</tag>
      <item>The command for starting the emulator.
       Default is <em>erl</em> in the same directory as the <em>erlc</em> program
       itself, or if it doesn't exist, <em>erl</em> in any of the directories
       given in the <em>PATH</em> environment variable.</item>
    </taglist>
  </section>

  <section>
    <title>SEE ALSO</title>
    <p><seealso marker="erl">erl(1)</seealso>,
      <seealso marker="compiler:compile">compile(3)</seealso>,
      <seealso marker="parsetools:yecc">yecc(3)</seealso>,
      <seealso marker="snmp:snmp">snmp(3)</seealso></p>
  </section>
</comref>