• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2009 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16# this file is used to prepare the NDK to build with the arm-eabi-4.2.1
17# toolchain any number of source files
18#
19# its purpose is to define (or re-define) templates used to build
20# various sources into target object files, libraries or executables.
21#
22# Note that this file may end up being parsed several times in future
23# revisions of the NDK.
24#
25
26TOOLCHAIN_NAME   := arm-eabi-4.2.1
27TOOLCHAIN_PREFIX := $(HOST_PREBUILT)/$(TOOLCHAIN_NAME)/bin/arm-eabi-
28
29TARGET_CFLAGS.common := \
30    -I$(SYSROOT)/usr/include \
31    -march=armv5te -mtune=xscale \
32    -msoft-float -fpic \
33    -mthumb-interwork \
34    -ffunction-sections \
35    -funwind-tables \
36    -fstack-protector \
37    -fno-short-enums \
38    -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
39    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
40
41
42TARGET_arm_release_CFLAGS :=  -O2 \
43                              -fomit-frame-pointer \
44                              -fstrict-aliasing    \
45                              -funswitch-loops     \
46                              -finline-limit=300
47
48TARGET_thumb_release_CFLAGS := -mthumb \
49                               -Os \
50                               -fomit-frame-pointer \
51                               -fno-strict-aliasing \
52                               -finline-limit=64
53
54# When building for debug, compile everything as arm.
55TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
56                           -fno-omit-frame-pointer \
57                           -fno-strict-aliasing
58
59TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
60                             -marm \
61                             -fno-omit-frame-pointer
62
63TARGET_CC       := $(TOOLCHAIN_PREFIX)gcc
64TARGET_CFLAGS   := $(TARGET_CFLAGS.common)
65
66
67TARGET_CXX      := $(TOOLCHAIN_PREFIX)g++
68TARGET_CXXFLAGS := $(TARGET_CFLAGS.common) -fno-exceptions -fno-rtti
69
70TARGET_LD      := $(TOOLCHAIN_PREFIX)ld
71TARGET_LDFLAGS :=
72
73TARGET_AR      := $(TOOLCHAIN_PREFIX)ar
74TARGET_ARFLAGS := crs
75
76TARGET_LIBGCC := $(shell $(TARGET_CC) -mthumb-interwork -print-libgcc-file-name)
77TARGET_LDLIBS := -Wl,-rpath-link=$(SYSROOT)/usr/lib
78
79# These flags are used to ensure that a binary doesn't reference undefined
80# flags.
81TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
82
83# The ABI-specific sub-directory that the SDK tools recognize for
84# this toolchain's generated binaries
85TARGET_ABI_SUBDIR := armeabi
86
87# NOTE: Ensure that TARGET_LIBGCC is placed after all private objects
88#       and static libraries, but before any other library in the link
89#       command line when generating shared libraries and executables.
90#
91#       This ensures that all libgcc.a functions required by the target
92#       will be included into it, instead of relying on what's available
93#       on other libraries like libc.so, which may change between system
94#       releases due to toolchain or library changes.
95#
96define cmd-build-shared-library
97$(TARGET_CC) \
98    -nostdlib -Wl,-soname,$(notdir $@) \
99    -Wl,-shared,-Bsymbolic \
100    $(PRIVATE_OBJECTS) \
101    -Wl,--whole-archive \
102    $(PRIVATE_WHOLE_STATIC_LIBRARIES) \
103    -Wl,--no-whole-archive \
104    $(PRIVATE_STATIC_LIBRARIES) \
105    $(TARGET_LIBGCC) \
106    $(PRIVATE_SHARED_LIBRARIES) \
107    $(PRIVATE_LDFLAGS) \
108    $(PRIVATE_LDLIBS) \
109    -o $@
110endef
111
112define cmd-build-executable
113$(TARGET_CC) \
114    -nostdlib -Bdynamic \
115    -Wl,-dynamic-linker,/system/bin/linker \
116    -Wl,--gc-sections \
117    -Wl,-z,nocopyreloc \
118    $(TARGET_CRTBEGIN_DYNAMIC_O) \
119    $(PRIVATE_OBJECTS) \
120    $(PRIVATE_STATIC_LIBRARIES) \
121    $(TARGET_LIBGCC) \
122    $(PRIVATE_SHARED_LIBRARIES) \
123    $(PRIVATE_LDFLAGS) \
124    $(PRIVATE_LDLIBS) \
125    $(TARGET_CRTEND_O) \
126    -o $@
127endef
128
129define cmd-build-static-library
130$(TARGET_AR) $(TARGET_ARFLAGS) $@ $(PRIVATE_OBJECTS)
131endef
132
133cmd-strip = $(TOOLCHAIN_PREFIX)strip --strip-debug $1
134