Chromium Code Reviews| Index: native_client_sdk/src/tools/nacl_llvm.mk |
| 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 0000000000000000000000000000000000000000..50e1d0dfb0c78e866422a0061e303256848104c1 |
| --- /dev/null |
| +++ b/native_client_sdk/src/tools/nacl_llvm.mk |
| @@ -0,0 +1,139 @@ |
| +# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
|
binji
2013/01/16 22:46:55
maybe should be called nacl_pnacl instead...?
noelallen1
2013/01/16 23:21:10
I'll do rename as a seperate CL to make it cleaner
|
| +# 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 |
| +# |
| +# |
| + |
| + |
| +# |
| +# 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. |
|
binji
2013/01/16 22:46:55
comment is wrong
noelallen1
2013/01/16 23:21:10
Done.
|
| +# |
| +# By default for x86 32 bit this expands to: |
| +# $(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug |
| +# |
| +LD_PNACL:=-L$(NACL_SDK_ROOT)/lib/pnacl/$(CONFIG) |
| + |
| + |
| +# |
| +# Macros for TOOLS |
| +# |
| +# We use the C++ compiler for everything and then use the -Wl,-as-needed flag |
|
binji
2013/01/16 22:46:55
comment is wrong
noelallen1
2013/01/16 23:21:10
Done.
|
| +# in the linker to drop libc++ unless it's actually needed. |
| +# |
| +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 |
| +# |
| +# |
| +GLIBC_REMAP:= |
| + |
| +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 |
| + |
| + |
| +# |
| +# Link Macro |
| +# |
| +# $1 = Target Name |
| +# $2 = List of Sources |
| +# $3 = List of LIBS |
| +# $4 = List of DEPS |
| +# $5 = POSIX Link Flags |
| +# $6 = VC Link Flags (unused) |
| +# |
| +define LINK_RULE |
| +NMF_TARGETS+=$(OUTDIR)/$(1).pexe |
| +$(OUTDIR)/$(1).pexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_pnacl.o) $(4) |
| + $(PNACL_LINK) -o $$@ $$(filter-out $(4),$$^) $(LD_PNACL) $$(LD_FLAGS) $(foreach lib,$(3),-l$(lib)) $(5) |
| +endef |
| + |
| + |
| +# |
| +# Generate NMF_TARGETS |
| +# |
| +NMF_ARCHES:=.pexe |
| + |
| + |
| +# |
| +# 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 : $(foreach arch,$(NMF_ARCHES),$(OUTDIR)/$(1)$(arch)) |
| + $(NMF) -o $$@ $$^ -s $(OUTDIR) $(2) |
| +endef |
| + |
| + |