blob: cf945fec6a375e383ca94023808fce879a08047d [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)
Bruce Beare45ac4342010-06-24 14:02:00 -070031TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
32TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090033
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080034TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090035
36TARGET_sh_release_CFLAGS := -O2 \
37 -fomit-frame-pointer \
38 -fstrict-aliasing \
39 -funswitch-loops \
40 -finline-limit=300
41
42# When building for debug, compile everything as superh.
43TARGET_sh_debug_CFLAGS := $(TARGET_sh_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing
44
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080045TARGET_GLOBAL_CFLAGS += \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090046 -fpic \
47 -ffunction-sections \
48 -funwind-tables \
49 -fstack-protector \
50 -include $(call select-android-config-h,linux-sh)
51
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080052TARGET_GLOBAL_CPPFLAGS += \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090053 -fno-use-cxa-atexit \
54 -fvisibility-inlines-hidden
55
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080056TARGET_RELEASE_CFLAGS := \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090057 -DSK_RELEASE -DNDEBUG \
58 -O2 -g \
59 -Wstrict-aliasing=2 \
60 -finline-functions \
61 -fno-inline-functions-called-once \
62 -fgcse-after-reload \
63 -frerun-cse-after-loop \
64 -frename-registers \
65 -fno-builtin
66
67libc_root := bionic/libc
68libm_root := bionic/libm
69libstdc++_root := bionic/libstdc++
70libthread_db_root := bionic/libthread_db
71
72
73## on some hosts, the target cross-compiler is not available so do not run this command
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080074ifneq ($(wildcard $(TARGET_CC)),)
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090075# We compile with the global cflags to ensure that
76# any flags which affect libgcc are correctly taken
77# into account.
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080078LIBGCC_FILENAME := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090079LIBGCC_EH_FILENAME := $(subst libgcc,libgcc_eh,$(LIBGCC_FILENAME))
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080080TARGET_LIBGCC := $(LIBGCC_EH_FILENAME) $(LIBGCC_FILENAME)
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090081endif
82
83# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
84# symlinks located in out/ to point to the appropriate kernel
85# headers. see 'config/kernel_headers.make' for more details
86#
87ifneq ($(CUSTOM_KERNEL_HEADERS),)
88 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
89 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
90else
91 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
92 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
93endif
94KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
95
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080096TARGET_C_INCLUDES := \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +090097 $(libc_root)/arch-sh/include \
98 $(libc_root)/include \
99 $(libstdc++_root)/include \
100 $(KERNEL_HEADERS) \
101 $(libm_root)/include \
102 $(libm_root)/include/arch/sh \
103 $(libthread_db_root)/include
104
105TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
106TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
107TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
Ying Wangb6a1c182010-07-13 17:41:14 -0700108TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o
109TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +0900110
Bruce Beare45ac4342010-06-24 14:02:00 -0700111TARGET_STRIP_MODULE:=true
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +0900112
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800113TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +0900114
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800115TARGET_CUSTOM_LD_COMMAND := true
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +0900116define transform-o-to-shared-lib-inner
117$(TARGET_CXX) \
118 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/shlelf.xsc \
119 -Wl,--gc-sections -Wl,-z,norelro \
120 -Wl,-shared,-Bsymbolic \
Ying Wang1a081002010-07-13 14:55:47 -0700121 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
Ying Wangb6a1c182010-07-13 17:41:14 -0700122 $(PRIVATE_TARGET_CRTBEGIN_SO_O) \
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +0900123 $(PRIVATE_ALL_OBJECTS) \
124 -Wl,--whole-archive \
125 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
126 -Wl,--no-whole-archive \
127 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
128 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
129 -o $@ \
130 $(PRIVATE_LDFLAGS) \
131 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
Ying Wang1a081002010-07-13 14:55:47 -0700132 $(PRIVATE_TARGET_LIBGCC) \
Ying Wangb6a1c182010-07-13 17:41:14 -0700133 $(PRIVATE_TARGET_CRTEND_SO_O)
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +0900134endef
135
136define transform-o-to-executable-inner
137$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
138 -Wl,-dynamic-linker,/system/bin/linker \
139 -Wl,--gc-sections -Wl,-z,norelro \
140 -Wl,-z,nocopyreloc \
141 -o $@ \
142 $(TARGET_GLOBAL_LD_DIRS) \
143 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
144 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
145 $(TARGET_CRTBEGIN_DYNAMIC_O) \
146 $(PRIVATE_ALL_OBJECTS) \
147 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
148 $(PRIVATE_LDFLAGS) \
149 $(TARGET_LIBGCC) \
150 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
151 $(TARGET_CRTEND_O)
152endef
153
154define transform-o-to-static-executable-inner
155$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
156 -Wl,--gc-sections -Wl,-z,norelro \
157 -o $@ \
158 $(TARGET_GLOBAL_LD_DIRS) \
159 $(TARGET_CRTBEGIN_STATIC_O) \
160 $(PRIVATE_LDFLAGS) \
161 $(PRIVATE_ALL_OBJECTS) \
162 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
163 $(TARGET_LIBGCC) \
164 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
165 $(TARGET_CRTEND_O)
166endef