chromium/native_client_sdk/src/README.Makefiles

Build System for Native Client SDK examples
===========================================

The examples and libraries that ship with the Native Client SDK use a
build system based on GNU Make.

Each example or library is contained in its own directory along with a
Makefile. The Makefiles are capable of building Native Client
applications and libraries using any of the available toolchains as well
as building host applications with the host's toolchain. In order to
keep the top-level Makefiles simple, most of actual build rules are
specified in as set of shared rules files in the $NACL_SDK_ROOT/tools
directory.

This document describes some of the variables and macros used by in the
build system.  For more details please see the .mk files in the tools
folder.

Using the build system for new projects
--------------------------------------

It is perfectly possible to use the included build system for projects
outside of the Native Client SDK.  A good starting point for doing this
would be to copy the Makefile from the hello_world example.  In most
simple cases the only changes needed are to update the SOURCES and
TARGET variables.

User Variables
--------------

TARGET
  This variable holds the name of your project.  Normally this is the
  basename of the library or executable which is the final target.

SOURCES
  The list of sources to be built.  In most cases this list is passed to
  the compile and link macros.

VALID_TOOLCHAINS
  This variable can be used to control which toolchains are supported by
  the project.  Valid entries for this list are: clang-newlib, glibc,
  pnacl, linux, mac, win.  The default value is: "clang-newlib glibc
  pnacl".

NACL_SDK_ROOT
  Optionally force the build system to use a certain location for the
  Native Client SDK. If not set within the Makefile the $NACL_SDK_ROOT
  environment variable will by used. It is an error if this variable is
  neither set within the Makefile nor in the environment.

Macros / Rules
--------------

The following macros can be used in the Makefiles to generate the rules
for building the various kinds types of target.  These are designed to
be used via the 'call' macro.  e.g.  $(call COMPILE_RULE,$(SOURCES))

COMPILE_RULE
  This rule is used to build object files from a list of sources.

SO_RULE
  Used to build shared objects from a list of sources.

LIB_RULE
  Used to build static libraries from a list of sources.

NMF_RULE
  Used to build nmf metadata file from a native client executable (or
  set of executables). This is needed in order to run the executable in
  chrome.

HTML_RULE
  Used to build both html and nmf files from a native client executable
  (or set of executables) which will allow the executable to be run
  in chrome.

For more information on how to use these rules in your Makefile see
the shared Makefiles in the tools folders:

common.mk
  Top level shared rules file that include the toolchain specific
  rules.

nacl_gcc.mk
  Rules for building using the gcc-based NaCl toolchains.

nacl_llvm.mk
  Rules for building using the llvm-based PNaCl toolchains.

host_gcc.mk
  Rules for building using the linux/mac host gcc toolchain.

host_vc.mk
  Rules for building using the windows Visual Studio toolchain.

.. vim: ft=rst tw=72