Compile MaNGOS On Mac OS X
From MangosWiki
Dependencies
The following software needs to be installed before continuing:
- Xcode - install from your OS X Installation DVD or downloaded from Apple's Developer Connection.
- You must install the optional package UNIX Development Support.
- MySQL Community Database Server from MySQL.com.
- If compiling on a 64-bit Mac (MacPro, etc), install the 32-bit MySQL package instead.
- To control MySQL from System Preferences, also install the MySQL.prefPane and MySQLStartupItem.pkg inside the disk image.
- Git Source Code Management Tool hosted at Google Code or compile it yourself.
- pkg-config - from freedesktop.org. Help on compilation and installation is below.
Notes
- This guide requires use of the Terminal application, commands to enter into the Terminal are displayed like this:
-
echo "hello world"
- Copying & pasting command lines from here into the Terminal is easier than typing by hand.
Compiling and Installing pkg-config
- Download the pkg-config source from pkgconfig.freedesktop.org/releases. The latest is pkg-config-0.23.tar.gz as of this writing.
- Untar the pkg-config source:
-
cd ~/Downloads/
-
tar xvfz pkg-config-0.23.tar.gz
-
cd pkg-config-0.23
- Configure pkg-config:
-
./configure
- Compile & install:
-
make -j2
-
sudo make install
- Add PKG_CONFIG_PATH to bash_profile so pkg-config can find the openssl.pc file.
export PKG_CONFIG_PATH=/usr/lib/pkgconfig/
Preparing MySQL
- Teach the location of the MySQL tools to your Terminal (Bash paths):
-
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> ~/.bash_profile
-
source ~/.bash_profile
- Link the MySQL developer files to their proper locations (requires admin password):
-
sudo ln -s /usr/local/mysql/include /usr/include/mysql
-
sudo ln -s /usr/local/mysql/lib /usr/lib/mysql
Obtain & merge ScriptDev2 (optional)
- This section is optional and will greatly extend the time it takes to compile. ScriptDev2 gives additional functionality to MaNGOS, such as enabling Guards to give directions and allowing creatures to cast spells and "talk".
- Download the latest ScriptDev2 version:
-
cd ~/source/mangos
-
svn co https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2 src/bindings/ScriptDev2
- You may receive an "Error validating server certificate" warning at this point however it is safe to type "p" & press return to choose the option "(p)ermanently".
- Merge ScriptDev2 into your repository:
-
git apply src/bindings/ScriptDev2/patches/MaNGOS-8759-ScriptDev2.patch
-
git commit -am "Using SD2."
Compile for the first time
- Create a directory to compile into:
-
cd ~/source/mangos
-
mkdir -p build
-
cd build
- Compile:
-
autoreconf -if ..
-
../configure --prefix=/usr/local --datadir=/usr/local/share --sysconfdir=/usr/local/etc LIBS="-lcrypto" CFLAGS="-O2" CXXFLAGS="-O2"
- See the section Configure Notes for more information on the configure options.
-
make -j 2
- With make -j 2, change 2 to the number of processors in your Mac. Affects compile speed.
- Install (requires admin password):
-
sudo make install
-
sudo cp /usr/local/etc/realmd.conf.dist /usr/local/etc/realmd.conf
-
sudo cp /usr/local/etc/mangosd.conf.dist /usr/local/etc/mangosd.conf
Update & recompile
- Examine the output of Steps 1 & 2. If any new *.sql files are added, you will need to apply each of those sql batch files to the appropriate database if you want to install and use the update.
- Update the MaNGOS source code:
-
cd ~/source/mangos
-
git pull
- Update ScriptDev2 (only if you chose to use it):
-
svn update src/bindings/ScriptDev2
- Compile:
-
cd ~/source/mangos/build
-
make -j 2
- With make -j 2, change 2 to the number of processors in your Mac. Affects compile speed.
- Install (requires admin password):
-
sudo make install
Clean the code base
- This is only needed if you have updated the source code and it cannot compile successfully.
-
cd ~/source/mangos/build
-
make clean
Compile the map & dbc extractor
- If you haven't already done so, apply the needed extractor patch:
-
cd ~/source/mangos
-
curl http://pastie.org/616725.txt | git apply
-
git add contrib/extractor/ad.xcodeproj
-
git commit -am "Applied Mac extractor patch."
- If the patch did not apply cleanly to loadlib.h, simply use http://pastie.org/753771 as a guide to hand-edit the loadlib.h changes.
- Open the ad Xcode project file:
-
open ~/source/mangos/contrib/extractor/ad.xcodeproj
- Click the Build button in the toolbar (or choose Build from the Build menu).
- When built, click the Products folder inside Groups & Files on the left. Right click ad in the pane to the right and choose Reveal in Finder.
Extracting maps and dbc files
- Copy/move the ad program into your World of Warcraft folder.
- Double-click the ad program and wait until it has finished (or press Control-C to cancel).
- Move the extracted maps and dbc folders from your World of Warcraft folder into the mangos folder (which is inside the folder you configured as --datadir when compiling, eg. /usr/local/share/mangos ).
Secure MySQL & Database Initialization
- Start the MySQL server by using the option in System Preferences.
- Enter the mysql console:
-
# mysql -u root
- Delete the test database and prevent anonymous login:
-
DROP DATABASE IF EXISTS `test`;
-
DELETE FROM mysql.user WHERE User = '';
- Set your MySQL root password; instead of the word oranges, type the password of your choice:
-
UPDATE mysql.user SET Password = PASSWORD('oranges') WHERE User = 'root';
-
FLUSH PRIVILEGES;
-
EXIT;
- To enter the mysql console again, you must provide a password. Make sure you can log in again. If not, correct your MySQL user account before continuing.
-
# mysql -u root -p
-
EXIT;
- Create the MaNGOS databases (use the pass you chose above, not oranges):
-
# mysql -u root -poranges < ~/source/mangos/sql/create_mysql.sql
-
# mysql -u root -poranges < ~/source/mangos/src/bindings/ScriptDev2/sql/scriptdev2_create_database.sql
- A new MySQL account called mangos with the password mangos will now exist. It is recommended to use this account for the MaNGOS databases instead of your root MySQL account for security, eg. mysql -u mangos -p
- See the following section Databases to populate the databases.
Databases
Besides using the MySQL console in the Terminal, you can use other tools to administer your databases:
MaNGOS makes use of 4 different databases:
- characters database - can be populated with the command:
-
mysql --user=mangos --password=mangos characters < ~/source/mangos/sql/characters.sql
- realmd database - can be populated with the command:
-
mysql --user=mangos --password=mangos realmd < ~/source/mangos/sql/realmd.sql
- mangos database - Several groups exist that can populate this database and each have their own method of installation and updating. Consult the forums of your choice:
- scriptdev2 database (if you chose to use ScriptDev2) can be initialized with these 2 commands:
-
mysql --user=mangos --password=mangos scriptdev2 < ~/source/mangos/src/bindings/ScriptDev2/sql/scriptdev2_create_structure_mysql.sql
-
mysql --user=mangos --password=mangos scriptdev2 < ~/source/mangos/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql
Configuration & settings
Inside the folder you configured as --sysconfdir when compiling (eg. /usr/local/etc), edit the following files:
- mangosd.conf
- Set the DataDir setting to the location of your maps, dbc (and vmaps) folders, eg /usr/local/share/mangos
- Change the LoginDatabaseInfo setting to use your MySQL account & password, eg 127.0.0.1;3306;mangos;mangos;realmd
- Change the WorldDatabaseInfo setting to use your MySQL account & password, eg 127.0.0.1;3306;mangos;mangos;mangos
- Change the CharacterDatabaseInfo setting to use your MySQL account & password, eg 127.0.0.1;3306;mangos;mangos;characters
- realmd.conf
- Change the LoginDatabaseInfo setting to use your MySQL account & password, eg 127.0.0.1;3306;mangos;mangos;realmd
- scriptdev2.conf (if you are using ScriptDev2)
- Change the ScriptDev2DatabaseInfo setting to use your MySQL account & password, eg 127.0.0.1;3306;mangos;mangos;scriptdev2
Configure Notes
- --prefix is the base directory that MaNGOS will be installed into. Common prefixes are:
- /usr/local
- /opt/mangos
- $HOME
- --sysconfdir is the location that the config (settings) files will be installed into. Common values are:
- /usr/local/etc
- /opt/mangos/etc
- $HOME/etc
- --datadir is the location where a folder called "mangos" will be created and the base database sql files installed, that's where you will need to place the extracted maps, dbc (and optionally vmaps) folders. Common values are:
- /usr/local/share
- /opt
- $HOME/share
- --enable-cli enables the command line interface, highly recommended.
- --enable-ra adds remote access code to your compile, it allows you to connect your server via Telnet if enabled in the configuration files.
- --with-debug-info includes debug info in compiled libraries.
- --LIBS="-lcrypto" is absolutely necessary in order to compile on OS X!
Vmap files (optional)
- Vmap files allow MaNGOS to perform "line of sight" calculations inside the environment, it also needs to be enabled in the mangosd.conf settings file.
- The vmaps extractor and assembler have not been ported to OS X, but the Windows versions work fine with Crossover (tested using an XP bottle).
- Locate the vmap files in the MaNGOS source code directory:
-
open ~/source/mangos/contrib/vmap_extract_assembler_bin
- Copy the following files into your World of Warcraft folder:
- splitConfig.txt
- vmap_assembler.exe
- vmapextract_v2.exe
- Launch Crossover and choose Run Command... from the Programs menu
- Click the Open Shell button in the resulting window
- After it automatically sets some variables, type cd and press the space bar, then drag your World of Warcraft folder into that Terminal window. Press the return key.
- Part 1 of the process (takes a long time):
-
wine vmapextract_v2.exe
- Part 2 (also takes a long time):
-
mkdir vmaps
-
wine vmap_assembler.exe buildings vmaps splitConfig.txt
- When Part 2 has finished, the buildings folder inside your World of Warcraft folder contains unneeded files and can be deleted. Move the extracted vmaps folder from your World of Warcraft folder into the mangos folder (which is inside the folder you configured as --datadir when compiling eg. /usr/local/share/mangos ). Don't forget to enable the vmap options in your mangosd.conf file.
Miscellaneous
- Remove all patches (even the needed Mac changes & ScriptDev2) from the source:
cd ~/source/mangos
git reset --hard origin
rm -rf ./build
rm -rf ./src/bindings/ScriptDev2
- Make a file that lists every MaNGOS command (commands.html on your Desktop):
mysql --user=mangos --password=mangos --html --execute='select * from `mangos`.`command` order by name' > ~/Desktop/commands.html
sed -i '' "s/\\\n/<BR>/g" ~/Desktop/commands.html
- View the MaNGOS change log. Use arrow keys to navigate, press q to quit:
cd ~/source/mangos
git log
- View the ScriptDev2 change log (if used). Use arrow keys to navigate, press q to quit:
cd ~/source/mangos
svn log --limit 10 ./src/bindings/ScriptDev2 | less
- Launch the Git Graphical Interface:
cd ~/source/mangos
git gui
- Launch the Git Repository Browser:
cd ~/source/mangos
gitkil
Based on the guide created by Saria then updated and improved by Jylan from the Mang4Mac forums.