Quick Nav
- Platform Makefile
- Windows Nmake
- Modifying Defaults
- Installing
- OpenSSL support
- Cross Compiling
- Specifying a Tool Chain
- Building with Bit
- Building with an IDE
See Also
Building with Make or Nmake
This document describes the process to build the software from source using Make or Nmake on Windows. First make sure you have read Building from Source to prepare your build environment.
Platform Makefiles
GoAhead provides a suite of generated, pre-configured Makefiles for common platforms. These are simple flat makefiles that build a default configuration of GoAhead for a specific operating system. These makefiles are provided under the ./projects directory.
A top level Makefile is also provided that detects your operating system and CPU architecture and then invokes the appropriate project Makefile for your system. For example:
$ make make --no-print-directory -f projects/goahead-macosx-default.mk all ...
Windows Nmake
On Windows, a make.bat file is provided to to invoke nmake. The make.bat file first invokes projects/windows.bat which runs the Visual Studio vcvarsall.bat procedure to setup the necessary Visual Studio environment variables for compiling.
To build on Windows with nmake, type:
$ make nmake -f projects\goahead-windows.nmake ...
Modifying the Makefile Defaults
You do not use the configure program when building via Make, that is used only for building with Bit. Rather, you supply configuration options directly to Make. These options override default values defined by the projects/goahead-OS-default.mk makefile and by the projects/goahead-OS-debug-bit.h file. For example, to disable use of SQLite:
$ make BIT_PACK_SQLITE=0
Extension packs are enabled by setting their corresponing BIT_PACK_NAME option to 1. Disable by setting to zero. Some packs requires a path to locate libraries and headers. Use BIT_PACK_NAME_PATH to define the path to the extension pack.
To see the list of configurable options, run:
$ make help usage: make [clean, compile, deploy, install, run, uninstall] With make, the default configuration can be modified by setting make variables. Set to 0 to disable and 1 to enable: PROFILE # Select default or static for static linking BIT_GOAHEAD_ACCESS_LOG # Enable request access log (true|false) BIT_GOAHEAD_CLIENT_CACHE # List of extensions to cache in the client BIT_GOAHEAD_CLIENT_CACHE_LIFESPAN # Time in seconds to cache in the client BIT_GOAHEAD_CA_FILE # File of client certificates (path) BIT_GOAHEAD_CERTIFICATE # Server certificate for SSL (path) BIT_GOAHEAD_CIPHERS # SSL cipher suite (string) BIT_GOAHEAD_CGI # Enable the CGI handler (true|false) BIT_GOAHEAD_CGI_BIN # Directory CGI programs (path) BIT_GOAHEAD_JAVASCRIPT # Enable the Javascript JST handler (true|false) BIT_GOAHEAD_KEY # Server private key for SSL (path) BIT_GOAHEAD_LEGACY # Enable the GoAhead 2.X legacy APIs (true|false) BIT_GOAHEAD_LIMIT_BUFFER # I/O Buffer size. Also chunk size. BIT_GOAHEAD_LIMIT_FILENAME # Maximum filename size BIT_GOAHEAD_LIMIT_HEADER # Maximum HTTP single header size BIT_GOAHEAD_LIMIT_HEADERS # Maximum HTTP header size BIT_GOAHEAD_LIMIT_NUM_HEADERS # Maximum number of headers BIT_GOAHEAD_LIMIT_PASSWORD # Maximum password size BIT_GOAHEAD_LIMIT_POST # Maximum incoming body size BIT_GOAHEAD_LIMIT_PUT # Maximum PUT body size ~ 200MB BIT_GOAHEAD_LIMIT_SESSION_LIFE # Session lifespan in seconds (30 mins) BIT_GOAHEAD_LIMIT_SESSION_COUNT # Maximum number of sessions to support BIT_GOAHEAD_LIMIT_STRING # Default string allocation size BIT_GOAHEAD_LIMIT_TIMEOUT # Request inactivity timeout in seconds BIT_GOAHEAD_LIMIT_URI # Maximum URI size BIT_GOAHEAD_LIMIT_UPLOAD # Maximum upload size ~ 200MB BIT_GOAHEAD_LISTEN # Addresses to listen to (["http://IP:port", ...]) BIT_GOAHEAD_LOGFILE # Default location and level for debug log BIT_GOAHEAD_LOGGING # Enable application logging (true|false) BIT_GOAHEAD_PAM # Enable Unix Pluggable Auth Module (true|false) BIT_GOAHEAD_PUT_DIR # Define the directory for file uploaded via PUT BIT_GOAHEAD_REALM # Authentication realm (string) BIT_GOAHEAD_REPLACE_MALLOC # Replace malloc with non-fragmenting allocator BIT_GOAHEAD_SSL # To enable SSL BIT_GOAHEAD_STATIC # Build with static linking (true|false) BIT_GOAHEAD_STEALTH # Run in stealth mode. Disable OPTIONS, TRACE BIT_GOAHEAD_TRACING # Enable debug tracing (true|false) BIT_GOAHEAD_TUNE # Optimize (size|speed|balanced) BIT_GOAHEAD_UPLOAD # Enable file upload (true|false) BIT_GOAHEAD_UPLOAD_DIR # Define directory for uploaded files (path) BIT_PACK_EST # Enable the EST SSL stack BIT_PACK_NANOSSL # Enable the Mocana NanoSSL stack BIT_PACK_MATRIXSSL # Enable the MatrixSSL SSL stack BIT_PACK_OPENSSL # Enable the OpenSSL SSL stack BIT_ROM # Build for ROM without a file system BIT_STACK_SIZE # Define the VxWorks stack size For example, to disable CGI: make BIT_GOAHEAD_CGI=0 Other make variables: ARCH # CPU architecture (x86, x64, ppc, ...) OS # Operating system (linux, macosx, windows, vxworks, ...) CC # Compiler to use LD # Linker to use DEBUG # Set to debug or release for debug or optimized builds CONFIG # Output directory for built items. Defaults to OS-ARCH-PROFILE CFLAGS # Add compiler options. For example: -Wall DFLAGS # Add compiler defines. For example: -DCOLOR=blue IFLAGS # Add compiler include directories. For example: -I/extra/includes LDFLAGS # Add linker options LIBPATHS # Add linker library search directories. For example: -L/libraries LIBS # Add linker libraries. For example: -lpthreads PROFILE # Build profile, used in output products directory name
By defining the make variables such as CC and CFLAGS, you can modify the compiler options. This is the technique used when cross-compiling. For more details, see Cross Compiling below.
Installing with Make
You can install the newly built software via:
sudo make install
You can remove by:
sudo make uninstall
Warning: Must Use Same Option
It is essential when invoking make install, that you provide the same make flags and options as you did when compiling. This is because the Makefile will conditionally install only the selected components for those options.
For example, to build and install OpenSSL:
$ make BIT_PACK_OPENSSL=1 BIT_PACK_OPENSSL_PATH=/usr/src/openssl compile $ sudo make BIT_PACK_OPENSSL=1 BIT_PACK_OPENSSL_PATH=/usr/src/openssl install
Deploying
If you need to deploy to a different system or capture the build products, you can install to a specific directory via:
make deploy
This will install to the deploy directory under the output platform directory.
Supporting OpenSSL
If OpenSSL is required to provide SSL support, you must specify the path to the OpenSSL source directory. For example:
make BIT_PACK_OPENSSL=1 BIT_PACK_OPENSSL_PATH=/path/to/openssl compile
If you are using a binary OpenSSL distribution, provide the path where the OpenSSL libraries are located (typically /usr/lib).
make BIT_PACK_OPENSSL=1 BIT_PACK_OPENSSL_PATH=/usr/lib compile
Cross Compiling with Make
Building a product for platform different to that of the local system is called cross compiling. Sometimes this compiling is just for a different instruction set (say x64 instead of x86). Other times, it is for a completely different operating system and/or CPU architecture. In such cases, a cross-compiler is typically required to build for the target platform.
GoAhead supplies makefiles for Linux, Windows, FreeBSD, MAC OSX and VxWorks. To cross compile, you invoke the relevant project makefile and pass the required CPU architecture as a make variable. For example, to cross compile for VxWorks on ARM:
make -f projects/goahead-vxworks-default.mk ARCH=arm PROFILE=debug
When make runs, it places the output products (executables, libraries and objects) in a platform-specific output directory. This is named using the form: OS-ARCH-PROFILE. For example: vxworks-arm-debug. In this manner, make can be invoked multiple times, once for each target platform and the results will be captured in separate platform output directories. Some of the supported architectures for the ARCH field are: arm, mips, ppc, x64 and x86. The PROFILE is a descriptive name chosen by you for your configuration.
If there is not a makefile for your target operating system, copy the closest makefile and edit to suit your target platform.
Specifying the CPU
The build will generic CPU type within the specified architecture. To override the default choice and specify a CPU type within an architecture, use the CPU variable. For example:/p>
make OS=vxworks ARCH=arm CPU=arm7tdmi
Specifying a Tool Chain
You may need to specify where Make can locate your cross-compiler and other tools. You can supply these via the make variables: CC, CFLAGS, DFLAGS, IFLAGS, LD and LDFLAGS.
For example:
make CC=/opt/bin/ccarm.exe LD=/opt/bin/ccarm.exe ARCH=arm PROFILE=release -f projects/goahead-vxworks-default.mk
Static Building
If you require a static build without the ability to dynamically load modules, use the static makefile profile. For example:
make PROFILE=static
Building for VxWorks
Before building for VxWorks, you must define the WIND_* environment variables via the wrenv.sh script provided with VxWorks. This defines the WIND_BASE, WIND_HOST_TYPE and other required environment variables.
The command below runs wrenv.sh and defines the WIND variables in the current shell's environment.
eval `/WindRiver/wrenv.sh -p vxworks-6.8 -o print_env -f sh`
Once defined, you can invoke make.
make OS=vxworks
If you require a static build, set the profile to "static".
make OS=vxworks PROFILE=static