Blame doc/adcli-devel.xml

Packit 8586cb
Packit 8586cb
Packit 8586cb
	"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
Packit 8586cb
Packit 8586cb
<chapter id="devel">
Packit 8586cb
	<title>Building, Packaging, and Contributing to adcli</title>
Packit 8586cb
Packit 8586cb
	<section id="devel-links">
Packit 8586cb
		<title>Helpful Resources</title>
Packit 8586cb
Packit 8586cb
		<para>Use the following to find more information about
Packit 8586cb
		contributing to adcli beyond what's in this manual:</para>
Packit 8586cb
Packit 8586cb
		<itemizedlist>
Packit 8586cb
			<listitem><para><ulink url="http://www.freedesktop.org/software/realmd/adcli/">Website</ulink></para></listitem>
Packit 8586cb
			<listitem><para><ulink url="mail:authentication@lists.freedesktop.org">Mailing list</ulink></para></listitem>
Packit 8586cb
			<listitem><para><ulink url="https://bugs.freedesktop.org/enter_bug.cgi?product=realmd&component=adcli">Bugzilla</ulink></para></listitem>
Packit 8586cb
		</itemizedlist>
Packit 8586cb
	</section>
Packit 8586cb
Packit 8586cb
	<section id="devel-building">
Packit 8586cb
		<title>Compiling adcli from Source</title>
Packit 8586cb
		<para>This describes how to compiling the adcli package from
Packit 8586cb
		source code. This is normally only necessary for those wishing to
Packit 8586cb
		contribute to the project or package adcli.</para>
Packit 8586cb
Packit 8586cb
		<para>You can download
Packit 8586cb
		<ulink url="http://www.freedesktop.org/software/realmd/releases/">tarballs
Packit 8586cb
		of the releases</ulink> of adcli or
Packit 8586cb
		<ulink url="http://cgit.freedesktop.org/realmd/adcli/">check
Packit 8586cb
		out the source code from git</ulink>. This documentation will not
Packit 8586cb
		go into all the details of how to get your development environment
Packit 8586cb
		set up and instead focus on the what's unique to compiling adcli.</para>
Packit 8586cb
Packit 8586cb
		<section id="devel-building-dependencies">
Packit 8586cb
			<title>Dependencies</title>
Packit 8586cb
Packit 8586cb
			<para>Besides the default autotools, binutils and GCC, adcli requires the
Packit 8586cb
			following development dependencies to build:</para>
Packit 8586cb
Packit 8586cb
			<itemizedlist>
Packit 8586cb
				<listitem><para>OpenLDAP client libraries</para></listitem>
Packit 8586cb
				<listitem><para>MIT Kerberos libraries</para></listitem>
Packit 8586cb
			</itemizedlist>
Packit 8586cb
Packit 8586cb
			<para>On <emphasis role="strong">Debian</emphasis> or <emphasis role="strong">Ubuntu</emphasis> you can use the following command to
Packit 8586cb
			install the dependencies:</para>
Packit 8586cb
Packit 8586cb
<programlisting>
Packit 8586cb
$ sudo apt-get install build-essential autoconf automake xmlto xsltproc \
Packit 8586cb
         libkrb5-dev libldap2-dev libsasl2-dev
Packit 8586cb
</programlisting>
Packit 8586cb
Packit 8586cb
			<para>On <emphasis role="strong">Fedora</emphasis> you can use the following command to install the
Packit 8586cb
			dependencies:</para>
Packit 8586cb
Packit 8586cb
<programlisting>
Packit 8586cb
$ sudo yum groupinstall "Development Tools"
Packit 8586cb
$ sudo yum install automake autoconf xmlto xsltproc krb5-devel openldap-devel \
Packit 8586cb
    cyrus-sasl-devel
Packit 8586cb
</programlisting>
Packit 8586cb
Packit 8586cb
		</section>
Packit 8586cb
Packit 8586cb
		<section id="devel-building-unix">
Packit 8586cb
			<title>Building on UNIX</title>
Packit 8586cb
			<para>adcli uses the standard GNU build system, using autoconf for package
