Original documentation by Thomas Kalla, 17.09.2009
Last updated by Fabio Bas, 2012.04.07
#########################

This document contains step-by-step instructions for compiling KVIrc4 from SVN
sources on a Mac OS X system. Due to changed prerequisites and compilation 
system, this compilation howto does not apply to older versions of KVirc.


All this has worked fine several times for me. I've been using KVirc on Mac 
since May 2004 without any crashes & faults. Only the sound interface does not
work, but I have no use for it within an IRC client. However, I cannot
guarantee that this instructions will work for you as they do for me and I'm
not responsible for any problems or damage you may encounter after following
them. You should always understand what you are doing!


IMPORTANT: Installing KVIrc "the usual way" like on other popular Unix-like
OSes with files spread across several directories does not work and is
unsupported. The provided compilation system builds a typical "Bundle" for 
Mac OS X. A bundle is "just" a special directory structure on Mac systems which
contains the application binary, dependant libraries, plugins, modules and
other resources.

For further details look at http://qt-project.org/doc/qt-4.8/deployment-mac.html
and the documentation on http://developer.apple.com, please.


#########################
      Prerequisites
#########################

1. Apple Xcode

Any version should work as long as it supports Mac OS X 10.6 and higher.
You can get the latest version from the Mac App Store, or previous ones
registering at the developer portal at http://developer.apple.com (it's
free), download XCode and follow the install instructions in the documentation.

2. QT-MAC

I suggest to download and install the latest binary package from
http://http://qt.nokia.com/downloads .
You want the "Mac OS X 10.6 or later 64-bit:" package.

3. GNU gettext

Get the latest sources from your favourite GNU mirror. This step is optional
but you will lose the localisation support.

If you already installed Fink or MacPorts, you already have gettext so you
may skip this step.

Below, sample instruction follow for version 0.17 used by me:

Open a terminal window

	# cd /Developer
	# tar -xzf <your_path_to_the_sources>/gettext-0.17.tar.gz
	# cd gettext-0.17
	# ./configure
	# make
	# make install

4. CMake

Get the latest version of the automatic build system from http://www.cmake.org.
Again it's up to you if you want the easily installable binary package or read 
the documentation and compile by yourself.
Please note that when using XCode >= 4.3 you need at least cmake 2.8.8.

5. Make sure that gettext and CMake are accessible from your $PATH!


#########################
   KVIrc installation
#########################


1) Get the KVIrc sources:

	# svn co https://svn.kvirc.de/svn/trunk/kvirc

2) Build! :-)

Two IMPORTANT hints before you start:

Notes for x86_64 arch:
---
Currently i found no way to successfully add scripting support for Perl and
Python on Intel 64-bit macs. When compiled in, they both mess up with the
target architecture and leads to linking failures. Perl can be safely use
to generate the documentation, anyway.

I found KVIrc crashing when compiled in debug mode with QtDbus enabled and
no dbus daemon running, so i advice you to disable it.

Additionally, if you installed any kde-based software, you could end up with
a kde-enabled kvirc installation: you probably want to avoid that.

To sum these suggestion up, this  is my current cmake invocation:
cmake .. -DWANT_KDE4=0 -DWANT_DEBUG=1 -DWANT_QTDBUS=0 -DWANT_PYTHON=0 -DWANT_PERL=0
---

Notes for ppc/386 archs:
---
* If you want to use Perl (Documentation and Modules) you have to build a
universal binary. This is due to Cmake overriding your architecture values
by the ones found in 'ldflags' returned by calling "perl -V".
* If you want python support than you cannot build for an older Mac OS X
version, i.e. the value of $MACOSX_DEPLOYMENT_TARGET has to match the value
used by Apple when they built the python package.
---

I suggest an "out-of-source" build:

	# mkdir kvirc-build
	# cd kvirc-build
	# cmake <path-to-kvirc-src-dir>
	# make
	# make install

Instead of cmake you may also consider to call ccmake which provides a nice gui
for the options.

The result is a KVIrc.app bundle within the build directory.

If you plan to redistribute your package, you can use "macdeployqt" on the
generated KVIrc.app to inject the necessary Qt libraries in it: this will make
the bundle size grow up a lot, but will remove the requirement for other people
to install Qt in order to run your bundle.

3) Enjoy :-)

Open Finder, move your bundle into a better location (e.g. /Applications),
and double click to start.


