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) |
| 32 | TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 33 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 34 | TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 35 | |
| 36 | TARGET_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. |
| 43 | TARGET_sh_debug_CFLAGS := $(TARGET_sh_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing |
| 44 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 45 | TARGET_GLOBAL_CFLAGS += \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 46 | -fpic \ |
| 47 | -ffunction-sections \ |
| 48 | -funwind-tables \ |
| 49 | -fstack-protector \ |
| 50 | -include $(call select-android-config-h,linux-sh) |
| 51 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 52 | TARGET_GLOBAL_CPPFLAGS += \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 53 | -fno-use-cxa-atexit \ |
| 54 | -fvisibility-inlines-hidden |
| 55 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 56 | TARGET_RELEASE_CFLAGS := \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 57 | -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 | |
| 67 | libc_root := bionic/libc |
| 68 | libm_root := bionic/libm |
| 69 | libstdc++_root := bionic/libstdc++ |
| 70 | libthread_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 Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 74 | ifneq ($(wildcard $(TARGET_CC)),) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 75 | # We compile with the global cflags to ensure that |
| 76 | # any flags which affect libgcc are correctly taken |
| 77 | # into account. |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 78 | 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] | 79 | LIBGCC_EH_FILENAME := $(subst libgcc,libgcc_eh,$(LIBGCC_FILENAME)) |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 80 | TARGET_LIBGCC := $(LIBGCC_EH_FILENAME) $(LIBGCC_FILENAME) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 81 | endif |
| 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 | # |
| 87 | ifneq ($(CUSTOM_KERNEL_HEADERS),) |
| 88 | KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) |
| 89 | KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) |
| 90 | else |
| 91 | KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common |
| 92 | KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) |
| 93 | endif |
| 94 | KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) |
| 95 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 96 | TARGET_C_INCLUDES := \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 97 | $(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 | |
| 105 | TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o |
| 106 | TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o |
| 107 | TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o |
Ying Wang | b6a1c18 | 2010-07-13 17:41:14 -0700 | [diff] [blame] | 108 | TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o |
| 109 | TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 110 | |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 111 | TARGET_STRIP_MODULE:=true |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 112 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 113 | TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 114 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 115 | TARGET_CUSTOM_LD_COMMAND := true |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 116 | define 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 Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 121 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
Ying Wang | b6a1c18 | 2010-07-13 17:41:14 -0700 | [diff] [blame] | 122 | $(PRIVATE_TARGET_CRTBEGIN_SO_O) \ |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 123 | $(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 Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 132 | $(PRIVATE_TARGET_LIBGCC) \ |
Ying Wang | b6a1c18 | 2010-07-13 17:41:14 -0700 | [diff] [blame] | 133 | $(PRIVATE_TARGET_CRTEND_SO_O) |
Shin-ichiro KAWASAKI | ff328a9 | 2009-07-09 17:51:25 +0900 | [diff] [blame] | 134 | endef |
| 135 | |
| 136 | define 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) |
| 152 | endef |
| 153 | |
| 154 | define 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) |
| 166 | endef |