Difference between revisions of "Building AMX Mod X"

From AlliedModders Wiki
Jump to: navigation, search
m
m (Added missing --symbol-files compilation option)
 
(7 intermediate revisions by 5 users not shown)
Line 5: Line 5:
 
==Windows==
 
==Windows==
 
<ol>
 
<ol>
  <li>Install Visual Studio or Visual C++ 2010 or higher. Express editions should work fine. If you use 2013 or higher, make sure to get the "Desktop" version: [http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop Visual Studio Express 2013 for Desktop].</li>
+
  <li>Install Visual Studio or Visual C++ 2013 or higher. Express editions should work fine. Make sure to get the "Desktop" version: [http://www.visualstudio.com/downloads/download-visual-studio-vs Visual Studio].</li>
 
  <li>Install [http://git-scm.com/ Git]. Make sure that you select the option that adds Git to PATH.</li>
 
  <li>Install [http://git-scm.com/ Git]. Make sure that you select the option that adds Git to PATH.</li>
 +
<li>Install [https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D Nasm]. Go the latest version, then choose either win32 or win64 directory. Optionally, add the Nasm to PATH.
 
  <li>Next, you will need to start an environment capable of running Python and interacting with the Visual Studio compiler. There are two ways to do this.
 
  <li>Next, you will need to start an environment capable of running Python and interacting with the Visual Studio compiler. There are two ways to do this.
 
  <ul>
 
  <ul>
   <li>Use [https://wiki.mozilla.org/MozillaBuild MozillaBuild]. MozillaBuild comes with Python, Mercurial, and a unix-like shell.
+
   <li>Use [https://wiki.mozilla.org/MozillaBuild MozillaBuild 2.2.0]. MozillaBuild comes with Python, Mercurial, and a unix-like shell. Do not use version 3 and higher.
 
   <ol>
 
   <ol>
 
     <li>Install MozillaBuild.</li>
 
     <li>Install MozillaBuild.</li>
     <li>Navigate to <tt>C:\mozilla-build</tt> and run the batch file corresponding to your Visual Studio version. For example, <tt>start-msvc10.bat</tt> for Visual Studio 2010 (10.0). Do not run an x64 version.</li>
+
     <li>Navigate to <tt>C:\mozilla-build</tt> and run the batch file corresponding to your Visual Studio version. For example, <tt>start-msvc13.bat</tt> for Visual Studio 2013 (12.0). Do not run an x64 version.</li>
 
     <li>Add Git to MozillaBuild's <tt>PATH</tt>. The easiest way to do this is to enter the following commands:
 
     <li>Add Git to MozillaBuild's <tt>PATH</tt>. The easiest way to do this is to enter the following commands:
 
<pre>
 
<pre>
Line 23: Line 24:
 
   <li>Or, you can manually set up a shell.
 
   <li>Or, you can manually set up a shell.
 
   <ol>
 
   <ol>
     <li>Install [http://mercurial.selenic.com/ Mercurial].</li>
+
     <li>Install [https://www.mercurial-scm.org/ Mercurial].</li>
 
     <li>Install [http://python.org/ Python] 2.7. It will install to C:\Python27 by default. (Version 3.4 will work, but is not recommended for compatibility with other tools).</li>
 
     <li>Install [http://python.org/ Python] 2.7. It will install to C:\Python27 by default. (Version 3.4 will work, but is not recommended for compatibility with other tools).</li>
 
     <li>Add Python to your <tt>PATH</tt> variable. Go to Control Panel, System, Advanced, Environment Variables. Add <tt>C:\Python27;C:\Python27\Scripts</tt> to <tt>PATH</tt> (or wherever your Python install is).</li>
 
     <li>Add Python to your <tt>PATH</tt> variable. Go to Control Panel, System, Advanced, Environment Variables. Add <tt>C:\Python27;C:\Python27\Scripts</tt> to <tt>PATH</tt> (or wherever your Python install is).</li>
     <li>Under Start, Programs, Microsoft Visual Studio, select the "Visual Studio Tools" folder and run "Visual Studio Command Prompt". Alternately, open a normal command prompt and run <tt>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars.bat"</tt>. Substitute your Visual Studio version if needed.</li>
+
     <li>Under Start, Programs, Microsoft Visual Studio, select the "Visual Studio Tools" folder and run "Visual Studio Command Prompt". Alternately, open a normal command prompt and run <tt>"C:\Program Files (x86)\Microsoft Visual Studio 13.0\VC\bin\vcvars.bat"</tt>. Substitute your Visual Studio version if needed.</li>
 
   </ol>
 
   </ol>
 
   </li>
 
   </li>
Line 37: Line 38:
 
<ol>
 
<ol>
 
  <li>Install Git, via either system packages or from the [http://git-scm.com/ Git] distribution.</li>
 
  <li>Install Git, via either system packages or from the [http://git-scm.com/ Git] distribution.</li>
<li>Install Mercurial, via either system packages or the [http://mercurial.selenic.com/ Mercurial] distribution.</li>
 
 
  <li>Install either the GNU C Compiler or the Clang compiler. On Debian/Ubuntu, the following commands will give you everything:
 
  <li>Install either the GNU C Compiler or the Clang compiler. On Debian/Ubuntu, the following commands will give you everything:
 
   <pre>
 
   <pre>
sudo apt-get install gcc g++ clang
+
sudo apt-get install gcc g++ clang nasm
 
   </pre>
 
   </pre>
 
  </li>
 
  </li>
Line 57: Line 57:
  
 
<ol>
 
<ol>
  <li>Install Mercurial if you do not have it - there are a few ways to do this. Using the [http://mercurial.selenic.com/ Mercurial] distribution will work, or you can use [http://www.macports.org/ macports] or [http://brew.sh/ homebrew].</i>
+
  <li>Install the Xcode Command Line Tools.
<li>Download and install XCode from the App Store. Launch XCode, then navigate to Preferences -> Downloads -> Command line tools -> Components -> Install. If you have recently upgraded XCode, you will need to perform this step again. AMX Mod X cannot build without XCode's command line tools.</li>
+
  <ul>
 +
    <li>For OS X 10.9 or higher, run the command below in Terminal and click the Install button in the window that appears.
 +
<pre>
 +
xcode-select --install
 +
</pre>
 +
    </li>
 +
    <li>For earlier versions of OS X, download and install Xcode from the App Store. Launch Xcode and then navigate to Preferences -> Downloads -> Components -> Command Line Tools -> Install. If you have recently upgraded Xcode, you will need to perform this step again. AMX Mod X cannot build without Xcode's command line tools.</li>
 +
  </ul>
 
</ol>
 
</ol>
  
 
=Dependencies=
 
=Dependencies=
Building AMX Mod X requires AMBuild, Metamod, the Half-Life SDK, and optionally MySQL 5. If you're using Linux, OS X, or Windows with MozillaBuild, you download and run the following script to get everything:
+
Building AMX Mod X requires AMBuild, Metamod, the Half-Life SDK, and optionally MySQL 5.5. If you're using Linux, OS X, or Windows with MozillaBuild, you download and run the following script to get everything:
  
 
<pre>
 
<pre>
wget https://raw2.github.com/alliedmodders/amxmodx/master/support/checkout-deps.sh
+
https://raw.githubusercontent.com/alliedmodders/amxmodx/master/support/checkout-deps.sh
 
bash checkout-deps.sh
 
bash checkout-deps.sh
 
</pre>
 
</pre>
Line 73: Line 80:
 
If for some reason this script doesn't work, or you can't use it, you can get AMX Mod X and its dependencies like so:
 
If for some reason this script doesn't work, or you can't use it, you can get AMX Mod X and its dependencies like so:
 
<pre>
 
<pre>
hg clone http://hg.alliedmods.net/ambuild
+
git clone https://github.com/alliedmodders/ambuild
hg clone http://hg.alliedmods.net/metamod-am
+
git clone https://github.com/alliedmodders/metamod-hl1
hg clone http://hg.alliedmods.net/hl2sdks/hlsdk
+
git clone https://github.com/alliedmodders/hlsdk
git clone https://github.com/alliedmodders/amxmodx
+
git clone --recursive https://github.com/alliedmodders/amxmodx
 
cd ambuild
 
cd ambuild
 
python setup.py install    # May need sudo or root on Linux/OS X
 
python setup.py install    # May need sudo or root on Linux/OS X
Line 87: Line 94:
 
mkdir build
 
mkdir build
 
cd build
 
cd build
python ../amxmodx/configure.py
+
python ../configure.py
 
</pre>
 
</pre>
  
Line 93: Line 100:
  
 
There are a few extra options you can pass to <tt>configure</tt>:
 
There are a few extra options you can pass to <tt>configure</tt>:
*--enable-debug - Compile with symbols and debug checks/assertions.
+
*<tt>--enable-debug</tt> - Compile with symbols and debug checks/assertions.
*--enable-optimize - Compile with optimizations.
+
*<tt>--enable-optimize</tt> - Compile with optimizations.
*--no-mysql - If you didn't install MySQL, you can choose not to build the extension.
+
*<tt>--symbol-files</tt> - Remove debugging symbols
 +
*<tt>--no-mysql</tt> - If you didn't install MySQL, you can choose not to build the extension.
 +
*<tt>--hlsdk</tt> - Custom path to HLSDK.
 +
*<tt>--metamod</tt> - Custom path to Metamod source code.
 +
*<tt>--mysql</tt> - Custom path to MySQL.
 +
*<tt>--disable-auto-versioning</tt> - Disable the auto-versioning script
 +
*<tt>--nasm</tt> - Path to Nasm. If you are under windows and you did not add Nasm to PATH, you can choose the location.
  
 
=Building=
 
=Building=

Latest revision as of 06:34, 3 October 2020

AMX Mod X is a large project, but we've tried to make it as easy to build as possible. The directions here will step you through the entire process.

Requirements

Windows

  1. Install Visual Studio or Visual C++ 2013 or higher. Express editions should work fine. Make sure to get the "Desktop" version: Visual Studio.
  2. Install Git. Make sure that you select the option that adds Git to PATH.
  3. Install Nasm. Go the latest version, then choose either win32 or win64 directory. Optionally, add the Nasm to PATH.
  4. Next, you will need to start an environment capable of running Python and interacting with the Visual Studio compiler. There are two ways to do this.
    • Use MozillaBuild 2.2.0. MozillaBuild comes with Python, Mercurial, and a unix-like shell. Do not use version 3 and higher.
      1. Install MozillaBuild.
      2. Navigate to C:\mozilla-build and run the batch file corresponding to your Visual Studio version. For example, start-msvc13.bat for Visual Studio 2013 (12.0). Do not run an x64 version.
      3. Add Git to MozillaBuild's PATH. The easiest way to do this is to enter the following commands:
        echo "export PATH=\$PATH:/c/Program\ Files\ \(x86\)/Git/bin" >> ~/.profile
        source ~/.profile
        
    • Or, you can manually set up a shell.
      1. Install Mercurial.
      2. Install Python 2.7. It will install to C:\Python27 by default. (Version 3.4 will work, but is not recommended for compatibility with other tools).
      3. Add Python to your PATH variable. Go to Control Panel, System, Advanced, Environment Variables. Add C:\Python27;C:\Python27\Scripts to PATH (or wherever your Python install is).
      4. Under Start, Programs, Microsoft Visual Studio, select the "Visual Studio Tools" folder and run "Visual Studio Command Prompt". Alternately, open a normal command prompt and run "C:\Program Files (x86)\Microsoft Visual Studio 13.0\VC\bin\vcvars.bat". Substitute your Visual Studio version if needed.

Note that AMX Mod X also has Visual Studio project files. These can be used for local development, however, they are not maintained nor are they used for official builds.

Linux

  1. Install Git, via either system packages or from the Git distribution.
  2. Install either the GNU C Compiler or the Clang compiler. On Debian/Ubuntu, the following commands will give you everything:
    sudo apt-get install gcc g++ clang nasm
      
  3. If building on a 64-bit system, a few additional packages may be required. For example on Debian/Ubuntu they are:
    sudo apt-get install ia32-libs
    sudo apt-get install lib32z1 lib32z1-dev
    sudo apt-get install libc6-dev-i386 libc6-i386
    sudo apt-get install gcc-multilib g++-multilib
    

Mac OS X

Mac OS X 10.7 or higher is required to build, however, AMX Mod X will work on versions as early as 10.5.

  1. Install the Xcode Command Line Tools.
    • For OS X 10.9 or higher, run the command below in Terminal and click the Install button in the window that appears.
      xcode-select --install
      
    • For earlier versions of OS X, download and install Xcode from the App Store. Launch Xcode and then navigate to Preferences -> Downloads -> Components -> Command Line Tools -> Install. If you have recently upgraded Xcode, you will need to perform this step again. AMX Mod X cannot build without Xcode's command line tools.

Dependencies

Building AMX Mod X requires AMBuild, Metamod, the Half-Life SDK, and optionally MySQL 5.5. If you're using Linux, OS X, or Windows with MozillaBuild, you download and run the following script to get everything:

https://raw.githubusercontent.com/alliedmodders/amxmodx/master/support/checkout-deps.sh
bash checkout-deps.sh

This will download everything required into amxmodx, hlsdk, and metamod-am. If AMBuild is not installed, it will also download it into ambuild, and prompt you for your password to install it.

If for some reason this script doesn't work, or you can't use it, you can get AMX Mod X and its dependencies like so:

git clone https://github.com/alliedmodders/ambuild
git clone https://github.com/alliedmodders/metamod-hl1
git clone https://github.com/alliedmodders/hlsdk
git clone --recursive https://github.com/alliedmodders/amxmodx
cd ambuild
python setup.py install     # May need sudo or root on Linux/OS X

Configuring

The first time you are building AMX Mod X, you must configure the build. First create a build folder, and then run configure.py. For example:

mkdir build
cd build
python ../configure.py

It is safe to reconfigure over an old build. However, it's probably a bad idea to configure inside a random, non-empty folder.

There are a few extra options you can pass to configure:

  • --enable-debug - Compile with symbols and debug checks/assertions.
  • --enable-optimize - Compile with optimizations.
  • --symbol-files - Remove debugging symbols
  • --no-mysql - If you didn't install MySQL, you can choose not to build the extension.
  • --hlsdk - Custom path to HLSDK.
  • --metamod - Custom path to Metamod source code.
  • --mysql - Custom path to MySQL.
  • --disable-auto-versioning - Disable the auto-versioning script
  • --nasm - Path to Nasm. If you are under windows and you did not add Nasm to PATH, you can choose the location.

Building

To build AMX Mod X, simply navigate to your build folder and type ambuild:

cd build
ambuild

Alternately, you can specify the path of the build folder:

ambuild build

The full package layouts that would be shipped for release are in the package folder of the build.