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 ifneq (,$(findstring $(TOOLCHAIN
),newlib bionic clang-newlib
))
33 ifeq ($(ARM_SUPPORT
),1)
34 ARM_CC
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=cc)
35 ARM_CXX
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=c
++)
36 ARM_LINK
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=c
++)
37 ARM_LIB
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=ar)
38 ARM_STRIP
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=strip)
39 ARM_NM
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=nm
)
42 NCVAL ?
= python
$(NACL_SDK_ROOT
)/tools
/ncval.py
44 # Architecture-specific variables
45 ifeq (,$(MULTI_PLATFORM
))
46 X86_32_OUTDIR ?
= $(OUTDIR
)
47 X86_64_OUTDIR ?
= $(OUTDIR
)
48 ARM_OUTDIR ?
= $(OUTDIR
)
50 X86_32_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/x86-32
51 X86_64_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/x86-64
52 ARM_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/arm
55 # Architecture-specific flags
61 # Use DWARF v3 which is more commonly available when debugging
62 ifeq ($(CONFIG
),Debug
)
63 ARM_CFLAGS ?
= -gdwarf-3
64 ARM_CXXFLAGS ?
= -gdwarf-3
70 ifeq (,$(MULTI_PLATFORM
))
71 X86_32_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_x86_32.map
72 X86_64_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_x86_64.map
73 ARM_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_arm.map
75 X86_32_LDFLAGS ?
= -Wl
,-Map
,$(X86_32_OUTDIR
)/$(TARGET
)_x86_32.map
76 X86_64_LDFLAGS ?
= -Wl
,-Map
,$(X86_64_OUTDIR
)/$(TARGET
)_x86_64.map
77 ARM_LDFLAGS ?
= -Wl
,-Map
,$(ARM_OUTDIR
)/$(TARGET
)_arm.map
81 # Choose between static and dynamic linking for Bionic
82 # (Default to dynamic)
84 ifeq ($(TOOLCHAIN
),bionic
)
85 ifeq (,$(BIONIC_USE_DYNAMIC
))
88 BIONIC_LINK
:=-Wl
,-Ttext-segment
=0x100000
92 LDFLAGS_SHARED
= -shared
100 define C_COMPILER_RULE
101 -include $(call SRC_TO_DEP
,$(1),_x86_32
)
102 $(call SRC_TO_OBJ
,$(1),_x86_32
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
103 $(call LOG
,CC
,$$@
,$(X86_32_CC
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(2) $(NACL_CFLAGS
) $(X86_32_CFLAGS
))
104 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32
)
106 -include $(call SRC_TO_DEP
,$(1),_x86_64
)
107 $(call SRC_TO_OBJ
,$(1),_x86_64
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
108 $(call LOG
,CC
,$$@
,$(X86_64_CC
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(2) $(NACL_CFLAGS
) $(X86_64_CFLAGS
))
109 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64
)
111 -include $(call SRC_TO_DEP
,$(1),_arm
)
112 $(call SRC_TO_OBJ
,$(1),_arm
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
113 $(call LOG
,CC
,$$@
,$(ARM_CC
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(2) $(NACL_CFLAGS
) $(ARM_CFLAGS
))
114 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm
)
116 -include $(call SRC_TO_DEP
,$(1),_x86_32_pic
)
117 $(call SRC_TO_OBJ
,$(1),_x86_32_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
118 $(call LOG
,CC
,$$@
,$(X86_32_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(2) $(NACL_CFLAGS
) $(X86_32_CFLAGS
))
119 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32_pic
)
121 -include $(call SRC_TO_DEP
,$(1),_x86_64_pic
)
122 $(call SRC_TO_OBJ
,$(1),_x86_64_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
123 $(call LOG
,CC
,$$@
,$(X86_64_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(2) $(NACL_CFLAGS
) $(X86_64_CFLAGS
))
124 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64_pic
)
126 -include $(call SRC_TO_DEP
,$(1),_arm_pic
)
127 $(call SRC_TO_OBJ
,$(1),_arm_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
128 $(call LOG
,CC
,$$@
,$(ARM_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(2) $(NACL_CFLAGS
) $(ARM_CFLAGS
))
129 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm_pic
)
132 define CXX_COMPILER_RULE
133 -include $(call SRC_TO_DEP
,$(1),_x86_32
)
134 $(call SRC_TO_OBJ
,$(1),_x86_32
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
135 $(call LOG
,CXX
,$$@
,$(X86_32_CXX
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(2) $(NACL_CXXFLAGS
) $(X86_32_CXXFLAGS
))
136 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32
)
138 -include $(call SRC_TO_DEP
,$(1),_x86_64
)
139 $(call SRC_TO_OBJ
,$(1),_x86_64
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
140 $(call LOG
,CXX
,$$@
,$(X86_64_CXX
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(2) $(NACL_CXXFLAGS
) $(X86_64_CXXFLAGS
))
141 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64
)
143 -include $(call SRC_TO_DEP
,$(1),_arm
)
144 $(call SRC_TO_OBJ
,$(1),_arm
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
145 $(call LOG
,CXX
,$$@
,$(ARM_CXX
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(2) $(NACL_CXXFLAGS
) $(ARM_CXXFLAGS
))
146 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm
)
148 -include $(call SRC_TO_DEP
,$(1),_x86_32_pic
)
149 $(call SRC_TO_OBJ
,$(1),_x86_32_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
150 $(call LOG
,CXX
,$$@
,$(X86_32_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(2) $(NACL_CXXFLAGS
) $(X86_32_CXXFLAGS
))
151 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32_pic
)
153 -include $(call SRC_TO_DEP
,$(1),_x86_64_pic
)
154 $(call SRC_TO_OBJ
,$(1),_x86_64_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
155 $(call LOG
,CXX
,$$@
,$(X86_64_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(2) $(NACL_CXXFLAGS
) $(X86_64_CXXFLAGS
))
156 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64_pic
)
158 -include $(call SRC_TO_DEP
,$(1),_arm_pic
)
159 $(call SRC_TO_OBJ
,$(1),_arm_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
160 $(call LOG
,CXX
,$$@
,$(ARM_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(2) $(NACL_CXXFLAGS
) $(ARM_CXXFLAGS
))
161 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm_pic
)
167 # $2 = POSIX Compile Flags
168 # $3 = Include Directories
169 # $4 = VC Flags (unused)
172 ifeq ($(suffix $(1)),.c
)
173 $(call C_COMPILER_RULE
,$(1),$(2) $(foreach inc
,$(INC_PATHS
),-I
$(inc
)) $(3))
175 $(call CXX_COMPILER_RULE
,$(1),$(2) $(foreach inc
,$(INC_PATHS
),-I
$(inc
)) $(3))
180 # Determine which architectures to build for. The user can set NACL_ARCH or
181 # ARCHES in the environment to control this.
183 ifneq ($(TOOLCHAIN
),bionic
)
184 VALID_ARCHES
:= x86_32 x86_64
186 ifeq ($(ARM_SUPPORT
),1)
191 ifeq (,$(findstring $(NACL_ARCH
),$(VALID_ARCHES
)))
192 $(error Invalid arch specified in NACL_ARCH
: $(NACL_ARCH
). Valid values are
: $(VALID_ARCHES
))
194 ARCHES
= ${NACL_ARCH}
196 ARCHES ?
= ${VALID_ARCHES}
204 # As well as building and installing a shared library this rule adds dependencies
205 # on the library's .stamp file in STAMPDIR. However, the rule for creating the stamp
206 # file is part of LIB_RULE, so users of the DEPS system are currently required to
207 # use the LIB_RULE macro as well as the SO_RULE for each shared library.
210 # $2 = List of Sources
214 # $6 = 1 => Don't add to NMF.
216 define SO_LINKER_RULE
217 ifneq (,$(findstring x86_32
,$(ARCHES
)))
218 all: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
219 $(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
)
220 $(MKDIR
) -p
$$(dir $$@
)
221 $(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
)))
222 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
224 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).so
225 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).so
226 $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).so
: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
227 $(MKDIR
) -p
$$(dir $$@
)
228 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
230 GLIBC_SO_LIST
+= $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
231 GLIBC_REMAP
+= -n lib
$(1)_x86_32.so
,lib
$(1).so
235 ifneq (,$(findstring x86_64
,$(ARCHES
)))
236 all: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
237 $(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
)
238 $(MKDIR
) -p
$$(dir $$@
)
239 $(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
)))
240 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
242 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).so
243 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).so
244 $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).so
: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
245 $(MKDIR
) -p
$$(dir $$@
)
246 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
248 GLIBC_SO_LIST
+= $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
249 GLIBC_REMAP
+= -n lib
$(1)_x86_64.so
,lib
$(1).so
253 ifneq (,$(findstring arm
,$(ARCHES
)))
254 all: $(ARM_OUTDIR
)/lib
$(1)_arm.so
255 $(ARM_OUTDIR
)/lib
$(1)_arm.so
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm_pic
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
256 $(MKDIR
) -p
$$(dir $$@
)
257 $(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
)))
258 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
260 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).so
261 install: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).so
262 $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).so
: $(ARM_OUTDIR
)/lib
$(1)_arm.so
263 $(MKDIR
) -p
$$(dir $$@
)
264 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
266 GLIBC_SO_LIST
+= $(ARM_OUTDIR
)/lib
$(1)_arm.so
267 GLIBC_REMAP
+= -n lib
$(1)_arm.so
,lib
$(1).so
274 # $2 = List of Sources
277 # $5 = 1 => Don't add to NMF.
280 $(call SO_LINKER_RULE
,$(1),$(2),$(filter-out pthread
,$(3)),$(4),$(LIB_PATHS
),$(5))
287 # $2 = List of Sources
288 # $3 = POSIX Link Flags
289 # $4 = VC Link Flags (unused)
292 $(STAMPDIR
)/$(1).stamp
:
294 @echo
"TOUCHED $$@" > $(STAMPDIR
)/$(1).stamp
296 ifneq (,$(findstring x86_32
,$(ARCHES
)))
297 all: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
298 $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_32
))
299 $(MKDIR
) -p
$$(dir $$@
)
301 $(call LOG
,LIB
,$$@
,$(X86_32_LIB
) -cr
$$@
$$^
)
303 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).a
304 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).a
305 $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)/lib
$(1).a
: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
306 $(MKDIR
) -p
$$(dir $$@
)
308 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
311 ifneq (,$(findstring x86_64
,$(ARCHES
)))
312 all: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
313 $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_64
))
314 $(MKDIR
) -p
$$(dir $$@
)
316 $(call LOG
,LIB
,$$@
,$(X86_64_LIB
) -cr
$$@
$$^
)
318 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).a
319 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).a
320 $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)/lib
$(1).a
: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
321 $(MKDIR
) -p
$$(dir $$@
)
322 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
325 ifneq (,$(findstring arm
,$(ARCHES
)))
326 ifeq ($(ARM_SUPPORT
),1)
327 all: $(ARM_OUTDIR
)/lib
$(1)_arm.a
328 $(ARM_OUTDIR
)/lib
$(1)_arm.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm
))
329 $(MKDIR
) -p
$$(dir $$@
)
331 $(call LOG
,LIB
,$$@
,$(ARM_LIB
) -cr
$$@
$$^
)
333 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).a
334 install: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).a
335 $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)/lib
$(1).a
: $(ARM_OUTDIR
)/lib
$(1)_arm.a
336 $(MKDIR
) -p
$$(dir $$@
)
337 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
344 # Specific Link Macro
347 # $2 = List of Sources
354 ifneq (,$(findstring x86_32
,$(ARCHES
)))
355 all: $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
356 $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_32
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
357 $(MKDIR
) -p
$$(dir $$@
)
358 $(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))
359 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
362 ifneq (,$(findstring x86_64
,$(ARCHES
)))
363 all: $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
364 $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_64
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
365 $(MKDIR
) -p
$$(dir $$@
)
366 $(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))
367 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
370 ifneq (,$(findstring arm
,$(ARCHES
)))
371 all: $(ARM_OUTDIR
)/$(1)_arm.nexe
372 $(ARM_OUTDIR
)/$(1)_arm.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
373 $(MKDIR
) -p
$$(dir $$@
)
374 $(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))
375 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
381 # Generalized Link Macro
384 # $2 = List of Sources
387 # $5 = POSIX Linker Switches
388 # $6 = VC Linker Switches
391 $(call LINKER_RULE
,$(1),$(2),$(filter-out pthread
,$(3)),$(4),$(5),$(LIB_PATHS
))
396 # Strip Macro for each arch (e.g., each arch supported by LINKER_RULE).
401 define STRIP_ALL_RULE
402 ifneq (,$(findstring x86_32
,$(ARCHES
)))
403 $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
: $(X86_32_OUTDIR
)/$(2)_x86_32.nexe
404 $(call LOG
,STRIP
,$$@
,$(X86_32_STRIP
) -o
$$@
$$^
)
407 ifneq (,$(findstring x86_64
,$(ARCHES
)))
408 $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
: $(X86_64_OUTDIR
)/$(2)_x86_64.nexe
409 $(call LOG
,STRIP
,$$@
,$(X86_64_STRIP
) -o
$$@
$$^
)
412 ifneq (,$(findstring arm
,$(ARCHES
)))
413 $(ARM_OUTDIR
)/$(1)_arm.nexe
: $(ARM_OUTDIR
)/$(2)_arm.nexe
414 $(call LOG
,STRIP
,$$@
,$(ARM_STRIP
) -o
$$@
$$^
)
420 # Top-level Strip Macro
422 # $1 = Target Basename
423 # $2 = Source Basename
426 $(call STRIP_ALL_RULE
,$(1),$(2))
431 # Strip Macro for each arch (e.g., each arch supported by MAP_RULE).
437 ifneq (,$(findstring x86_32
,$(ARCHES
)))
438 all: $(X86_32_OUTDIR
)/$(1)_x86_32.map
439 $(X86_32_OUTDIR
)/$(1)_x86_32.map
: $(X86_32_OUTDIR
)/$(2)_x86_32.nexe
440 $(call LOG
,MAP
,$$@
,$(X86_32_NM
) -l
$$^
> $$@
)
443 ifneq (,$(findstring x86_64
,$(ARCHES
)))
444 all: $(X86_64_OUTDIR
)/$(1)_x86_64.map
445 $(X86_64_OUTDIR
)/$(1)_x86_64.map
: $(X86_64_OUTDIR
)/$(2)_x86_64.nexe
446 $(call LOG
,MAP
,$$@
,$(X86_64_NM
) -l
$$^
> $$@
)
449 ifneq (,$(findstring arm
,$(ARCHES
)))
450 all: $(ARM_OUTDIR
)/$(1)_arm.map
451 $(ARM_OUTDIR
)/$(1)_arm.map
: $(ARM_OUTDIR
)/$(2)_arm.nexe
452 $(call LOG
,MAP
,$$@
,$(ARM_NM
) -l
$$^
> $$@
)
458 # Top-level MAP Generation Macro
460 # $1 = Target Basename
461 # $2 = Source Basename
464 $(call MAP_ALL_RULE
,$(1),$(2))
469 # NMF Manifiest generation
471 # Use the python script create_nmf to scan the binaries for dependencies using
472 # objdump. Pass in the (-L) paths to the default library toolchains so that we
473 # can find those libraries and have it automatically copy the files (-s) to
474 # the target directory for us.
476 # $1 = Target Name (the basename of the nmf
477 # $2 = Additional create_nmf.py arguments
479 NMF
:= python
$(NACL_SDK_ROOT
)/tools
/create_nmf.py
480 ifeq ($(CONFIG
),Debug
)
481 NMF_FLAGS
+= --debug-libs
482 HTML_FLAGS
+= --debug-libs
485 EXECUTABLES
= $(GLIBC_SO_LIST
)
486 ifneq (,$(findstring x86_32
,$(ARCHES
)))
487 EXECUTABLES
+= $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
489 ifneq (,$(findstring x86_64
,$(ARCHES
)))
490 EXECUTABLES
+= $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
492 ifneq (,$(findstring arm
,$(ARCHES
)))
493 EXECUTABLES
+= $(ARM_OUTDIR
)/$(1)_arm.nexe
496 ifneq (,$(MULTI_PLATFORM
))
497 # When building a multi-platform package, stage all dependent shared libraries
498 # in the same directory as the .nexe (which will be an architecture-specific
499 # directory under _platform_specific).
500 NMF_FLAGS
+= -s
$(OUTDIR
) --no-arch-prefix
502 # Otherwise stage dependent libraries the normal way, under lib32 for x86_32
503 # libraries, and lib64 for x86_64 libraries.
504 NMF_FLAGS
+= -s
$(OUTDIR
)
507 ifneq (,$(MULTI_PLATFORM
))
508 # This script fixes the manifest.json file for this App to point to:
510 # <toolchain>/<config>/_platform_specific/<arch>/
514 # _platform_specific/<arch>
515 FIX_MANIFEST
:= python
$(NACL_SDK_ROOT
)/tools
/fix_manifest.py
516 MANIFEST_JSON ?
= manifest.json
520 all: $(OUTDIR
)/$(1).nmf
521 $(OUTDIR
)/$(1).nmf
$(MANIFEST_JSON
): $(EXECUTABLES
)
522 $(call LOG
,CREATE_NMF
,$$@
,$(NMF
) $(NMF_FLAGS
) -o
$$@
$$^
$(GLIBC_PATHS
) $(2) $(GLIBC_REMAP
))
523 ifneq (,$(MULTI_PLATFORM
))
524 $(call LOG
,FIX_MANIFEST
,$(MANIFEST_JSON
),$(FIX_MANIFEST
) $(MANIFEST_JSON
)) -p
"$(TOOLCHAIN)/$(CONFIG)"
529 # HTML file generation
531 CREATE_HTML
:= python
$(NACL_SDK_ROOT
)/tools
/create_html.py
534 all: $(OUTDIR
)/$(1).html
535 $(OUTDIR
)/$(1).html
: $(EXECUTABLES
)
536 $(call LOG
,CREATE_HTML
,$$@
,$(CREATE_HTML
) $(HTML_FLAGS
) -o
$$@
$$^
)
541 # Determine which executable to pass into the debugger. For newlib
542 # this is the NEXE which will actually be used. For glibc, runnable-ld.so
543 # is the "app", and the "app" is actual an .so we load.
545 ifeq (x86_32
,$(SYSARCH
))
552 ifeq (newlib
,$(TOOLCHAIN
))
553 GDB_DEBUG_TARGET
= $(abspath
$(OUTDIR
))/$(TARGET
)_
$(SYSARCH
).nexe
555 GDB_DEBUG_TARGET
= $(abspath
$(OUTDIR
))/$(LIB_NAME
)/runnable-ld.so
561 $(error Cannot run in sel_ldr unless
$$NACL_ARCH is set
)
563 $(SEL_LDR_PATH
) $(SEL_LDR_ARGS
) $(OUTDIR
)/$(TARGET
)_
$(NACL_ARCH
).nexe
-- $(EXE_ARGS
)
567 $(error Cannot run in sel_ldr unless
$$NACL_ARCH is set
)
569 $(SEL_LDR_PATH
) -d
$(SEL_LDR_ARGS
) $(OUTDIR
)/$(TARGET
)_
$(NACL_ARCH
).nexe
-- $(EXE_ARGS
)