Compiling KiCad on Gentoo
=========================

Information
-----------
First written: 02-Mar-2010

Written by: calchan at gentoo dot org


For regular users
-----------------

In order to install Kicad from sources in Gentoo you just need to:
----
    # emerge kicad
----
The package manager will resolve all dependencies, download the
necessary source code, and then configure it, compile it and install
it. You're done.

If you want to fine-tune your installation you can set some of the USE
flags. Do the following to see them:
----
    # emerge -vp kicad
----
The currently available USE flags are:
debug: make a debug build
doc: install documentation
examples: install examples
python: enable python
minimal: do not install the default component libraries (unsupported)

Enable or disable whatever USE flag(s) you want or don't want, for
example like this:
----
    # echo "sci-electronics/kicad doc -python" >> /etc/portage/package.use
----
Here we've just enabled documentation and disabled python. After that
you can emerge kicad.


For advanced users
------------------
If you're running stable gentoo and want the unstable (more recent)
version of kicad then do the following before running emerge:
----
    # echo "sci-electronics/kicad ~arch" >> /usr/portage/package.keywords
----
where ~arch is either ~amd64, ~ppc, ~ppc64 or ~x86 depending on your
architecture.

If you want to experiment with cmake flags to pass for compilation or
override one that's set by default in the ebuild you can do so like
this:
----
    # MYCMAKEARGS="-DUSE_WX_GRAPHICS_CONTEXT=ON" emerge kicad
----


For Kicad developers and packagers
----------------------------------

You can install from live sources instead of the latest package
version by doing the following:
----
    # echo "sci-electronics/kicad **" >> /etc/portage/package.keywords
    # emerge kicad
----
The version of Kicad that is going to be installed is called
kicad-99999999. The package manager will then checkout all sources
from the subversion repository, or update it to the latest revision if
you had already installed the live version of Kicad, and then do its
usual thing. You will get an additional USE flag called dev-doc which
is to set if you want to build the Doxygen documentation.

If you want to build a specific revision of Kicad from the subversion
repository, you can do:
----
    # ESVN_REVISION="2400" emerge kicad
----
Note that you can combine that with MYCMAKEARGS on the same command-line.

If you have built and tested Kicad and want to package it, it's very simple:
----
    # quickpkg kicad
----
This works for both live and standard installs of Kicad. The tarball
will be in /usr/portage/packages.

Here is one way to find out which packages contain the shared
libraries Kicad was built against, and what exact version they are:
----
    # equery belongs $(cat /var/db/pkg/sci-electronics/kicad-99999999/NEEDED | cut -d ' ' -f 2 | tr ',' '\n' | sort -u) | sort -u
----
You should replace kicad-99999999 with the version you have just
built. You might want to be careful with the interpretation of the
results from the above one-liner, but if you made it this far you
obviously know what you're dealing with.
