<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="libsoup-build-howto">
<refmeta>
<refentrytitle>Compiling with libsoup</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>LIBSOUP Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Compiling with libsoup</refname><refpurpose>Notes on compiling</refpurpose>
</refnamediv>

<refsect2>
<title>Using pkg-config</title>

<para>
Like other GNOME libraries, <application>libsoup</application> uses
<application>pkg-config</application> to provide compiler options. The
package name is "<literal>libsoup-2.4</literal>". So in your
<literal>configure</literal> script, you might specify something like:
</para>

<informalexample><programlisting>
PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.26])
AC_SUBST(LIBSOUP_CFLAGS)
AC_SUBST(LIBSOUP_LIBS)
</programlisting></informalexample>

<para>
The "<literal>2.4</literal>" in the package name is the "API version"
(indicating "the version of the <application>libsoup</application> API
that first appeared in version 2.4") and is essentially just part of
the package name.
</para>

</refsect2>

<refsect2>
<title>API Availability and Deprecation Warnings</title>

<para>
If you want to restrict your program to a particular
<application>libsoup</application> version or range of versions, you
can define <link
linkend="SOUP-VERSION-MIN-REQUIRED:CAPS"><literal>SOUP_VERSION_MIN_REQUIRED</literal></link>
and/or <link
linkend="SOUP-VERSION-MAX-ALLOWED:CAPS"><literal>SOUP_VERSION_MAX_ALLOWED</literal></link>.
Eg:
</para>

<informalexample><programlisting>
LIBSOUP_CFLAGS="$LIBSOUP_CFLAGS -DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_36"
LIBSOUP_CFLAGS="$LIBSOUP_CFLAGS -DSOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_2_40"
</programlisting></informalexample>

<para>
The <literal>SOUP_VERSION_MIN_REQUIRED</literal> declaration states
that the code is not expected to compile on versions of
<application>libsoup</application> older than the indicated version
(here, 2.36), and so the compiler should print warnings if the code
uses functions that were deprecated as of that release.
</para>

<para>
The <literal>SOUP_VERSION_MAX_ALLOWED</literal> declaration states
that the code <emphasis>is</emphasis> expected to compile on versions
of <application>libsoup</application> up to the indicated version
(here, 2.40), and so, when compiling the program against a newer
version than that, the compiler should print warnings if the code uses
functions that did not yet exist in the max-allowed release.
</para>

<para>
You can use <link
linkend="SOUP-CHECK-VERSION:CAPS"><literal>SOUP_CHECK_VERSION</literal></link>
to check the version of libsoup at compile time, to compile different
code for different <application>libsoup</application> versions. (If
you are setting <literal>SOUP_VERSION_MIN_REQUIRED</literal> and
<literal>SOUP_VERSION_MAX_ALLOWED</literal> to different versions, as
in the example above, then you almost certainly need to be doing
this.)
</para>

</refsect2>

<refsect2>
<title>Headers</title>

<para>
Code using <application>libsoup</application> should do:
</para>

<informalexample><programlisting>
#include &lt;libsoup/soup.h&gt;
</programlisting></informalexample>

<para>
Including individual headers rather than <literal>soup.h</literal> is not
recommended.
</para>

</refsect2>

</refentry>
