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 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 17 | # Configuration for Linux on x86 as a target. |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 18 | # Included by combo/select.mk |
| 19 | |
| 20 | ifeq ($(TARGET_SIMULATOR),true) |
| 21 | # When building for the simulator, use the HOST settings as TARGET settings |
| 22 | TARGET_CC := $(HOST_CC) |
| 23 | TARGET_CXX := $(HOST_CXX) |
| 24 | TARGET_AR := $(HOST_AR) |
Andy McFadden | 16e95bb | 2010-02-24 08:29:39 -0800 | [diff] [blame] | 25 | TARGET_GLOBAL_CFLAGS := $(HOST_GLOBAL_CFLAGS) -m32 |
Andy McFadden | 99e087b | 2010-03-08 12:42:46 -0800 | [diff] [blame] | 26 | TARGET_GLOBAL_LDFLAGS := $(HOST_GLOBAL_LDFLAGS) -m32 -lpthread |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 27 | TARGET_NO_UNDEFINED_LDFLAGS := $(HOST_NO_UNDEFINED_LDFLAGS) |
Johnnie Birch | a4716b2 | 2010-08-02 12:12:15 -0700 | [diff] [blame] | 28 | ifeq ($(strip $(TARGET_ARCH_VARIANT)),) |
Andy McFadden | ef26218 | 2010-02-26 13:26:03 -0800 | [diff] [blame] | 29 | TARGET_ARCH_VARIANT := x86 |
Johnnie Birch | a4716b2 | 2010-08-02 12:12:15 -0700 | [diff] [blame] | 30 | endif |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 31 | else #simulator |
| 32 | |
| 33 | # Provide a default variant. |
| 34 | ifeq ($(strip $(TARGET_ARCH_VARIANT)),) |
| 35 | TARGET_ARCH_VARIANT := x86 |
| 36 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 37 | |
| 38 | # 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] | 39 | ifeq ($(strip $(TARGET_TOOLS_PREFIX)),) |
| 40 | TARGET_TOOLS_PREFIX := \ |
Bruce Beare | a17b91f | 2011-01-26 18:43:15 -0800 | [diff] [blame] | 41 | prebuilt/$(HOST_PREBUILT_TAG)/toolchain/i686-android-linux-4.4.3/bin/i686-android-linux- |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 42 | endif |
| 43 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 44 | TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) |
| 45 | TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) |
| 46 | TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) |
| 47 | TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX) |
| 48 | TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX) |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 49 | TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX) |
Evgeniy Stepanov | 8f77c9d | 2011-06-21 17:08:49 +0400 | [diff] [blame^] | 50 | |
| 51 | ifeq ($(TARGET_BUILD_VARIANT),user) |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 52 | TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ |
Evgeniy Stepanov | 8f77c9d | 2011-06-21 17:08:49 +0400 | [diff] [blame^] | 53 | else |
| 54 | TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ && \ |
| 55 | $(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@ |
| 56 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 57 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 58 | ifneq ($(wildcard $(TARGET_CC)),) |
| 59 | TARGET_LIBGCC := \ |
Bruce Beare | a17b91f | 2011-01-26 18:43:15 -0800 | [diff] [blame] | 60 | $(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 61 | endif |
| 62 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 63 | TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 64 | |
| 65 | libc_root := bionic/libc |
| 66 | libm_root := bionic/libm |
| 67 | libstdc++_root := bionic/libstdc++ |
| 68 | libthread_db_root := bionic/libthread_db |
| 69 | |
| 70 | # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use |
| 71 | # symlinks located in out/ to point to the appropriate kernel |
| 72 | # headers. see 'config/kernel_headers.make' for more details |
| 73 | # |
| 74 | ifneq ($(CUSTOM_KERNEL_HEADERS),) |
| 75 | KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) |
| 76 | KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) |
| 77 | else |
| 78 | KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common |
| 79 | KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) |
| 80 | endif |
| 81 | KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) |
| 82 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 83 | TARGET_GLOBAL_CFLAGS += \ |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 84 | -O2 \ |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 85 | -Ulinux \ |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 86 | -Wa,--noexecstack \ |
| 87 | -Werror=format-security \ |
| 88 | -Wstrict-aliasing=2 \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 89 | -fPIC \ |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 90 | -ffunction-sections \ |
| 91 | -finline-functions \ |
| 92 | -finline-limit=300 \ |
| 93 | -fno-inline-functions-called-once \ |
| 94 | -fno-short-enums \ |
| 95 | -fstrict-aliasing \ |
| 96 | -funswitch-loops \ |
| 97 | -funwind-tables \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 98 | -include $(call select-android-config-h,target_linux-x86) |
| 99 | |
Martijn Coenen | 3c22287 | 2011-06-07 08:57:34 -0700 | [diff] [blame] | 100 | # Needs to be fixed later |
| 101 | #TARGET_GLOBAL_CFLAGS += \ |
| 102 | # -fstack-protector |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 103 | |
| 104 | # Needs to be added for RELEASE |
| 105 | #TARGET_GLOBAL_CFLAGS += \ |
| 106 | # -DNDEBUG |
| 107 | |
| 108 | |
Bruce Beare | 6ddd4ea | 2011-04-01 09:09:02 -0700 | [diff] [blame] | 109 | # Fix this after ssp.c is fixed for x86 |
| 110 | # TARGET_GLOBAL_CFLAGS += -fstack-protector |
| 111 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 112 | TARGET_GLOBAL_CPPFLAGS += \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 113 | -fno-use-cxa-atexit |
| 114 | |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 115 | ifeq ($(TARGET_ARCH_VARIANT),x86-atom) |
Bruce Beare | a17b91f | 2011-01-26 18:43:15 -0800 | [diff] [blame] | 116 | TARGET_GLOBAL_CFLAGS += -march=atom -mstackrealign -DUSE_SSSE3 -DUSE_SSE2 -mfpmath=sse |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 117 | else |
| 118 | TARGET_GLOBAL_CFLAGS += -march=i686 |
| 119 | endif |
| 120 | |
Bruce Beare | 2e8283d | 2011-02-01 08:00:09 -0800 | [diff] [blame] | 121 | TARGET_GLOBAL_CFLAGS += -mbionic |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 122 | TARGET_GLOBAL_CFLAGS += -D__ANDROID__ |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 123 | |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 124 | TARGET_GLOBAL_LDFLAGS += -m32 |
| 125 | TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack |
| 126 | TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 127 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 128 | TARGET_C_INCLUDES := \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 129 | $(libc_root)/arch-x86/include \ |
| 130 | $(libc_root)/include \ |
| 131 | $(libstdc++_root)/include \ |
| 132 | $(KERNEL_HEADERS) \ |
| 133 | $(libm_root)/include \ |
| 134 | $(libm_root)/include/i387 \ |
| 135 | $(libthread_db_root)/include |
| 136 | |
| 137 | TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o |
| 138 | TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o |
| 139 | TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o |
| 140 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 141 | TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o |
| 142 | TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o |
| 143 | |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 144 | TARGET_STRIP_MODULE:=true |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 145 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 146 | TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 147 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 148 | TARGET_CUSTOM_LD_COMMAND := true |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 149 | define transform-o-to-shared-lib-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 150 | $(hide) $(PRIVATE_CXX) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 151 | $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 152 | -nostdlib -Wl,-soname,$(notdir $@) \ |
| 153 | -shared -Bsymbolic \ |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 154 | $(TARGET_GLOBAL_CFLAGS) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 155 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 156 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 157 | $(PRIVATE_ALL_OBJECTS) \ |
| 158 | -Wl,--whole-archive \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 159 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 160 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 161 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 162 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 163 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 164 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 165 | -o $@ \ |
| 166 | $(PRIVATE_LDFLAGS) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 167 | $(PRIVATE_TARGET_LIBGCC) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 168 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 169 | endef |
| 170 | |
| 171 | |
| 172 | define transform-o-to-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 173 | $(hide) $(PRIVATE_CXX) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 174 | $(TARGET_GLOBAL_LDFLAGS) \ |
| 175 | -nostdlib -Bdynamic \ |
| 176 | -Wl,-dynamic-linker,/system/bin/linker \ |
| 177 | -Wl,-z,nocopyreloc \ |
| 178 | -o $@ \ |
| 179 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 180 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 181 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 182 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 183 | $(PRIVATE_ALL_OBJECTS) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 184 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 185 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 186 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 187 | $(PRIVATE_LDFLAGS) \ |
| 188 | $(TARGET_LIBGCC) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 189 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 190 | endef |
| 191 | |
| 192 | define transform-o-to-static-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 193 | $(hide) $(PRIVATE_CXX) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 194 | $(TARGET_GLOBAL_LDFLAGS) \ |
| 195 | -nostdlib -Bstatic \ |
| 196 | -o $@ \ |
| 197 | $(TARGET_GLOBAL_LD_DIRS) \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 198 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 199 | $(PRIVATE_LDFLAGS) \ |
| 200 | $(PRIVATE_ALL_OBJECTS) \ |
| 201 | -Wl,--start-group \ |
| 202 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 203 | $(TARGET_LIBGCC) \ |
| 204 | -Wl,--end-group \ |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 205 | $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 206 | endef |
| 207 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 208 | endif #simulator |