doc/en/gnome/docs/porting.sgml
2002-01-27 07:00:04 +00:00

185 lines
7.3 KiB
Text

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" [
<!ENTITY base CDATA "../..">
<!ENTITY date "$FreeBSD$">
<!ENTITY title "FreeBSD GNOME Project: How To Make a Port">
<!ENTITY % gnomeincludes SYSTEM "../includes.sgml"> %gnomeincludes;
<!ENTITY % includes SYSTEM "../../includes.sgml"> %includes;
]>
<html>
&header;
<table border="0">
<tr>
<td>
<p>This document assumes that you already know how port system works,
and therefore only provides GNOME-specific hints and tips. General
instructions can be found in the
<a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/index.html">FreeBSD Porter's Handbook</a>.
</p>
<h2>GNOME Makefile Macros</h2>
<p>For ports that <i>require</i> GNOME, you should define the following
in your port's Makefile:</p>
<pre>
USE_GNOME= yes
USE_X_PREFIX= yes
</pre>
<p>These will take care of the install prefix and requiring all the
core GNOME dependencies. If your port can use GNOME, but it isn't
required, you can define the following in your Makefile:</p>
<pre>
WANT_GNOME= yes
</pre>
<p>If the user has defined <tt>WITH_GNOME</tt> in their
<tt>/etc/make.conf</tt> then GNOME components will be built.
Other useful GNOME-related macros that can be define in your port's
Makefile include:</p>
<!-- Begin GNOME-related Makefile macros -->
<ul>
<li><p><tt>USE_GLIB (WANT_GLIB)</tt> : The application requires
(can use) Glib. Defining <tt>USE_GNOME</tt> or <tt>USE_GTK</tt>
takes care of this option automatically.</p></li>
<li><p><tt>USE_GTK (WANT_GTK)</tt> : The application may not be
GNOME-compliant, but requires GTK+ widgets. This will take care of
those dependencies. Note, this option should <b>not</b> be defined
if <tt>USE_GNOME</tt> is defined.</p></li>
<li><p><tt>USE_ESOUND (WANT_ESOUND)</tt> : The application requires
(can use) esound. Normally, esound support is added by specifying
<tt>USE_GNOME</tt>.</p></li>
<li><p><tt>USE_IMLIB (WANT_IMLIB)</tt> : The application requires
(can use) the Imlib image library. This is not needed if
<tt>USE_GNOME</tt> is defined.</p></li>
<li><p><tt>USE_GNOMELIBS (WANT_GNOMELIBS)</tt> : The application
requires (can use) GNOME libraries. This does not import as many
dependencies as <tt>USE_GNOME</tt> and should be used for
applications that use GNOME, but do not need the GNOME Control
Center, the GNOME capplet library, or anything from the GNOME
Core.</p></li>
<li><p><tt>USE_GNOMECTRL (WANT_GNOMECTRL)</tt> : The application
requires (can use) all the GNOME libraries and the GNOME Control
Center, but does not use anything from GNOME Core. This option is
usually used for backend APIs.</p></li>
</ul>
<p>If your port can optionally use GNOME, you must set
<tt>WANT_GNOME= yes</tt> in your Makefile, then check to see if
<tt>HAVE_GNOME</tt> is set. Since this is a conditional
evaluation, you need to stick it between <tt>bsd.port.pre.mk</tt>
and <tt>bsd.port.post.mk</tt>. For example:</p>
<pre>
WANT_GNOME= yes
.include &lt;bsd.port.pre.mk&gt;
.if defined(HAVE_GNOME)
USE_GNOME= yes
CONFIGURE_ARGS+= --with-gnome
.else
CONFIGURE_ARGS+= --without-gnome
.endif
.include &lt;bsd.port.post.mk&gt;
</pre>
<p>What happens here is <tt>WANT_GNOME</tt> tells the ports system
to check for the existence of <tt>gnome-config</tt>. If it
exists, <tt>HAVE_GNOME</tt> is set. If not, <tt>HAVE_GNOME</tt>
remains unset. By setting <tt>USE_GNOME</tt> after checking for
<tt>HAVE_GNOME</tt> the port will register all the GNOME
dependencies properly.</p>
<p>When building GNOME ports, remember that many applications
require shared directories in <tt>${PREFIX}/share/gnome</tt>. Ports
should be constructed in a way such that files placed in these
directories are removed before the package which created the
directories (i.e. the package that has an appropriate
<tt>@dirrm</tt> in its pkg-plist). For GNOME, the principle
parent port is <tt>gnomecore</tt>. If your port incudes
<tt>USE_GNOME= yes</tt> you should be fine. If you're
uncertain if you need to require any other packages, you can use
the script <tt>${PORTSDIR}/Tools/scripts/gnomedepends.py</tt>
to examine your port's pkg-plist.</p>
<p>To see a list of what packages your port will actually require,
use the command <tt>make package-depends</tt>.</p>
<!-- End GNOME-related Makefile macros -->
<!-- Begine GNOME I18N -->
<h2>GNOME Internationalization</h2>
<p>GNOME relies on the <tt>gettext</tt> port to do
internationalization (I18N). FreeBSD currently supports two versions
of <tt>gettext</tt>: 0.10.35 and 0.10.40. Most ports can use
0.10.35. However, if, when compiling your port, you get an error
building the .po translation files similar to the following you will
need to use the newer version of <tt>gettext</tt>:</p>
<pre>
/usr/local/bin/msgfmt -o zh_TW.mo zh_TW.po
zh_TW.po:255: end-of-line within string
zh_TW.po:912: illegal control sequence
zh_TW.po:2806: end-of-line within string
zh_TW.po:2856: end-of-line within string
zh_TW.po:2879: illegal control sequence
zh_TW.po:2982: end-of-line within string
found 6 fatal errors
</pre>
<p>To use the newer <tt>gettext</tt>, add the following to your port's
Makefile:</p>
<pre>
BUILD_DEPENDS= msgfmt-new:${PORTSDIR}/devel/gettext-devel
CONFIGURE_ENV+= MSGFMT=${LOCALBASE}/bin/msgfmt-new \
XGETTEXT=${LOCALBASE}/bin/xgettext-new
</pre>
<p>When installing GNOME applications, make sure the translation
files are put in <tt>/usr/X11R6/share/locale</tt> and
not <tt>/usr/X11R6/share/gnome/locale</tt>. To do this, add the
following to your port's Makefile's <tt>pre-patch:</tt> section:</p>
<pre>
pre-patch:
@find ${WRKSRC} -name "Makefile.in*" | xargs ${PERL} -pi -e \
's|\$\(datadir\)/gnome/|\$\(datadir\)/|g ; \
s|\$\(datadir\)/locale|\$\(prefix\)/share/locale|g'
</pre>
<p>Also, make sure the translation files are installed as .mo files and
not .gmo files. To do this, you can generally use this
<a href="../patches/patch-po::Makefile.in.in">patch</a>.</p>
<p>If your port depends on iconv, make sure you substitute all
instances of <tt>iconv.h</tt> with <tt>giconv.h</tt>, and all
instances of <tt>-liconv</tt> with <tt>-lgiconv</tt>.</p>
<!-- End GNOME I18N -->
<!-- Begin GNOME libtool -->
<h2>Libtool Issues</h2>
<p>Most if not all GNOME applications depend on GNU's libtool. They
also use the GNU configure system. Newer versions of libtool have
a problem with FreeBSD's <tt>USE_LIBTOOL</tt> macro. Use of this
macro should be avoided. Instead, set <tt>GNU_CONFIGURE= yes</tt>,
and use the following <a href="../patches/patch-ltmain.sh">patch</a>
to prevent the installation of .la files.</p>
<!-- End GNOME libtool -->
<p>The more ported applications we have, the better.</p>
</td>
</tr>
</table>
&footer;
</body>
</html>