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 ARM_CC
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=cc)
30 ARM_CXX
:= $(NACL_COMPILER_PREFIX
) $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=c
++)
31 ARM_LINK
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=c
++)
32 ARM_LIB
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=ar)
33 ARM_STRIP
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=strip)
34 ARM_NM
:= $(shell $(NACL_CONFIG
) -t
$(TOOLCHAIN
) -a arm
--tool
=nm
)
36 NCVAL ?
= python
$(NACL_SDK_ROOT
)/tools
/ncval.py
38 # Architecture-specific variables
39 ifeq (,$(MULTI_PLATFORM
))
40 X86_32_OUTDIR ?
= $(OUTDIR
)
41 X86_64_OUTDIR ?
= $(OUTDIR
)
42 ARM_OUTDIR ?
= $(OUTDIR
)
44 X86_32_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/x86-32
45 X86_64_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/x86-64
46 ARM_OUTDIR ?
= $(OUTDIR
)/_platform_specific
/arm
49 # Architecture-specific flags
55 # Use DWARF v3 which is more commonly available when debugging
56 ifeq ($(CONFIG
),Debug
)
57 ARM_CFLAGS ?
= -gdwarf-3
58 ARM_CXXFLAGS ?
= -gdwarf-3
64 ifeq (,$(MULTI_PLATFORM
))
65 X86_32_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_x86_32.map
66 X86_64_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_x86_64.map
67 ARM_LDFLAGS ?
= -Wl
,-Map
,$(OUTDIR
)/$(TARGET
)_arm.map
69 X86_32_LDFLAGS ?
= -Wl
,-Map
,$(X86_32_OUTDIR
)/$(TARGET
)_x86_32.map
70 X86_64_LDFLAGS ?
= -Wl
,-Map
,$(X86_64_OUTDIR
)/$(TARGET
)_x86_64.map
71 ARM_LDFLAGS ?
= -Wl
,-Map
,$(ARM_OUTDIR
)/$(TARGET
)_arm.map
75 # Choose between static and dynamic linking for Bionic
76 # (Default to dynamic)
78 ifeq ($(TOOLCHAIN
),bionic
)
79 ifeq (,$(BIONIC_USE_DYNAMIC
))
82 BIONIC_LINK
:=-Wl
,-Ttext-segment
=0x100000
86 LDFLAGS_SHARED
= -shared
94 define C_COMPILER_RULE
95 -include $(call SRC_TO_DEP
,$(1),_x86_32
)
96 $(call SRC_TO_OBJ
,$(1),_x86_32
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
97 $(call LOG
,CC
,$$@
,$(X86_32_CC
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(NACL_CFLAGS
) $(X86_32_CFLAGS
) $(CFLAGS
) $(2))
98 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32
)
100 -include $(call SRC_TO_DEP
,$(1),_x86_64
)
101 $(call SRC_TO_OBJ
,$(1),_x86_64
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
102 $(call LOG
,CC
,$$@
,$(X86_64_CC
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(NACL_CFLAGS
) $(X86_64_CFLAGS
) $(CFLAGS
) $(2))
103 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64
)
105 -include $(call SRC_TO_DEP
,$(1),_arm
)
106 $(call SRC_TO_OBJ
,$(1),_arm
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
107 $(call LOG
,CC
,$$@
,$(ARM_CC
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(NACL_CFLAGS
) $(ARM_CFLAGS
) $(CFLAGS
) $(2))
108 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm
)
110 -include $(call SRC_TO_DEP
,$(1),_x86_32_pic
)
111 $(call SRC_TO_OBJ
,$(1),_x86_32_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
112 $(call LOG
,CC
,$$@
,$(X86_32_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(NACL_CFLAGS
) $(X86_32_CFLAGS
) $(CFLAGS
) $(2))
113 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32_pic
)
115 -include $(call SRC_TO_DEP
,$(1),_x86_64_pic
)
116 $(call SRC_TO_OBJ
,$(1),_x86_64_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
117 $(call LOG
,CC
,$$@
,$(X86_64_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(NACL_CFLAGS
) $(X86_64_CFLAGS
) $(CFLAGS
) $(2))
118 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64_pic
)
120 -include $(call SRC_TO_DEP
,$(1),_arm_pic
)
121 $(call SRC_TO_OBJ
,$(1),_arm_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
122 $(call LOG
,CC
,$$@
,$(ARM_CC
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(NACL_CFLAGS
) $(ARM_CFLAGS
) $(CFLAGS
) $(2))
123 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm_pic
)
126 define CXX_COMPILER_RULE
127 -include $(call SRC_TO_DEP
,$(1),_x86_32
)
128 $(call SRC_TO_OBJ
,$(1),_x86_32
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
129 $(call LOG
,CXX
,$$@
,$(X86_32_CXX
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(NACL_CXXFLAGS
) $(X86_32_CXXFLAGS
) $(CXXFLAGS
) $(2))
130 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32
)
132 -include $(call SRC_TO_DEP
,$(1),_x86_64
)
133 $(call SRC_TO_OBJ
,$(1),_x86_64
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
134 $(call LOG
,CXX
,$$@
,$(X86_64_CXX
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(NACL_CXXFLAGS
) $(X86_64_CXXFLAGS
) $(CXXFLAGS
) $(2))
135 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64
)
137 -include $(call SRC_TO_DEP
,$(1),_arm
)
138 $(call SRC_TO_OBJ
,$(1),_arm
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
139 $(call LOG
,CXX
,$$@
,$(ARM_CXX
) -o
$$@
-c
$$< $(POSIX_CFLAGS
) $(NACL_CXXFLAGS
) $(ARM_CXXFLAGS
) $(CXXFLAGS
) $(2))
140 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm
)
142 -include $(call SRC_TO_DEP
,$(1),_x86_32_pic
)
143 $(call SRC_TO_OBJ
,$(1),_x86_32_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
144 $(call LOG
,CXX
,$$@
,$(X86_32_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(NACL_CXXFLAGS
) $(X86_32_CXXFLAGS
) $(CXXFLAGS
) $(2))
145 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_32_pic
)
147 -include $(call SRC_TO_DEP
,$(1),_x86_64_pic
)
148 $(call SRC_TO_OBJ
,$(1),_x86_64_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
149 $(call LOG
,CXX
,$$@
,$(X86_64_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(NACL_CXXFLAGS
) $(X86_64_CXXFLAGS
) $(CXXFLAGS
) $(2))
150 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_x86_64_pic
)
152 -include $(call SRC_TO_DEP
,$(1),_arm_pic
)
153 $(call SRC_TO_OBJ
,$(1),_arm_pic
): $(1) $(TOP_MAKE
) |
$(dir $(call SRC_TO_OBJ
,$(1)))dir.stamp
154 $(call LOG
,CXX
,$$@
,$(ARM_CXX
) -o
$$@
-c
$$< -fPIC
$(POSIX_CFLAGS
) $(NACL_CXXFLAGS
) $(ARM_CXXFLAGS
) $(CXXFLAGS
) $(2))
155 @
$(FIXDEPS
) $(call SRC_TO_DEP_PRE_FIXUP
,$(1),_arm_pic
)
161 # $2 = POSIX compiler flags
162 # $3 = Include directories
163 # $4 = VC flags (unused)
166 ifeq ($(suffix $(1)),.c
)
167 $(call C_COMPILER_RULE
,$(1),$(2) $(foreach inc
,$(INC_PATHS
),-I
$(inc
)) $(3))
169 $(call CXX_COMPILER_RULE
,$(1),$(2) $(foreach inc
,$(INC_PATHS
),-I
$(inc
)) $(3))
174 # Determine which architectures to build for. The user can set NACL_ARCH or
175 # ARCHES in the environment to control this.
177 ifneq ($(TOOLCHAIN
),bionic
)
178 VALID_ARCHES
:= x86_32 x86_64
183 ifeq (,$(findstring $(NACL_ARCH
),$(VALID_ARCHES
)))
184 $(error Invalid arch specified in NACL_ARCH
: $(NACL_ARCH
). Valid values are
: $(VALID_ARCHES
))
186 ARCHES
= ${NACL_ARCH}
188 ARCHES ?
= ${VALID_ARCHES}
196 # As well as building and installing a shared library this rule adds dependencies
197 # on the library's .stamp file in STAMPDIR. However, the rule for creating the stamp
198 # file is part of LIB_RULE, so users of the DEPS system are currently required to
199 # use the LIB_RULE macro as well as the SO_RULE for each shared library.
202 # $2 = List of source files
206 # $6 = 1 => Don't add to NMF.
208 define SO_LINKER_RULE
209 ifneq (,$(findstring x86_32
,$(ARCHES
)))
210 all: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
211 $(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
)
212 $(MKDIR
) -p
$$(dir $$@
)
213 $(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_DIR
) -L
$(path
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)))
214 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
216 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG_DIR
)/lib
$(1).so
217 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG_DIR
)/lib
$(1).so
218 $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG_DIR
)/lib
$(1).so
: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
219 $(MKDIR
) -p
$$(dir $$@
)
220 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
222 GLIBC_SO_LIST
+= $(X86_32_OUTDIR
)/lib
$(1)_x86_32.so
223 GLIBC_REMAP
+= -n lib
$(1)_x86_32.so
,lib
$(1).so
227 ifneq (,$(findstring x86_64
,$(ARCHES
)))
228 all: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
229 $(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
)
230 $(MKDIR
) -p
$$(dir $$@
)
231 $(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_DIR
) -L
$(path
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)))
232 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
234 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG_DIR
)/lib
$(1).so
235 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG_DIR
)/lib
$(1).so
236 $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG_DIR
)/lib
$(1).so
: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
237 $(MKDIR
) -p
$$(dir $$@
)
238 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
240 GLIBC_SO_LIST
+= $(X86_64_OUTDIR
)/lib
$(1)_x86_64.so
241 GLIBC_REMAP
+= -n lib
$(1)_x86_64.so
,lib
$(1).so
245 ifneq (,$(findstring arm
,$(ARCHES
)))
246 all: $(ARM_OUTDIR
)/lib
$(1)_arm.so
247 $(ARM_OUTDIR
)/lib
$(1)_arm.so
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm_pic
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
248 $(MKDIR
) -p
$$(dir $$@
)
249 $(call LOG
,LINK
,$$@
,$(ARM_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(LDFLAGS_SHARED
) -marm
$(NACL_LDFLAGS
) $(ARM_LDFLAGS
) $(LDFLAGS
) $(foreach path
,$(5),-L
$(path
)/$(TOOLCHAIN
)_arm
/$(CONFIG_DIR
) -L
$(path
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)))
250 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
252 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG_DIR
)/lib
$(1).so
253 install: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG_DIR
)/lib
$(1).so
254 $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG_DIR
)/lib
$(1).so
: $(ARM_OUTDIR
)/lib
$(1)_arm.so
255 $(MKDIR
) -p
$$(dir $$@
)
256 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
258 GLIBC_SO_LIST
+= $(ARM_OUTDIR
)/lib
$(1)_arm.so
259 GLIBC_REMAP
+= -n lib
$(1)_arm.so
,lib
$(1).so
266 # $2 = List of source files
269 # $5 = 1 => Don't add to NMF.
272 $(call SO_LINKER_RULE
,$(1),$(2),$(filter-out pthread
,$(3)),$(4),$(LIB_PATHS
),$(5))
279 # $2 = List of source files
280 # $3 = POSIX linker flags
281 # $4 = VC linkr flags (unused)
284 $(STAMPDIR
)/$(1).stamp
:
286 @echo
"TOUCHED $$@" > $(STAMPDIR
)/$(1).stamp
288 ifneq (,$(findstring x86_32
,$(ARCHES
)))
289 all: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
290 $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_32
))
291 $(MKDIR
) -p
$$(dir $$@
)
293 $(call LOG
,LIB
,$$@
,$(X86_32_LIB
) -cr
$$@
$$^
)
295 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG_DIR
)/lib
$(1).a
296 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG_DIR
)/lib
$(1).a
297 $(LIBDIR
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG_DIR
)/lib
$(1).a
: $(X86_32_OUTDIR
)/lib
$(1)_x86_32.a
298 $(MKDIR
) -p
$$(dir $$@
)
300 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
303 ifneq (,$(findstring x86_64
,$(ARCHES
)))
304 all: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
305 $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_64
))
306 $(MKDIR
) -p
$$(dir $$@
)
308 $(call LOG
,LIB
,$$@
,$(X86_64_LIB
) -cr
$$@
$$^
)
310 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG_DIR
)/lib
$(1).a
311 install: $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG_DIR
)/lib
$(1).a
312 $(LIBDIR
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG_DIR
)/lib
$(1).a
: $(X86_64_OUTDIR
)/lib
$(1)_x86_64.a
313 $(MKDIR
) -p
$$(dir $$@
)
314 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
317 ifneq (,$(findstring arm
,$(ARCHES
)))
318 all: $(ARM_OUTDIR
)/lib
$(1)_arm.a
319 $(ARM_OUTDIR
)/lib
$(1)_arm.a
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm
))
320 $(MKDIR
) -p
$$(dir $$@
)
322 $(call LOG
,LIB
,$$@
,$(ARM_LIB
) -cr
$$@
$$^
)
324 $(STAMPDIR
)/$(1).stamp
: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG_DIR
)/lib
$(1).a
325 install: $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG_DIR
)/lib
$(1).a
326 $(LIBDIR
)/$(TOOLCHAIN
)_arm
/$(CONFIG_DIR
)/lib
$(1).a
: $(ARM_OUTDIR
)/lib
$(1)_arm.a
327 $(MKDIR
) -p
$$(dir $$@
)
328 $(call LOG
,CP
,$$@
,$(OSHELPERS
) cp
$$^
$$@
)
334 # Specific Link Macro
337 # $2 = List of source files
344 ifneq (,$(findstring x86_32
,$(ARCHES
)))
345 all: $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
346 $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_32
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
347 $(MKDIR
) -p
$$(dir $$@
)
348 $(call LOG
,LINK
,$$@
,$(X86_32_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(NACL_LDFLAGS
) $(X86_32_LDFLAGS
) $(LDFLAGS
) $(foreach path
,$(6),-L
$(path
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG_DIR
) -L
$(path
)/$(TOOLCHAIN
)_x86_32
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)) $(5))
349 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
352 ifneq (,$(findstring x86_64
,$(ARCHES
)))
353 all: $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
354 $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_x86_64
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
355 $(MKDIR
) -p
$$(dir $$@
)
356 $(call LOG
,LINK
,$$@
,$(X86_64_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(NACL_LDFLAGS
) $(X86_64_LDFLAGS
) $(LDFLAGS
) $(foreach path
,$(6),-L
$(path
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG_DIR
) -L
$(path
)/$(TOOLCHAIN
)_x86_64
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)) $(5))
357 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
360 ifneq (,$(findstring arm
,$(ARCHES
)))
361 all: $(ARM_OUTDIR
)/$(1)_arm.nexe
362 $(ARM_OUTDIR
)/$(1)_arm.nexe
: $(foreach src
,$(2),$(call SRC_TO_OBJ
,$(src
),_arm
)) $(foreach dep
,$(4),$(STAMPDIR
)/$(dep
).stamp
)
363 $(MKDIR
) -p
$$(dir $$@
)
364 $(call LOG
,LINK
,$$@
,$(ARM_LINK
) $(BIONIC_LINK
) -o
$$@
$$(filter %.o
,$$^
) $(NACL_LDFLAGS
) $(ARM_LDFLAGS
) $(LDFLAGS
) $(foreach path
,$(6),-L
$(path
)/$(TOOLCHAIN
)_arm
/$(CONFIG_DIR
) -L
$(path
)/$(TOOLCHAIN
)_arm
/$(CONFIG
)) $(foreach lib
,$(3),-l
$(lib
)) $(5))
365 $(call LOG
,VALIDATE
,$$@
,$(NCVAL
) $$@
)
371 # Generalized Link Macro
374 # $2 = List of source files
377 # $5 = POSIX linker flags
378 # $6 = VC linker flags
381 $(call LINKER_RULE
,$(1),$(2),$(filter-out pthread
,$(3)),$(4),$(5),$(LIB_PATHS
))
386 # Strip Macro for each arch (e.g., each arch supported by LINKER_RULE).
391 define STRIP_ALL_RULE
392 ifneq (,$(findstring x86_32
,$(ARCHES
)))
393 $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
: $(X86_32_OUTDIR
)/$(2)_x86_32.nexe
394 $(call LOG
,STRIP
,$$@
,$(X86_32_STRIP
) -o
$$@
$$^
)
397 ifneq (,$(findstring x86_64
,$(ARCHES
)))
398 $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
: $(X86_64_OUTDIR
)/$(2)_x86_64.nexe
399 $(call LOG
,STRIP
,$$@
,$(X86_64_STRIP
) -o
$$@
$$^
)
402 ifneq (,$(findstring arm
,$(ARCHES
)))
403 $(ARM_OUTDIR
)/$(1)_arm.nexe
: $(ARM_OUTDIR
)/$(2)_arm.nexe
404 $(call LOG
,STRIP
,$$@
,$(ARM_STRIP
) -o
$$@
$$^
)
410 # Top-level Strip Macro
412 # $1 = Target Basename
413 # $2 = Source Basename
416 $(call STRIP_ALL_RULE
,$(1),$(2))
421 # Strip Macro for each arch (e.g., each arch supported by MAP_RULE).
427 ifneq (,$(findstring x86_32
,$(ARCHES
)))
428 all: $(X86_32_OUTDIR
)/$(1)_x86_32.map
429 $(X86_32_OUTDIR
)/$(1)_x86_32.map
: $(X86_32_OUTDIR
)/$(2)_x86_32.nexe
430 $(call LOG
,MAP
,$$@
,$(X86_32_NM
) -l
$$^
> $$@
)
433 ifneq (,$(findstring x86_64
,$(ARCHES
)))
434 all: $(X86_64_OUTDIR
)/$(1)_x86_64.map
435 $(X86_64_OUTDIR
)/$(1)_x86_64.map
: $(X86_64_OUTDIR
)/$(2)_x86_64.nexe
436 $(call LOG
,MAP
,$$@
,$(X86_64_NM
) -l
$$^
> $$@
)
439 ifneq (,$(findstring arm
,$(ARCHES
)))
440 all: $(ARM_OUTDIR
)/$(1)_arm.map
441 $(ARM_OUTDIR
)/$(1)_arm.map
: $(ARM_OUTDIR
)/$(2)_arm.nexe
442 $(call LOG
,MAP
,$$@
,$(ARM_NM
) -l
$$^
> $$@
)
448 # Top-level MAP Generation Macro
450 # $1 = Target Basename
451 # $2 = Source Basename
454 $(call MAP_ALL_RULE
,$(1),$(2))
459 # NMF Manifiest generation
461 # Use the python script create_nmf to scan the binaries for dependencies using
462 # objdump. Pass in the (-L) paths to the default library toolchains so that we
463 # can find those libraries and have it automatically copy the files (-s) to
464 # the target directory for us.
466 # $1 = Target Name (the basename of the nmf
467 # $2 = Additional create_nmf.py arguments
469 NMF
:= python
$(NACL_SDK_ROOT
)/tools
/create_nmf.py
470 NMF_FLAGS
+= --config
=$(CONFIG_DIR
)
471 SEL_LDR_ARGS
+= --config
=$(CONFIG_DIR
)
473 EXECUTABLES
= $(GLIBC_SO_LIST
)
474 ifneq (,$(findstring x86_32
,$(ARCHES
)))
475 EXECUTABLES
+= $(X86_32_OUTDIR
)/$(1)_x86_32.nexe
477 ifneq (,$(findstring x86_64
,$(ARCHES
)))
478 EXECUTABLES
+= $(X86_64_OUTDIR
)/$(1)_x86_64.nexe
480 ifneq (,$(findstring arm
,$(ARCHES
)))
481 EXECUTABLES
+= $(ARM_OUTDIR
)/$(1)_arm.nexe
484 ifneq (,$(MULTI_PLATFORM
))
485 # When building a multi-platform package, stage all dependent shared libraries
486 # in the same directory as the .nexe (which will be an architecture-specific
487 # directory under _platform_specific).
488 NMF_FLAGS
+= -s
$(OUTDIR
) --no-arch-prefix
490 # Otherwise stage dependent libraries the normal way, under lib32 for x86_32
491 # libraries, and lib64 for x86_64 libraries.
492 NMF_FLAGS
+= -s
$(OUTDIR
)
495 ifneq (,$(MULTI_PLATFORM
))
496 # This script fixes the manifest.json file for this App to point to:
498 # <toolchain>/<config>/_platform_specific/<arch>/
502 # _platform_specific/<arch>
503 FIX_MANIFEST
:= python
$(NACL_SDK_ROOT
)/tools
/fix_manifest.py
504 MANIFEST_JSON ?
= manifest.json
508 all: $(OUTDIR
)/$(1).nmf
509 $(OUTDIR
)/$(1).nmf
$(MANIFEST_JSON
): $(EXECUTABLES
)
510 $(call LOG
,CREATE_NMF
,$$@
,$(NMF
) $(NMF_FLAGS
) -o
$$@
$$^
$(GLIBC_PATHS
) $(2) $(GLIBC_REMAP
))
511 ifneq (,$(MULTI_PLATFORM
))
512 $(call LOG
,FIX_MANIFEST
,$(MANIFEST_JSON
),$(FIX_MANIFEST
) $(MANIFEST_JSON
)) -p
"$(TOOLCHAIN)/$(CONFIG)"
517 # HTML file generation
519 CREATE_HTML
:= python
$(NACL_SDK_ROOT
)/tools
/create_html.py
522 all: $(OUTDIR
)/$(1).html
523 $(OUTDIR
)/$(1).html
: $(EXECUTABLES
)
524 $(call LOG
,CREATE_HTML
,$$@
,$(CREATE_HTML
) $(HTML_FLAGS
) -o
$$@
$$^
)
529 # Determine which executable to pass into the debugger. For newlib
530 # this is the NEXE which will actually be used. For glibc, runnable-ld.so
531 # is the "app", and the "app" is actual an .so we load.
533 ifeq (x86_32
,$(SYSARCH
))
535 ifeq (x86_64
,$(SYSARCH
))
543 ifeq (newlib
,$(TOOLCHAIN
))
544 GDB_DEBUG_TARGET
= $(abspath
$(OUTDIR
))/$(TARGET
)_
$(SYSARCH
).nexe
546 GDB_DEBUG_TARGET
= $(abspath
$(OUTDIR
))/$(LIB_NAME
)/runnable-ld.so
552 $(error Cannot run in sel_ldr unless
$$NACL_ARCH is set
)
554 $(SEL_LDR_PATH
) $(SEL_LDR_ARGS
) $(OUTDIR
)/$(TARGET
)_
$(NACL_ARCH
).nexe
-- $(EXE_ARGS
)
558 $(error Cannot run in sel_ldr unless
$$NACL_ARCH is set
)
560 $(SEL_LDR_PATH
) -d
$(SEL_LDR_ARGS
) $(OUTDIR
)/$(TARGET
)_
$(NACL_ARCH
).nexe
-- $(EXE_ARGS
)