nsis64 / Docs / src / build.but

Full commit
\A{build} Building NSIS

NSIS version 2.07 introduced a new build system, based on \W{}{SCons}. The build system can build the entire NSIS package so there is no longer need to build it project by project. It allows building using several simultaneous jobs, installation without an installer on both Windows and POSIX and easy compilation with debugging symbols.

\#{ MSVC6.SP5 direct link: }
The official release is built with MSVC6 \W{}{Service Pack 5} \W{}{(Mirror)} with the \W{}{Processor Pack} and the February 2003 Platform SDK (5.2.3790.0).

\H{build_general} Building in General

Source code is available in \W{}{SVN} and as a separate package with every \W{}{NSIS distribution}.

To build NSIS \W{}{Python}, \W{}{SCons} must be installed. Currently, the supported version of SCons is version 1.2.0 and above. Any version of Python above 1.6 is supported.

NSIS uses the \W{}{zlib} compression library. As a
consequence the header and library files of zlib must be installed. 

In case these zlib development files aren't present then they could be
installed via a package manager (apt-get, aptitude, rpm, yum) on POSIX
platforms. Another option is to build zlib from scratch and install it.

For Windows it is recommended to download \W{}{zlib} from
Extract the contents of this zip archive to a folder of your choice, e.g.
\c{C:\\dev\\zlib-1.2.5} and set an environment variable named \c{ZLIB_W32} 
containing this path. 

\c C:\>set ZLIB_W32=C:\dev\zlib-1.2.5

Alternatively the command line option ZLIB_W32 specifying the path
could be passed with scons instead of the environment variable.

\c C:\dev\nsis>scons ZLIB_W32=C:\dev\zlib-1.2.5

The header and library files are assumed to be in %ZLIB_W32%. In addition
scons checks for zlib header files in %ZLIB_W32%\\include, the
import library zdll.lib in %ZLIB_W32%\\lib and the dynamic link library
zlib1.dll in %ZLIB_W32% respectively %ZLIB_W32%\\lib.

To build, open a console, change the working directory to the root directory of NSIS and type \c{scons}. That's it. For example:

\c C:\>cd dev\nsis
\c C:\dev\nsis>scons
\c scons: Reading SConscript files ...
\c Using Microsoft tools configuration
\c Checking for main() in C library gdi32... (cached) yes
\c Checking for main() in C library user32... (cached) yes
\c Checking for main() in C library version... (cached) yes
\c Checking for main() in C library pthread... (cached) no
\c Checking for main() in C library stdc++... (cached) no
\c Checking for main() in C library iconv... (cached) no
\c Checking for main() in C library libiconv... (cached) no
\c scons: done reading SConscript files.
\c scons: Building targets ...
\c ...

To install the built files, type:

\c scons PREFIX="C:\Program Files\NSIS" install

To create an installer (only on Windows), type:

\c scons dist-installer

To create a distribution zip file, type:

\c scons dist-zip

To create both, type:

\c scons dist

To get a complete list of options that the build system has to offer, type:

\c scons -h

To get a complete list of options SCons has to offer, type:

\c scons -H

\H{build_windows} Building on Windows

SCons will automatically detect Microsoft Visual C++. If you are looking for a free compiler to compile NSIS, we recommend \W{}{Microsoft Visual C++ 2005 Express Edition}.

When using the Microsoft Visual C++ Toolkit 2003, add MSTOOLKIT=yes to the build command line:

\c scons MSTOOLKIT=yes

In case of errors about the compiler or the Platform SDK not being found, use:

\c set MSSDK=C:\Path\To\Platform SDK
\c set VCToolkitInstallDir=C:\Path\To\VCToolkit
\c scons MSTOOLKIT=yes

The open-source \W{}{MinGW} can also be used to for building, but this results in noticeably larger installers. Borland C++ or Open Watcom C/C++ might also work, but haven't been tested.

To compile the documentation as a CHM file, hhc.exe must be in the PATH. It is available as part of \W{}{HTML Help Workshop}.

To build NSIS Menu, install \W{}{wxWidgets 2.8}, create an environment variable named \c{WXWIN} containing the path to the installation directory of wxWidgets, run \c{Contrib\\NSIS Menu\\wx\\wxbuild.bat} and build NSIS as usual.

\\<b\\>Important notes for Microsoft Visual C++ 6.0 users:\\</b\\> The 2003 Platform SDK must be installed before building, you can download it \W{}{here} or \W{}{order it on CD}. Because of flaws in the libraries distributed with Microsoft Visual C++ 6.0, not installing the Platform SDK will result in crashes when using the \R{copyfiles}{CopyFiles} command. See \W{}{this forum topic} for more information. Installing the \W{}{Processor Pack} is highly recommended to decrease the size of the installer overhead.

\H{build_posix} Building on POSIX

As of NSIS 2.01, the compiler, makensis, also compiles on POSIX platforms. POSIX platforms include Linux, *BSD, Mac OS X and others. Since the generated installer will eventually run on Windows, a \W{}{cross-compiler} is needed in order to compile them.

The command line option XGCC_W32_PREFIX could be used to explicitly select a specific win32 targeted cross compiler. The value of XGCC_W32_PREFIX has to be the prefix of the toolchain. For example XGCC_W32_PREFIX=i686-w64-mingw32 would deploy the win32 targeted MinGW-w64 cross compiler if it is available on the build system.

If no cross-compiler is available, use the following:

\c       NSIS_CONFIG_CONST_DATA_PATH=no PREFIX=/path/to/extracted/zip
\c       install-compiler
\c scons NSIS_CONFIG_CONST_DATA_PATH=no PREFIX=/path/to/extracted/zip
\c       /path/to/extracted/zip/LibraryLocal

This should only build makensis and install it to the directory where a precompiled package, such as the \R{build_nightly}{nightly build} or a \W{}{zipped release version} (, is extracted. Note that the in order for this to work, the precompiled package must be compiled using the exact same sources as makensis. In particular, \c{Source\\exehead\\config.h}, the options passed to scons and \c{Source\\exehead\\fileform.h} must be identical. Nightly builds and zipped release versions are built with the default options.

To build a native version of NSIS Menu, install \W{}{wxWidgets 2.8} and build as usual. \c{wx-config} must be in the path.

\H{build_nightly} Nightly Builds

There is no need to manually build the latest SVN version for Windows. A \W{}{nightly build} is available. The nightly build is automatically generated every night, using the latest version of the source code from SVN. There is no official nightly build for other platforms.