?? z70.html
字號:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head> <title> Makefile.am </title> <meta name="GENERATOR" content= "Modular DocBook HTML Stylesheet Version 1.45"> <link rel="HOME" title="GTK+ / Gnome Application Development" href="ggad.html"> <link rel="UP" title="Creating Your Source Tree" href= "cha-source.html"> <link rel="PREVIOUS" title="configure.in" href="z69.html"> <link rel="NEXT" title="Relevant GNU Documentation" href= "z71.html"> </head> <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink= "#840084" alink="#0000FF"> <div class="NAVHEADER"> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <th colspan="4" align="center"> <font color="#000000" size="2">GTK+ / Gnome Application Development</font> </th> </tr> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="z69.html"><font color="#0000ff" size="2"><b> <<< Previous</b></font></a> </td> <td width="25%" colspan="2" bgcolor="#ffffff" align= "center"> <font color="#0000ff" size="2"><b><a href="ggad.html"> <font color="#0000ff" size="2"><b> Home</b></font></a></b></font> </td> <td width="25%" bgcolor="#ffffff" align="right"> <a href="z71.html"><font color="#0000ff" size="2"><b> Next >>></b></font></a> </td> </tr> </table> </div> <div class="SECT1"> <h1 class="SECT1"> <a name="Z70"><tt class="FILENAME">Makefile.am</tt></a> </h1> <p> <tt class="APPLICATION">automake</tt> processes <tt class= "FILENAME">Makefile.am</tt> to produce a standards-compliant <tt class="FILENAME">Makefile.in</tt>. <tt class="APPLICATION">automake</tt> does a lot of work for you: it keeps up with dependencies between source files, for example. It creates all the standard targets, such as <tt class="APPLICATION">install</tt> and <tt class= "APPLICATION">clean</tt>. It also creates more complex targets: simply typing <tt class="APPLICATION">make dist</tt> creates a standard <tt class="APPLICATION"> .tar.gz</tt> file if your <tt class="FILENAME"> Makefile.am</tt> is correct. </p> <p> The <tt class="FILENAME">Makefile.am</tt> in the top source directory is generally very simple; here is an example: </p> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="PROGRAMLISTING"> SUBDIRS = macros po intl src pixmaps doc## We dist autogen.sh since this is an example program## Real-world programs do not need to distribute autogen.shEXTRA_DIST = \ gnome-hello.desktop \ autogen.shApplicationsdir = $(datadir)/gnome/apps/ApplicationsApplications_DATA = gnome-hello.desktop </pre> </td> </tr> </table> <p> The <tt class="APPLICATION">SUBDIRS</tt> line instructs <tt class="APPLICATION">automake</tt> to recursively look for <tt class="APPLICATION">Makefile.am</tt> files in the given subdirectories. (<a href="z72.html#SEC-.DESKTOP">the section called <i><tt class="APPLICATION">.desktop</tt> Entries</i></a> describes the remainder of the file, ignore it for now.) The <tt class="FILENAME">Makefile.am</tt> in the <tt class="FILENAME">src</tt> directory is a little more interesting: </p> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="PROGRAMLISTING"> INCLUDES = -I$(top_srcdir) -I$(includedir) $(GNOME_INCLUDEDIR) \ -DG_LOG_DOMAIN=\"GnomeHello\" -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ -I../intl -I$(top_srcdir)/intlbin_PROGRAMS = gnome-hellognome_hello_SOURCES = \ app.c \ hello.c \ menus.c \ app.h \ hello.h \ menus.hgnome_hello_LDADD = $(GNOMEUI_LIBS) $(GNOME_LIBDIR) $(INTLLIBS) </pre> </td> </tr> </table> <p> <tt class="APPLICATION">automake</tt> understands a number of "magic variables" and can use them to create <tt class= "APPLICATION">Makefile.in</tt>. In the small example above, the following variables are used: </p> <ul> <li> <p> <tt class="APPLICATION">INCLUDES</tt> specifies flags to pass to the C compiler during the compile phase (as opposed to the link phase). The variables used in this line come from the <tt class="FILENAME"> configure.in</tt> shown in the previous section. </p> </li> <li> <p> <tt class="APPLICATION">bin_PROGRAMS</tt> lists the programs to be compiled. </p> </li> <li> <p> <tt class="APPLICATION">hello_SOURCES</tt> lists the files to be compiled and linked to create the program called <tt class="APPLICATION">hello</tt>; <tt class= "APPLICATION">hello</tt> must be listed in <tt class= "APPLICATION">bin_PROGRAMS</tt>. All files in this variable are automatically included in the distribution. </p> </li> <li> <p> <tt class="APPLICATION">hello_LDADD</tt> lists flags to be passed to the linker. In this case, Gnome library flags determined by <tt class="FILENAME"> configure</tt>. </p> </li> </ul> <p> Several elements of the <tt class="APPLICATION"> INCLUDES</tt> line should be used in all Gnome programs. <tt class="APPLICATION">G_LOG_DOMAIN</tt> should always be defined; error messages from checks and assertions will report this value, so you can determine where the error occurred (in your code, or in a library). <tt class= "APPLICATION">GNOMELOCALEDIR</tt> is used to locate translation files. The <tt class="APPLICATION">intl</tt> directory is added to the header search path so the application can find the <tt class="APPLICATION">intl</tt> headers. </p> <p> There are many more complex things one can do in <tt class= "FILENAME">Makefile.am</tt>; in particular, you can add <tt class="APPLICATION">@</tt>-bounded variables to be substituted by <tt class="FILENAME">configure</tt>, you can conditionally include portions of the <tt class="FILENAME"> Makefile</tt> based on <tt class="FILENAME">configure</tt> checks, and you can build libraries. The <tt class= "APPLICATION">automake</tt> manual gives more details. </p> <p> <a href="z70.html#TAB-MAKETARGETS">Table 1</a> summarizes the most interesting targets generated by <tt class= "APPLICATION">automake</tt>. Of course the default target is <tt class="APPLICATION">all</tt>, which compiles the program. The GNU Coding Standards (<a href= "http://www.gnu.org/prep/standards_toc.html" target= "_top">http://www.gnu.org/prep/standards_toc.html</a>) have more information about these targets and GNU makefiles in general. </p> <div class="TABLE"> <a name="TAB-MAKETARGETS"></a> <p> <b>Table 1. Standard <tt class="FILENAME">make</tt> targets</b> </p> <table border="1" bgcolor="#E0E0E0" cellspacing="0" cellpadding="4" class="CALSTABLE"> <tr> <th align="LEFT" valign="TOP"> Target </th> <th align="LEFT" valign="TOP"> Description </th> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">dist</tt> </td> <td align="LEFT" valign="TOP"> Builds a tarball (<tt class= "APPLICATION">.tar.gz</tt>) for distribution </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">distcheck</tt> </td> <td align="LEFT" valign="TOP"> Builds a tarball, then tries to compile it </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">clean</tt> </td> <td align="LEFT" valign="TOP"> Deletes the results of compilation (object files and executables), but may not delete some generated files that come with the distribution. </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">install</tt> </td> <td align="LEFT" valign="TOP"> Creates installation directories if needed, and copies the software into them. </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">uninstall</tt> </td> <td align="LEFT" valign="TOP"> Reverses the install (deletes installed files). </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">distclean</tt> </td> <td align="LEFT" valign="TOP"> Reverse the effects of the <tt class="APPLICATION"> configure</tt> script and the <tt class= "APPLICATION">all</tt> target; that is, revert a tarball to its pristine state. </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">mostlyclean</tt> </td> <td align="LEFT" valign="TOP"> Nearly the same as <tt class="APPLICATION"> clean</tt>, but leaves some object files that most likely don't need to be rebuilt. </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">maintainer-clean</tt> </td> <td align="LEFT" valign="TOP"> More thorough than <tt class="APPLICATION"> clean</tt>; may delete some files that require special tools to rebuild, such as machine-generated source code. </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">TAGS</tt> </td> <td align="LEFT" valign="TOP"> Creates a tag table, for use with Emacs. </td> </tr> <tr> <td align="LEFT" valign="TOP"> <tt class="APPLICATION">check</tt> </td> <td align="LEFT" valign="TOP"> Runs a test suite if you have one </td> </tr> </table> </div> </div> <div class="NAVFOOTER"> <br> <br> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="z69.html"><font color="#0000ff" size="2"><b> <<< Previous</b></font></a> </td> <td width="25%" colspan="2" bgcolor="#ffffff" align= "center"> <font color="#0000ff" size="2"><b><a href="ggad.html"> <font color="#0000ff" size="2"><b> Home</b></font></a></b></font> </td> <td width="25%" bgcolor="#ffffff" align="right"> <a href="z71.html"><font color="#0000ff" size="2"><b> Next >>></b></font></a> </td> </tr> <tr> <td colspan="2" align="left"> <font color="#000000" size="2"><b><tt class="FILENAME"> configure.in</tt></b></font> </td> <td colspan="2" align="right"> <font color="#000000" size="2"><b>Relevant GNU Documentation</b></font> </td> </tr> </table> </div> </body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -