docs: Move building documentation to Markdown

Helps: #3037
This commit is contained in:
Matthias Clasen 2023-10-09 23:41:22 +01:00 committed by Philip Withnall
parent abf99f533f
commit c2798e6c2a
5 changed files with 176 additions and 341 deletions

View File

@ -0,0 +1,174 @@
Title: Building GLib
# Building GLib
GLib uses the [Meson build system](https://mesonbuild.com). The normal
sequence for compiling and installing the GLib library is thus:
$ meson setup _build
$ meson compile -C _build
$ meson install -C _build
On FreeBSD, you will need something more complex:
$ env CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib -Wl,--disable-new-dtags" \
> meson setup \
> -Dxattr=false \
> -Dinstalled_tests=true \
> -Db_lundef=false \
> _build
$ meson compile -C _build
The standard options provided by Meson may be passed to the `meson` command. Please see the Meson documentation or run:
meson configure --help
for information about the standard options.
GLib is compiled with
[strict aliasing](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fstrict-aliasing)
disabled. It is strongly recommended that this is not re-enabled by overriding
the compiler flags, as GLib has not been tested with strict aliasing and cannot
be guaranteed to work.
## Dependencies
Before you can compile the GLib library, you need to have various other
tools and libraries installed on your system. If you are building from a
release archive, you will need a [compliant C
toolchain](https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md),
Meson, and pkg-config; the requirements are the same when building from a
Git repository clone of GLib.
- [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) is a
tool for tracking the compilation flags needed for libraries that are used
by the GLib library. (For each library, a small `.pc` text file is
installed in a standard location that contains the compilation flags
needed for that library along with version number information).
A UNIX build of GLib requires that the system implements at least the
original 1990 version of POSIX. Beyond this, it depends on a number of other
libraries.
- The [GNU libiconv library](http://www.gnu.org/software/libiconv/) is
needed to build GLib if your system doesn't have the `iconv()` function
for doing conversion between character encodings. Most modern systems
should have `iconv()`, however many older systems lack an `iconv()`
implementation. On such systems, you must install the libiconv library.
This can be found at: http://www.gnu.org/software/libiconv.
If your system has an `iconv()` implementation but you want to use libiconv
instead, make sure it is installed to the default compiler header/library
search path (for instance, in `/usr/local/`). The `iconv.h` that libiconv
installs hides the system iconv. Meson then detects this, recognizes that the
system iconv is unusable and the external one is mandatory, and automatically
forces it to be used.
If you are using the native iconv implementation on Solaris instead of
libiconv, you'll need to make sure that you have the converters between
locale encodings and UTF-8 installed. At a minimum you'll need the
SUNWuiu8 package. You probably should also install the SUNWciu8, SUNWhiu8,
SUNWjiu8, and SUNWkiu8 packages.
The native iconv on Compaq Tru64 doesn't contain support for UTF-8, so
you'll need to use GNU libiconv instead. (When using GNU libiconv for
GLib, you'll need to use GNU libiconv for GNU gettext as well.) This
probably applies to related operating systems as well.
- Python 3.5 or newer is required. Your system Python must conform to
[PEP 394](https://www.python.org/dev/peps/pep-0394/) For FreeBSD, this means
that the `lang/python3` port must be installed.
- The libintl library from the [GNU
gettext](http://www.gnu.org/software/gettext) package is needed if your
system doesn't have the `gettext()` functionality for handling message
translation databases.
- A thread implementation is needed. The thread support in GLib can be based
upon POSIX threads or win32 threads.
- GRegex uses the [PCRE library](http://www.pcre.org/) for regular
expression matching. The system version of PCRE is used, unless not available
(which is the case on Android), in which case a fallback subproject is used.
- The optional extended attribute support in GIO requires the `getxattr()`
family of functions that may be provided by the C library or by the
standalone libattr library. To build GLib without extended attribute
support, use the `-Dxattr=false` option.
- The optional SELinux support in GIO requires libselinux. To build GLib
without SELinux support, use the `-Dselinux=disabled` option.
- The optional support for DTrace requires the `sys/sdt.h` header, which is
provided by SystemTap on Linux. To build GLib without DTrace, use the
`-Ddtrace=false` option.
- The optional support for SystemTap can be disabled with the
`-Dsystemtap=false` option. Additionally, you can control the location
where GLib installs the SystemTap probes, using the
`-Dtapset_install_dir=DIR` option.
## Extra Configuration Options
In addition to the normal options, these additional ones are supported when
configuring the GLib library:
`--buildtype`
: This is a standard Meson option which specifies how much debugging and
optimization to enable. If the build type is `debug`, `G_ENABLE_DEBUG` will be
defined and GLib will be built with additional debug code enabled. You can
override this behavior using `-Dglib_debug`.
`-Dforce_posix_threads=true`
: Normally, Meson should be able to work out the correct thread implementation
to use. This option forces POSIX threads to be used even if the platform
provides another threading API (for example, on Windows).
`-Dbsymbolic_functions=false` and `-Dbsymbolic_functions=true`
: By default, GLib uses the `-Bsymbolic-functions` linker flag to avoid
intra-library PLT jumps. A side-effect of this is that it is no longer
possible to override internal uses of GLib functions with `LD_PRELOAD`.
Therefore, it may make sense to turn this feature off in some
situations. The `-Dbsymbolic_functions=false` option allows to do that.
`-Dgtk_doc=false` and `-Dgtk_doc=true`
: By default, GLib will detect whether the gtk-doc package is installed.
If it is, then it will use it to extract and build the documentation
for the GLib library. These options can be used to explicitly control
whether gtk-doc should be used or not. If it is not used, the
distributed, pre-generated HTML files will be installed instead of
building them on your machine.
`-Dman=false` and `-Dman=true`
: By default, GLib will detect whether `xsltproc` and the necessary DocBook
stylesheets are installed. If they are, then it will use them to rebuild
the included man pages from the XML sources. These options can be used to
explicitly control whether man pages should be rebuilt used or not. The
distribution includes pre-generated man pages.
`-Dxattr=false` and `-Dxattr=true`
: By default, GLib will detect whether the `getxattr()` family of functions is
available. If it is, then extended attribute support will be included in
GIO. These options can be used to explicitly control whether extended
attribute support should be included or not. `getxattr()` and friends can be
provided by glibc or by the standalone libattr library.
`-Dselinux=auto`, `-Dselinux=enabled` or `-Dselinux=disabled`
: By default, GLib will detect if libselinux is available and include SELinux
support in GIO if it is. These options can be used to explicitly control
whether SELinux support should be included.
`-Ddtrace=false` and `-Ddtrace=true`
: By default, GLib will detect if DTrace support is available, and use it.
These options can be used to explicitly control whether DTrace support is
compiled into GLib.
`-Dsystemtap=false` and `-Dsystemtap=true`
: This option requires DTrace support. If it is available, then GLib will also
check for the presence of SystemTap.
`-Db_coverage=true` and `-Db_coverage=false`
: Enable the generation of coverage reports for the GLib tests. This requires
the lcov frontend to gcov from the Linux Test Project. To generate a
coverage report, use `ninja coverage-html`. The report is placed in the
`meson-logs` directory.

View File

@ -1,339 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>
<refentry id="glib-building">
<refmeta>
<refentrytitle>Compiling the GLib package</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLib Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Compiling the GLib Package</refname>
<refpurpose>How to compile GLib itself</refpurpose>
</refnamediv>
<refsect1 id="building">
<title>Building the Library on UNIX</title>
<para>
On UNIX, GLib uses the standard <application>Meson</application> build
system. The normal sequence for compiling and installing the GLib library
is thus:
<literallayout>
<userinput>meson setup _build</userinput>
<userinput>meson compile -C _build</userinput>
<userinput>meson install -C _build</userinput>
</literallayout>
On FreeBSD:
<literallayout>
<userinput>env CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib -Wl,--disable-new-dtags" meson setup -Dxattr=false -Dinstalled_tests=true -Db_lundef=false _build</userinput>
<userinput>meson compile -C _build</userinput>
</literallayout>
</para>
<para>
The standard options provided by <application>Meson</application> may be
passed to the <command>meson</command> command. Please see the
<application>Meson</application> documentation or run
<command>meson configure --help</command> for information about
the standard options.
</para>
<para>
GLib is compiled with
<ulink url="https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fstrict-aliasing">strict aliasing</ulink>
disabled. It is strongly recommended that this is not re-enabled by
overriding the compiler flags, as GLib has not been tested with strict
aliasing and cannot be guaranteed to work.
</para>
<para>
The GTK documentation contains
<ulink url="https://developer.gnome.org/gtk3/stable/gtk-building.html">further details</ulink>
about the build process and ways to influence it.
</para>
</refsect1>
<refsect1 id="dependencies">
<title>Dependencies</title>
<para>
Before you can compile the GLib library, you need to have
various other tools and libraries installed on your system.
If you are building from a release archive, you will need
<ulink url="https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md">a compliant C toolchain</ulink>,
<application>Meson</application>, and <application>pkg-config</application>;
the requirements are the same when building from a Git repository clone
of GLib.
</para>
<itemizedlist>
<listitem>
<para>
<ulink url="https://www.freedesktop.org/wiki/Software/pkg-config/">pkg-config</ulink>
is a tool for tracking the compilation flags needed for
libraries that are used by the GLib library. (For each
library, a small <literal>.pc</literal> text file is
installed in a standard location that contains the compilation
flags needed for that library along with version number
information).
</para>
</listitem>
</itemizedlist>
<para>
A UNIX build of GLib requires that the system implements at
least the original 1990 version of POSIX. Beyond this, it
depends on a number of other libraries.
</para>
<itemizedlist>
<listitem>
<para>
The <ulink url="http://www.gnu.org/software/libiconv/">GNU
libiconv library</ulink> is needed to build GLib if your
system doesn't have the <function>iconv()</function>
function for doing conversion between character
encodings. Most modern systems should have
<function>iconv()</function>, however many older systems lack
an <function>iconv()</function> implementation. On such systems,
you must install the libiconv library. This can be found at:
<ulink url="http://www.gnu.org/software/libiconv">http://www.gnu.org/software/libiconv</ulink>.
</para>
<para>
If your system has an <function>iconv()</function> implementation but
you want to use libiconv instead, make sure it is installed to the
default compiler header/library search path (for instance, in
<filename>/usr/local/</filename>). The <filename>iconv.h</filename>
that libiconv installs hides the system iconv. Meson then detects
this, recognizes that the system iconv is unusable and the external
one is mandatory, and automatically forces it to be used.
</para>
<para>
If you are using the native iconv implementation on Solaris
instead of libiconv, you'll need to make sure that you have
the converters between locale encodings and UTF-8 installed.
At a minimum you'll need the SUNWuiu8 package. You probably
should also install the SUNWciu8, SUNWhiu8, SUNWjiu8, and
SUNWkiu8 packages.
</para>
<para>
The native iconv on Compaq Tru64 doesn't contain support for
UTF-8, so you'll need to use GNU libiconv instead. (When
using GNU libiconv for GLib, you'll need to use GNU libiconv
for GNU gettext as well.) This probably applies to related
operating systems as well.
</para>
</listitem>
<listitem>
<para>
Python 3.5 or newer is required. Your system Python must
conform to <ulink
url="https://www.python.org/dev/peps/pep-0394/">PEP 394
</ulink>
For FreeBSD, this means that the
<literal>lang/python3</literal> port must be installed.
</para>
</listitem>
<listitem>
<para>
The libintl library from the <ulink
url="http://www.gnu.org/software/gettext">GNU gettext
package</ulink> is needed if your system doesn't have the
<function>gettext()</function> functionality for handling
message translation databases.
</para>
</listitem>
<listitem>
<para>
A thread implementation is needed. The thread support in GLib
can be based upon POSIX threads or win32 threads.
</para>
</listitem>
<listitem>
<para>
GRegex uses the <ulink url="http://www.pcre.org/">PCRE library</ulink>
for regular expression matching. The system version of PCRE is used,
unless not available (which is the case on Android), in which case a
fallback subproject is used.
</para>
</listitem>
<listitem>
<para>
The optional extended attribute support in GIO requires the
<function>getxattr()</function> family of functions that may be
provided by the C library or by the standalone libattr library. To
build GLib without extended attribute support, use the
<option>-Dxattr=false</option> option.
</para>
</listitem>
<listitem>
<para>
The optional SELinux support in GIO requires libselinux.
To build GLib without SELinux support, use the
<option>-Dselinux=disabled</option> option.
</para>
</listitem>
<listitem>
<para>
The optional support for DTrace requires the
<filename>sys/sdt.h</filename> header, which is provided
by SystemTap on Linux. To build GLib without DTrace, use
the <option>-Ddtrace=false</option> option.
</para>
</listitem>
<listitem>
<para>
The optional support for
<ulink url="http://sourceware.org/systemtap/">SystemTap</ulink>
can be disabled with the <option>-Dsystemtap=false</option>
option. Additionally, you can control the location
where GLib installs the SystemTap probes, using the
<option>-Dtapset_install_dir=DIR</option> option.
</para>
</listitem>
</itemizedlist>
</refsect1>
<refsect1 id="extra-configuration-options">
<title>Extra Configuration Options</title>
<para>
In addition to the normal options, these additional ones are supported
when configuring the GLib library:
</para>
<formalpara>
<title><option>--buildtype</option></title>
<para>
This is a standard <application>Meson</application> option which
specifies how much debugging and optimization to enable. If the build
type is <literal>debug</literal>,
<literal>G_ENABLE_DEBUG</literal> will be defined and GLib will be built
with additional debug code enabled. You can override this behavior using
<option>-Dglib_debug</option>.
</para>
</formalpara>
<formalpara>
<title><option>-Dforce_posix_threads=true</option></title>
<para>
Normally, <application>Meson</application> should be able to work out
the correct thread implementation to use. This option forces POSIX
threads to be used even if the platform provides another threading API
(for example, on Windows).
</para>
</formalpara>
<formalpara>
<title><option>-Dbsymbolic_functions=false</option> and
<option>-Dbsymbolic_functions=true</option></title>
<para>
By default, GLib uses the <option>-Bsymbolic-functions</option>
linker flag to avoid intra-library PLT jumps. A side-effect
of this is that it is no longer possible to override
internal uses of GLib functions with
<envar>LD_PRELOAD</envar>. Therefore, it may make
sense to turn this feature off in some situations.
The <option>-Dbsymbolic_functions=false</option> option allows
to do that.
</para>
</formalpara>
<formalpara>
<title><option>-Dgtk_doc=false</option> and
<option>-Dgtk_doc=true</option></title>
<para>
By default, GLib will detect whether the
<application>gtk-doc</application> package is installed.
If it is, then it will use it to extract and build the
documentation for the GLib library. These options
can be used to explicitly control whether
<application>gtk-doc</application> should be
used or not. If it is not used, the distributed,
pre-generated HTML files will be installed instead of
building them on your machine.
</para>
</formalpara>
<formalpara>
<title><option>-Dman=false</option> and
<option>-Dman=true</option></title>
<para>
By default, GLib will detect whether <application>xsltproc</application>
and the necessary DocBook stylesheets are installed.
If they are, then it will use them to rebuild the included
man pages from the XML sources. These options can be used
to explicitly control whether man pages should be rebuilt
used or not. The distribution includes pre-generated man
pages.
</para>
</formalpara>
<formalpara>
<title><option>-Dxattr=false</option> and
<option>-Dxattr=true</option></title>
<para>
By default, GLib will detect whether the
<function>getxattr()</function>
family of functions is available. If it is, then extended
attribute support will be included in GIO. These options can
be used to explicitly control whether extended attribute
support should be included or not. <function>getxattr()</function>
and friends can be provided by glibc or by the standalone
libattr library.
</para>
</formalpara>
<formalpara>
<title><option>-Dselinux=auto</option>,
<option>-Dselinux=enabled</option> or
<option>-Dselinux=disabled</option></title>
<para>
By default, GLib will detect if libselinux is available and
include SELinux support in GIO if it is. These options can be
used to explicitly control whether SELinux support should
be included.
</para>
</formalpara>
<formalpara>
<title><option>-Ddtrace=false</option> and
<option>-Ddtrace=true</option></title>
<para>
By default, GLib will detect if DTrace support is available, and use it.
These options can be used to explicitly control whether DTrace support
is compiled into GLib.
</para>
</formalpara>
<formalpara>
<title><option>-Dsystemtap=false</option> and
<option>-Dsystemtap=true</option></title>
<para>
This option requires DTrace support. If it is available, then
GLib will also check for the presence of SystemTap.
</para>
</formalpara>
<formalpara>
<title><option>-Db_coverage=true</option> and
<option>-Db_coverage=false</option></title>
<para>
Enable the generation of coverage reports for the GLib tests.
This requires the lcov frontend to gcov from the
<ulink url="http://ltp.sourceforge.net">Linux Test Project</ulink>.
To generate a coverage report, use
<command>ninja coverage-html</command>. The report is placed in the
<filename>meson-logs</filename> directory.
</para>
</formalpara>
</refsect1>
</refentry>

View File

@ -24,7 +24,6 @@
General Public License (GNU LGPL).
</para>
<xi:include href="building.xml" />
<xi:include href="programming.xml" />
<xi:include href="changes.xml" />
<xi:include href="resources.xml" />

View File

@ -40,6 +40,7 @@ show_class_hierarchy = true
urlmap_file = "urlmap.js"
# The same order will be used when generating the index
content_files = [
"building.md",
"compiling.md",
"cross-compiling.md",
"running.md",

View File

@ -71,7 +71,6 @@ if get_option('gtk_doc')
'--ignore-headers=' + ' '.join(ignore_headers),
],
content_files : [
'building.xml',
'changes.xml',
'programming.xml',
'resources.xml',
@ -146,6 +145,7 @@ endif
# gi-docgen version
expand_content_files = [
'building.md',
'character-set.md',
'compiling.md',
'cross-compiling.md',