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) |
Andy McFadden | ef26218 | 2010-02-26 13:26:03 -0800 | [diff] [blame] | 28 | TARGET_ARCH_VARIANT := x86 |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 29 | else #simulator |
| 30 | |
| 31 | # Provide a default variant. |
| 32 | ifeq ($(strip $(TARGET_ARCH_VARIANT)),) |
| 33 | TARGET_ARCH_VARIANT := x86 |
| 34 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 35 | |
| 36 | # 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] | 37 | ifeq ($(strip $(TARGET_TOOLS_PREFIX)),) |
| 38 | TARGET_TOOLS_PREFIX := \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 39 | prebuilt/$(HOST_PREBUILT_TAG)/toolchain/i686-unknown-linux-gnu-4.2.1/bin/i686-unknown-linux-gnu- |
| 40 | endif |
| 41 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 42 | TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) |
| 43 | TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) |
| 44 | TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) |
| 45 | TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX) |
| 46 | TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 47 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 48 | ifneq ($(wildcard $(TARGET_CC)),) |
| 49 | TARGET_LIBGCC := \ |
| 50 | $(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a) \ |
| 51 | $(shell $(TARGET_CC) -m32 -print-file-name=libgcc_eh.a) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 52 | endif |
| 53 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 54 | TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 55 | |
| 56 | libc_root := bionic/libc |
| 57 | libm_root := bionic/libm |
| 58 | libstdc++_root := bionic/libstdc++ |
| 59 | libthread_db_root := bionic/libthread_db |
| 60 | |
| 61 | # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use |
| 62 | # symlinks located in out/ to point to the appropriate kernel |
| 63 | # headers. see 'config/kernel_headers.make' for more details |
| 64 | # |
| 65 | ifneq ($(CUSTOM_KERNEL_HEADERS),) |
| 66 | KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) |
| 67 | KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) |
| 68 | else |
| 69 | KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common |
| 70 | KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) |
| 71 | endif |
| 72 | KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) |
| 73 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 74 | TARGET_GLOBAL_CFLAGS += \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 75 | -march=i686 \ |
| 76 | -m32 \ |
| 77 | -fPIC \ |
| 78 | -include $(call select-android-config-h,target_linux-x86) |
| 79 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 80 | TARGET_GLOBAL_CPPFLAGS += \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 81 | -fno-use-cxa-atexit |
| 82 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 83 | TARGET_C_INCLUDES := \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 84 | $(libc_root)/arch-x86/include \ |
| 85 | $(libc_root)/include \ |
| 86 | $(libstdc++_root)/include \ |
| 87 | $(KERNEL_HEADERS) \ |
| 88 | $(libm_root)/include \ |
| 89 | $(libm_root)/include/i387 \ |
| 90 | $(libthread_db_root)/include |
| 91 | |
| 92 | TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o |
| 93 | TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o |
| 94 | TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o |
| 95 | |
| 96 | |
| 97 | TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o |
| 98 | TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o |
| 99 | |
| 100 | # TARGET_STRIP_MODULE:=true |
| 101 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 102 | TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 103 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 104 | TARGET_CUSTOM_LD_COMMAND := true |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 105 | define transform-o-to-shared-lib-inner |
| 106 | $(TARGET_CXX) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 107 | $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 108 | -nostdlib -Wl,-soname,$(notdir $@) \ |
| 109 | -shared -Bsymbolic \ |
| 110 | -fPIC -march=i686 \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 111 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
| 112 | $(PRIVATE_TARGET_CRTBEGIN_SO_O) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 113 | $(PRIVATE_ALL_OBJECTS) \ |
| 114 | -Wl,--whole-archive \ |
| 115 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 116 | -Wl,--no-whole-archive \ |
| 117 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 118 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 119 | -o $@ \ |
| 120 | $(PRIVATE_LDFLAGS) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 121 | $(PRIVATE_TARGET_LIBGCC) \ |
| 122 | $(PRIVATE_TARGET_CRTEND_SO_O) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 123 | endef |
| 124 | |
| 125 | |
| 126 | define transform-o-to-executable-inner |
| 127 | $(TARGET_CXX) \ |
| 128 | $(TARGET_GLOBAL_LDFLAGS) \ |
| 129 | -nostdlib -Bdynamic \ |
| 130 | -Wl,-dynamic-linker,/system/bin/linker \ |
| 131 | -Wl,-z,nocopyreloc \ |
| 132 | -o $@ \ |
| 133 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 134 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 135 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 136 | $(TARGET_CRTBEGIN_DYNAMIC_O) \ |
| 137 | $(PRIVATE_ALL_OBJECTS) \ |
| 138 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 139 | $(PRIVATE_LDFLAGS) \ |
| 140 | $(TARGET_LIBGCC) \ |
| 141 | $(TARGET_CRTEND_O) |
| 142 | endef |
| 143 | |
| 144 | define transform-o-to-static-executable-inner |
| 145 | $(TARGET_CXX) \ |
| 146 | $(TARGET_GLOBAL_LDFLAGS) \ |
| 147 | -nostdlib -Bstatic \ |
| 148 | -o $@ \ |
| 149 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 150 | $(TARGET_CRTBEGIN_STATIC_O) \ |
| 151 | $(PRIVATE_LDFLAGS) \ |
| 152 | $(PRIVATE_ALL_OBJECTS) \ |
| 153 | -Wl,--start-group \ |
| 154 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 155 | $(TARGET_LIBGCC) \ |
| 156 | -Wl,--end-group \ |
| 157 | $(TARGET_CRTEND_O) |
| 158 | endef |
| 159 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 160 | TARGET_GLOBAL_CFLAGS += -m32 |
| 161 | TARGET_GLOBAL_LDFLAGS += -m32 |
| 162 | |
| 163 | endif #simulator |