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 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 20 | # Provide a default variant. |
| 21 | ifeq ($(strip $(TARGET_ARCH_VARIANT)),) |
| 22 | TARGET_ARCH_VARIANT := x86 |
| 23 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 24 | |
| 25 | # 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] | 26 | ifeq ($(strip $(TARGET_TOOLS_PREFIX)),) |
| 27 | TARGET_TOOLS_PREFIX := \ |
Bruce Beare | a17b91f | 2011-01-26 18:43:15 -0800 | [diff] [blame] | 28 | 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] | 29 | endif |
| 30 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 31 | TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) |
| 32 | TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) |
| 33 | TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) |
| 34 | TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX) |
| 35 | TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX) |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 36 | TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX) |
Evgeniy Stepanov | 8f77c9d | 2011-06-21 17:08:49 +0400 | [diff] [blame] | 37 | |
| 38 | ifeq ($(TARGET_BUILD_VARIANT),user) |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 39 | TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ |
Evgeniy Stepanov | 8f77c9d | 2011-06-21 17:08:49 +0400 | [diff] [blame] | 40 | else |
| 41 | TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ && \ |
| 42 | $(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@ |
| 43 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 44 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 45 | ifneq ($(wildcard $(TARGET_CC)),) |
| 46 | TARGET_LIBGCC := \ |
Bruce Beare | a17b91f | 2011-01-26 18:43:15 -0800 | [diff] [blame] | 47 | $(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 48 | endif |
| 49 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 50 | TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 51 | |
| 52 | libc_root := bionic/libc |
| 53 | libm_root := bionic/libm |
| 54 | libstdc++_root := bionic/libstdc++ |
| 55 | libthread_db_root := bionic/libthread_db |
| 56 | |
| 57 | # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use |
| 58 | # symlinks located in out/ to point to the appropriate kernel |
| 59 | # headers. see 'config/kernel_headers.make' for more details |
| 60 | # |
| 61 | ifneq ($(CUSTOM_KERNEL_HEADERS),) |
| 62 | KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) |
| 63 | KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) |
| 64 | else |
| 65 | KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common |
| 66 | KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) |
| 67 | endif |
| 68 | KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) |
| 69 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 70 | TARGET_GLOBAL_CFLAGS += \ |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 71 | -O2 \ |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 72 | -Ulinux \ |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 73 | -Wa,--noexecstack \ |
| 74 | -Werror=format-security \ |
| 75 | -Wstrict-aliasing=2 \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 76 | -fPIC \ |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 77 | -ffunction-sections \ |
| 78 | -finline-functions \ |
| 79 | -finline-limit=300 \ |
| 80 | -fno-inline-functions-called-once \ |
| 81 | -fno-short-enums \ |
| 82 | -fstrict-aliasing \ |
| 83 | -funswitch-loops \ |
| 84 | -funwind-tables \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 85 | -include $(call select-android-config-h,target_linux-x86) |
| 86 | |
Martijn Coenen | 3c22287 | 2011-06-07 08:57:34 -0700 | [diff] [blame] | 87 | # Needs to be fixed later |
| 88 | #TARGET_GLOBAL_CFLAGS += \ |
| 89 | # -fstack-protector |
Mark D Horn | 5812d7b | 2011-04-26 14:15:26 -0700 | [diff] [blame] | 90 | |
| 91 | # Needs to be added for RELEASE |
| 92 | #TARGET_GLOBAL_CFLAGS += \ |
| 93 | # -DNDEBUG |
| 94 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 95 | TARGET_GLOBAL_CPPFLAGS += \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 96 | -fno-use-cxa-atexit |
| 97 | |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 98 | ifeq ($(TARGET_ARCH_VARIANT),x86-atom) |
Bruce Beare | 3343b27 | 2011-12-09 13:27:08 -0800 | [diff] [blame^] | 99 | # Basic ATOM flags. |
| 100 | TARGET_GLOBAL_CFLAGS += -march=atom -mstackrealign -mfpmath=sse |
| 101 | |
| 102 | # There are various levels of ATOM processors out there. Different ones have different |
| 103 | # capabilities. This first define matches the NDK's minimum ABI requirements. |
| 104 | # Note: Not all of the flags set here are actually used in Android. They are provided |
| 105 | # to allow for the addition of corresponding optimizations. |
| 106 | TARGET_GLOBAL_CFLAGS += -DUSE_MMX -DUSE_SSE -DUSE_SSE2 -DUSE_SSE3 |
| 107 | |
| 108 | # If you wish to build a BSP that will only be used on hardware that has additional |
| 109 | # available instructions, enable them here. By default, this is commented off so that |
| 110 | # the default images can run on all processors that are NDK ABI compliant. |
| 111 | # TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 112 | else |
Bruce Beare | 3343b27 | 2011-12-09 13:27:08 -0800 | [diff] [blame^] | 113 | # Plain 'x86' - lowest common denominator. This should run pretty much on any hardware. |
| 114 | # |
| 115 | # Note: The NDK's ABI (see the NDK ABI documentation) requires many of the more recent |
| 116 | # instruction set additions. You can build an "x86" BSP that will run on very old hardware, |
| 117 | # but it won't be able to run much of the x86 NDK compliant code. |
Bruce Beare | ccec9c4 | 2010-10-14 14:12:46 -0700 | [diff] [blame] | 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 |