Quick Nav
- Supported Platforms
- Build Overview
- Prepare the Environment
- Configuring the Build
- Main Options
- Cross Compilation
- Building
- Customizing
- Installing
- Source Repository
- Key File and Directories
See Also
Building from Source Code
This document describes the process to build the software from source for a supported platform. The source distribution contains all the necessary source files, headers and tools to reconfigure, build and verify the software.
Several build environments are supported:
- Linux — Linux 2.6 with GNU C/C++
- Windows — Microsoft Windows XP with Visual Studio 2010
- Mac OS X — Mac OS X 10.7 (Lion) or later
The source code has been designed to run on Free BSD, Linux, Mac OS X, Solaris Windows, VxWorks and other operating systems. It has been tested under Fedora Linux based on the Linux 2.6 Kernel, Microsoft Windows XP, Vista, 7 (32 and 64-bit), VxWorks 5.4, 6.3 and MAC OS X 10.7. Both single and multi-cpu systems are supported.
If you are wanting to run the software to an unsupported platform, you are welcome to try your hand at adapting it to a new platform. The software is very portable. See the Porting Guide for more details.
If you want to build using source from the source code repository, please read these additional instructions.
Build Overview
GoAhead supports several methods of building from source:
- Building via the Bit (Build It) tool
- Building via make (or nmake on Windows)
- Building via an IDE such as Visual Studio or Xcode
Building with Bit is the most flexible and offers the most control. It requires installing the Ejscript Product which includes the bit tool. Using bit is required if you are cross-compiling or using static linking.
Building with make or nmake is useful for a default (pre-configured) build, but you do not have the flexibility to configure the product for your system. Similarly, IDE builds are convenient, but are somewhat fixed in the software configuration they build. We recommend building with Bit. It is fast, flexible and configurable.
Preparing the Environment
Before building, you may need to install required tools such as cross-compilers, SDKs, and system libraries. If you wish to build GoAhead with the support of third-party packages such as MatrixSSL or OpenSSL, you may need to download the source from the relevant vendor and build the required libraries for GoAhead to utilize.
Windows
To build on Windows, you will need to install Microsoft Visual Studio 10.0 or later. Either the full product or the express editions will work fine. You will also need to install the Windows SDK.
Before building or configuring, you need to define certain Microsoft compiler environment variables as described in the Microsoft Visual Studio installation. These variables are the PATH, INCLUDE and LIB variables. They need to be defined so they will contain references to where the Microsoft compiler and libraries are installed on your system. The vcvarsall.bat command supplied with Visual Studio is the normal way to define these variables.
Unix / Linux
To build on Linux, you may need to install the libpam and zlib libraries.
Building with Make/Nmake
GoAhead provides a suite of Makefiles under the projects directory for common platforms. These are single, simple Makefiles that build a generic configuration of GoAhead. You may need to edit the Makefile for your platform to adjust compiler or linker options. A top level Makefile is provided that attempts to determine the correct project Makefile for your system. To build using make, type the following in the top directory of the source code:
make
Alternatively, invoke the platform Makefile specifically. For example:
make -f projects/goahead-macosx.mk
To build on Windows with nmake, type:
nmake -f projects\goahead-windows.nmake
Building with Shell Scripts
GoAhead provides simple shell scripts to build GoAhead. Unlike building with make, bit or and IDE, these scripts will always completely rebuild the product from source. For example:
bash projects/linux-x86.sh
Building with an IDE
GoAhead provides Visual Studio and Xcode projects. To build GoAhead with the Visual Studio project, run Visual Studio 2010 or later (The Express editions are fine to use). Then open the projects/goahead-windows.sln Solution project. Select Build Solution to build. Select GoAhead as the start up project to debug.
To build GoAhead with the Xcode on Mac OS X, run Xcode and open the projects/goahead-macosx.xcodeproj project. Then select Product->Build to build. To debug, you will need to create use Product->Edit Scheme to set the executable to run under the Info tab, and define the working directory under the Options tab. Set the working directory to the "test" directory of the source tree.
If you have built first with bit, make, nmake or shell scripts, you should remove the generated platform output directory and all its contents before building with the IDE.
bash projects/linux-x86.sh
Building with Bit
The procedure for building with Bit is the same for all supported platforms. The bit tool is used to configure and to build GoAhead. Bit is part of the Ejscript JavaScript environment. Click to Download Ejscript.
Configure GoAhead
GoAhead may be customized for environment by running bit configure. This is used to select features, options, and integrate third-party packages.
A configure script is provided to give a familiar "configure" command interface to the bit tool. This script simply invokes the bit configure command and passed all command line options to bit.
During configuration, bit will read the master main.bit configuration file. This file controls and specifies essential GoAhead settings. You can edit this file to suit your neds. After configuration, several output files are created that contain settings for each specified platform.
- A bit file that specifies the platforms to build named: start.bit
- A bit file for each platform named: OS-ARCH[-CPU].bit
- A source header with for the build configuration named: OS-ARCH[-CPU]-PROFILE/inc/bit.h
- An output products directory for each platform named: OS-ARCH[-CPU]-PROFILE
where OS is the name of the operating system, ARCH is the name of the CPU architecture and PROFILE is the build profile name, typically "debug" or "release". For example: linux-x86-debug.
The generated Bit files are readable JavaScript files that contain the settings to control the build when Bit is run. When compiling, all source code includes the relevant platform bit.h header to configure how the source is built.
Running Configure
You may run the configure script with no options to accept the factory defaults — this is a good starting point:
./configure
Alternatively, invoke bit directly:
bit configure
You may also supply options to configure which are passed onto bit, for example:
./configure --release --without all
The --release switch instructs bit to build an optimized production release. This will disable non-essential debugging code and logging. The --without all switch will disable non-essential features to create a minimal build.
Configure Options
The tables below describe the configuration options.
Basic Configure Options
Option | Description |
---|---|
--debug | Build a debug build. This builds a development, non-optimized build with debug symbols. |
--help | Display the bit program usage help. |
--set KEY=VALUE | Set the value of a property in the bit settings collection. For example: "--set product=myProduct". |
--quiet, -q | Run quietly without progress trace. |
--release | Build a release build. This builds an optimized, production-ready build of the software. |
--static | Configure for static linking. |
--verbose, -v | Run verbosely and emit more detailed progress trace. |
Cross Building
Option | Description |
---|---|
--platform OS-ARCH[-CPU] | Specify the target platform for which to build. For example "-platform linux-arm". Supported operating systems are: freebsd, linux, macosx, solaris, vxworks and windows. Supported architectures are: arm, mips, ppc, x64 or x86. If the -platform option is omitted, the local system is added as the target platform. You may use the 'local' alias to indicate the local platform. Multiple platforms may be specified. The optional CPU component specifies a CPU instance to tune for. The CPU setting is used in a -DCPU=VALUE compiler define. For example: "-platform linux-arm-arm7tdmi". |
Optional Packages
Option | Description |
---|---|
--with PACKAGE[=dir] | Specify if a PACKAGE should be included in the build. The optional directory is the path to the source distribution of the package. If the directory is omitted, bit will search the local system for the package in well known places. |
--without PACKAGE | Do not include the PACKAGE in the build. Use --without all to disable all possible non-essential packages. |
Example Use
configure --with openssl=/usr/src/openssl
Packages
The following table describes the packages that can extend GoAhead configure. The use of the Internal/External field states whether the package is shipped internally with the GoAhead source code, or whether it is an external third party package.
Package | Integrated | Description |
---|---|---|
est | Internal | Embedded Security Transport. SSL stack. |
matrixssl | External | MatrixSSL SSL stack. Requires a commerical license from PeerSec. |
mocana | External | Mocana NanoSSL stack. Requires a commerical license from Mocana. |
openssl | External | OpenSSL SSL stack. Requires OpenSSL libraries. |
The following table describes the tool packages that can be used when building, running and managing GoAhead. The use of the Internal/External field documents whether the package is shipped internally with the GoAhead source code, or whether it is an external third party package.
Package | Integrated | Description |
---|---|---|
doxygen | External | C API documentation generator. |
dsi | External | Dev Side Includes. Simple static web page templates. |
http | Internal | Http test client program. |
man | External | Manual page reader and renderer. |
man2html | External | Program to convert man pages to HTML. |
pmaker | External | Native package maker. This resolves to InnoSetup on Windows and PackageMaker on MAC OS X. |
utest | External | Ejscript unit test framework. See http://ejscript.org. |
zip | External | Zip compression program. Used when creating installable packages. |
Main Configuration Options
The main.bit configuration file specifies build-time defaults. Some of the important values are listed below:
accessLog | Enable request URI logging to an access log |
certificate | SSL certificate file |
cgi | Set to true to enable the CGI handler |
javascript | Enable the Javascript template handler |
key | SSL private key |
legacy | Enable GoAhead 2.X APIs to improve backward compatibility |
listens | List of endpoints on which GoAhead will listen |
limitBuffer | General I/O buffer size |
limitFilename | Maximum filename size |
limitFiles | Maximum number of files/sockets (ulimit) |
limitHeader | Maximum size of the request header |
limitNumHeaders | Maximum number of header lines in the request |
limitParseTimeout | Maximum time to parse the request headers |
limitPassword | Maximum size of a password |
limitPost | Maximum size of the incoming request body |
limitPut | Maximum size of a put request |
limitSessionLife | Default session lifespan in seconds |
limitSessionCount | Maximum number of sessions |
limitString | Default string size |
limitTimeout | Request inactivity timeout in seconds |
limitUri | Maximum URI size |
limitUpload | Maximum size of a file upload request |
pam | Build with Unix PAM authentication password support |
trace | Trace log destination. Uses the form: path:level |
stealth | Enable stealth mode. Disable OPTIONS and TRACE methods. Enabled by default. |
upload | Enable the upload handler |
uploadDir | Directory to store uploaded files |
Environment Variables
When cross-building, certain environment variables may be passed to the configure script and on to bit to configure the compiler and linker paths and flags.
Variable | Description |
---|---|
AR | Path to the archiver program to use to archive libraries for the target system. |
CC | Path to the C/C++ compiler to use to compile for the target system. |
CFLAGS | Compiler control flags |
DFLAGS | Compiler preprocessor defines |
IFLAGS | Include directory options |
LD | Path to the linker program to link objects for the target system. |
LDFLAGS | Linker flags. E.g. -Ldir to specify a non-standard directory for libraries. |
Example Use
CC=/opt/bin/ccarm configure
Configure Examples
Here are some useful configure command options.
To configure for building outside a source tree. This supports building from source from a read-only file system.
configure --config /path/to/source
To configure for a debug build with debug symbols:
To configure without TLS/SSL:
configure --without ssl
To configure to build for 32-bit X86 (when on a 64-bit system):
configure --platform linux-x86
Use the "--help" switch to see the available options or see the Bit document for more details.
Building with Third-Party Packages
The configuration process supports the resolution of external packages that extend and enhance GoAhead, such as MatrixSSL and OpenSSL. By default, GoAhead can locate these packages if the source distributions are installed in standard locations. Otherwise, the packages can be identified by using configure --with PACKAGE=PATH switch. This specifies the path to the package source directory.
For example, to build with Ejscript, follow these steps:
- Download Ejscript from https://github.com/embedthis/ejs-2. Contact sales@embedthis.com if you require a commercial license.
- Configure and build Ejscript via the Ejscript configure command in the Ejscript directory:
./configure make # Does a bootstrap build */bin/bit configure build # Configure and build sudo bit install # Install so GoAhead can use bit
- Then, from the GoAhead source directory run the GoAhead configure:
./configure --with openssl bit # To build GoAhead with OpenSSL support
Cross Compilation
To build a product for platform different to that of the local system is called cross compiling. Sometimes this cross 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 may be required to build for the target platform.
Bit supports cross compiling via the -platform PLATFORM bit configure option. This option adds a platform to the list of platforms to be made. Multiple platforms may be specified and the 'local' platform alias may be used for the local development platform.
bit -platform linux-arm-arm7 -configure .
This will create a windows-x64.bit configuration file and a start.es that references it. The platform switch does not need to be restated after configuration.
Some products require local building to make tools that are required to build for any platform. These products add a "platforms: ['local']" property to their settings collection in the main.bit file. This automatically adds the local platform to the platforms list and is the same as adding '-platform local' on the command line when configuring.
Platforms
A platform specification is of the form OS-ARCH, where the supported operating systems are: freebsd, linux, macosx, solaris, vxworks and windows. The ARCH field is one of arm, mips, ppc, x64 or x86. X64 is the AMD/Intel 64-bit instruction set and x86 is the Intel X86 Pentium instruction set. You may also use i386 or i686 for specific Intel X86 instruction sets. The CPU field is optional and specifies a CPU to tune for.
Environment Variables
When cross compiling, you may need to inform configure about your cross-compilation tool chain. Bit will do its best to discover the installed cross tool chain and will look in well known directories to locate the compiler, linker and other required tools. If bit cannot locate the tool chain, you can supply the tool chain details via the environment variables: CC, CFLAGS, DFLAGS, IFLAGS LD and LDFLAGS. These will be used to define and configure the cross-compilation tool chain.
For example, here is a cross-compilation configure command line:
CC=/opt/bin/cc.exe \ LD=/opt/bin/cc.exe \ CFLAGS=-I/opt/include \ ./configure --debug --platform linux-arm-arm7
Building Bit
Once the build configuration is complete, you may proceed to build the source code by typing:
bit
This will build the software. If cross compiling, depending on your configuration, it may build twice: once for the local system and once for the target platform.
Useful Bit options and targets
Here are some useful bit examples:
bit --show # Show actual commands while building bit --why # Show why each target is or is not being built bit --dump # Dump the combined bit configuration in one file bit rebuild # Rebuild all targets bit clean # Clean all built targets bit rebuild # Rebuild all targets bit install # Install the built software locally bit --help # Show bit usage
Static Linking
On some platforms, it is desirable to statically link GoAhead. The default bit files are setup to build GoAhead using shared libraries and to build the loadable modules separately. If you want to statically link GoAhead and the modules together, run configure with the --static option and then rebuild.
./configure --static bit
Serving from ROM
GoAhead supports systems without a file system where web documents are compiled into C code and served from ROM. To enable this, configure with the --rom switch.
configure --rom
See Serving Pages from ROM for more information.
Building from the Source Code Repository
You can checkout a copy of the product source code via:
git clone https://github.com/embedthis/goahead
There are three repository branches that you can select:
- stable — Source code for the most recent release.
- master — Most recent, quasi-stable development snapshot.
- dev — Current source code under active development. Least stable.
Once checked out, the normal instructions for building from source apply.
Key Files and Directories
Source trees contain the following key directories under the top directory.
Directory | Subdirectory | Description |
---|---|---|
bits | Bit configuration and scripts. | |
packs | Bit extension packs. | |
OS-ARCH[-CPU]-PROFILE | Build output directory. | |
inc | Include headers | |
obj | Directory to hold generated objects. | |
releases | Generated release distributions. | |
package | Scripts for creating release distribution packages. | |
projects | Microsoft Visual Studio and Eclipse project and workspace files. | |
src | Product source code. | |
deps | Dependant libraries including MPR, Http, Pcre. | |
samples | Sample source code and examples | |
test | Unit and integration tests. |
Key Build Files
Name | Description |
---|---|
configure | Build configuration script. This invokes Bit to configure GoAhead on the development system. |
OS-ARCH[-CPU].bit | Platform specific Bit file. There will be one platform bit file for each target platform. |
main.bit | Main Bit file for GoAhead. It specifies the GoAhead key settings and configured options. |
start.bit | Startup bit file for GoAhead. This file refers to the relevant Bit files for platforms. |
*/inc/bit.h | Build header created by Bit and included in all source files. |