Packit 8586cb
			configuration and resolving portability issues, automake for building makefiles
Packit 8586cb
			that comply with the GNU Coding Standards, and libtool for building shared
Packit 8586cb
			libraries on multiple platforms. The normal sequence for compiling and
Packit 8586cb
			installing adcli is thus:</para>
Packit 8586cb
Packit 8586cb
<programlisting>
Packit 8586cb
$ ./configure --prefix=/usr --sysconfdir=/etc...
Packit 8586cb
$ make
Packit 8586cb
$ make install
Packit 8586cb
</programlisting>
Packit 8586cb
Packit 8586cb
			<para>If you've checked out the source code from git, then the
Packit 8586cb
			<command>configure</command> script does not yet exist. So use
Packit 8586cb
			the following instead:</para>
Packit 8586cb
Packit 8586cb
<programlisting>
Packit 8586cb
$ ./autogen.sh --prefix=/usr --sysconfdir=/etc ...
Packit 8586cb
$ make
Packit 8586cb
$ make install
Packit 8586cb
</programlisting>
Packit 8586cb
Packit 8586cb
			<para>The standard options provided by GNU autoconf may be passed to the configure
Packit 8586cb
			script. Please see the autoconf documentation or run <literal>./configure --help</literal>
Packit 8586cb
			for information about the standard options. In particular you probably want to adjust
Packit 8586cb
			the <literal>--prefix=/xxx</literal> argument depending on your system and development
Packit 8586cb
			environment.</para>
Packit 8586cb
Packit 8586cb
			<para>Make sure that the <literal>--sysconfdir=/etc</literal> matches the directory
Packit 8586cb
			where the the MIT kerberos library stores its <literal>krb5.conf</literal>. This is
Packit 8586cb
			usually <literal>/etc</literal></para>
Packit 8586cb
		</section>
Packit 8586cb
Packit 8586cb
		<section id="devel-building-configure">
Packit 8586cb
			<title>Extra Configuration Options</title>
Packit 8586cb
Packit 8586cb
			<para>In addition to the normal options, the configure script in the adcli
Packit 8586cb
			supports these additional arguments:</para>
Packit 8586cb
Packit 8586cb
			<variablelist>
Packit 8586cb
				<varlistentry>
Packit 8586cb
					<term><option>--disable-debug</option>, <option>--enable-debug</option></term>
Packit 8586cb
					<listitem><para>By default adcli is built with debug symbols assertions and
Packit 8586cb
					and precondition checks. Enabling the debug option configures even more
Packit 8586cb
					detailed debug build, including disabling optimization. Disabling the debug
Packit 8586cb
					option is not recommended, as it disables all assertions, preconditions and
Packit 8586cb
					internal consistency checks, although it may result it a slightly faster
Packit 8586cb
					library.</para></listitem>
Packit 8586cb
				</varlistentry>
Packit 8586cb
				<varlistentry>
Packit 8586cb
					<term><option>--disable-doc</option></term>
Packit 8586cb
					<listitem><para>Disables building of the documentation and command line manual.
Packit 8586cb
					The documentation is built in the <literal>doc/html/</literal> directory of
Packit 8586cb
					the build.</para></listitem>
Packit 8586cb
				</varlistentry>
Packit 8586cb
				<varlistentry>
Packit 8586cb
					<term><option>--enable-strict</option></term>
Packit 8586cb
					<listitem><para>Enables strict checks during building of adcli. All
Packit 8586cb
					compiler warnings become errors.</para></listitem>
Packit 8586cb
				</varlistentry>
Packit 8586cb
			</variablelist>
Packit 8586cb
			<para></para>
Packit 8586cb
		</section>
Packit 8586cb
	</section>
Packit 8586cb
Packit 8586cb
	<section id="devel-building-style">
Packit 8586cb
		<title>Coding Style</title>
Packit 8586cb
Packit 8586cb
		<para>We use a code style similar to the linux kernel. Use tabs
Packit 8586cb
		to indent and spaces to align/wrap beyond the indentation level.</para>
Packit 8586cb
Packit 8586cb
		<para>We don't try to guarantee completely robust and problem free
