Thomas Kalla, 29.06.2006
#########################

This document contains step-by-step instructions for compiling kvirc on a MacOS X system.
I compiled several versions of kvirc (beginning with 3.0.0 up to recent CVS) on a Powerbook G4, 1.5GHz, 512 MB RAM and MacOS X 10.3.3-9.


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: These instructions refer to Qt/Mac. If you want Qt/X11 which is included in Fink you are on your own. There is no support for the latter and most probably you don't get a working build. 


#########################
Compilation with QT-MAC
#########################

IMPORTANT: When compiled with QT-MAC, kvirc has to be run out of a bundle! Otherwise the application won't dispatch the keyboard events correctly and will be pretty unusable for you.

A bundle is "just" a special directory structure on Mac systems which contains the application binary, dependant libraries, plugins, modules and other resources. So all we have to do is to run configure with proper paths and relink the binary, libraries and modules with relative paths after the compilation.

For details look at http://doc.trolltech.com/qq/qq09-mac-deployment.html and the documentation on http://developer.apple.com, please.

Prerequisites:

1. Apple XCode
Get the latest version from Apple. I've been using only V1.5 for building with QT-MAC

2. QT-MAC
Get the latest V3.*-version from Trolltech.

3. GNU gettext
Get the latest sources from your favourite GNU mirror.

Prerequisites installation:

1) Install XCode
If not included on your Panther install media or if you want the latest version, you have to register at http://developer.apple.com (it's free), download XCode and  follow the install instructions in the documentation.

2) Install QT-MAC
You have to compile QT yourself. As far as I know there are no compiled binaries avaiable. Download and unpack the sources and follow the documentation.

I used V3.3.4

Add the following two lines to your ~/.profile file, otherwise the compilation if Qt may fail.

export QTDIR=/Developer/qt-mac-free-3.3.4
export DYLD_FALLBACK_LIBRARY_PATH=$QTDIR/lib


Open a terminal window
# cd /Developer
# tar -xjf <your_path_to_the_sources>/qt-mac-free-3.3.4.tar.bz2
# cd qt-mac-free-3.3.4
# ./configure -thread -qt-gif -fast -no-exceptions -debug
# make sub-tools

(If you don't want to build with debug information, remove the "-debug" switch in te configure line. You may also want to change "QMAKE_CFLAGS_RELEASE = -Os" in the mkspec/macx-g++/qmake.conf file to -O2. If you want the tutorial and examples, run "make" instead of "make sub-tools")

3) Install GNU gettext
If you want non-english locales, you need GNU gettext.
If you already installed Fink, you already have gettext so you may skip this step.

I used V0.14.5

Open a terminal window
# cd /Developer
# tar -xzf <your_path_to_the_sources>/gettext-0.14.5.tar.gz
# cd gettext-0.14.5
# ./configure
# make
# make install


#########################
KVirc installation:


1) Get the KVirc sources:

IMOPRTANT: Only the CVS sources compile cleanly with QT-MAC for now!

# cvs -d:pserver:anonymous@cvs.kvirc.net:/cvs login

You will be asked for a password: just hit return.

# cvs -z3 -d:pserver:anonymous@cvs.kvirc.net:/cvs co kvirccvs

Run autogen:
# cd kvirccvs/kvirc
# ./autogen.sh


2) Run configure

The application bundle will be built in the kvirc sources directory.
Feel free to remove --enable-debug if you don't want to have a debuggable build and use addictional options like --enable-optimisation=2 or --with-big-channels.

# ./configure --enable-pipes --enable-debug --exec-prefix=$(pwd)/KVirc.app/Contents/Resources --prefix=$(pwd)/KVirc.app/Contents --bindir=$(pwd)/KVirc.app/Contents/MacOS --libdir=$(pwd)/KVirc.app/Contents/Frameworks --datadir=$(pwd)//KVirc.app/Contents/Resources --disable-x-support 


3) Run make

CAUTION!!! Because of a problem with libtool you have to remove or rename the file libqt-mt.la (or libqt.la if you compiled QT without threads). It is located in $QTDIR/lib/. Otherwise the compilation will stop with a link error.

# mv $QTDIR/lib/libqt-mt.la $QTDIR/lib/libqt-mt.la.bak

Now run make and relax :-)

# make

(A debuggable, non-optimized build takes about 40 minutes on my PowerBook.)


4) Run make install

# make install


5) Relinking

KVirc and its modules depend on libkvilib and libqt which are not in the dynamic linker search path by default. The paths set during the compilation are absolute paths and have to be changed to be realtive to the executable path.

The following commands do this for libkvilib:

# install_name_tool -id @executable_path/../Frameworks/libkvilib.3.dylib $(pwd)/KVirc.app/Contents/Frameworks/libkvilib.3.dylib
# install_name_tool -change $(pwd)/KVirc.app/Contents/Frameworks/libkvilib.3.dylib @executable_path/../Frameworks/libkvilib.3.dylib $(pwd)/KVirc.app/Contents/MacOS/kvirc
# find $(pwd)/KVirc.app/Contents -name '*.so' | xargs -n1 install_name_tool -change $(pwd)/KVirc.app/Contents/Frameworks/libkvilib.3.dylib @executable_path/../Frameworks/libkvilib.3.dylib

Now you have to decide whether you want to include libqt within the bundle or not. This is useful if you consider to share your bundle with your friends and they don't want to compile QT themselves.


a) You don't want to include libqt within the bundle

Make sure the dynamic linker is able to find libqt. The easiest way is to make symlinks in the /usr/lib directory.

# ln -sf $QTDIR/lib/libqt-mt.3.dylib /usr/lib
# ln -sf $QTDIR/lib/libqui.1.dylib /usr/lib


b) You want to include libqt within the bundle

Copy libqt into the bundle:

# cp $QTDIR/lib/libqt-mt.3.dylib $(pwd)/KVirc.app/Contents/Frameworks/

Relinking commands for libqt:

# install_name_tool -id @executable_path/../Frameworks/libqt-mt.3.dylib $(pwd)/KVirc.app/Contents/Frameworks/libqt-mt.3.dylib
# install_name_tool -change libqt-mt.3.dylib @executable_path/../Frameworks/libqt-mt.3.dylib $(pwd)/KVirc.app/Contents/MacOS/kvirc
# install_name_tool -change libqt-mt.3.dylib @executable_path/../Frameworks/libqt-mt.3.dylib $(pwd)/KVirc.app/Contents/Frameworks/libkvilib.3.dylib
# find $(pwd)/KVirc.app/Contents -name '*.so' | xargs -n1 install_name_tool -change libqt-mt.3.dylib @executable_path/../Frameworks/libqt-mt.3.dylib

6) Cleaning up

The bundle is funtional but is looks better with a nice icon :-)
Copy the icon file from the data/resources_mac directory to the resources directory and the Info.plist file to the contents directory

# cp data/resources_mac/kvirc.icns $(pwd)/KVirc.app/Contents/Resources
# cp data/resources_mac/Info.plist $(pwd)/KVirc.app/Contents


7) Enjoy :-)

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


