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
13 PNACL_CC
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) --tool
=cc)
14 PNACL_CXX
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) --tool
=c
++)
15 PNACL_LINK
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) --tool
=c
++)
16 PNACL_LIB
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) --tool
=ar)
17 PNACL_STRIP
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) --tool
=strip)
18 PNACL_FINALIZE
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) --tool
=finalize
)
25 # $3 = Include Directories
27 define C_COMPILER_RULE
28 -include $(call SRC_TO_DEP
,$(1))
29 $(call SRC_TO_OBJ
,$(1)): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
30 $(call LOG
,CC
,$$@
,$(PNACL_CC
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
))
31 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1))
34 define CXX_COMPILER_RULE
35 -include $(call SRC_TO_DEP
,$(1))
36 $(call SRC_TO_OBJ
,$(1)): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
37 $(call LOG
,CXX
,$$@
,$(PNACL_CXX
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
))
38 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1))
43 # $2 = POSIX Compile Flags
44 # $3 = Include Directories
45 # $4 = VC Flags (unused)
47 ifeq ($(suffix $(1)),.c
)
48 $(call C_COMPILER_RULE
,$(1),$(2) $(foreach inc
,$(INC_PATHS
),-I
$(inc
)) $(3))
50 $(call CXX_COMPILER_RULE
,$(1),$(2) $(foreach inc
,$(INC_PATHS
),-I
$(inc
)) $(3))
59 # $2 = List of Sources
63 $(error
'Shared libraries not supported by PNaCl')
71 # $2 = List of Sources
72 # $3 = POSIX Link Flags
73 # $4 = VC Link Flags (unused)
75 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)/$(CONFIG
)/lib
$(1).a
76 @echo
"TOUCHED $$@" > $(STAMPDIR
)/$(1).stamp
78 all: $(LIBDIR
)/$(TOOLCHAIN
)/$(CONFIG
)/lib
$(1).a
79 $(LIBDIR
)/$(TOOLCHAIN
)/$(CONFIG
)/lib
$(1).a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
)))
80 $(MKDIR
) -p
$$(dir $$@
)
82 $(call LOG
,LIB
,$$@
,$(PNACL_LIB
) -cr
$$@
$$^
$(3))
93 # $5 = List of lib dirs
94 # $6 = Other Linker Args
99 $(call LOG
,FINALIZE
,$$@
,$(PNACL_FINALIZE
) -o
$$@
$$^
)
101 $(1).bc
: $(2) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
102 $(call LOG
,LINK
,$$@
,$(PNACL_LINK
) -o
$$@
$(2) $(PNACL_LDFLAGS
) $(foreach path
,$(5),-L
$(path
)/pnacl
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)) $(6))
107 # Generalized Link Macro
110 # $2 = List of Sources
113 # $5 = POSIX Linker Switches
114 # $6 = VC Linker Switches
117 $(call LINKER_RULE
,$(OUTDIR
)/$(1),$(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
))),$(filter-out pthread
,$(3)),$(4),$(LIB_PATHS
),$(5))
124 # NOTE: pnacl-strip does not really do much for finalized pexes (in a
125 # sense, they are already stripped), but set this rule up for uniformity.
131 all: $(OUTDIR
)/$(1).pexe
132 $(OUTDIR
)/$(1).pexe
: $(OUTDIR
)/$(2).pexe
133 $(call LOG
,STRIP
,$$@
,$(PNACL_STRIP
) $$^
-o
$$@
)
138 # NMF Manifest generation
140 # Use the python script create_nmf to scan the binaries for dependencies using
141 # objdump. Pass in the (-L) paths to the default library toolchains so that we
142 # can find those libraries and have it automatically copy the files (-s) to
143 # the target directory for us.
145 # $1 = Target Name (the basename of the nmf)
146 # $2 = Additional create_nmf.py arguments
148 NMF
:=python
$(NACL_SDK_ROOT
)/tools
/create_nmf.py
150 EXECUTABLES
=$(OUTDIR
)/$(1).pexe
$(OUTDIR
)/$(1)_unstripped.bc
153 all: $(OUTDIR
)/$(1).nmf
154 $(OUTDIR
)/$(1).nmf
: $(EXECUTABLES
)
155 $(call LOG
,CREATE_NMF
,$$@
,$(NMF
) -o
$$@
$$^
-s
$(OUTDIR
) $(2))
159 # HTML file generation
161 CREATE_HTML
:= python
$(NACL_SDK_ROOT
)/tools
/create_html.py
164 all: $(OUTDIR
)/$(1).html
165 $(OUTDIR
)/$(1).html
: $(EXECUTABLES
)
166 $(call LOG
,CREATE_HTML
,$$@
,$(CREATE_HTML
) -o
$$@
$$^
)