blob: 361fe2ea8f8640c9f2def19acd0a2db7591d63ab [file] [log] [blame]
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -08001#
2# Copyright (C) 2006 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090017# Configuration for Linux on SuperH.
18# Included by combo/select.make
19
20# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080021ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
22TARGET_TOOLS_PREFIX := \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090023 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/sh-4.3.3/bin/sh-linux-gnu-
24endif
25
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080026TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
27TARGET_CXX := $(TARGET_TOOLS_PREFIX)c++$(HOST_EXECUTABLE_SUFFIX)
28TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
29TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
30TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090031
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080032TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090033
34TARGET_sh_release_CFLAGS := -O2 \
35 -fomit-frame-pointer \
36 -fstrict-aliasing \
37 -funswitch-loops \
38 -finline-limit=300
39
40# When building for debug, compile everything as superh.
41TARGET_sh_debug_CFLAGS := $(TARGET_sh_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing
42
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080043TARGET_GLOBAL_CFLAGS += \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090044 -fpic \
45 -ffunction-sections \
46 -funwind-tables \
47 -fstack-protector \
48 -include $(call select-android-config-h,linux-sh)
49
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080050TARGET_GLOBAL_CPPFLAGS += \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090051 -fno-use-cxa-atexit \
52 -fvisibility-inlines-hidden
53
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080054TARGET_RELEASE_CFLAGS := \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090055 -DSK_RELEASE -DNDEBUG \
56 -O2 -g \
57 -Wstrict-aliasing=2 \
58 -finline-functions \
59 -fno-inline-functions-called-once \
60 -fgcse-after-reload \
61 -frerun-cse-after-loop \
62 -frename-registers \
63 -fno-builtin
64
65libc_root := bionic/libc
66libm_root := bionic/libm
67libstdc++_root := bionic/libstdc++
68libthread_db_root := bionic/libthread_db
69
70
71## on some hosts, the target cross-compiler is not available so do not run this command
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080072ifneq ($(wildcard $(TARGET_CC)),)
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090073# We compile with the global cflags to ensure that
74# any flags which affect libgcc are correctly taken
75# into account.
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080076LIBGCC_FILENAME := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090077LIBGCC_EH_FILENAME := $(subst libgcc,libgcc_eh,$(LIBGCC_FILENAME))
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080078TARGET_LIBGCC := $(LIBGCC_EH_FILENAME) $(LIBGCC_FILENAME)
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090079endif
80
81# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
82# symlinks located in out/ to point to the appropriate kernel
83# headers. see 'config/kernel_headers.make' for more details
84#
85ifneq ($(CUSTOM_KERNEL_HEADERS),)
86 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
87 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
88else
89 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
90 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
91endif
92KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
93
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080094TARGET_C_INCLUDES := \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090095 $(libc_root)/arch-sh/include \
96 $(libc_root)/include \
97 $(libstdc++_root)/include \
98 $(KERNEL_HEADERS) \
99 $(libm_root)/include \
100 $(libm_root)/include/arch/sh \
101 $(libthread_db_root)/include
102
103TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
104TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
105TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
106TARGET_SOBEGIN := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o
107TARGET_SOEND := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o
108
109TARGET_STRIP_MODULE:=false
110
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800111TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +0900112
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800113TARGET_CUSTOM_LD_COMMAND := true
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +0900114define transform-o-to-shared-lib-inner
115$(TARGET_CXX) \
116 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/shlelf.xsc \
117 -Wl,--gc-sections -Wl,-z,norelro \
118 -Wl,-shared,-Bsymbolic \
119 $(TARGET_GLOBAL_LD_DIRS) \
120 $(TARGET_SOBEGIN) \
121 $(PRIVATE_ALL_OBJECTS) \
122 -Wl,--whole-archive \
123 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
124 -Wl,--no-whole-archive \
125 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
126 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
127 -o $@ \
128 $(PRIVATE_LDFLAGS) \
129 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
130 $(TARGET_LIBGCC) \
131 $(TARGET_SOEND)
132endef
133
134define transform-o-to-executable-inner
135$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
136 -Wl,-dynamic-linker,/system/bin/linker \
137 -Wl,--gc-sections -Wl,-z,norelro \
138 -Wl,-z,nocopyreloc \
139 -o $@ \
140 $(TARGET_GLOBAL_LD_DIRS) \
141 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
142 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
143 $(TARGET_CRTBEGIN_DYNAMIC_O) \
144 $(PRIVATE_ALL_OBJECTS) \
145 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
146 $(PRIVATE_LDFLAGS) \
147 $(TARGET_LIBGCC) \
148 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
149 $(TARGET_CRTEND_O)
150endef
151
152define transform-o-to-static-executable-inner
153$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
154 -Wl,--gc-sections -Wl,-z,norelro \
155 -o $@ \
156 $(TARGET_GLOBAL_LD_DIRS) \
157 $(TARGET_CRTBEGIN_STATIC_O) \
158 $(PRIVATE_LDFLAGS) \
159 $(PRIVATE_ALL_OBJECTS) \
160 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
161 $(TARGET_LIBGCC) \
162 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
163 $(TARGET_CRTEND_O)
164endef