From Amarok Wiki
Building amarok 2 on OS X might present something of a challenge for the typical non-technical OS X user. Realize one thing while you suffer through this process however; this is amarok. It will be worth it. It builds, it runs, and it plays back audio. For the hardcore amarok junkie: this is enough. And make no mistake about it, you should only attempt this, if you are truly: HAAAAAAAARDCoooOOOOoooore. *Ahem* On to the show.
Contents |
In the beginning
In the beginning there was naught. Naught royally sucked, so we fought to get aught. This is where we begin. I will be using Mac OS X 10.5 (known as Leopard to all the cool kids) as my build system. Similar instructions apply for 10.4 (Tiger) and you should have an easier time of compiling. One day when I'm feeling far more benevolent I'll drop back into the rancid depths of Tiger and subject myself to testing these instructions on that platform. Till then, good night and good luck.
Install XCode 3.1
Install XCode from the iPhone SDK. Search google for it. Register with the ADC. Then download it. If you can't bother then wait for amarok packages and stop whining. P.S. Google loves you.
Install MacPorts
Grab the latest version of MacPorts, which as of this writing is, 1.6.0 and install it. As I am using 10.5, I installed the MacPorts-1.6.0-10.5-Leopard.dmg version from http://svn.macports.org/repository/macports/downloads/MacPorts-1.6.0/ Detailed information of how to do this can be found at http://guide.macports.org/#installing . Don't forget to update after installing via the 'port selfupdate' and 'port sync' commands.
If a ~/.profile file does not exist run these command to set up the macports environment:
echo 'export PATH=/opt/local/bin:/opt/local/sbin:$PATH' >> ~/.profile
source ~/.profile
After this you should be able to 'sudo port install' software to your heart's content. Use of sudo requires you to input the password of the user you are logged in as. If sudo isn't working you're either using the wrong password, don't own the computer and are using an unprivileged account (in which case you probably shouldn't be trying this) or are doing something of equal or greater silliness.
The Main Event
During this section we will install all the necessary non-KDE prerequisites for Amarok.
Xine: The dream killer.
The installation of xine-lib on intel-based mac machines requires a bit of command line sleight of hand. The only way the author has successfully been able to get this software to compile is following the instructions below. If you are able to successfully compile the application via another route, please add this information.
To begin we will open a terminal. The terminal provided in OS X is located in Applications -> Utilities -> Terminal. We'll begin by modifying the portfile (a useful thing to know) before we use it to install xine. This requires that we set an editor. OS X provides nano and vim. I will use vim as my editor, but nano might be a better choice for the command line novices. First we will set the editor by typing this into the Terminal
echo "export EDITOR=vim" >> ~/.profile; source ~/.profile
You will of course replace vim with nano if you're too scared. :-) Next we will begin to edit the xine-lib portfile via the command
sudo port edit xine-lib.
Now look for the line which begins with
depends_lib.
Delete everything up to and including the '\' on that line. That should bring the first item on this line to be lib:libaa:aalib. Now save the file and exit. Don't worry about screwing up, you just wont be able to compile xine-lib is all.
Next issue the command:
sudo port install xine-lib
This will allow macports to grab all the dependencies of xine-lib and build them. The two entries we previously removed were for XFree86, and esound, the linux sound daemon. If you were trying to get this to work for amarok on kde3 you'd want to keep those, but this, boys and girls is Amarok 2. We shall be using the native graphical AND audio frameworks of OS X. But I digress. You may encounter failed compilations or installations with some of these prerequisites. Don't worry, just re-issue the command 'sudo port install xine-lib' to continue the build and installation process. If at first you don't succeed try, try and try again (that's 3 times for those of you counting improperly. Seriously.) This will begin the installation from the last failed dependency and continue until xine-lib starts building. If you're an an intel mac when you finally get around to building xine-lib, you will fail. Fret not, I have defeated the vile beast with my superior ingenuity and intellect.
(Note: this next section is possibly deprecated. Please try the updated instructions at the end for xine 1.1.13 first, and fall back to this if necessary.)
Xine 1.1.9:
It seems xine-lib is failing on intel, i.e. x86 machines, because of how gcc 4.0 handles compilation of some pseudo-assembly xine/ffmpeg code. We get around this by installing the standalone ffmpeg port. This is done by issuing the command
sudo port install libtool ffmpeg +postproc +x264 +xvid +a52 +faac +faad +theora +lame +extvorbis
The important part here is the '+postproc'. Xine wants it. Xine needs it. Without further mangling our already butchered portfiles, xine must have it.
If you're using 10.4 you may encounter some problems, depending on whether the ffmpeg port has been updated yet. See http://trac.macosforge.org/projects/macports/ticket/14509 for info on how to fix. If ffmpeg stops working in 10.5 a similar strategy should work. Edit the portfile for ffmpeg and change the revision to svn.tag 12276. If ffmpeg still doesn't work for you, get it from svn and leave me alone.
After installing the ffmpeg we can now finally move on to xine-lib proper. What we're actually going to do is not use the macports version of xine at all. Instead, go and download the latest build of xine from their website. The version I used was xine-lib 1.1.9.1. So what I'm trying to say is these instructions are only guaranteed for 1.1.9.1. Once you've got it, unpack and enter the directory. After that run the ./autogen.sh script to set up the build environment like so:
./autogen.sh --enable-macosx-video --enable-coreaudio --prefix=/opt/local --without-esound --with-external-ffmpeg --without-x && make
This will eventually be followed by a compilation error. It seems some de-interlacing code also doesn't agree with apple's version of gcc which causes the xine-lib build to fail. We could conceivably use 'make -k' to get past the compilation error and keep compiling, but I have happened upon a more "elegant" solution. The offending code is in the kdetv de-interlace files. Since we're compiling xine to play music w/ Amarok we don't really care much about video. And certainly not de-interlacing video. What does de-interlacing even do? Anyways it's only one of the de-interlacing plugins available so no big loss.
I could provide a patch but that is only guaranteed to work with xine-lib 1.1.9.1. So instead I'm going to tell you which lines to change, but first let me tell you what they do. They will conditionally disable the non-building code on apple machines. You have been warned. Open the files kdetv_greedyh.c and kdetv_tomsmocomp.c, which can be found in the src/post/deinterlace/plugins directory, and look for the lines
- if defined (ARCH_X86) || defined (ARCH_X86_64)
Change all instances found (I found two) to instead read
- if (defined (ARCH_X86) || defined (ARCH_X86_64)) && !(defined (__APPLE__))
Then start your compilation by typing 'make' again. Once the build is finished, type 'sudo make install'. xine-lib should now be installed and FINALLY we can get on with the relatively simple (by comparison) task of installing Amarok 2.
Xine 1.1.13:
I (jefferai) did not have troubles installing xine 1.1.13 from source without using external ffmpeg. In fact, using external ffmpeg caused me difficulties. I used xine's internal ffmpeg and passed the postproc flag to it (...I think). Here is exactly what I did:
1) Grabbed the 1.1.13 tarball from the xine site and unpacked it. 2) Ran
./autogen.sh --enable-macosx-video --enab
le-coreaudio --prefix=/opt/local --without-esound --without-x --enable-pp
3) Ran "make"...and everything compiled, without all the heartache above. (Not sure it works yet, of course...)
Pre KDE requisites
Before we can start on Amarok a mini hurdle still exists in the form of the requirements for compiling kdelibs (which Amarok requires) and kdebase-workspace (which Amarok requires if you want the accompanying artwork to... well, work. We will again use the might macports build system to our advantage. I won't bother explaining what these packages are for as this is getting long, for more info see http://techbase.kde.org/Getting_Started/Build/KDE4
sudo port install dbus cmake subversion libxslt libxml2 shared-mime-info pkgconfig openssl jpeg giflib boost gpgme libpng libmng
if you're having problems install boost. See http://lists.macosforge.org/pipermail/macports-users/2008-May/010225.html
You may also want to consider adding the redland and clucene packages to this list as well. They are add useful functionality to KDE via soprano and strigi respectively. As I haven't actually gotten this functionality to work, and as this is about Amarok, I'll leave those out for now.
The next phase includes compilation of things which KDE needs which is not currently in macports or which we want to pull directly from the kde's svn repo. These include qimageblitz (necessary for amarok?), strigi, and soprano (again, necessary for amarok?). To get these items we will pull them from svn. Follow along closely in the terminal kids:
mkdir amarokin
cd amarokin
svn checkout svn://anonsvn.kde.org/home/kde/trunk/qt-copy
svn -N checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport
cd kdesupport
svn up automoc akonadi taglib strigi qimageblitz soprano phonon
cd ..
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepimlibs
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase
svn -N checkout svn://anonsvn.kde.org/home/kde/trunk/extragear/multimedia
cd multimedia
svn up amarok
Right. Now that should be everything we need. All that's necessary now is to compile the damn thing.
Compile your little heart out
Custom Linker Flags
Linking c++ code on OS X is tricky. Sometimes the gremlins in your computer decide that they want to be difficult and don't properly link code. This, as you can imagine, is far from an optimal solution should you wish to actually achieve some sort of success in this project. Therefore, you'll need to provide a little bit of m anual push to make the linker stay quiet. Add the following to your ~/.profile as such:
echo 'PATH=/opt/qt4/bin:/opt/kde4/bin:$PATH' >> ~/.profile
echo 'LDFLAGS="-undefined dynamic_lookup"' >> ~/.profile
. ~/.profile
And all should be good.
The Good Stuff
Currently you should be in the multimedia directory. The following commands should, hopefully, get everything you need built and installed in the proper order.
cd ..
cd qt-copy
CXXFLAGS=-isystem/opt/local/include ./configure -webkit -dbus-linked -qt-gif -phonon -prefix /opt/qt4 -L /opt/local/lib -lresolv -nomake demos -nomake examples
make
sudo make install
Next up is the support libraries in use by KDE4. I will be installing them into the KDE4 prefix /opt/kde4. Strictly speaking they aren't KDE4 apps and /usr/local or /opt/local are more suitable locations. Putting them into /opt/kde4 makes them much easier to manage however (since I usually rm /opt/kde4 at least once a month). I also don't want to mix these manual installations with the macports managed /opt/local. I've chosen to reserve /usr/local for apps not related to KDE4, whose state on my system are not in a constant state of flux.
Cmake is used to configure the the directories before make takes over. The syntax is very simple. Use "-DINSERT_BUILD_OPTION=value_you_want" to modify the available options. cmake also has to be told which directory it's working in, hence the '..' at the end. We could just have easily have used the absolute path instead of the relative one. If what I just said doesn't make any sense, make sure you copy and paste the commands below. The rest of you, feel free to modify as necessary.
cd ../kdesupport/strigi
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
cd ../../automoc
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
cd ../../akonadi
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
cd ../../taglib
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
cd ../../qimageblitz
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
cd ../../phonon
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
On to the good stuff. You'll notice after each cmake configuration that you will be notified of things which are missing. If you decide to install these later you can modify the makefile configuration using ccmake. Its use is identical to that of the cmake command, but it provides a command line gui that allows you to change build settings.
kdelibs has been having issues compiling cleanly lately. Here's an svn diff for the adventurous to fix this.
Index: /Users/orville/kdesvn/trunk/KDE/kdelibs/kinit/CMakeLists.txt
===================================================================
--- /Users/orville/kdesvn/trunk/KDE/kdelibs/kinit/CMakeLists.txt (revision 810365)
+++ /Users/orville/kdesvn/trunk/KDE/kdelibs/kinit/CMakeLists.txt (working copy)
@@ -34,7 +34,7 @@
set(kdeinit_SRCS kinit_win.cpp )
set(kdeinit_LIBS kparts psapi)
else (WIN32)
- set(kdeinit_SRCS kinit.cpp proctitle.cpp )
+ set(kdeinit_SRCS kinit.cpp proctitle.cpp ../kdecore/kernel/kkernel_mac.cpp)
set(kdeinit_LIBS kparts)
endif (WIN32)
Index: /Users/orville/kdesvn/trunk/KDE/kdelibs/kdeui/CMakeLists.txt
===================================================================
--- /Users/orville/kdesvn/trunk/KDE/kdelibs/kdeui/CMakeLists.txt (revision 810365)
+++ /Users/orville/kdesvn/trunk/KDE/kdelibs/kdeui/CMakeLists.txt (working copy)
@@ -238,7 +238,7 @@
set(kdeui_LIB_SRCS ${kdeui_LIB_SRCS} util/kkeyserver_x11.cpp )
endif (Q_WS_X11)
if (Q_WS_MAC)
- set(kdeui_LIB_SRCS ${kdeui_LIB_SRCS} util/kkeyserver_mac.cpp )
+ set(kdeui_LIB_SRCS ${kdeui_LIB_SRCS} util/kkeyserver_mac.cpp ../kdecore/kernel/kkernel_mac.cpp)
endif (Q_WS_MAC)
if (Q_WS_WIN)
set(kdeui_LIB_SRCS ${kdeui_LIB_SRCS} kernel/kapplication_win.cpp )
cd ../../../kdelibs
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
cd ../../kdepimlibs
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
cd ../../kdebase
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
And finally, we're down to amarok. <strikeout>Just so you know, that bit of ugliness in the cmake commands below are the result of a bug in leopard. If you're using tiger you'll be spared the indignity of needing it. In other words, if you're on tiger and the build fails due to an OpenGL error, try removing the linker flags below. </strikeout> For jefferai, this didn't work on Panther at all, in fact it made the build break. Apply the patch linked below from Ranger Rick, and use the normal cmake command.
cd ../../multimedia/amarok
mkdir build
cd build
CC=/usr/bin/gcc-4.2 CXX=/usr/bin/g++-4.2 cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..
make
sudo make install
Misc Stuff
http://paste.lisp.org/display/61739
Run, Fat Boy, Run
In the Terminal type
install_name_tool -change libphonon.4.dylib /opt/kde4/lib/libphonon.4.dylib /opt/kde4/bin/amarok.app/Contents/MacOS/Amarok
install_name_tool -change libphonon.4.dylib /opt/kde4/lib/libphonon.4.dylib /opt/kde4/bin/knotify4.app/Contents/MacOS/knotify4
install_name_tool -change libphonon.4.dylib /opt/kde4/lib/libphonon.4.dylib /opt/kde4/lib/kde4/plugins/phonon_platform/kde.so
for i in `ls /opt/kde4/lib/kde4/`; do install_name_tool -change libphonon.4.dylib /opt/kde4/lib/libphonon.4.dylib /opt/kde4/lib/kde4/$i; echo $?; done
for i in `ls /opt/kde4/lib/`; do install_name_tool -change libphonon.4.dylib /opt/kde4/lib/libphonon.4.dylib /opt/kde4/lib/$i; echo $?; done
kbuildsycoca4
open /opt/kde4/bin/amarok.app
Then pray, if Amarok loves you, it will bless you with its presence.
If not using RangerRick's "kick ass dbus-git" branch (whose url I repeatedly forget) you'll need to launch apps from the console using the open command.
You will also need to add the following to your ~/.profile
export XDG_CONFIG_DIRS=/opt/kde4/etc/xdg
export XDG_DATA_DIRS=/opt/kde4/share:/opt/local/share
eval `dbus-launch --auto-syntax`
TODO :
- add info about RangerRick's kick ass dbus-git branch
The Post-Game Show
The stuff you probably want to do AFTER you install to enjoy the hard earned fruits of your labor.
The Payoff
This is what you have to look forward to
or with a little sleight of hand in the source code
