1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE erlref SYSTEM "erlref.dtd">
3
4<erlref>
5  <header>
6    <copyright>
7      <year>1996</year>
8      <year>2020</year>
9      <holder>Ericsson AB, All Rights Reserved</holder>
10    </copyright>
11    <legalnotice>
12  Licensed under the Apache License, Version 2.0 (the "License");
13  you may not use this file except in compliance with the License.
14  You may obtain a copy of the License at
15
16      http://www.apache.org/licenses/LICENSE-2.0
17
18  Unless required by applicable law or agreed to in writing, software
19  distributed under the License is distributed on an "AS IS" BASIS,
20  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  See the License for the specific language governing permissions and
22  limitations under the License.
23
24  The Initial Developer of the Original Code is Ericsson AB.
25    </legalnotice>
26
27    <title>make</title>
28    <prepared></prepared>
29    <docno></docno>
30    <date></date>
31    <rev></rev>
32  </header>
33  <module since="">make</module>
34  <modulesummary>A Make Utility for Erlang</modulesummary>
35  <description>
36    <p>The module <c>make</c> provides a set of functions similar to
37      the UNIX type <c>Make</c> functions.</p>
38  </description>
39  <funcs>
40    <func>
41      <name since="">all() -> up_to_date | error</name>
42      <name since="">all(Options) -> up_to_date | error</name>
43      <fsummary>Compile a set of modules.</fsummary>
44      <type>
45        <v>Options = [Option]</v>
46	<v>&nbsp;Option = noexec | load | netload | {emake, Emake} | &lt;compiler option&gt;</v>
47      </type>
48      <desc>
49      <p>This function determines the set of modules to compile and the
50          compile options to use, by first looking for the <c>emake</c> make
51          option, if not present reads the configuration from a file named
52          <c>Emakefile</c> (see below). If no such file is found, the
53          set of modules to compile defaults to all modules in the
54          current working directory.</p>
55        <p>Traversing the set of modules, it then recompiles every module for
56          which at least one of the following conditions apply:</p>
57        <list type="bulleted">
58          <item>there is no object file, or</item>
59          <item>the source file has been modified since it was last compiled,
60           or,</item>
61          <item>an include file has been modified since the source file was
62           last compiled.</item>
63        </list>
64        <p>As a side effect, the function prints the name of each module it
65          tries to compile. If compilation fails for a module, the make
66          procedure stops and <c>error</c> is returned.</p>
67        <p><c>Options</c> is a list of make- and compiler options.
68          The following make options exist:</p>
69        <list type="bulleted">
70          <item><c>noexec</c>          <br></br>
71
72           No execution mode. Just prints the name of each module that needs
73           to be compiled.</item>
74          <item><c>load</c>          <br></br>
75
76           Load mode. Loads all recompiled modules.</item>
77          <item><c>netload</c>          <br></br>
78
79           Net load mode. Loads all recompiled modules on all known nodes.</item>
80          <item><c>{emake, Emake}</c>          <br></br>
81
82           Rather than reading the <c>Emakefile</c> specify configuration explicitly.</item>
83        </list>
84        <p>All items in <c>Options</c> that are not make options are assumed
85          to be compiler options and are passed as-is to
86          <c>compile:file/2</c>. <c>Options</c> defaults to <c>[]</c>.</p>
87      </desc>
88    </func>
89    <func>
90      <name since="">files(ModFiles) -> up_to_date | error</name>
91      <name since="">files(ModFiles, Options) -> up_to_date | error</name>
92      <fsummary>Compile a set of modules.</fsummary>
93      <type>
94        <v>ModFiles = [Module | File]</v>
95        <v>&nbsp;Module = atom()</v>
96        <v>&nbsp;File = string()</v>
97        <v>Options = [Option]</v>
98        <v>&nbsp;Option = noexec | load | netload | &lt;compiler option&gt;</v>
99      </type>
100      <desc>
101        <p><c>files/1,2</c> does exactly the same thing as <c>all/0,1</c> but
102          for the specified <c>ModFiles</c>, which is a list of module or
103          file names. The file extension <c>.erl</c> may be omitted.</p>
104        <p>The <c>Emakefile</c> (if it exists) in the current
105          directory is searched for compiler options for each module. If
106          a given module does not exist in <c>Emakefile</c> or if
107          <c>Emakefile</c> does not exist, the module is still compiled.</p>
108      </desc>
109    </func>
110  </funcs>
111
112  <section>
113    <title>Emakefile</title>
114    <p><c>make:all/0,1</c> and <c>make:files/1,2</c> first looks for
115      <c>{emake, Emake}</c> in options, then in the current working directory
116      for a file named <c>Emakefile</c>. If present <c>Emake</c> should
117      contain elements like this:</p>
118    <code type="none">
119Modules.
120{Modules,Options}.    </code>
121    <p><c>Modules</c> is an atom or a list of atoms. It can be
122      </p>
123    <list type="bulleted">
124      <item>a module name, e.g. <c>file1</c></item>
125      <item>a module name in another directory,
126       e.g. <c>../foo/file3</c></item>
127      <item>a set of modules specified with a wildcards,
128       e.g. <c>'file*'</c></item>
129      <item>a wildcard indicating all modules in current directory,
130       i.e. <c>'*'</c></item>
131      <item>a list of any of the above,
132       e.g. <c>['file*','../foo/file3','File4']</c></item>
133    </list>
134    <p><c>Options</c> is a list of compiler options.
135      </p>
136    <p><c>Emakefile</c> is read from top to bottom. If a module
137      matches more than one entry, the first match is valid. For
138      example, the following <c>Emakefile</c> means that <c>file1</c>
139      shall be compiled with the options
140      <c>[debug_info,{i,"../foo"}]</c>, while all other files in the
141      current directory shall be compiled with only the
142      <c>debug_info</c> flag.</p>
143    <code type="none">
144{'file1',[debug_info,{i,"../foo"}]}.
145{'*',[debug_info]}.    </code>
146    <p></p>
147  </section>
148
149  <section>
150    <title>See Also</title>
151    <p><seealso marker="compiler:compile"><c>compile(3)</c></seealso></p>
152  </section>
153</erlref>
154
155