<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!-- Based on an example constructed by Colin Watson
     <email>cjwatson@debian.org</email>, based on a man page template
     provided by Tom Christiansen <email>tchrist@jhereg.perl.com</email>
     and a DocBook man page example by Craig Small
     <email>csmall@debian.org</email>.
  -->
  <!ENTITY manfirstname "<firstname>Bram</firstname>">
  <!ENTITY mansurname   "<surname>Neijt</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY mandate      "<date>2009-12-30</date>">
  <!-- SECTION should be 1-8, maybe with subsection. Other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY mansection   "<manvolnum>1</manvolnum>">
  <!ENTITY manemail     "<email>bneijt@gmail.com</email>">
  <!ENTITY manusername  "bneijt">
  <!ENTITY manucpackage "<refentrytitle>ccbuild</refentrytitle>">
  <!ENTITY manpackage   "ccbuild">
  <!ENTITY ccb "<command>ccbuild</command>">
]>
<refentry>
  <refentryinfo>
    <address>
      &manemail;
    </address>
    <author>
      &manfirstname;
      &mansurname;
    </author>
    <copyright>
      <year>2009</year>
      <holder>&manusername;</holder>
    </copyright>
    &mandate;
  </refentryinfo>
  <refmeta>
    &manucpackage;

    &mansection;
  </refmeta>
  <refnamediv>
    <refname>&manpackage;</refname>

    <refpurpose>Strict C++ developer&apos;s build utility</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&manpackage;</command>

<!--      <group choice="req"><arg>this</arg><arg>that</arg></group> -->
      <group choice="opt"><arg>options</arg></group>
<!--
      <group choice="opt">
       <arg><replaceable>command</replaceable></arg>
      </group>
-->
      <group choice="opt"><arg>command</arg></group>
