Merge branch 'g-clear-pointer-no-side-effects' into 'master'
[glib.git] / docs / reference / glib / cross.xml
blobc4520043767eae77a1796bee3b81cab12387eebc
1 <?xml version="1.0"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3                "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 ]>
5 <refentry id="glib-cross-compiling" revision="7 Aug 2018">
6 <refmeta>
7 <refentrytitle>Cross-compiling the GLib package</refentrytitle>
8 <manvolnum>3</manvolnum>
9 <refmiscinfo>GLib Library</refmiscinfo>
10 </refmeta>
12 <refnamediv>
13 <refname>Cross-compiling the GLib Package</refname>
14 <refpurpose>
15 How to cross-compile GLib
16 </refpurpose>
17 </refnamediv>
19     <refsect1 id="cross">
20       <title>Building the Library for a different architecture</title>
21       <para>
22         Cross-compilation is the process of compiling a program or
23         library on a different architecture or operating system then
24         it will be run upon. GLib is slightly more difficult to 
25         cross-compile than many packages because much of GLib is
26         about hiding differences between different systems. 
27       </para>
28       <para>
29         These notes cover things specific to cross-compiling GLib;
30         for general information about cross-compilation, see the
31         <ulink url="http://mesonbuild.com/Cross-compilation.html">meson</ulink>
32         info pages.
33       </para>
34       <para>
35         GLib tries to detect as much information as possible about
36         the target system by compiling and linking programs without
37         actually running anything; however, some information GLib
38         needs is not available this way. This information needs
39         to be provided to meson via a ‘cross file’.
40       </para>
41       <para>
42         As an example of using a cross file, to cross compile for
43         the ‘MingW32’ Win64 runtime environment on a Linux system,
44         create a file <filename>cross_file.txt</filename> with the following
45         contents:
46       </para>
47       <programlisting> 
48 [host_machine]
49 system = 'windows'
50 cpu_family = 'x86_64'
51 cpu = 'x86_64'
52 endian = 'little'
54 [properties]
55 c_args = []
56 c_link_args = []
58 [binaries]
59 c = 'x86_64-w64-mingw32-gcc'
60 cpp = 'x86_64-w64-mingw32-g++'
61 ar = 'x86_64-w64-mingw32-ar'
62 strip = 'x86_64-w64-mingw32-strip'
63 pkgconfig = 'x86_64-w64-mingw32-pkg-config'
64 windres = 'x86_64-w64-mingw32-windres'
65       </programlisting>
66       <para>
67         Then execute the following commands:
68       </para>
69       <programlisting>
70 meson --cross_file cross_file.txt builddir
71       </programlisting>
72       <para>
73         The complete list of cross properties follows. Most
74          of these won't need to be set in most cases.
75       </para>
76     </refsect1>
77     <refsect1 id="cross-properties">
78       <title>Cross properties</title>
79       <formalpara>
80         <title>have_[function]</title>
82         <para>
83            When meson checks if a function is supported, the test can be
84            overridden by setting the
85            <literal>have_<replaceable>function</replaceable></literal> property
86            to <constant>true</constant> or <constant>false</constant>.
87            For example <programlisting>Checking for function "alloca" : YES</programlisting>
88            can be overridden by setting <programlisting>have_alloca = false</programlisting>
89         </para>
90       </formalpara>
91       <formalpara>
92         <title>growing_stack=[true/false]</title>
94         <para>
95            Whether the stack grows up or down. Most places will want
96            <constant>false</constant>.
97            A few architectures, such as PA-RISC need <constant>true</constant>.
98         </para>
99       </formalpara>
100       <formalpara>
101          <title>have_strlcpy=[true/false]</title>
103          <para>
104             Whether you have <function>strlcpy()</function> that matches 
105             OpenBSD. Defaults to <constant>false</constant>, which is safe,
106             since GLib uses a built-in version in that case.
107         </para>
108       </formalpara>
109       <formalpara>
110          <title>va_val_copy=[true/false]</title>
112          <para>
113             Whether <type>va_list</type> can be copied as a pointer. If set 
114             to <constant>false</constant>, then <function>memcopy()</function>
115             will be used. Only matters if you don't have
116             <function>va_copy()</function> or <function>__va_copy()</function>.
117             (So, doesn't matter for GCC.)
118             Defaults to <constant>true</constant> which is slightly more common
119             than <constant>false</constant>.
120         </para>
121       </formalpara>
122       <formalpara>
123          <title>have_c99_vsnprintf=[true/false]</title>
125          <para>
126             Whether you have a <function>vsnprintf()</function> with C99 
127             semantics. (C99 semantics means returning the number of bytes 
128             that would have been written had the output buffer had enough 
129             space.) Defaults to <constant>false</constant>.
130          </para>
131       </formalpara>
132       <formalpara>
133          <title>have_c99_snprintf=[true/false]</title>
135          <para>
136             Whether you have a <function>snprintf()</function> with C99 
137             semantics. (C99 semantics means returning the number of bytes 
138             that would have been written had the output buffer had enough 
139             space.) Defaults to <constant>false</constant>.
140          </para>
141       </formalpara>
143     </refsect1>
145 </refentry>