Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 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 | |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 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 |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 21 | ifeq ($(strip $(TARGET_TOOLS_PREFIX)),) |
| 22 | TARGET_TOOLS_PREFIX := \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 23 | prebuilt/$(HOST_PREBUILT_TAG)/toolchain/sh-4.3.3/bin/sh-linux-gnu- |
| 24 | endif |
| 25 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 26 | TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) |
| 27 | TARGET_CXX := $(TARGET_TOOLS_PREFIX)c++$(HOST_EXECUTABLE_SUFFIX) |
| 28 | TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) |
| 29 | TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX) |
| 30 | TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX) |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 31 | TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX) |
Evgeniy Stepanov | 8f77c9d | 2011-06-21 17:08:49 +0400 | [diff] [blame] | 32 | |
| 33 | ifeq ($(TARGET_BUILD_VARIANT),user) |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 34 | TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ |
Evgeniy Stepanov | 8f77c9d | 2011-06-21 17:08:49 +0400 | [diff] [blame] | 35 | else |
| 36 | TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ && \ |
| 37 | $(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@ |
| 38 | endif |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 39 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 40 | TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 41 | |
| 42 | TARGET_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. |
| 49 | TARGET_sh_debug_CFLAGS := $(TARGET_sh_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing |
| 50 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 51 | TARGET_GLOBAL_CFLAGS += \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 52 | -fpic \ |
| 53 | -ffunction-sections \ |
| 54 | -funwind-tables \ |
| 55 | -fstack-protector \ |
| 56 | -include $(call select-android-config-h,linux-sh) |
| 57 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 58 | TARGET_GLOBAL_CPPFLAGS += \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 59 | -fno-use-cxa-atexit \ |
| 60 | -fvisibility-inlines-hidden |
| 61 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 62 | TARGET_RELEASE_CFLAGS := \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 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 | |
| 73 | libc_root := bionic/libc |
| 74 | libm_root := bionic/libm |
| 75 | libstdc++_root := bionic/libstdc++ |
| 76 | libthread_db_root := bionic/libthread_db |
| 77 | |
| 78 | |
| 79 | ## on some hosts, the target cross-compiler is not available so do not run this command |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 80 | ifneq ($(wildcard $(TARGET_CC)),) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 81 | # We compile with the global cflags to ensure that |
| 82 | # any flags which affect libgcc are correctly taken |
| 83 | # into account. |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 84 | LIBGCC_FILENAME := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 85 | LIBGCC_EH_FILENAME := $(subst libgcc,libgcc_eh,$(LIBGCC_FILENAME)) |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 86 | TARGET_LIBGCC := $(LIBGCC_EH_FILENAME) $(LIBGCC_FILENAME) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 87 | endif |
| 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 | # |
| 93 | ifneq ($(CUSTOM_KERNEL_HEADERS),) |
| 94 | KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) |
| 95 | KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) |
| 96 | else |
| 97 | KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common |
| 98 | KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) |
| 99 | endif |
| 100 | KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) |
| 101 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 102 | TARGET_C_INCLUDES := \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 103 | $(libc_root)/arch-sh/include \ |
| 104 | $(libc_root)/include \ |
| 105 | $(libstdc++_root)/include \ |
| 106 | $(KERNEL_HEADERS) \ |
| 107 | $(libm_root)/include \ |
Dima Zavin | 6d98f5f | 2010-08-05 17:46:47 -0700 | [diff] [blame] | 108 | $(libm_root)/include/sh \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 109 | $(libthread_db_root)/include |
| 110 | |
| 111 | TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o |
| 112 | TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o |
| 113 | TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 114 | |
Ying Wang | b6a1c18 | 2010-07-13 17:41:14 -0700 | [diff] [blame] | 115 | TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o |
| 116 | TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 117 | |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 118 | TARGET_STRIP_MODULE:=true |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 119 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 120 | TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 121 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 122 | TARGET_CUSTOM_LD_COMMAND := true |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 123 | define transform-o-to-shared-lib-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 124 | $(hide) $(PRIVATE_CXX) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 125 | -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/shlelf.xsc \ |
| 126 | -Wl,--gc-sections -Wl,-z,norelro \ |
| 127 | -Wl,-shared,-Bsymbolic \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 128 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 129 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 130 | $(PRIVATE_ALL_OBJECTS) \ |
| 131 | -Wl,--whole-archive \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 132 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 133 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 134 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 135 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 136 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 137 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 138 | -o $@ \ |
| 139 | $(PRIVATE_LDFLAGS) \ |
| 140 | $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 141 | $(PRIVATE_TARGET_LIBGCC) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 142 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 143 | endef |
| 144 | |
| 145 | define transform-o-to-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 146 | $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 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)) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 154 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 155 | $(PRIVATE_ALL_OBJECTS) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 156 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 157 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 158 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 159 | $(PRIVATE_LDFLAGS) \ |
| 160 | $(TARGET_LIBGCC) \ |
| 161 | $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 162 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 163 | endef |
| 164 | |
| 165 | define transform-o-to-static-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 166 | $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 167 | -Wl,--gc-sections -Wl,-z,norelro \ |
| 168 | -o $@ \ |
| 169 | $(TARGET_GLOBAL_LD_DIRS) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 170 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 171 | $(PRIVATE_LDFLAGS) \ |
| 172 | $(PRIVATE_ALL_OBJECTS) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 173 | -Wl,--start-group \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 174 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 175 | -Wl,--end-group \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 176 | $(TARGET_LIBGCC) \ |
| 177 | $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 178 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 179 | endef |