m (Reverted edits by TreroLotrr (Talk); changed back to last version by Trapdoor) |
|||
Line 131: | Line 131: | ||
--[[User:Trapdoor|Trapdoor]] 01:39, 18 February 2007 (CET) / Updated 21 November 2007 | --[[User:Trapdoor|Trapdoor]] 01:39, 18 February 2007 (CET) / Updated 21 November 2007 | ||
[[Category:programming]] |
Revision as of 08:31, 15 November 2010
Introduction
The following is the result of a lot of hacking and working around small problems, and certainly not complete yet nor probably the way you should actually be building TMW for Mac.
Note that TMW and all libraries are being installed to /Users/bjorn, you should probably use your own home directory. ;-)
Dependencies
All dependencies except the OpenGL library were statically linked.
OpenGL
On Tiger, we found the OpenGL headers in:
/System/Library/Frameworks/OpenGL.framework/Headers
These were copied to:
/Users/bjorn/include/GL
This is in order for Guichan and TMW to find "GL/gl.h".
libpng
libpng 1.2.8 does not use GNU autotools. We used "scripts/makefile.darwin" after modifying it to change the install prefix. Static libraries were installed by "make -f makefile.darwin install-static".
libogg
libvorbis
While the vorbis.com download page is still listing libvorbis 1.0.1, this version failed on Mac so libvorbis 1.1.1 was used which compiled fine.
libxml2
SDL
After installing SDL, make sure sdl-config is in your path (like add /Users/bjorn/bin to the PATH environment variable). This ensures dependent packages can find the SDL headers and libraries.
SDL_image
SDL_mixer
Guichan
We took the Guichan 0.4.0 release and applied one small fix to get transparency to work right on the big endian system. This fix can be found here.
Configure command:
./configure --prefix=$HOME --disable-shared \ --enable-force-sdl --enable-force-sdlimage --enable-force-opengl \ CXXFLAGS="-I/Users/bjorn/include -I/Users/bjorn/include/SDL"
PhysFS
PhysFS 1.0.0 needed a -lreadline added to its test_physfs_LDFLAGS in Makefile.in line 280.
The Mana World
The src/Makefile.in file had to be modified to include net/win2mac.cpp.
Configure command:
./configure --prefix=$HOME --with-opengl \ CXXFLAGS="-I/Users/bjorn/include -I/Users/bjorn/include/SDL -I/Users/bjorn/include/libxml2 -DMACOSX" \ LIBS="-L/Users/bjorn/lib -L/System/Library/Frameworks/OpenGL.framework/Libraries -lSDL -lpng"
Problems
- Sound is crashy
- Performance could use some improvement (drawing windows like the chat window appears to be the main CPU hog
Suggestions
Try --enable-static-link configure option and -static linker option.
Managed to build a segfaulting static binary of TMW on Linux with following command:
./configure --prefix=$HOME --with-opengl LDFLAGS="-static" LIBS="-L/usr/X11R6/lib/ -lssl -lcrypto \ -lpng -lmikmod -lSDL -ljpeg -lvorbisfile -lvorbis -logg -lz -lXext -lX11 -lpthread -ldl"
It might be a good idea to try to get the OSX version done with a .app instead of static linking anyway since as http://developer.apple.com/qa/qa2001/qa1118.html states, you appear to need Csu module to link statically in OSX. I'm currently looking at how to make an Xcode Application that would include those dependencies as Frameworks which would apparently be a more OSX approach. I think that could also result in a more stable binary.
Making it more Mac-like
Raw binaries, data files in folders, and .zip distributions are all nontypical for Mac applications. The source code for a Cocoa wrapper-program for tmw to solve these issues can be found here: http://home.comcast.net/~Catfish_Man/ManaWorld.zip
Place the tmw binary and data folder in the project folder, open ManaWorld.xcode (or .xcodeproj for Xcode 2.1 and later users. It can automatically convert between the two formats), and click build. You should get a copy of ManaWorld.app located in the build folder. Since it's built in development mode, this won't work except on the computer it's built on. To switch to deployment mode go to the build menu, choose build results, and change the active build configuration to Deployment.
You can make a compressed disk image of the application for distribution by running the following script (included with the wrapper):
./buildDMG.pl -dmgName "ManaWorld" -buildDir . -volSize 4 -volName "ManaWorld" -compressionLevel=9 ./build/Deployment/ManaWorld.app/
To add an icon, like the one TMW sets later, open /Developer/Applications/Utilities/Icon Composer. from there, drag the png icon from the data directories into each pane on the left. Then, save the icon to *.icns, and place it within the Resoures directory. Then, go up one level, then open Info.plist. There, click on Root, then click "add Child". name it CFBundleiconFile, change it's class to string, and it's value to your icon name. Logo out, then log back in, and it's icon has changed.
Using Xcode
For this you will need to have already downloaded the SDL.framework, SDL_mixer.framework, SDL_image.framework and (if not using trunk) the SDL_net.framework from the SDL site. You will also need libpng, zlib and guichan which I will link to dynamically from /usr/lib. You will also need to download physfs (and if using the trunk version enet), which I compile inside the project.
First compile and install libpng, zlib and guichan to /usr/lib using the Makefiles (type make install in their respective directories from Terminal).
Create a new project and select SDL OpenGL Application. This should already link you to the SDL and OpenGL frameworks.
Add all the tmw .cpp and .h files to the source group. (Remove any atlantis files that may be there)
Select Frameworks group and then choose Project->Add to Project. Do this for (by default in /System/Library/Frameworks)IOKit, Carbon, (by default these will be in /Library/Frameworks)SDL_mixer, SDL_net, SDL_image. (For trunk SDL_net is not needed)
Create a new group called physfs, and another called libs. (For trunk create another group called enet)
Put the relevant physfs files inside the physfs group. (For trunk add the enet files to enet group) Add -L/usr/lib -lpng -lz -lguichan -lxml2 -lcurl to the linker flags inside the build options.
Add the search header paths needed (mainly /usr/include/[lib] or possibly need to add the path to headers in a Framework). Add library search path if needed for /usr/lib.
Add -DPHYSFS_SUPPORTS_ZIP to compiler flags (or preprocessor macros). If you want to use OpenGL, add -DUSE_OPENGL to the compiler flags.
Click build.
If you have any problems, ask in the forums.
--Trapdoor 01:39, 18 February 2007 (CET) / Updated 21 November 2007