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

<para>
If you are using any of the GNOME-specific features of
<application>libsoup</application> (such as automatic proxy
configuration), you must require
"<literal>libsoup-gnome-2.4</literal>" instead:
</para>

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

<para>
You can also make <application>libsoup-gnome</application> an optional
dependency:
</para>

<informalexample><programlisting>
PKG_CHECK_MODULES(LIBSOUP_GNOME,
		  [libsoup-gnome-2.4 >= 2.26],
		  [LIBSOUP_CFLAGS="$LIBSOUP_GNOME_CFLAGS"
		   LIBSOUP_LIBS="$LIBSOUP_GNOME_LIBS"
		   AC_DEFINE(HAVE_LIBSOUP_GNOME, 1, [Have libsoup-gnome])],
		  [PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.26])])
AC_SUBST(LIBSOUP_CFLAGS)
AC_SUBST(LIBSOUP_LIBS)
</programlisting></informalexample>

<para>
This will allow the application to be built with either plain
<application>libsoup</application> or with
<application>libsoup-gnome</application>, and it will define the C
preprocessor symbol <literal>HAVE_LIBSOUP_GNOME</literal> if
<application>libsoup-gnome</application> features are available.
</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>
or, for <application>libsoup-gnome</application>:
</para>

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

<para>
Including individual headers besides the two main header files is not
recommended. You may include both <literal>soup.h</literal> and
<literal>soup-gnome.h</literal> (though this is not required; the
latter automatically includes the former).
</para>

</refsect2>

</refentry>
