?? cha-source.html
字號:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head> <title> Creating Your Source Tree </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="Building a Gnome Application" href= "build-app.html"> <link rel="PREVIOUS" title="Building a Gnome Application" href= "build-app.html"> <link rel="NEXT" title="Source Tree Checklist" href="z68.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="build-app.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="z68.html"><font color="#0000ff" size="2"><b> Next >>></b></font></a> </td> </tr> </table> </div> <div class="CHAPTER"> <h1> <a name="CHA-SOURCE">Creating Your Source Tree</a> </h1> <div class="TOC"> <dl> <dt> <b>Table of Contents</b> </dt> <dt> <a href="cha-source.html#Z67">Overview of a Gnome Source Tree</a> </dt> <dt> <a href="z68.html">Source Tree Checklist</a> </dt> <dt> <a href="z69.html"><tt class="FILENAME"> configure.in</tt></a> </dt> <dt> <a href="z70.html"><tt class="FILENAME"> Makefile.am</tt></a> </dt> <dt> <a href="z71.html">Relevant GNU Documentation</a> </dt> <dt> <a href="z72.html">Installing Support Files</a> </dt> </dl> </div> <p> Almost all Gnome applications use the same build system based on the GNU tools <tt class="APPLICATION"> automake</tt>, <tt class="APPLICATION">autoconf</tt>, and <tt class="APPLICATION">libtool</tt>. GTK+ and Gnome provide a set of <tt class="APPLICATION">autoconf</tt> macros that make it easy to create a portable, standards-compliant build setup. Due to the bewildering array of tools involved, it can be difficult to figure out how Gnome source trees work; there are manuals available for each tool, but none describes the "big picture." This chapter gives you a simple overview that should help you get started. It also covers some Gnome-specific details, and tells you how to ship and install your application's icons, translations, and documentation. </p> <p> If you're writing a large application, or a library, this chapter won't have all the information you need; you will probably need to consult the GNU tools' manuals to get more details. A complete discussion would fill the entire book. </p> <p> Beginning with this chapter and continuing throughout Part 2 of the book, a sample application called <tt class= "APPLICATION">GnomeHello</tt> will be used to demonstrate Gnome features. The <tt class="APPLICATION">GnomeHello</tt> source code is listed in Appendix E and the entire <tt class="APPLICATION">GnomeHello</tt> source tree is available online. It may be convenient to use it as a template for your own application's source code. </p> <p> You may miss the simple <tt class="APPLICATION"> Makefile</tt> made possible by the <tt class="APPLICATION"> gtk-config</tt> script; there is an equivalent <tt class= "APPLICATION">gnome-config</tt> script (use <tt class= "APPLICATION">gnome-config --help</tt> to learn how to use it). However, these simple makefiles are not adequate for any real-world application. </p> <div class="SECT1"> <h1 class="SECT1"> <a name="Z67">Overview of a Gnome Source Tree</a> </h1> <p> Gnome application build trees and distributed tarballs follow a set of conventions, most of them widespread in the free software community. Aspects of these conventions are formalized in documents such as the GNU Project's Coding Standards (<a href= "http://www.gnu.org/prep/standards_toc.html" target= "_top">http://www.gnu.org/prep/standards_toc.html</a>) and the Linux Filesystem Hierarchy Standard (<a href= "http://www.pathname.com/fhs/" target= "_top">http://www.pathname.com/fhs/</a>). It's worth using these standards even with non-free software---partially because they are very good from a technical standpoint, and partially because "going with the flow" will save you a lot of trouble, especially if you're using the GNU toolset. Besides, you might want to free your software someday. </p> <p> The GNU toolset, including <tt class="APPLICATION"> automake</tt> and <tt class="APPLICATION">autoconf</tt> will make it easy to comply with these standards. However, sometimes there are reasons not to use the GNU tools; for example, you may want a unified build that works on platforms such as Windows and MacOS. (Some of the tools do work with Windows using the Cygnus "Cygwin" environment, however; see <a href= "http://sourceware.cygnus.com/cygwin" target="_top"> http://sourceware.cygnus.com/cygwin</a>.) </p> <p> If you use <tt class="APPLICATION">autoconf</tt> and <tt class="APPLICATION">automake</tt>, users are not required to have these tools in order to build your software. The purpose of the tools is to build portable shell scripts and makefiles that will work in the user's environment. </p> <p> The <tt class="APPLICATION">autoconf</tt> package encompasses the <tt class="APPLICATION">aclocal</tt>, <tt class="APPLICATION">autoheader</tt>, and <tt class= "APPLICATION">autoconf</tt> executables. Together, these tools are used to create a portable shell script called <tt class="APPLICATION">configure</tt>; <tt class= "APPLICATION">configure</tt> is distributed to users with your software package. It explores the compilation system and creates makefiles and a special header called <tt class="FILENAME">config.h</tt>. The files created by <tt class="APPLICATION">configure</tt> are adapted to the specifics of the user's system. </p> <p> <tt class="APPLICATION">configure</tt> creates each <tt class="APPLICATION">Makefile</tt> from a template, called <tt class="APPLICATION">Makefile.in</tt>; <tt class= "APPLICATION">automake</tt> is a tool for creating these templates. <tt class="APPLICATION">automake</tt> generates <tt class="APPLICATION">Makefile.in</tt> from a hand-written <tt class="APPLICATION">Makefile.am</tt>. You distribute <tt class="APPLICATION">Makefile.in</tt> with your software, and users create a <tt class= "APPLICATION">Makefile</tt> when they run <tt class= "APPLICATION">configure</tt>. </p> <p> The <tt class="APPLICATION">libtool</tt> package is the third important GNU tool; its purpose is to abstract the idiosyncracies of shared libraries (static library behavior is fairly uniform across UNIX-like systems, but shared libraries present major portability issues). </p> <p> Informally, here are some of characteristics most Gnome packages have in common: </p> <ul> <li> <p> A file called <tt class="FILENAME">README</tt> that describes the package. </p> </li> <li> <p> A file called <tt class="FILENAME">INSTALL</tt> that explains how to compile and install the package. </p> </li> <li> <p> A script called <tt class="FILENAME">configure</tt> that automatically adapts the program to platform-specific features (or the lack thereof). <tt class="FILENAME">configure</tt> is expected to take an argument <tt class="APPLICATION">--prefix</tt>, specifying where to install the package. </p> </li> <li> <p> Standard <tt class="APPLICATION">make</tt> targets, such as <tt class="APPLICATION">clean</tt>, etc. </p> </li> <li> <p> A file called <tt class="FILENAME">COPYING</tt> containing the package's copyright. </p> </li> <li> <p> A <tt class="FILENAME">ChangeLog</tt> in which changes to the software are recorded. </p> </li> <li> <p> Tar files are traditionally compressed with <tt class="APPLICATION">gzip</tt> and their name includes the package version (for example, <tt class= "FILENAME">foo-0.2.1.tar.gz</tt>). They should unpack into a single directory, named with package and version---<tt class="FILENAME">foo-0.2.1</tt>. </p> </li> <li> <p> <i class="FIRSTTERM">Internationalization</i> is provided via the GNU <tt class="APPLICATION"> gettext</tt> package. A copy of <tt class= "APPLICATION">gettext</tt> is shipped along with the application, so users do not have to have one. </p> </li> </ul> </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="build-app.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="z68.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>Building a Gnome Application</b></font> </td> <td colspan="2" align="right"> <font color="#000000" size="2"><b>Source Tree Checklist</b></font> </td> </tr> </table> </div> </body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -