summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'native_client_sdk/src/tools')
-rw-r--r--native_client_sdk/src/tools/common.mk241
-rw-r--r--native_client_sdk/src/tools/host_gcc.mk137
-rw-r--r--native_client_sdk/src/tools/host_vc.mk130
-rw-r--r--native_client_sdk/src/tools/nacl_gcc.mk202
-rw-r--r--native_client_sdk/src/tools/nacl_llvm.mk132
5 files changed, 694 insertions, 148 deletions
diff --git a/native_client_sdk/src/tools/common.mk b/native_client_sdk/src/tools/common.mk
index 5797755..ad7d586 100644
--- a/native_client_sdk/src/tools/common.mk
+++ b/native_client_sdk/src/tools/common.mk
@@ -15,7 +15,24 @@
# currently supported by x86 and ARM. To switch to glibc, you would need
# to drop support for ARM.
#
-TOOLCHAIN?=newlib
+VALID_TOOLCHAINS?=newlib
+TOOLCHAIN?=$(word 1,$(VALID_TOOLCHAINS))
+
+
+#
+# Top Make file, which we want to trigger a rebuild on if it changes
+#
+TOP_MAKE:=$(word 1,$(MAKEFILE_LIST))
+
+
+#
+# Verify we selected a valid toolchain for this example
+#
+ifeq (,$(findstring $(TOOLCHAIN),$(VALID_TOOLCHAINS)))
+$(warning Availbile choices are: $(VALID_TOOLCHAINS))
+$(error Can not use TOOLCHAIN=$(TOOLCHAIN) on this example.)
+endif
+
#
# Build Configuration
@@ -27,6 +44,7 @@ TOOLCHAIN?=newlib
CONFIG?=Debug
+
# Note for Windows:
# Both GCC and LLVM bases tools (include the version of Make.exe that comes
# with the SDK) both expect and are capable of dealing with the '/' seperator.
@@ -38,7 +56,6 @@ CONFIG?=Debug
# is used. For Cygwin shells this can include automatic and incorrect expansion
# of response files (files starting with '@').
#
-
# Disable DOS PATH warning when using Cygwin based NaCl tools on Windows.
#
CYGWIN?=nodosfilewarning
@@ -46,40 +63,12 @@ export CYGWIN
#
-# Get pepper directory for toolchain and includes.
-#
-# If NACL_SDK_ROOT is not set, then assume it can be found a two directories up,
-# from the default example directory location.
-#
-THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST)))
-THIS_DIR:=$(abspath $(dir $(THIS_MAKEFILE)))
-NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..)
-
-
-#
-# Defaults build flags
-#
-# Convert warnings to errors, and build with no optimization.
-#
-NACL_WARNINGS:=-Wno-long-long -Werror
-OPT_FLAGS:=-g -O0
-CXX_FLAGS:=-pthread -I$(NACL_SDK_ROOT)/include
-LD_FLAGS:=-pthread
-
-
-#
-# Library Paths
-#
-# Libraries are stored in different directories for each achitecture as well
-# as different subdirectories for Debug vs Release configurations. This make
-# only supports the Debug configuration for simplicity.
-#
-# By default for x86 32 bit this expands to:
-# $(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug
+# Alias for standard POSIX file system commands
#
-LD_X86_32:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_32/$(CONFIG)
-LD_X86_64:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_64/$(CONFIG)
-LD_ARM:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_arm/$(CONFIG)
+CP:=python $(NACL_SDK_ROOT)/tools/oshelpers.py cp
+MKDIR:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mkdir
+MV:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mv
+RM:=python $(NACL_SDK_ROOT)/tools/oshelpers.py rm
#
@@ -89,13 +78,6 @@ OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain)
-#
-# Alias for standard POSIX file system commands
-#
-CP:=python $(NACL_SDK_ROOT)/tools/oshelpers.py cp
-MKDIR:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mkdir
-MV:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mv
-RM:=python $(NACL_SDK_ROOT)/tools/oshelpers.py rm
#
@@ -109,6 +91,26 @@ all:
#
+# Target a toolchain
+#
+# $1 = Toolchain Name
+#
+define TOOLCHAIN_RULE
+.PHONY: all_$(1)
+all_$(1):
+ +$(MAKE) TOOLCHAIN=$(1)
+TOOLCHAIN_LIST+=all_$(1)
+endef
+
+
+#
+# The target for all versions
+#
+USABLE_TOOLCHAINS=$(filter $(OSNAME) newlib glibc pnacl,$(VALID_TOOLCHAINS))
+$(foreach tool,$(USABLE_TOOLCHAINS),$(eval $(call TOOLCHAIN_RULE,$(tool),$(dep))))
+all_versions: $(TOOLCHAIN_LIST)
+
+#
# Target to remove temporary files
#
.PHONY: clean
@@ -116,21 +118,6 @@ clean:
$(RM) $(TARGET).nmf
$(RM) -fr $(TOOLCHAIN)
-#
-# Macros for TOOLS
-#
-# We use the C++ compiler for everything and then use the -Wl,-as-needed flag
-# in the linker to drop libc++ unless it's actually needed.
-#
-X86_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++
-X86_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++ -Wl,-as-needed
-
-ARM_CXX?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++
-ARM_LINK?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++ -Wl,-as-needed
-
-PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++ -c
-PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++
-
#
# Rules for output directories.
@@ -147,6 +134,7 @@ $(TOOLCHAIN)/$(CONFIG): | $(TOOLCHAIN)
$(MKDIR) $(TOOLCHAIN)/$(CONFIG)
OUTDIR:=$(TOOLCHAIN)/$(CONFIG)
+-include $(OUTDIR)/*.d
#
@@ -157,116 +145,67 @@ OUTDIR:=$(TOOLCHAIN)/$(CONFIG)
define DEPEND_RULE
.PHONY: $(1)
$(1):
+ifeq (,$(IGNORE_DEPS))
+ @echo "Checking library: $(1)"
+$(MAKE) -C $(NACL_SDK_ROOT)/src/$(1)
DEPS_LIST+=$(1)
+else
+ @echo "Ignore DEPS: $(1)"
+endif
endef
-#
-# Compile Macro
-#
-# $1 = Source Name
-#
-# By default, if $(1) = source.c, this rule expands to:
-# newlib/Debug/source_x86_32.o : souce.c Makefile | newlib/Debug
-#
-# Which means if 'source.c' or Makefile are newer than the object
-# newlib/Debug/source_x86_32.o, then run the step:
-# $(X86_CC) -o newlib/Debug/source_x86_32.o -c source.c ....
-#
-# We repeat this expansion for 64 bit X86 and conditionally for ARM if
-# TOOLCHAIN=newlib
-#
-define COMPILE_RULE
-$(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(THIS_MAKE) | $(OUTDIR)
- $(X86_CXX) -o $$@ -c $$< -m32 $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS)
-
-$(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(THIS_MAKE) | $(OUTDIR)
- $(X86_CXX) -o $$@ -c $$< -m64 $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS)
-
-$(OUTDIR)/$(basename $(1))_arm.o : $(1) $(THIS_MAKE) | $(OUTDIR)
- $(ARM_CXX) -o $$@ -c $$< $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS)
-$(OUTDIR)/$(basename $(1))_pnacl.o : $(1) $(THIS_MAKE) | $(OUTDIR)
- $(PNACL_CXX) -o $$@ -c $$< $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS)
-endef
+ifeq ('win','$(TOOLCHAIN)')
+HOST_EXT=.dll
+else
+HOST_EXT=.so
+endif
#
-# Link Macro
-#
-# $1 = Target Name
-# $2 = List of Sources
-#
-# By default, if $(1) = foo $(2) = A.c B.cc, this rule expands to:
-# newlib/Debug/foo_x86_32.nexe : newlib/Debug/A_x86_32.o ...
-#
-# Which means if A_x86_32.o or sourceB_32.o is newer than the nexe then
-# run the build step:
-# $(X86_LINK) -o newlib/Debug/foo_x86_32.nexe newlib/Debug/A_x86_32.o ...
+# Common Compile Options
#
-# Note:
-# We expand each library as '-l<name>' which will look for lib<name> in the
-# directory specified by $(LD_X86_32)
-#
-# We repeat this expansion for 64 bit X86 and conditionally for ARM if
-# TOOLCHAIN=newlib
-#
-define LINK_RULE
-NMF_TARGETS+=$(OUTDIR)/$(1)_x86_32.nexe
-$(OUTDIR)/$(1)_x86_32.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86_32.o)
- $(X86_LINK) -o $$@ $$^ -m32 $(LD_X86_32) $(LD_FLAGS) $(foreach lib,$(LIBS),-l$(lib))
-
-NMF_TARGETS+=$(OUTDIR)/$(1)_x86_64.nexe
-$(OUTDIR)/$(1)_x86_64.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86_64.o)
- $(X86_LINK) -o $$@ $$^ -m64 $(LD_X86_64) $(LD_FLAGS) $(foreach lib,$(LIBS),-l$(lib))
-
-NMF_TARGETS+=$(OUTDIR)/$(1)_arm.nexe
-$(OUTDIR)/$(1)_arm.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_arm.o)
- $(ARM_LINK) -o $$@ $$^ $(LD_ARM) $(LD_FLAGS) $(foreach lib,$(LIBS),-l$(lib))
-
-NMF_TARGETS+=$(OUTDIR)/$(1).pexe
-$(OUTDIR)/$(1).pexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_pnacl.o)
- $(PNACL_LINK) -o $$@ $$^ $(LD_PNACL) $(LD_FLAGS) $(foreach lib,$(LIBS),-l$(lib))
-endef
-
+ifeq ('Release','$(CONFIG)')
+POSIX_OPT_FLAGS?=-g -O2 -pthread
+else
+POSIX_OPT_FLAGS?=-g -O0 -pthread
+endif
+NACL_CFLAGS?=-Wno-long-long -Werror
+NACL_CXXFLAGS?=-Wno-long-long -Werror
#
-# Generate NMF_TARGETS
+# Default Paths
#
-ARCHES=x86_32 x86_64
-ifeq "newlib" "$(TOOLCHAIN)"
-ARCHES+=arm
+ifeq (,$(findstring $(TOOLCHAIN),linux mac win))
+INC_PATHS?=$(NACL_SDK_ROOT)/include $(EXTRA_INC_PATHS)
+else
+INC_PATHS?=$(NACL_SDK_ROOT)/include/$(OSNAME) $(NACL_SDK_ROOT)/include $(EXTRA_INC_PATHS)
endif
-NMF_ARCHES:=$(foreach arch,$(ARCHES),_$(arch).nexe)
-ifeq "pnacl" "$(TOOLCHAIN)"
-NMF_ARCHES:=.pexe
-endif
+LIB_PATHS?=$(NACL_SDK_ROOT)/lib $(EXTRA_LIB_PATHS)
#
-# NMF Manifiest generation
+# If the requested toolchain is a NaCl or PNaCl toolchain, the use the
+# macros and targets defined in nacl.mk, otherwise use the host sepecific
+# macros and targets.
#
-# Use the python script create_nmf to scan the binaries for dependencies using
-# objdump. Pass in the (-L) paths to the default library toolchains so that we
-# can find those libraries and have it automatically copy the files (-s) to
-# the target directory for us.
-#
-# $1 = Target Name (the basename of the nmf
-# $2 = Additional create_nmf.py arguments
-#
-NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
-GLIBC_DUMP:=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump
-GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32
-GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib
+ifneq (,$(findstring $(TOOLCHAIN),linux mac))
+include $(NACL_SDK_ROOT)/tools/host_gcc.mk
+endif
-define NMF_RULE
-$(OUTDIR)/$(1).nmf : $(foreach arch,$(NMF_ARCHES),$(OUTDIR)/$(1)$(arch))
- $(NMF) -o $$@ $$^ -D $(GLIBC_DUMP) $(GLIBC_PATHS) -s $(OUTDIR) $(2)
+ifneq (,$(findstring $(TOOLCHAIN),win))
+include $(NACL_SDK_ROOT)/tools/host_vc.mk
+endif
-all : $(DEPS_LIST) $(OUTDIR)/$(1).nmf
-endef
+ifneq (,$(findstring $(TOOLCHAIN),glibc newlib))
+include $(NACL_SDK_ROOT)/tools/nacl_gcc.mk
+endif
+
+ifneq (,$(findstring $(TOOLCHAIN),pnacl))
+include $(NACL_SDK_ROOT)/tools/nacl_llvm.mk
+endif
#
@@ -297,7 +236,13 @@ CHROME_ENV?=
CHROME_ARGS+=--enable-nacl --enable-pnacl --incognito --ppapi-out-of-process
-CONFIG?=Debug
+# Paths to Debug and Release versions of the Host Pepper plugins
+PPAPI_DEBUG=$(abspath $(OSNAME)/Debug/$(TARGET)$(HOST_EXT));application/x-ppapi-debug
+PPAPI_RELEASE=$(abspath $(OSNAME)/Release/$(TARGET)$(HOST_EXT));application/x-ppapi-release
+
+info:
+ @echo "DEBUG=$(PPAPI_DEBUG)"
+
PAGE?=index_$(TOOLCHAIN)_$(CONFIG).html
RUN: LAUNCH
@@ -306,7 +251,7 @@ ifeq (,$(wildcard $(PAGE)))
$(warning No valid HTML page found at $(PAGE))
$(error Make sure TOOLCHAIN and CONFIG are properly set)
endif
- $(RUN_PY) -C $(THIS_DIR) -P $(PAGE) $(addprefix -E ,$(CHROME_ENV)) -- \
+ $(RUN_PY) -C $(CURDIR) -P $(PAGE) $(addprefix -E ,$(CHROME_ENV)) -- \
$(CHROME_PATH) $(CHROME_ARGS) \
--register-pepper-plugins="$(PPAPI_DEBUG),$(PPAPI_RELEASE)"
diff --git a/native_client_sdk/src/tools/host_gcc.mk b/native_client_sdk/src/tools/host_gcc.mk
new file mode 100644
index 0000000..4f85a0c
--- /dev/null
+++ b/native_client_sdk/src/tools/host_gcc.mk
@@ -0,0 +1,137 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+#
+# GNU Make based build file. For details on GNU Make see:
+# http://www.gnu.org/software/make/manual/make.html
+#
+#
+
+
+#
+# Macros for TOOLS
+#
+# We use the C++ compiler for everything and then use the -Wl,-as-needed flag
+# in the linker to drop libc++ unless it's actually needed.
+#
+HOST_CC?=gcc
+HOST_CXX?=g++
+HOST_LINK?=g++
+HOST_LIB?=ar r
+
+
+LINUX_WARNINGS?=-Wno-long-long
+LINUX_CCFLAGS=-fPIC -MMD -pthread $(LINUX_WARNINGS) -I$(NACL_SDK_ROOT)/include -I$(NACL_SDK_ROOT)/include/linux
+
+
+#
+# Individual Macros
+#
+# $1 = Source Name
+# $2 = Compile Flags
+#
+define C_COMPILER_RULE
+$(OUTDIR)/$(basename $(1)).o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(HOST_CC) -o $$@ -c $$< -fPIC $(POSIX_OPT_FLAGS) $(2) $(LINUX_FLAGS)
+endef
+
+define CXX_COMPILER_RULE
+$(OUTDIR)/$(basename $(1)).o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(HOST_CXX) -o $$@ -c $$< -fPIC $(POSIX_OPT_FLAGS) $(2) $(LINUX_FLAGS)
+endef
+
+
+# $1 = Source Name
+# $2 = POSIX Compile Flags
+# $3 = VC Flags (unused)
+#
+define COMPILE_RULE
+ifeq ('.c','$(suffix $(1))')
+$(call C_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)))
+else
+$(call CXX_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)))
+endif
+endef
+
+
+#
+# SO Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+#
+#
+define SO_RULE
+$(error 'Shared libraries not supported by Host')
+endef
+
+
+#
+# LIB Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+#
+#
+define LIB_RULE
+all:$(NACL_SDK_ROOT)/lib/$(OSNAME)_host/$(CONFIG)/lib$(1).a
+$(NACL_SDK_ROOT)/lib/$(OSNAME)_host/$(CONFIG)/lib$(1).a : $(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o)
+ $(MKDIR) -p $(dir $$@)
+ $(HOST_LIB) $$@ $$^
+endef
+
+
+#
+# Link Macro
+#
+# $1 = Target Name
+# $2 = List of inputs
+# $3 = List of libs
+# $4 = List of deps
+# $5 = List of lib dirs
+# $6 = Other Linker Args
+#
+define LINKER_RULE
+all: $(1)
+$(1) : $(2) $(4)
+ $(HOST_LINK) -shared -o $(1) $(2) $(foreach path,$(5),-L$(path)/$(OSNAME)_host)/$(CONFIG) $(foreach lib,$(3),-l$(lib)) $(6)
+endef
+
+
+#
+# Link Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+# $3 = List of LIBS
+# $4 = List of DEPS
+# $5 = POSIX Linker Switches
+# $6 = VC Linker Switches
+#
+define LINK_RULE
+$(call LINKER_RULE,$(OUTDIR)/$(1)$(HOST_EXT),$(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5))
+endef
+
+
+#
+# NMF Manifiest generation
+#
+# Use the python script create_nmf to scan the binaries for dependencies using
+# objdump. Pass in the (-L) paths to the default library toolchains so that we
+# can find those libraries and have it automatically copy the files (-s) to
+# the target directory for us.
+#
+# $1 = Target Name (the basename of the nmf
+# $2 = Additional create_nmf.py arguments
+#
+NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
+
+define NMF_RULE
+NMF_LIST+=$(OUTDIR)/$(1).nmf
+$(OUTDIR)/$(1).nmf : $(OUTDIR)/$(1)$(HOST_EXT)
+ @echo "Host Toolchain" > $$@
+endef
+
+all : $(LIB_LIST) $(DEPS_LIST) $(NMF_LIST)
+
diff --git a/native_client_sdk/src/tools/host_vc.mk b/native_client_sdk/src/tools/host_vc.mk
new file mode 100644
index 0000000..6413c09
--- /dev/null
+++ b/native_client_sdk/src/tools/host_vc.mk
@@ -0,0 +1,130 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+#
+# GNU Make based build file. For details on GNU Make see:
+# http://www.gnu.org/software/make/manual/make.html
+#
+#
+
+
+#
+# Macros for TOOLS
+#
+# We use the C++ compiler for everything and then use the -Wl,-as-needed flag
+# in the linker to drop libc++ unless it's actually needed.
+#
+HOST_CC?=cl.exe /nologo /WX
+HOST_CXX?=cl.exe /nologo /EHsc /WX
+HOST_LINK?=link.exe /nologo
+HOST_LIB?=lib.exe /nologo
+
+
+ifeq ('Debug','$(CONFIG)')
+WIN_OPT_FLAGS?=/Od /MTd /Z7
+else
+WIN_OPT_FLAGS?=/O2 /MT /Z7
+endif
+
+WIN_FLAGS?=-D WIN32 -D _WIN32 -D PTW32_STATIC_LIB
+
+
+#
+# Individual Macros
+#
+# $1 = Source Name
+# $2 = Compile Flags
+#
+define C_COMPILER_RULE
+$(OUTDIR)/$(basename $(1)).o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(HOST_CC) /Fo$$@ /c $$< $(WIN_OPT_FLAGS) $(2) $(WIN_FLAGS)
+endef
+
+define CXX_COMPILER_RULE
+$(OUTDIR)/$(basename $(1)).o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(HOST_CXX) /Fo$$@ -c $$< $(WIN_OPT_FLAGS) $(2) $(WIN_FLAGS)
+endef
+
+
+# $1 = Source Name
+# $2 = POSIX Compile Flags (unused)
+# $3 = VC Compile Flags
+#
+define COMPILE_RULE
+ifeq ('.c','$(suffix $(1))')
+$(call C_COMPILER_RULE,$(1),$(3) $(foreach inc,$(INC_PATHS),/I$(inc)))
+else
+$(call CXX_COMPILER_RULE,$(1),$(3) $(foreach inc,$(INC_PATHS),/I$(inc)))
+endif
+endef
+
+
+#
+# LIB Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+#
+#
+define LIB_RULE
+all:$(NACL_SDK_ROOT)/lib/$(OSNAME)_host/$(CONFIG)/$(1).lib
+$(NACL_SDK_ROOT)/lib/$(OSNAME)_host/$(CONFIG)/$(1).lib : $(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o)
+ $(MKDIR) -p $(dir $$@)
+ $(HOST_LIB) $$@ $$^ $(WIN_LDFLAGS)
+endef
+
+
+#
+# Link Macro
+#
+# $1 = Target Name
+# $2 = List of inputs
+# $3 = List of libs
+# $4 = List of deps
+# $5 = List of lib dirs
+# $6 = Other Linker Args
+#
+define LINKER_RULE
+all: $(1)
+$(1) : $(2) $(4)
+ $(HOST_LINK) /DLL /OUT:$(1) /PDB:$(1).pdb $(2) /DEBUG $(foreach path,$(5),/LIBPATH:$(path)) $(foreach lib,$(3),$(lib.lib)) $(6)
+endef
+
+
+#
+# Link Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+# $3 = List of LIBS
+# $4 = List of DEPS
+# $5 = POSIX Linker Switches
+# $6 = VC Linker Switches
+#
+define LINK_RULE
+$(call LINKER_RULE,$(OUTDIR)/$(1)$(HOST_EXT),$(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o),$(3),$(4),$(LIB_PATHS),$(6))
+endef
+
+
+#
+# NMF Manifiest generation
+#
+# Use the python script create_nmf to scan the binaries for dependencies using
+# objdump. Pass in the (-L) paths to the default library toolchains so that we
+# can find those libraries and have it automatically copy the files (-s) to
+# the target directory for us.
+#
+# $1 = Target Name (the basename of the nmf
+# $2 = Additional create_nmf.py arguments
+#
+NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
+
+define NMF_RULE
+NMF_LIST+=$(OUTDIR)/$(1).nmf
+$(OUTDIR)/$(1).nmf : $(OUTDIR)/$(1)$(HOST_EXT)
+ @echo "Host Toolchain" > $$@
+endef
+
+all : $(LIB_LIST) $(DEPS_LIST) $(NMF_LIST)
+
diff --git a/native_client_sdk/src/tools/nacl_gcc.mk b/native_client_sdk/src/tools/nacl_gcc.mk
new file mode 100644
index 0000000..97dddce
--- /dev/null
+++ b/native_client_sdk/src/tools/nacl_gcc.mk
@@ -0,0 +1,202 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+#
+# GNU Make based build file. For details on GNU Make see:
+# http://www.gnu.org/software/make/manual/make.html
+#
+#
+
+
+#
+# Default Paths
+#
+
+LD_X86_32:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_32/$(CONFIG)
+LD_X86_64:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_64/$(CONFIG)
+LD_ARM:=-L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_arm/$(CONFIG)
+
+
+#
+# Macros for TOOLS
+#
+# We use the C++ compiler for everything and then use the -Wl,-as-needed flag
+# in the linker to drop libc++ unless it's actually needed.
+#
+X86_CC?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-gcc
+X86_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++
+X86_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++ -Wl,-as-needed
+X86_LIB?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-ar r
+
+ARM_CC?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-gcc
+ARM_CXX?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++
+ARM_LINK?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++ -Wl,-as-needed
+ARM_LIB?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-ar r
+
+
+#
+# Compile Macro
+#
+# $1 = Source Name
+# $2 = Compile Flags
+#
+define C_COMPILER_RULE
+$(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(X86_CC) -o $$@ -c $$< -m32 $(POSIX_OPT_FLAGS) $(2) $(NACL_CFLAGS)
+
+$(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(X86_CC) -o $$@ -c $$< -m64 $(POSIX_OPT_FLAGS) $(2) $(NACL_CFLAGS)
+
+$(OUTDIR)/$(basename $(1))_arm.o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(ARM_CC) -o $$@ -c $$< $(POSIX_OPT_FLAGS) $(2) $(NACL_CFLAGS)
+endef
+
+define CXX_COMPILER_RULE
+$(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(X86_CXX) -o $$@ -c $$< -m32 $(POSIX_OPT_FLAGS) $(2) $(NACL_CXXFLAGS)
+
+$(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(X86_CXX) -o $$@ -c $$< -m64 $(POSIX_OPT_FLAGS) $(2) $(NACL_CXXFLAGS)
+
+$(OUTDIR)/$(basename $(1))_arm.o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(ARM_CXX) -o $$@ -c $$< $(POSIX_OPT_FLAGS) $(2) $(NACL_CXXFLAGS)
+endef
+
+
+#
+# $1 = Source Name
+# $2 = POSIX Compile Flags
+# $3 = Include Directories
+# $4 = VC Flags (unused)
+#
+define COMPILE_RULE
+ifeq ('.c','$(suffix $(1))')
+$(call C_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3))
+else
+$(call CXX_COMPILER_RULE,$(1),$(2) $(foreach inc,$(INC_PATHS),-I$(inc)) $(3))
+endif
+endef
+
+
+#
+# SO Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+#
+#
+GLIBC_REMAP:=
+define SO_RULE
+NMF_TARGETS+=$$(OUTDIR)/$(1)_x86_32.so
+$(OUTDIR)/$(1)_x86_32.so : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86_32.o) $(4)
+ $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -shared -m32 $$(LD_X86_32) $$(LD_FLAGS) $(foreach lib,$(3),-l$(lib))
+
+NMF_TARGETS+=$(OUTDIR)/$(1)_x86_64.so
+$(OUTDIR)/$(1)_x86_64.so : $(foreach src,$(2),$$(OUTDIR)/$(basename $(src))_x86_64.o) $(4)
+ $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -shared -m64 $(LD_X86_64) $$(LD_FLAGS) $(foreach lib,$(3),-l$(lib))
+
+GLIBC_SO_LIST+=$(OUTDIR)/$(1)_x86_32.so $(OUTDIR)/$(1)_x86_64.so
+GLIBC_REMAP+=-n $(1)_x86_32.so,$(1).so
+GLIBC_REMAP+=-n $(1)_x86_64.so,$(1).so
+endef
+
+
+#
+# LIB Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+# $3 = POSIX Link Flags
+# $4 = VC Link Flags (unused)
+#
+define LIB_RULE
+all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a
+$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86_32.o)
+ $(MKDIR) -p $$(dir $$@)
+ $(X86_LIB) $$@ $$^
+
+all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a
+$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86_64.o)
+ $(MKDIR) -p $$(dir $$@)
+ $(X86_LIB) $$@ $$^
+
+ifneq ('glibc','$(TOOLCHAIN)')
+all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a
+endif
+$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_arm.o)
+ $(MKDIR) -p $$(dir $$@)
+ $(ARM_LIB) $$@ $$^
+endef
+
+
+#
+# Specific Link Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+# $3 = List of LIBS
+# $4 = List of DEPS
+# $5 = POSIX Link Flags
+# $6 = Library Paths
+#
+define LINKER_RULE
+$(OUTDIR)/$(1)_x86_32.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86_32.o) $(4)
+ $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -m32 $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_x86_32/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)
+
+$(OUTDIR)/$(1)_x86_64.nexe : $(foreach src,$(2),$$(OUTDIR)/$(basename $(src))_x86_64.o) $(4)
+ $(X86_LINK) -o $$@ $$(filter-out $(4),$$^) -m64 $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_x86_64/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)
+
+$(OUTDIR)/$(1)_arm.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_arm.o) $(4)
+ $(ARM_LINK) -o $$@ $$(filter-out $(4),$$^) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)
+endef
+
+
+#
+# Generalized Link Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+# $3 = List of LIBS
+# $4 = List of DEPS
+# $5 = POSIX Linker Switches
+# $6 = VC Linker Switches
+#
+define LINK_RULE
+$(call LINKER_RULE,$(1),$(2),$(filter-out pthread,$(3)),$(4),$(5),$(LIB_PATHS))
+endef
+
+
+#
+# Generate NMF_TARGETS
+#
+ARCHES=x86_32 x86_64
+ifeq "newlib" "$(TOOLCHAIN)"
+ARCHES+=arm
+endif
+NMF_ARCHES:=$(foreach arch,$(ARCHES),_$(arch).nexe)
+
+
+#
+# NMF Manifiest generation
+#
+# Use the python script create_nmf to scan the binaries for dependencies using
+# objdump. Pass in the (-L) paths to the default library toolchains so that we
+# can find those libraries and have it automatically copy the files (-s) to
+# the target directory for us.
+#
+# $1 = Target Name (the basename of the nmf
+# $2 = Additional create_nmf.py arguments
+#
+NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
+GLIBC_DUMP:=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump
+GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32
+GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib
+
+define NMF_RULE
+all:$(OUTDIR)/$(1).nmf
+$(OUTDIR)/$(1).nmf : $(foreach arch,$(NMF_ARCHES),$(OUTDIR)/$(1)$(arch)) $(GLIBC_SO_LIST)
+ $(NMF) -o $$@ $$^ -D $(GLIBC_DUMP) $(GLIBC_PATHS) -s $(OUTDIR) $(2) $(GLIBC_REMAP)
+endef
+
+
diff --git a/native_client_sdk/src/tools/nacl_llvm.mk b/native_client_sdk/src/tools/nacl_llvm.mk
new file mode 100644
index 0000000..289efc8
--- /dev/null
+++ b/native_client_sdk/src/tools/nacl_llvm.mk
@@ -0,0 +1,132 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+#
+# GNU Make based build file. For details on GNU Make see:
+# http://www.gnu.org/software/make/manual/make.html
+#
+#
+
+
+#
+# Paths to Tools
+#
+PNACL_CC?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang -c
+PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++ -c
+PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++
+PNACL_LIB?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-ar r
+
+
+#
+# Compile Macro
+#
+# $1 = Source Name
+# $2 = Compile Flags
+# $3 = Include Directories
+#
+define C_COMPILER_RULE
+$(OUTDIR)/$(basename $(1))_pnacl.o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(PNACL_CC) -o $$@ -c $$< $(POSIX_OPT_FLAGS) $(2) $(NACL_CFLAGS)
+endef
+
+define CXX_COMPILER_RULE
+$(OUTDIR)/$(basename $(1))_pnacl.o : $(1) $(TOP_MAKE) | $(OUTDIR)
+ $(PNACL_CXX) -o $$@ -c $$< $(POSIX_OPT_FLAGS) $(2) $(NACL_CFLAGS)
+endef
+
+
+# $1 = Source Name
+# $2 = POSIX Compile Flags
+# $3 = Include Directories
+# $4 = VC Flags (unused)
+define COMPILE_RULE
+ifeq ('.c','$(suffix $(1))')
+$(call C_COMPILER_RULE,$(1),$(2) -I$(NACL_SDK_ROOT)/include $(foreach inc,$(3),-I$(inc)))
+else
+$(call CXX_COMPILER_RULE,$(1),$(2) -I$(NACL_SDK_ROOT)/include $(foreach inc,$(3),-I$(inc)))
+endif
+endef
+
+
+#
+# SO Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+#
+#
+define SO_RULE
+$(error 'Shared libraries not supported by PNaCl')
+endef
+
+
+#
+# LIB Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+# $3 = POSIX Link Flags
+# $4 = VC Link Flags (unused)
+define LIB_RULE
+all: $(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a
+$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_pnacl.o)
+ $(MKDIR) -p $$(dir $$@)
+ $(PNACL_LIB) $$@ $$^ $(3)
+endef
+
+
+#
+# Specific Link Macro
+#
+# $1 = Target Name
+# $2 = List of inputs
+# $3 = List of libs
+# $4 = List of deps
+# $5 = List of lib dirs
+# $6 = Other Linker Args
+#
+define LINKER_RULE
+all: $(1)
+$(1) : $(2) $(4)
+ $(PNACL_LINK) -o $(1) $(2) $(foreach path,$(5),-L$(path)/pnacl/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(6)
+endef
+
+
+
+#
+# Generalized Link Macro
+#
+# $1 = Target Name
+# $2 = List of Sources
+# $3 = List of LIBS
+# $4 = List of DEPS
+# $5 = POSIX Linker Switches
+# $6 = VC Linker Switches
+#
+define LINK_RULE
+$(call LINKER_RULE,$(OUTDIR)/$(1).pexe,$(foreach src,$(2),$(OUTDIR)/$(basename $(src))_pnacl.o),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5))
+endef
+
+
+
+#
+# NMF Manifiest generation
+#
+# Use the python script create_nmf to scan the binaries for dependencies using
+# objdump. Pass in the (-L) paths to the default library toolchains so that we
+# can find those libraries and have it automatically copy the files (-s) to
+# the target directory for us.
+#
+# $1 = Target Name (the basename of the nmf
+# $2 = Additional create_nmf.py arguments
+#
+NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
+
+define NMF_RULE
+all:$(OUTDIR)/$(1).nmf
+$(OUTDIR)/$(1).nmf : $(OUTDIR)/$(1).pexe
+ $(NMF) -o $$@ $$^ -s $(OUTDIR) $(2)
+endef
+
+