• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
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
17# 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
21ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
22TARGET_TOOLS_PREFIX := \
23	prebuilt/$(HOST_PREBUILT_TAG)/toolchain/sh-4.3.3/bin/sh-linux-gnu-
24endif
25
26TARGET_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)
31TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
32
33ifeq ($(TARGET_BUILD_VARIANT),user)
34TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
35else
36TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ && \
37	$(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@
38endif
39
40TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
41
42TARGET_sh_release_CFLAGS :=     -O2 \
43                                -fomit-frame-pointer \
44                                -fstrict-aliasing    \
45                                -funswitch-loops     \
46                                -finline-limit=300
47
48# When building for debug, compile everything as superh.
49TARGET_sh_debug_CFLAGS := $(TARGET_sh_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing
50
51TARGET_GLOBAL_CFLAGS += \
52			-fpic \
53			-ffunction-sections \
54			-funwind-tables \
55			-fstack-protector \
56			-include $(call select-android-config-h,linux-sh)
57
58TARGET_GLOBAL_CPPFLAGS += \
59			-fno-use-cxa-atexit \
60			-fvisibility-inlines-hidden
61
62TARGET_RELEASE_CFLAGS := \
63			-DSK_RELEASE -DNDEBUG \
64			-O2 -g \
65			-Wstrict-aliasing=2 \
66			-finline-functions \
67			-fno-inline-functions-called-once \
68			-fgcse-after-reload \
69			-frerun-cse-after-loop \
70			-frename-registers \
71			-fno-builtin
72
73libc_root := bionic/libc
74libm_root := bionic/libm
75libstdc++_root := bionic/libstdc++
76libthread_db_root := bionic/libthread_db
77
78
79## on some hosts, the target cross-compiler is not available so do not run this command
80ifneq ($(wildcard $(TARGET_CC)),)
81# We compile with the global cflags to ensure that
82# any flags which affect libgcc are correctly taken
83# into account.
84LIBGCC_FILENAME := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
85LIBGCC_EH_FILENAME := $(subst libgcc,libgcc_eh,$(LIBGCC_FILENAME))
86TARGET_LIBGCC := $(LIBGCC_EH_FILENAME) $(LIBGCC_FILENAME)
87endif
88
89# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
90# symlinks located in out/ to point to the appropriate kernel
91# headers. see 'config/kernel_headers.make' for more details
92#
93ifneq ($(CUSTOM_KERNEL_HEADERS),)
94    KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
95    KERNEL_HEADERS_ARCH   := $(CUSTOM_KERNEL_HEADERS)
96else
97    KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
98    KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/arch-$(TARGET_ARCH)
99endif
100KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
101
102TARGET_C_INCLUDES := \
103	$(libc_root)/arch-sh/include \
104	$(libc_root)/include \
105	$(libstdc++_root)/include \
106	$(KERNEL_HEADERS) \
107	$(libm_root)/include \
108	$(libm_root)/include/sh \
109	$(libthread_db_root)/include
110
111TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
112TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
113TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
114
115TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o
116TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o
117
118TARGET_STRIP_MODULE:=true
119
120TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
121
122TARGET_CUSTOM_LD_COMMAND := true
123define transform-o-to-shared-lib-inner
124$(hide) $(PRIVATE_CXX) \
125	-nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/shlelf.xsc \
126	-Wl,--gc-sections -Wl,-z,norelro \
127	-Wl,-shared,-Bsymbolic \
128	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
129	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
130	$(PRIVATE_ALL_OBJECTS) \
131	-Wl,--whole-archive \
132	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
133	-Wl,--no-whole-archive \
134	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
135	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
136	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
137	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
138	-o $@ \
139	$(PRIVATE_LDFLAGS) \
140	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
141	$(PRIVATE_TARGET_LIBGCC) \
142	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
143endef
144
145define transform-o-to-executable-inner
146$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
147	-Wl,-dynamic-linker,/system/bin/linker \
148	-Wl,--gc-sections -Wl,-z,norelro \
149	-Wl,-z,nocopyreloc \
150	-o $@ \
151	$(TARGET_GLOBAL_LD_DIRS) \
152	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
153	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
154	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
155	$(PRIVATE_ALL_OBJECTS) \
156	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
157	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
158	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
159	$(PRIVATE_LDFLAGS) \
160	$(TARGET_LIBGCC) \
161	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
162	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
163endef
164
165define transform-o-to-static-executable-inner
166$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
167	-Wl,--gc-sections -Wl,-z,norelro \
168	-o $@ \
169	$(TARGET_GLOBAL_LD_DIRS) \
170	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
171	$(PRIVATE_LDFLAGS) \
172	$(PRIVATE_ALL_OBJECTS) \
173	-Wl,--start-group \
174	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
175	-Wl,--end-group \
176	$(TARGET_LIBGCC) \
177	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
178	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
179endef
180