<!--      <arg rep="repeat" choice="opt"><replaceable>command argument</replaceable></arg> -->
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>
    <para><command>&manpackage;</command> is a build utility that will read C++ source. It collects all source surrounding your local includes and links these to your main program. Global include statements (#include &lt;something&gt;) are used to make sure the compiler gets the right arguments. The link between compiler arguments and these global includes is made using configuration files. These files contain lines with a global header file name and the extra arguments the compiler needs to find and use this file. The file name and arguments are separated by tab character(s) or a space. <command>&manpackage;</command> reads these configuration files in order. Only the first mention of a global header file in these files is used. Usually only <filename>./ccResolutions</filename> is used, but there are more possibilities. See the section FILES for more information.</para>
    <para><command>&manpackage;</command> will follow any local include (#include &quot;something.hh&quot;) to try to find more source code to compile. To keep <command>&manpackage;</command> from following up on an include statement, separate the #-sign and the include statement by a single space (&quot;# include&quot;).</para>
<!--
    <refsect2>
      <title>A Sample Subsection</title>
      <para></para>
    </refsect2>
    <refsect2>
      <title>Yet Another Sample Subsection</title>

      <para>References to the
        <citerefentry>
         <refentrytitle>foo</refentrytitle><manvolnum>SECTION</manvolnum>
        </citerefentry> (or other) manual page should use the
        <markup>&lt;citerefentry&gt;</markup> element as here.
      </para>

      <para>Each paragraph within a section is contained within a
        <markup>&lt;para&gt;</markup> tag.</para>
    </refsect2>
-->
  </refsect1>
  <refsect1>
    <title>COMMANDS</title>
    <variablelist>
<!--
      <varlistentry>
        <term> [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para></para>
        </listitem>
      </varlistentry>
 -->
      <varlistentry>
        <term>build [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>Build everything or the given source.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>lib [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>Collect all objects into an archive. If a version is given, using --pversion, then a shared library is also build with symbolic links. This currently forces the -fPIC argument addition. The name of your library is given the name of the current directory or it's parent when the current directory is called src.</para>
          <para>Example: create an empty .cc file which simply includes all the local libraries, run &ccb; --pversion 0.0.1 lib thatfile.cc</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>clean [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>Clean everything or the given source.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>distclean</term>
        <listitem>
          <para>Recursively remove all &quot;o&quot; directories after removing all .md5 and .o files therein. And removes all .gch files.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>deps [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>List all files this source depends on. It lists three lines separated by empty lines.
          The first contains the local dependencies, 
          the second the ignored headers (for the file) and the last contains all global includes needed.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>dot [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>Generate dot graph files for sources on the stdout. If no source file name is given, then for all binary targets in the local directory a .dot file will be created. If the <option>--verbose</option> flag is used
          the dot graph will also contain all object file names and their dependencies and lists of ignored headers. Objects will be coloured light grey, binary targets light blue, ignored headers by a red line.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>makefile [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>Generate a Makefile on stdout. If no file name is given, an all rule will be generated. Otherwise only the rules for the given file are generated.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>aap [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>Generate an A-A-P file on stdout. If the file name is not given, an &quot;all&quot; rule will be added and all local binary targets will be listed.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>check [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>Dsplay source status and file name on the stdout. Status and source path are separated with a tab character. Status is either &quot;old&quot; or &quot;ok&quot;. When the <option>--verbose</option> flag is used, another tab separated column will be inserted containing a two letter file type &ccb; identifies it as. This file type is &quot;bt&quot;, &quot;ot&quot;, &quot;ih&quot; or &quot;hh&quot; for binary target, object target, internal header and header respectively.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>icmake [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para><command>icmake</command> slave mode. This will output the used directories with one directory per line. If a CLASSES file already exists, it will only output the class directories not mentioned in the CLASSES file. If <option>--verbose</option> is given, all classes will be listed. The output will not contain directories with only header files. Updating the CLASSES is typically done by running: &ccb; icmake &gt;&gt; CLASSES</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>resolve [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>Print all unresolved globals onto the stdout followed by a tab character. These can be appended to the ccResolutions file using: &ccb; resolve &gt;&gt; ccResolutions .</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>md5 [<replaceable>filename.cc</replaceable>]</term>
        <listitem>
          <para>MD5 sum all sources needed to compile all binary targets, or the given source on stdout.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>OPTIONS</title>

    <para>Options are used to change the behaviour of the commands. Some options are useless for some commands.</para>

    <variablelist>
      <varlistentry>
        <term><option>-f</option> <option>--force-update</option></term>
        <listitem>
          <para>Update everything by labelling everything as old.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-h</option> <option>--help</option></term>
        <listitem>
          <para>Get a list of options and commands.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--gnutouch</option></term>
        <listitem>
          <para>Touch files part of the GNU software standard. They will be touched in ../ except when there is a directory called src in the current directory, then the current directory will be used. This will touch AUTHORS, NEWS, README, INSTALL, COPYING, TODO and ChangeLog.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-s</option> <option>--no-act</option></term>
        <listitem>
          <para>Simulate, don&apos;t really execute any writing commands.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--compiler</option> <replaceable>cmd</replaceable></term>
        <listitem>
          <para>Set the compiler command. The default is &quot;g++&quot;.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-a</option> <option>--args</option> <replaceable>argument</replaceable></term>
        <listitem>
          <para>Set these default compiler arguments, removing the standard default arguments (&quot;-Wall -g&quot;). Multiple uses of this option are concatenated with spaces.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-C</option> <replaceable>path</replaceable></term>
        <listitem>
          <para>Change directory before anything else.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-p</option> <option>--precompile-ih</option></term>
        <listitem>
          <para>Pre-compile only internal headers. This requires g++ version 3.4 up.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--precompile-all</option></term>
        <listitem>
          <para>Pre-compile both internal headers and normal headers. This requires g++ version 3.4 up. When you use internal headers, this will only slow you down. However, when you don&apos;t use internal headers, this pre-compilation is all you&apos;ve got.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--brute</option></term>
        <listitem>
          <para>Continue on compiler errors.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--md5</option></term>
        <listitem>
          <para>Use MD5 hashes to check for file changes. The hashes are store in &quot;o/filename.md5&quot; for every file. These sums are only	stored after a clean exit from &ccb; (last line showing &quot;[WR] MD5 data&quot;) or a successful compilation.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-I</option> <replaceable>path</replaceable></term>
        <listitem>
          <para>Add this path to the local include search path of &ccb; and the compiler (which will receive the same argument).</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--recursive-include</option> <replaceable>path</replaceable></term>
        <listitem>
          <para>This is just like <option>-I</option>, but for the given path and every non-empty directory with a name other then &quot;o&quot;. Make sure you do not come to depend on this behaviour, that would be bad practice.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-l</option> <option>--highlight</option></term>
        <listitem>
          <para>Highlight the output of the compiler using a red terminal colour.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--xof</option> <option>--exec-on-fail</option> <replaceable>command</replaceable></term>
        <listitem>
          <para>Execute this command when the command (pre)compilation returns anything but 0.
           The first argument given to the command will be relative path to the file the command was executed on (which is either a C++ source or header). If you don&apos;t want to use the file name, you can append an echo command like &quot;sleep 2; echo&quot;.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--xop</option> <option>--exec-on-pass</option> <replaceable>cmd</replaceable></term>
        <listitem>
          <para>This is the same as <option>--exec-on-fail</option>, except it only works when the command returns 0. The first argument given to the command will be the relative path to the file the command was executed on.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--clearpc</option></term>
        <listitem>
          <para>Clear the screen just before executing the command (clear per command).</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--append</option> <replaceable>cmd</replaceable></term>
        <listitem>
          <para>Append this to every command. This can be used to redirect output or set up pipes for compiler output.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--loop</option></term>
        <listitem>
          <para>
          Loop the system with one second intervals. This only works for the build command at the moment.
          All sources who are touched will be reloaded. If a file is removed, the whole source tree is reloaded.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--nodefargs</option></term>
        <listitem>
          <para>Do not read the first line of ./ccResolutions for extra arguments.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--nodefres</option></term>
        <listitem>
          <para>Do not load any ccResolutions files outside of ./ccResolutions. This can be used to create a monolithic ccResolutions file or discover your project&apos;s dependencies with the resolve command.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--addres</option> <replaceable>filename</replaceable></term>
        <listitem>
          <para>Load the given resolution file before any other.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--pversion</option> <replaceable>version</replaceable></term>
        <listitem>
          <para>Set the program version you are working on to <replaceable>version</replaceable>. This is currently only used for the library command. When defined, the library command can make a shared object (.so) and symbolic links by using the version number. It should not contain any file system special characters like slashes.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--ar</option></term>
        <listitem>
          <para>Archive the objects before linking. This should reduce the binary size because it leaves out unused objects.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--verbose</option></term>
        <listitem>
          <para>Show commands and produce more output for dot and check commands.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-V</option> <option>--version</option></term>
        <listitem>
          <para>Output version number on stdout and copyright/license on stderr.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--xml</option></term>
        <listitem>
          <para>Output in XML where supported. Currently this is only the check command.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--nowarn</option></term>
        <listitem>
          <para>Leave out most warnings.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>--batch</option></term>
        <listitem>
          <para>Compile a batch of files with one g++ call before any other compilation. This effectively disables any multi-threading, but may speed things up for larger collections of small files. This process involves creating a temporary directory in /tmp/ccbuild_batch.XXXX. The exact behaviour of this option may change in the future based on performance results and user experience.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-j</option> <replaceable>number_threads</replaceable></term>
        <listitem>
          <para>Set the maximum number of threads used during build. Only available when OpenMP is enabled.</para>
        </listitem>
      </varlistentry>
<!--
      <varlistentry>
        <term><option></option> <option></option> <replaceable></replaceable></term>
        <listitem>
          <para></para>
        </listitem>
      </varlistentry>

          <para>Pass the user-supplied <replaceable>option</replaceable> to
            <command>foo</command> to change its behaviour. The fact that
            <replaceable>option</replaceable> is underlined or in italics
            means that the user replaces it with a valid value for this
            option. The [ and ] brackets mean it isn&apos;t required.</para>
-->
    </variablelist>
  </refsect1>
  <refsect1>
    <title>RESOLUTION CONFIGURATION</title>

    <para>The ccResolutions file links global headers to compiler arguments. Every line should be either empty, start with a comment character &quot;#&quot; or contain a configuration line. 
    A configuration line contains the name of the global header, followed by one or more tab characters and then the additional arguments needed when a source depends on this global header.
    The arguments are POSIX shell expanded.</para>
<para>
    If the first line of the ccResolutions file starts with &quot;#&amp;&quot;, the rest of this line is shell expanded and used and appended to the argument list of &ccb;.
    </para>
  </refsect1>
<!--
  <refsect1>
    <title>RETURN VALUE</title>

    <para>What the program or function returns if successful.</para>
  </refsect1>
  <refsect1>
    <title>ERRORS</title>

    <para>Return codes, either exit status or errno settings.</para>
  </refsect1>
-->
  <refsect1>
    <title>EXAMPLES</title>

    <para>Examples of program use.</para>
    <variablelist>
      <varlistentry>
        <term>&ccb; resolve &gt;&gt; ccResolutions</term>
        <listitem>
          <para>Add any of the unknown global headers to the ccResolutions file. You can also use --nowarn to keep <command>&manpackage;</command> quiet, but you will have to think twice if you get compilation errors.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>&ccb; --brute</term>
        <listitem>
          <para>Get back to development after a distclean. This will update as much objects as will compile. Which will allow you to focus on the errors in the next &manpackage; call.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>&ccb; -p --compiler &apos;g++-3.4&apos; --args -Wall --args &apos;-Wextra -ansi&apos;</term>
        <listitem>
          <para>Precompile internal headers using <command>g++-3.4</command> and highlight all compiler output (-l). Also give all compiler commands the parameters &quot;-Wall -Wextra -ansi&quot;.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>&ccb; -f --args -O3</term>
        <listitem>
          <para>Recompiling your project for benchmarking tests. Forces the update of all code (-f) and sets the compiler argument to -O3.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>&ccb; --verbose dot; <command>dotty</command> *.dot</term>
        <listitem>
          <para>Graph the dependencies for all programs with colours. Then view these using <command>dotty</command>. This can help you to discover irregular dependencies and what test programs use.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>&ccb; --xof &apos;gedit&apos;</term>
        <listitem>
          <para>Try to compile the program and open the first file that does not compile correctly. Open all error producing sources in gedit. Very useful for when you change the interface of a class.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>&ccb; --compiler distcc -j 20</term>
        <listitem>
          <para>Use 20 distcc compilers to compile the project.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>&ccb; --nodefargs -f --args &apos;-Wall -Werror&apos; &amp;&amp; <command>svn</command> commit -m &apos;buildable backup&apos;</term>
        <listitem>
          <para>If all the sources are buildable without any warnings, commit everything to the repository using subversion.</para>
        </listitem>
      </varlistentry>
 		</variablelist>
  </refsect1>
<!--  
  <refsect1>
    <title>ENVIRONMENT</title>

    <para>Environment variables this program might care about.</para>
  </refsect1>
-->
  <refsect1>
    <title>FILES</title>

    <para>Configuration files used by &ccb;</para>
    <variablelist>
      <varlistentry>
        <term><filename>./ccResolutions[.USERNAME,.HOSTNAME,.KERNEL_NAME,.MACHINE,]</filename></term>
        <listitem><para>Local configuration which is project specific. It will load the first existing file of: ./ccResolutions.USERNAME, ./ccResolutions.HOSTNAME, ./ccResolutions.KERNEL_NAME, ./ccResolutions.MACHINE, ./ccResolutions. Hostname, kernel name and machine can be found with <command>uname -nsm</command>.</para></listitem>
      </varlistentry>
      <varlistentry>
        <term><filename>&tilde;/.ccbuild/ccResolutions</filename></term>
        <listitem><para>Global configuration file.</para></listitem>
      </varlistentry>
      <varlistentry>
        <term><filename>&tilde;/.ccbuild/ccResolutions.d</filename></term>
        <listitem><para>The resolution configuration directory. All files in this directory are considered configuration files.</para></listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
<!--
  <refsect1>
    <title>NOTES</title>

    <para>Miscellaneous commentary.</para>
  </refsect1>
-->
  <refsect1>
    <title>CAVEATS</title>
    <para>Don&apos;t place any file into <filename>o</filename> directories, these will be removed when using the distclean command. Also don&apos;t use files with the same basename, but different C++ extensions, this will give problems with the objects created (for example &quot;add.cc&quot; and &quot;add.cpp&quot; in the same directory).</para>
    <para>Currently there is no way to allow one object file to effect the command-line parameters of another. This means that if all objects need a flag, you must use the --args argument and cannot use a global header resolution line. Examples of these flags that need to be defined everywhere are -pthreads, -mthreads and -threads. Please read the g++ manual for more information on usage of flags.</para>
		<para>&manpackage; seems to be incompatible with flex 2.5.4. That version of flex places an int main function in the resulting scanner and there doesn't seem to be a way to stop it from mentioning it. The result is that &manpackage; will think that the generated scanner is a test program for your class and won't link it into the main program. A solution is to move to a newer version of flex or find a way to remove the int main function from the resulting scanner file.</para>    
  </refsect1>

<!--
  <refsect1>
    <title>DIAGNOSTICS</title>
    <para></para>
  </refsect1>
-->

  <refsect1>
    <title>REPORTING BUGS</title>

    <para>Report any issue with &manpackage; at: https://github.com/bneijt/ccbuild</para>
  </refsect1>

  <refsect1>
    <title>RESTRICTIONS</title>

    <para>&manpackage; will not follow or act on any include statements with a single space between the #-sign and the include. So all include statements starting with &quot;#&nbsp;include&quot; will be ignored, all other combinations will be acted on. This is a feature, not a bug. In verbose mode (--verbose) these are mentioned as warnings.</para>
  </refsect1>

  <refsect1>
    <title>AUTHOR</title>

    <para>A. Bram Neijt &lt;bneijt@gmail.com&gt;</para>
  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>pkg-config(1), dotty(1), make(1), icmake(1), g++(1), aap(1), svn(1)</para>
  </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