Packit 8586cb
		behavior in cases where the caller or system isn't behaving. We
Packit 8586cb
		consider these to be outside of our control:</para>
Packit 8586cb
Packit 8586cb
		<itemizedlist>
Packit 8586cb
			<listitem><para>Broken input from callers. We use preconditions
Packit 8586cb
			to check input and immediately return. We don't try to provide
Packit 8586cb
			error codes for all the various ways callers can screw
Packit 8586cb
			around.</para></listitem>
Packit 8586cb
Packit 8586cb
			<listitem>
Packit 8586cb
			<para>Out of memory. It is pretty much impossible to handle out
Packit 8586cb
			of memory errors correctly. Handling them alongside other errors
Packit 8586cb
			is naive and broken. We don't try to guarantee library state
Packit 8586cb
			(such as locks or memory leaks) when memory allocation fails.</para>
Packit 8586cb
			<para>We do check the results from all memory allocations, but
Packit 8586cb
			treat them as unexpected conditions. As a nod to the behavior
Packit 8586cb
			of callers of this library, we don't abort on memory allocation
Packit 8586cb
			failures. We use preconditions with somewhat sane results.</para>
Packit 8586cb
			<para>Exception: when reading files or allocating potentially
Packit 8586cb
			unbounded amounts of memory, we should respond robustly to memory
Packit 8586cb
			allocation failures.</para>
Packit 8586cb
			</listitem>
Packit 8586cb
		</itemizedlist>
Packit 8586cb
Packit 8586cb
		<para>These unexpected conditions indicate a bug either in adcli or
Packit 8586cb
		in the system. All bets are off once this occurs.</para>
Packit 8586cb
Packit 8586cb
		<para>Use the <literal>return_val_xxx()</literal> precondition macros to
Packit 8586cb
		check for unexpected conditions.</para>
Packit 8586cb
	</section>
Packit 8586cb
Packit 8586cb
	<section id="devel-testing">
Packit 8586cb
		<title>Testing and Code Coverage</title>
Packit 8586cb
Packit 8586cb
		<para>Low level input parsers and such code should have unit tests
Packit 8586cb
		excercizing it. Use the <literal>make check</literal> command to run all
Packit 8586cb
		the tests. If you run it from a subdirectory only the tests in that
Packit 8586cb
		directory will be run.</para>
Packit 8586cb
Packit 8586cb
		<para>To check for memory errors or memory leaks, run <literal>make memcheck</literal>
Packit 8586cb
		or <literal>make leakcheck</literal> respectively. This requires valgrind
Packit 8586cb
		be installed.</para>
Packit 8586cb
Packit 8586cb
		<para>Build adcli with the <option>--enable-coverage</option> configure
Packit 8586cb
		option to build code coverage support.</para>
Packit 8586cb
Packit 8586cb
		<para>Once you've done that you can either use <literal>make coverage</literal>
Packit 8586cb
		to build code coverage information. Alternatively (and this is usually
Packit 8586cb
		easier) you can use
Packit 8586cb
		<ulink url="http://stef.thewalter.net/2012/12/git-coverage-useful-code-coverage.html">
Packit 8586cb
			<literal>git coverage</literal></ulink> to easily check whether
Packit 8586cb
		you've tested the lines changed by a patch.</para>
Packit 8586cb
	</section>
Packit 8586cb
Packit 8586cb
	<section id="devel-debugging">
Packit 8586cb
		<title>Debugging Tips</title>
Packit 8586cb
Packit 8586cb
		<para>Unexpected conditions will produce critical warnings by adcli.
Packit 8586cb
		These are often failed internal preconditions, and usually indicate a
Packit 8586cb
		bug either in adcli or the software calling it.</para>
Packit 8586cb
Packit 8586cb
		<para>You can use the environment variable <literal>ADCLI_STRICT=yes</literal>
Packit 8586cb
		to make adcli do an <literal>abort()</literal> (and core dump depending on
Packit 8586cb
		your configuration) when a critical warning occurs.</para>
Packit 8586cb
	</section>
Packit 8586cb
</chapter>