Embedthis GoAhead 3.3.1
Home >Source Code> Building with Make

# Quick Nav

- Platform Makefile
- Windows Nmake
- Modifying Defaults
- Installing
- OpenSSL support
- Cross Compiling
- Specifying a Tool Chain
- Building with MakeMe
- 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 MakeMe. 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-me.h file. For example, to disable use of SQLite:

    $ make ME_COM_SQLITE=0

Extension packs are enabled by setting their corresponing ME_COM_NAME option to 1. Disable by setting to zero. Some packs requires a path to locate libraries and headers. Use ME_COM_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
      ME_GOAHEAD_ACCESS_LOG            # Enable request access log (true|false)
      ME_GOAHEAD_CLIENT_CACHE          # List of extensions to cache in the client
      ME_GOAHEAD_CLIENT_CACHE_LIFESPAN # Time in seconds to cache in the client
      ME_GOAHEAD_CA_FILE               # File of client certificates (path)
      ME_GOAHEAD_CERTIFICATE           # Server certificate for SSL (path)
      ME_GOAHEAD_CIPHERS               # SSL cipher suite (string)
      ME_GOAHEAD_CGI                   # Enable the CGI handler (true|false)
      ME_GOAHEAD_CGI_BIN               # Directory CGI programs (path)
      ME_GOAHEAD_JAVASCRIPT            # Enable the Javascript JST handler (true|false)
      ME_GOAHEAD_KEY                   # Server private key for SSL (path)
      ME_GOAHEAD_LEGACY                # Enable the GoAhead 2.X legacy APIs (true|false)
      ME_GOAHEAD_LIMIT_BUFFER          # I/O Buffer size. Also chunk size.
      ME_GOAHEAD_LIMIT_FILENAME        # Maximum filename size
      ME_GOAHEAD_LIMIT_HEADER          # Maximum HTTP single header size
      ME_GOAHEAD_LIMIT_HEADERS         # Maximum HTTP header size
      ME_GOAHEAD_LIMIT_NUM_HEADERS     # Maximum number of headers
      ME_GOAHEAD_LIMIT_PASSWORD        # Maximum password size
      ME_GOAHEAD_LIMIT_POST            # Maximum incoming body size
      ME_GOAHEAD_LIMIT_PUT             # Maximum PUT body size ~ 200MB
      ME_GOAHEAD_LIMIT_SESSION_LIFE    # Session lifespan in seconds (30 mins)
      ME_GOAHEAD_LIMIT_SESSION_COUNT   # Maximum number of sessions to support
      ME_GOAHEAD_LIMIT_STRING          # Default string allocation size
      ME_GOAHEAD_LIMIT_TIMEOUT         # Request inactivity timeout in seconds
      ME_GOAHEAD_LIMIT_URI             # Maximum URI size
      ME_GOAHEAD_LIMIT_UPLOAD          # Maximum upload size ~ 200MB
      ME_GOAHEAD_LISTEN                # Addresses to listen to (["http://IP:port", ...])
      ME_GOAHEAD_LOGFILE               # Default location and level for debug log
      ME_GOAHEAD_LOGGING               # Enable application logging (true|false)
      ME_GOAHEAD_PAM                   # Enable Unix Pluggable Auth Module (true|false)
      ME_GOAHEAD_PUT_DIR               # Define the directory for file uploaded via PUT
      ME_GOAHEAD_REALM                 # Authentication realm (string)
      ME_GOAHEAD_REPLACE_MALLOC        # Replace malloc with non-fragmenting allocator
      ME_GOAHEAD_SSL                   # To enable SSL
      ME_GOAHEAD_STATIC                # Build with static linking (true|false)
      ME_GOAHEAD_STEALTH               # Run in stealth mode. Disable OPTIONS, TRACE
      ME_GOAHEAD_TRACING               # Enable debug tracing (true|false)
      ME_GOAHEAD_TUNE                  # Optimize (size|speed|balanced)
      ME_GOAHEAD_UPLOAD                # Enable file upload (true|false)
      ME_GOAHEAD_UPLOAD_DIR            # Define directory for uploaded files (path)
      ME_COM_EST                       # Enable the EST SSL stack
      ME_COM_NANOSSL                   # Enable the Mocana NanoSSL stack
      ME_COM_MATRIXSSL                 # Enable the MatrixSSL SSL stack
      ME_COM_OPENSSL                   # Enable the OpenSSL SSL stack
      ME_ROM                           # Build for ROM without a file system
      ME_STACK_SIZE                    # Define the VxWorks stack size
    For example, to disable CGI:
      make ME_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 ME_COM_OPENSSL=1 ME_COM_OPENSSL_PATH=/usr/src/openssl compile
    $ sudo make ME_COM_OPENSSL=1 ME_COM_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 ME_COM_OPENSSL=1 ME_COM_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 ME_COM_OPENSSL=1 ME_COM_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

© Embedthis Software LLC, 2003-2014. All rights reserved. Embedthis and Embedthis GoAhead are trademarks of Embedthis Software LLC.