⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 4 页
字号:
    $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $&lt;.f:    $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $&lt;.sh:    cp $&lt; $@    chmod a+x $@.c~:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.c    $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $*.c.f~:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.f    $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.f.sh~:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.sh    cp $*.sh $@    chmod a+x $@<i>DOUBLE SUFFIX RULES</i>.c.o:    $(CC) $(CFLAGS) -c $&lt;.f.o:    $(FC) $(FFLAGS) -c $&lt;.y.o:    $(YACC) $(YFLAGS) $&lt;    $(CC) $(CFLAGS) -c y.tab.c    rm -f y.tab.c    mv y.tab.o $@.l.o:    $(LEX) $(LFLAGS) $&lt;    $(CC) $(CFLAGS) -c lex.yy.c    rm -f lex.yy.c    mv lex.yy.o $@.y.c:    $(YACC) $(YFLAGS) $&lt;    mv y.tab.c $@.l.c:    $(LEX) $(LFLAGS) $&lt;    mv lex.yy.c $@.c~.o:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.c    $(CC) $(CFLAGS) -c $*.c.f~.o:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.f    $(FC) $(FFLAGS) -c $*.f.y~.o:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.y    $(YACC) $(YFLAGS) $*.y    $(CC) $(CFLAGS) -c y.tab.c    rm -f y.tab.c    mv y.tab.o $@.l~.o:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.l    $(LEX) $(LFLAGS) $*.l    $(CC) $(CFLAGS) -c lex.yy.c    rm -f lex.yy.c    mv lex.yy.o $@.y~.c:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.y    $(YACC) $(YFLAGS) $*.y    mv y.tab.c $@.l~.c:    $(GET) $(GFLAGS) -p $&lt; &gt; $*.l    $(LEX) $(LFLAGS) $*.l    mv lex.yy.c $@.c.a:    $(CC) -c $(CFLAGS) $&lt;    $(AR) $(ARFLAGS) $@ $*.o    rm -f $*.o.f.a:    $(FC) -c $(FFLAGS) $&lt;    $(AR) $(ARFLAGS) $@ $*.o    rm -f $*.o</code></pre></blockquote><h4><a name = "tag_001_014_1378">&nbsp;</a>EXIT STATUS</h4><blockquote>When the<b>-q</b>option is specified, the<i>make</i>utility will exit with one of the following values:<dl compact><dt>0<dd>Successful completion.<dt>1<dd>The target was not up-to-date.<dt>&gt;1<dd>An error occurred.</dl><p>When the<b>-q</b>option is not specified, the<i>make</i>utility will exit with one of the following values:<dl compact><dt>0<dd>successful completion<dt>&gt;0<dd>an error occurred</dl></blockquote><h4><a name = "tag_001_014_1379">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1380">&nbsp;</a>APPLICATION USAGE</h4><blockquote>If there is a source file (such as<b>./source.c</b>)and there are two SCCS files corresponding to it(<b>./s.source.c</b> and<b>./SCCS/s.source.c</b>),<i>make</i>will use the SCCS file in the current directory.However, users are advised to use the underlying SCCS utilities(<i>admin</i>,<i><a href="delta.html">delta</a></i>,<i><a href="get.html">get</a></i>,and so on) or the<i><a href="sccs.html">sccs</a></i>utility for all source files in a given directory.If both forms are used for a given source file,future developers are very likely to be confused.<p>It is incumbent upon portable makefiles to specify the<b>.POSIX</b>special target in order to guarantee that they are not affected by localextensions.<p>The<b>-k</b>and<b>-S</b>options are both present so that therelationship between the command line, the<i>MAKEFLAGS</i>variable, and the makefile can be controlled precisely.If thekflag is passed in<i>MAKEFLAGS</i>and a command is of the form:<pre><code>$(MAKE) -S foo</code></pre>then the default behaviour is restored for the child<i>make</i>.<p>When the<b>-n</b>option is specified, it is always added to<i>MAKEFLAGS .</i>This allows a recursive<i>make</i><b>-n</b><i>target</i>to be used to see all of the action that would be taken to update<i>target</i>.<p>Because of widespread historical practice,interpreting a # number sign inside a variable as the start of a commenthas the unfortunate side effect of making it impossible toplace a number sign in a variable, thus forbidding something like:<pre><code>CFLAGS = "-D COMMENT_CHAR='#'"</code></pre><p>Many historical<i>make</i>utilitiesstop chaining togetherinference rules when an intermediate target is non-existent.For example, it might be possible for a<i>make</i>to determine that both.y.cand.c.ocould be used to convert a.yto a.o.Instead, in this case,<i>make</i>requires the use of a.y.orule.<p>The best way to provide portable makefilesis to include all of the rules needed in the makefile itself.The rules provided use only features provided by other parts of the standard.The default rules include rules for optional commands in the standard.Only rules pertaining to commandsthat are provided are needed in an implementation's default set.<p>Macros used within other macros are evaluated when the new macrois used rather than when the new macro is defined.Therefore:<pre><code>MACRO = <i>value1</i>NEW   = $(MACRO)MACRO = <i>value2</i>target:    echo $(NEW)</code></pre>would produce<i>value2</i>and not<i>value1</i>since<b>NEW</b>was not expanded untilit was needed in the<i><a href="echo.html">echo</a></i>command line.<p>Some historical applicationshave been known to intermix<i>target_name</i>and<i>macro=name</i>operands on the command line,expecting that all of the macros will be processedbefore any of the targets are dealt with.Portable applications do not do this,although some backward compatibility support may be includedin some implementations.<p>The following characters in filenames may give trouble:<pre><code>=   :   `   '   @</code></pre>For inference rules, the description of$&lt;and$?seem similar.However, an example shows the minor difference.In a makefile containing:<pre><code>foo.o: foo.h</code></pre>if<b>foo.h</b>is newer than<b>foo.o</b>,yet<b>foo.c</b>is older than<b>foo.o</b>,the built-in rule to make<b>foo.o</b>from<b>foo.c</b>will be used, with$&lt;equal to<b>foo.c</b>and$?equal to<b>foo.h</b>.If<b>foo.c</b>is also newer than<b>foo.o</b>,$&lt;is equal to<b>foo.c</b>and$?is equal to<b>foo.h foo.c</b>.</blockquote><h4><a name = "tag_001_014_1381">&nbsp;</a>EXAMPLES</h4><blockquote><ol><p><li>The following command:<pre><code>make</code></pre>makes the first target found in the makefile.<p><li>The following command:<pre><code>make junk</code></pre>makes the target<b>junk</b>.<p><li>The following makefile says that <b>pgm</b> depends on two files,<b>a.o</b> and <b>b.o,</b> and that they in turn depend ontheir corresponding source files (<b>a.c</b> and <b>b.c</b>),and a common file <b>incl.h</b>:<pre><code>pgm: a.o b.o      c89 a.o b.o -o pgma.o: incl.h a.c      c89 -c a.cb.o: incl.h b.c      c89 -c b.c</code></pre><p><li>An example for making optimised<b>.o</b>files from<b>.c</b>files is:<pre><code>.c.o:      c89 -c -O $*.c</code></pre><p>or:<pre><code>.c.o:      c89 -c -O $&lt;</code></pre><p><li>The most common use of the archive interface follows.Here, it is assumed that the source files are all C-language source:<pre><code>lib:  lib(file1.o) lib(file2.o) lib(file3.o)      @echo lib is now up-to-date</code></pre><p>The<b>.c.a</b>rule is used to make<b>file1.o</b>,<b>file2.o</b>and<b>file3.o</b>and insert them into<b>lib</b>.<p>The treatment of escaped newline charactersthroughout the makefile is historical practice.For example, the inference rule:<pre><code>.c.o\:</code></pre><p>works, and the macro:<pre><code>f=  bar baz\   biza:    echo ==$f==</code></pre><p>will echo==bar&nbsp;baz&nbsp;biz==.<p>If$?were:<pre><code>/usr/include/stdio.h /usr/include/unistd.h foo.h</code></pre>then$(?D)would be:<pre><code>/usr/include /usr/include .</code></pre>and$(?F)would be:<pre><code>stdio.h unistd.h foo.h</code></pre><p><li>The contents of the built-in rules can be viewed by running:<pre><code>make -p -f /dev/null 2&gt;/dev/null</code></pre><p></ol></blockquote><h4><a name = "tag_001_014_1382">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>The IEEE PASC 1003.2 Interpretations Committee has forwarded concerns aboutparts of this interface definition to the IEEE PASC Shell and Utilities Working Groupwhich is identifying the corrections.A future revision of this specification will align withIEEE Std. 1003.2b when finalised.</blockquote><h4><a name = "tag_001_014_1383">&nbsp;</a>SEE ALSO</h4><blockquote><i><a href="ar.html">ar</a></i>,<i><a href="c89.html">c89</a></i>,<i><a href="cc.html">cc</a></i>,<i><a href="get.html">get</a></i>,<i><a href="lex.html">lex</a></i>,<i><a href="sh.html">sh</a></i>,<i><a href="yacc.html">yacc</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -