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
|
<!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>
|