1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 # GNU Make based build file. For details on GNU Make see:
7 # http://www.gnu.org/software/make/manual/make.html
15 PNACL_CC?
=$(TC_PATH
)/$(OSNAME
)_x86_
$(TOOLCHAIN
)/newlib
/bin
/pnacl-clang
-c
16 PNACL_CXX?
=$(TC_PATH
)/$(OSNAME
)_x86_
$(TOOLCHAIN
)/newlib
/bin
/pnacl-clang
++ -c
17 PNACL_LINK?
=$(TC_PATH
)/$(OSNAME
)_x86_
$(TOOLCHAIN
)/newlib
/bin
/pnacl-clang
++
18 PNACL_LIB?
=$(TC_PATH
)/$(OSNAME
)_x86_
$(TOOLCHAIN
)/newlib
/bin
/pnacl-ar r
26 # $3 = Include Directories
28 define C_COMPILER_RULE
29 $(OUTDIR
)/$(basename $(1))_pnacl.o
: $(1) $(TOP_MAKE
) |
$(OUTDIR
)
30 $(PNACL_CC
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
)
33 define CXX_COMPILER_RULE
34 $(OUTDIR
)/$(basename $(1))_pnacl.o
: $(1) $(TOP_MAKE
) |
$(OUTDIR
)
35 $(PNACL_CXX
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
)
40 # $2 = POSIX Compile Flags
41 # $3 = Include Directories
42 # $4 = VC Flags (unused)
44 ifeq ('.c','$(suffix $(1))')
45 $(call C_COMPILER_RULE
,$(1),$(2) -I
$(NACL_SDK_ROOT
)/include $(foreach inc
,$(3),-I
$(inc
)))
47 $(call CXX_COMPILER_RULE
,$(1),$(2) -I
$(NACL_SDK_ROOT
)/include $(foreach inc
,$(3),-I
$(inc
)))
56 # $2 = List of Sources
60 $(error
'Shared libraries not supported by PNaCl')
68 # $2 = List of Sources
69 # $3 = POSIX Link Flags
70 # $4 = VC Link Flags (unused)
72 all: $(NACL_SDK_ROOT
)/lib
/$(TOOLCHAIN
)/$(CONFIG
)/lib
$(1).a
73 $(NACL_SDK_ROOT
)/lib
/$(TOOLCHAIN
)/$(CONFIG
)/lib
$(1).a
: $(foreach src
,$(2),$(OUTDIR
)/$(basename $(src
))_pnacl.o
)
74 $(MKDIR
) -p
$$(dir $$@
)
75 $(PNACL_LIB
) $$@
$$^
$(3)
86 # $5 = List of lib dirs
87 # $6 = Other Linker Args
92 $(PNACL_LINK
) -o
$(1) $(2) $(foreach path
,$(5),-L
$(path
)/pnacl
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)) $(6)
98 # Generalized Link Macro
101 # $2 = List of Sources
104 # $5 = POSIX Linker Switches
105 # $6 = VC Linker Switches
108 $(call LINKER_RULE
,$(OUTDIR
)/$(1).pexe
,$(foreach src
,$(2),$(OUTDIR
)/$(basename $(src
))_pnacl.o
),$(filter-out pthread
,$(3)),$(4),$(LIB_PATHS
),$(5))
114 # NMF Manifiest generation
116 # Use the python script create_nmf to scan the binaries for dependencies using
117 # objdump. Pass in the (-L) paths to the default library toolchains so that we
118 # can find those libraries and have it automatically copy the files (-s) to
119 # the target directory for us.
121 # $1 = Target Name (the basename of the nmf
122 # $2 = Additional create_nmf.py arguments
124 NMF
:=python
$(NACL_SDK_ROOT
)/tools
/create_nmf.py
127 all:$(OUTDIR
)/$(1).nmf
128 $(OUTDIR
)/$(1).nmf
: $(OUTDIR
)/$(1).pexe
129 $(NMF
) -o
$$@
$$^
-s
$(OUTDIR
) $(2)