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 ifneq ($(TOOLCHAIN
),bionic
)
14 X86_32_CC
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_32
--tool
=cc)
15 X86_32_CXX
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_32
--tool
=c
++)
16 X86_32_LINK
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_32
--tool
=c
++)
17 X86_32_LIB
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_32
--tool
=ar)
18 X86_32_STRIP
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_32
--tool
=strip)
19 X86_32_NM
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_32
--tool
=nm
)
21 X86_64_CC
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_64
--tool
=cc)
22 X86_64_CXX
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_64
--tool
=c
++)
23 X86_64_LINK
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_64
--tool
=c
++)
24 X86_64_LIB
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_64
--tool
=ar)
25 X86_64_STRIP
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_64
--tool
=strip)
26 X86_64_NM
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a x86_64
--tool
=nm
)
29 ifeq (,$(findstring $(TOOLCHAIN
),glibc
))
30 ARM_CC
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=cc)
31 ARM_CXX
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=c
++)
32 ARM_LINK
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=c
++)
33 ARM_LIB
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=ar)
34 ARM_STRIP
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=strip)
35 ARM_NM
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=nm
)
38 NCVAL ?
= python
$(NACL_SDK_ROOT
)/tools
/ncval.py
40 # Architecture-specific variables
41 ifeq (,$(MULTI_PLATFORM
))
42 X86_32_OUTDIR ?
= $(OUTDIR
)
43 X86_64_OUTDIR ?
= $(OUTDIR
)
44 ARM_OUTDIR ?
= $(OUTDIR
)
46 X86_32_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/x86-32
47 X86_64_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/x86-64
48 ARM_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/arm
51 # Architecture-specific flags
57 # Use DWARF v3 which is more commonly available when debugging
58 ifeq ($(CONFIG
),Debug
)
59 ARM_CFLAGS ?
= -gdwarf-3
60 ARM_CXXFLAGS ?
= -gdwarf-3
66 ifeq (,$(MULTI_PLATFORM
))
67 X86_32_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_x86_32.map
68 X86_64_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_x86_64.map
69 ARM_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_arm.map
71 X86_32_LDFLAGS ?
= -Wl
,-Map
,$(X86_32_OUTDIR
)/$(TARGET
)_x86_32.map
72 X86_64_LDFLAGS ?
= -Wl
,-Map
,$(X86_64_OUTDIR
)/$(TARGET
)_x86_64.map
73 ARM_LDFLAGS ?
= -Wl
,-Map
,$(ARM_OUTDIR
)/$(TARGET
)_arm.map
77 # Choose between static and dynamic linking for Bionic
78 # (Default to dynamic)
80 ifeq ($(TOOLCHAIN
),bionic
)
81 ifeq (,$(BIONIC_USE_DYNAMIC
))
84 BIONIC_LINK
:=-Wl
,-Ttext-segment
=0x100000
88 LDFLAGS_SHARED
= -shared
96 define C_COMPILER_RULE
97 -include $(call SRC_TO_DEP
,$(1),_x86_32
)
98 $(call SRC_TO_OBJ
,$(1),_x86_32
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
99 $(call LOG
,CC
,$$@
,$(X86_32_CC
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
) $(X86_32_CFLAGS
))
100 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32
)
102 -include $(call SRC_TO_DEP
,$(1),_x86_64
)
103 $(call SRC_TO_OBJ
,$(1),_x86_64
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
104 $(call LOG
,CC
,$$@
,$(X86_64_CC
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
) $(X86_64_CFLAGS
))
105 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64
)
107 -include $(call SRC_TO_DEP
,$(1),_arm
)
108 $(call SRC_TO_OBJ
,$(1),_arm
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
109 $(call LOG
,CC
,$$@
,$(ARM_CC
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
) $(ARM_CFLAGS
))
110 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm
)
112 -include $(call SRC_TO_DEP
,$(1),_x86_32_pic
)
113 $(call SRC_TO_OBJ
,$(1),_x86_32_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
114 $(call LOG
,CC
,$$@
,$(X86_32_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
) $(X86_32_CFLAGS
))
115 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32_pic
)
117 -include $(call SRC_TO_DEP
,$(1),_x86_64_pic
)
118 $(call SRC_TO_OBJ
,$(1),_x86_64_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
119 $(call LOG
,CC
,$$@
,$(X86_64_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
) $(X86_64_CFLAGS
))
120 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64_pic
)
122 -include $(call SRC_TO_DEP
,$(1),_arm_pic
)
123 $(call SRC_TO_OBJ
,$(1),_arm_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
124 $(call LOG
,CC
,$$@
,$(ARM_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_FLAGS
) $(2) $(NACL_CFLAGS
) $(ARM_CFLAGS
))
125 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm_pic
)
128 define CXX_COMPILER_RULE
129 -include $(call SRC_TO_DEP
,$(1),_x86_32
)
130 $(call SRC_TO_OBJ
,$(1),_x86_32
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
131 $(call LOG
,CXX
,$$@
,$(X86_32_CXX
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CXXFLAGS
) $(X86_32_CXXFLAGS
))
132 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32
)
134 -include $(call SRC_TO_DEP
,$(1),_x86_64
)
135 $(call SRC_TO_OBJ
,$(1),_x86_64
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
136 $(call LOG
,CXX
,$$@
,$(X86_64_CXX
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CXXFLAGS
) $(X86_64_CXXFLAGS
))
137 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64
)
139 -include $(call SRC_TO_DEP
,$(1),_arm
)
140 $(call SRC_TO_OBJ
,$(1),_arm
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
141 $(call LOG
,CXX
,$$@
,$(ARM_CXX
) -o
$$@
-c
$$< $(POSIX_FLAGS
) $(2) $(NACL_CXXFLAGS
) $(ARM_CXXFLAGS
))
142 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm
)
144 -include $(call SRC_TO_DEP
,$(1),_x86_32_pic
)
145 $(call SRC_TO_OBJ
,$(1),_x86_32_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
146 $(call LOG
,CXX
,$$@
,$(X86_32_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_FLAGS
) $(2) $(NACL_CXXFLAGS
) $(X86_32_CXXFLAGS
))
147 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32_pic
)
149 -include $(call SRC_TO_DEP
,$(1),_x86_64_pic
)
150 $(call SRC_TO_OBJ
,$(1),_x86_64_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
151 $(call LOG
,CXX
,$$@
,$(X86_64_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_FLAGS
) $(2) $(NACL_CXXFLAGS
) $(X86_64_CXXFLAGS
))
152 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64_pic
)
154 -include $(call SRC_TO_DEP
,$(1),_arm_pic
)
155 $(call SRC_TO_OBJ
,$(1),_arm_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
156 $(call LOG
,CXX
,$$@
,$(ARM_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_FLAGS
) $(2) $(NACL_CXXFLAGS
) $(ARM_CXXFLAGS
))
157 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm_pic
)
163 # $2 = POSIX Compile Flags
164 # $3 = Include Directories
165 # $4 = VC Flags (unused)
168 ifeq ($(suffix $(1)),.c
)
169 $(call C_COMPILER_RULE
,$(1),$(2) $(foreach inc
,$(INC_PATHS
),-I
$(inc
)) $(3))
171 $(call CXX_COMPILER_RULE
,$(1),$(2) $(foreach inc
,$(INC_PATHS
),-I
$(inc
)) $(3))
176 # Determine which architectures to build for. The user can set NACL_ARCH or
177 # ARCHES in the environment to control this.
179 ifneq ($(TOOLCHAIN
),bionic
)
180 VALID_ARCHES
:= x86_32 x86_64
182 ifneq (glibc
,$(TOOLCHAIN
))
187 ifeq (,$(findstring $(NACL_ARCH
),$(VALID_ARCHES
)))
188 $(error Invalid arch specified in NACL_ARCH
: $(NACL_ARCH
). Valid values are
: $(VALID_ARCHES
))
190 ARCHES
= ${NACL_ARCH}
192 ARCHES ?
= ${VALID_ARCHES}
200 # As well as building and installing a shared library this rule adds dependencies
201 # on the library's .stamp file in STAMPDIR. However, the rule for creating the stamp
202 # file is part of LIB_RULE, so users of the DEPS system are currently required to
203 # use the LIB_RULE macro as well as the SO_RULE for each shared library.
206 # $2 = List of Sources
210 # $6 = 1 => Don't add to NMF.
212 define SO_LINKER_RULE
213 ifneq (,$(findstring x86_32
,$(ARCHES
)))
214 all: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
215 $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_32_pic
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
216 $(MKDIR
) -p
$$(dir $$@
)
217 $(call LOG
,LINK
,$$@
,$(X86_32_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(LDFLAGS_SHARED
) -m32
$(NACL_LDFLAGS
) $(X86_32_LDFLAGS
) $(LDFLAGS
) $(foreach path
,$(5),-L
$(path
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)))
218 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
220 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).so
221 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).so
222 $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).so
: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
223 $(MKDIR
) -p
$$(dir $$@
)
224 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
226 GLIBC_SO_LIST
+= $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
227 GLIBC_REMAP
+= -n lib
$(1)_x86_32.so
,lib
$(1).so
231 ifneq (,$(findstring x86_64
,$(ARCHES
)))
232 all: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
233 $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_64_pic
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
234 $(MKDIR
) -p
$$(dir $$@
)
235 $(call LOG
,LINK
,$$@
,$(X86_32_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(LDFLAGS_SHARED
) -m64
$(NACL_LDFLAGS
) $(X86_64_LDFLAGS
) $(LDFLAGS
) $(foreach path
,$(5),-L
$(path
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)))
236 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
238 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).so
239 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).so
240 $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).so
: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
241 $(MKDIR
) -p
$$(dir $$@
)
242 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
244 GLIBC_SO_LIST
+= $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
245 GLIBC_REMAP
+= -n lib
$(1)_x86_64.so
,lib
$(1).so
249 ifneq (,$(findstring arm
,$(ARCHES
)))
250 all: $(ARM_OUTDIR
)/lib
$(1)_arm.so
251 $(ARM_OUTDIR
)/lib
$(1)_arm.so
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm_pic
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
252 $(MKDIR
) -p
$$(dir $$@
)
253 $(call LOG
,LINK
,$$@
,$(ARM_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(LDFLAGS_SHARED
) -marm
$(NACL_LDFLAGS
) $(ARM_LDFLAGS
) $(LDFLAGS
) $(foreach path
,$(5),-L
$(path
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)))
254 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
256 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).so
257 install: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).so
258 $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).so
: $(ARM_OUTDIR
)/lib
$(1)_arm.so
259 $(MKDIR
) -p
$$(dir $$@
)
260 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
262 GLIBC_SO_LIST
+= $(ARM_OUTDIR
)/lib
$(1)_arm.so
263 GLIBC_REMAP
+= -n lib
$(1)_arm.so
,lib
$(1).so
270 # $2 = List of Sources
273 # $5 = 1 => Don't add to NMF.
276 $(call SO_LINKER_RULE
,$(1),$(2),$(filter-out pthread
,$(3)),$(4),$(LIB_PATHS
),$(5))
283 # $2 = List of Sources
284 # $3 = POSIX Link Flags
285 # $4 = VC Link Flags (unused)
288 $(STAMPDIR
)/$(1).stamp
:
290 @echo
"TOUCHED $$@" > $(STAMPDIR
)/$(1).stamp
292 ifneq (,$(findstring x86_32
,$(ARCHES
)))
293 all: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
294 $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_32
))
295 $(MKDIR
) -p
$$(dir $$@
)
297 $(call LOG
,LIB
,$$@
,$(X86_32_LIB
) -cr
$$@
$$^
)
299 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).a
300 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).a
301 $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).a
: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
302 $(MKDIR
) -p
$$(dir $$@
)
304 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
307 ifneq (,$(findstring x86_64
,$(ARCHES
)))
308 all: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
309 $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_64
))
310 $(MKDIR
) -p
$$(dir $$@
)
312 $(call LOG
,LIB
,$$@
,$(X86_64_LIB
) -cr
$$@
$$^
)
314 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).a
315 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).a
316 $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).a
: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
317 $(MKDIR
) -p
$$(dir $$@
)
318 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
321 ifneq (,$(findstring arm
,$(ARCHES
)))
322 ifneq ($(TOOLCHAIN
),glibc
)
323 all: $(ARM_OUTDIR
)/lib
$(1)_arm.a
324 $(ARM_OUTDIR
)/lib
$(1)_arm.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm
))
325 $(MKDIR
) -p
$$(dir $$@
)
327 $(call LOG
,LIB
,$$@
,$(ARM_LIB
) -cr
$$@
$$^
)
329 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).a
330 install: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).a
331 $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).a
: $(ARM_OUTDIR
)/lib
$(1)_arm.a
332 $(MKDIR
) -p
$$(dir $$@
)
333 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
340 # Specific Link Macro
343 # $2 = List of Sources
350 ifneq (,$(findstring x86_32
,$(ARCHES
)))
351 all: $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
352 $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_32
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
353 $(MKDIR
) -p
$$(dir $$@
)
354 $(call LOG
,LINK
,$$@
,$(X86_32_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(NACL_LDFLAGS
) $(X86_32_LDFLAGS
) $(foreach path
,$(6),-L
$(path
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)) $(5))
355 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
358 ifneq (,$(findstring x86_64
,$(ARCHES
)))
359 all: $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
360 $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_64
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
361 $(MKDIR
) -p
$$(dir $$@
)
362 $(call LOG
,LINK
,$$@
,$(X86_64_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(NACL_LDFLAGS
) $(X86_64_LDFLAGS
) $(foreach path
,$(6),-L
$(path
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)) $(5))
363 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
366 ifneq (,$(findstring arm
,$(ARCHES
)))
367 all: $(ARM_OUTDIR
)/$(1)_arm.nexe
368 $(ARM_OUTDIR
)/$(1)_arm.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
369 $(MKDIR
) -p
$$(dir $$@
)
370 $(call LOG
,LINK
,$$@
,$(ARM_LINK
) $(BIONIC_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(NACL_LDFLAGS
) $(ARM_LDFLAGS
) $(foreach path
,$(6),-L
$(path
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)) $(5))
371 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
377 # Generalized Link Macro
380 # $2 = List of Sources
383 # $5 = POSIX Linker Switches
384 # $6 = VC Linker Switches
387 $(call LINKER_RULE
,$(1),$(2),$(filter-out pthread
,$(3)),$(4),$(5),$(LIB_PATHS
))
392 # Strip Macro for each arch (e.g., each arch supported by LINKER_RULE).
397 define STRIP_ALL_RULE
398 ifneq (,$(findstring x86_32
,$(ARCHES
)))
399 $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
: $(X86_32_OUTDIR
)/$(2)_x86_32.nexe
400 $(call LOG
,STRIP
,$$@
,$(X86_32_STRIP
) -o
$$@
$$^
)
403 ifneq (,$(findstring x86_64
,$(ARCHES
)))
404 $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
: $(X86_64_OUTDIR
)/$(2)_x86_64.nexe
405 $(call LOG
,STRIP
,$$@
,$(X86_64_STRIP
) -o
$$@
$$^
)
408 ifneq (,$(findstring arm
,$(ARCHES
)))
409 $(ARM_OUTDIR
)/$(1)_arm.nexe
: $(ARM_OUTDIR
)/$(2)_arm.nexe
410 $(call LOG
,STRIP
,$$@
,$(ARM_STRIP
) -o
$$@
$$^
)
416 # Top-level Strip Macro
418 # $1 = Target Basename
419 # $2 = Source Basename
422 $(call STRIP_ALL_RULE
,$(1),$(2))
427 # Strip Macro for each arch (e.g., each arch supported by MAP_RULE).
433 ifneq (,$(findstring x86_32
,$(ARCHES
)))
434 all: $(X86_32_OUTDIR
)/$(1)_x86_32.map
435 $(X86_32_OUTDIR
)/$(1)_x86_32.map
: $(X86_32_OUTDIR
)/$(2)_x86_32.nexe
436 $(call LOG
,MAP
,$$@
,$(X86_32_NM
) -l
$$^
> $$@
)
439 ifneq (,$(findstring x86_64
,$(ARCHES
)))
440 all: $(X86_64_OUTDIR
)/$(1)_x86_64.map
441 $(X86_64_OUTDIR
)/$(1)_x86_64.map
: $(X86_64_OUTDIR
)/$(2)_x86_64.nexe
442 $(call LOG
,MAP
,$$@
,$(X86_64_NM
) -l
$$^
> $$@
)
445 ifneq (,$(findstring arm
,$(ARCHES
)))
446 all: $(ARM_OUTDIR
)/$(1)_arm.map
447 $(ARM_OUTDIR
)/$(1)_arm.map
: $(ARM_OUTDIR
)/$(2)_arm.nexe
448 $(call LOG
,MAP
,$$@
,$(ARM_NM
) -l
$$^
> $$@
)
454 # Top-level MAP Generation Macro
456 # $1 = Target Basename
457 # $2 = Source Basename
460 $(call MAP_ALL_RULE
,$(1),$(2))
465 # NMF Manifiest generation
467 # Use the python script create_nmf to scan the binaries for dependencies using
468 # objdump. Pass in the (-L) paths to the default library toolchains so that we
469 # can find those libraries and have it automatically copy the files (-s) to
470 # the target directory for us.
472 # $1 = Target Name (the basename of the nmf
473 # $2 = Additional create_nmf.py arguments
475 NMF
:= python
$(NACL_SDK_ROOT
)/tools
/create_nmf.py
476 ifeq ($(CONFIG
),Debug
)
477 NMF_FLAGS
+= --debug-libs
478 HTML_FLAGS
+= --debug-libs
481 EXECUTABLES
= $(GLIBC_SO_LIST
)
482 ifneq (,$(findstring x86_32
,$(ARCHES
)))
483 EXECUTABLES
+= $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
485 ifneq (,$(findstring x86_64
,$(ARCHES
)))
486 EXECUTABLES
+= $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
488 ifneq (,$(findstring arm
,$(ARCHES
)))
489 EXECUTABLES
+= $(ARM_OUTDIR
)/$(1)_arm.nexe
492 ifneq (,$(MULTI_PLATFORM
))
493 # When building a multi-platform package, stage all dependent shared libraries
494 # in the same directory as the .nexe (which will be an architecture-specific
495 # directory under _platform_specific).
496 NMF_FLAGS
+= -s
$(OUTDIR
) --no-arch-prefix
498 # Otherwise stage dependent libraries the normal way, under lib32 for x86_32
499 # libraries, and lib64 for x86_64 libraries.
500 NMF_FLAGS
+= -s
$(OUTDIR
)
503 ifneq (,$(MULTI_PLATFORM
))
504 # This script fixes the manifest.json file for this App to point to:
506 # <toolchain>/<config>/_platform_specific/<arch>/
510 # _platform_specific/<arch>
511 FIX_MANIFEST
:= python
$(NACL_SDK_ROOT
)/tools
/fix_manifest.py
512 MANIFEST_JSON ?
= manifest.json
516 all: $(OUTDIR
)/$(1).nmf
517 $(OUTDIR
)/$(1).nmf
$(MANIFEST_JSON
): $(EXECUTABLES
)
518 $(call LOG
,CREATE_NMF
,$$@
,$(NMF
) $(NMF_FLAGS
) -o
$$@
$$^
$(GLIBC_PATHS
) $(2) $(GLIBC_REMAP
))
519 ifneq (,$(MULTI_PLATFORM
))
520 $(call LOG
,FIX_MANIFEST
,$(MANIFEST_JSON
),$(FIX_MANIFEST
) $(MANIFEST_JSON
)) -p
"$(TOOLCHAIN)/$(CONFIG)"
525 # HTML file generation
527 CREATE_HTML
:= python
$(NACL_SDK_ROOT
)/tools
/create_html.py
530 all: $(OUTDIR
)/$(1).html
531 $(OUTDIR
)/$(1).html
: $(EXECUTABLES
)
532 $(call LOG
,CREATE_HTML
,$$@
,$(CREATE_HTML
) $(HTML_FLAGS
) -o
$$@
$$^
)
537 # Determine which executable to pass into the debugger. For newlib
538 # this is the NEXE which will actually be used. For glibc, runnable-ld.so
539 # is the "app", and the "app" is actual an .so we load.
541 ifeq (x86_32
,$(SYSARCH
))
548 ifeq (newlib
,$(TOOLCHAIN
))
549 GDB_DEBUG_TARGET
= $(abspath
$(OUTDIR
))/$(TARGET
)_
$(SYSARCH
).nexe
551 GDB_DEBUG_TARGET
= $(abspath
$(OUTDIR
))/$(LIB_NAME
)/runnable-ld.so
557 $(error Cannot run in sel_ldr unless
$$NACL_ARCH is set
)
559 $(SEL_LDR_PATH
) $(SEL_LDR_ARGS
) $(OUTDIR
)/$(TARGET
)_
$(NACL_ARCH
).nexe
-- $(EXE_ARGS
)
563 $(error Cannot run in sel_ldr unless
$$NACL_ARCH is set
)
565 $(SEL_LDR_PATH
) -d
$(SEL_LDR_ARGS
) $(OUTDIR
)/$(TARGET
)_
$(NACL_ARCH
).nexe
-- $(EXE_ARGS
)