Home | History | Annotate | Download | only in combo
      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 
     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
     21 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
     22 TARGET_TOOLS_PREFIX := \
     23 	prebuilt/$(HOST_PREBUILT_TAG)/toolchain/sh-4.3.3/bin/sh-linux-gnu-
     24 endif
     25 
     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)
     31 
     32 TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
     33 
     34 TARGET_sh_release_CFLAGS :=     -O2 \
     35                                 -fomit-frame-pointer \
     36                                 -fstrict-aliasing    \
     37                                 -funswitch-loops     \
     38                                 -finline-limit=300
     39 
     40 # When building for debug, compile everything as superh.
     41 TARGET_sh_debug_CFLAGS := $(TARGET_sh_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing
     42 
     43 TARGET_GLOBAL_CFLAGS += \
     44 			-fpic \
     45 			-ffunction-sections \
     46 			-funwind-tables \
     47 			-fstack-protector \
     48 			-include $(call select-android-config-h,linux-sh)
     49 
     50 TARGET_GLOBAL_CPPFLAGS += \
     51 			-fno-use-cxa-atexit \
     52 			-fvisibility-inlines-hidden
     53 
     54 TARGET_RELEASE_CFLAGS := \
     55 			-DSK_RELEASE -DNDEBUG \
     56 			-O2 -g \
     57 			-Wstrict-aliasing=2 \
     58 			-finline-functions \
     59 			-fno-inline-functions-called-once \
     60 			-fgcse-after-reload \
     61 			-frerun-cse-after-loop \
     62 			-frename-registers \
     63 			-fno-builtin
     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 
     71 ## on some hosts, the target cross-compiler is not available so do not run this command
     72 ifneq ($(wildcard $(TARGET_CC)),)
     73 # We compile with the global cflags to ensure that
     74 # any flags which affect libgcc are correctly taken
     75 # into account.
     76 LIBGCC_FILENAME := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
     77 LIBGCC_EH_FILENAME := $(subst libgcc,libgcc_eh,$(LIBGCC_FILENAME))
     78 TARGET_LIBGCC := $(LIBGCC_EH_FILENAME) $(LIBGCC_FILENAME)
     79 endif
     80 
     81 # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
     82 # symlinks located in out/ to point to the appropriate kernel
     83 # headers. see 'config/kernel_headers.make' for more details
     84 #
     85 ifneq ($(CUSTOM_KERNEL_HEADERS),)
     86     KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
     87     KERNEL_HEADERS_ARCH   := $(CUSTOM_KERNEL_HEADERS)
     88 else
     89     KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
     90     KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/arch-$(TARGET_ARCH)
     91 endif
     92 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
     93 
     94 TARGET_C_INCLUDES := \
     95 	$(libc_root)/arch-sh/include \
     96 	$(libc_root)/include \
     97 	$(libstdc++_root)/include \
     98 	$(KERNEL_HEADERS) \
     99 	$(libm_root)/include \
    100 	$(libm_root)/include/arch/sh \
    101 	$(libthread_db_root)/include
    102 
    103 TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
    104 TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
    105 TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
    106 TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o
    107 TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o
    108 
    109 TARGET_STRIP_MODULE:=false
    110 
    111 TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
    112 
    113 TARGET_CUSTOM_LD_COMMAND := true
    114 define transform-o-to-shared-lib-inner
    115 $(TARGET_CXX) \
    116 	-nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/shlelf.xsc \
    117 	-Wl,--gc-sections -Wl,-z,norelro \
    118 	-Wl,-shared,-Bsymbolic \
    119 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
    120 	$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
    121 	$(PRIVATE_ALL_OBJECTS) \
    122 	-Wl,--whole-archive \
    123 	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
    124 	-Wl,--no-whole-archive \
    125 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
    126 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
    127 	-o $@ \
    128 	$(PRIVATE_LDFLAGS) \
    129 	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
    130 	$(PRIVATE_TARGET_LIBGCC) \
    131 	$(PRIVATE_TARGET_CRTEND_SO_O)
    132 endef
    133 
    134 define transform-o-to-executable-inner
    135 $(TARGET_CXX) -nostdlib -Bdynamic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
    136 	-Wl,-dynamic-linker,/system/bin/linker \
    137 	-Wl,--gc-sections -Wl,-z,norelro \
    138 	-Wl,-z,nocopyreloc \
    139 	-o $@ \
    140 	$(TARGET_GLOBAL_LD_DIRS) \
    141 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
    142 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
    143 	$(TARGET_CRTBEGIN_DYNAMIC_O) \
    144 	$(PRIVATE_ALL_OBJECTS) \
    145 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
    146 	$(PRIVATE_LDFLAGS) \
    147 	$(TARGET_LIBGCC) \
    148 	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
    149 	$(TARGET_CRTEND_O)
    150 endef
    151 
    152 define transform-o-to-static-executable-inner
    153 $(TARGET_CXX) -nostdlib -Bstatic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
    154 	-Wl,--gc-sections -Wl,-z,norelro \
    155 	-o $@ \
    156 	$(TARGET_GLOBAL_LD_DIRS) \
    157 	$(TARGET_CRTBEGIN_STATIC_O) \
    158 	$(PRIVATE_LDFLAGS) \
    159 	$(PRIVATE_ALL_OBJECTS) \
    160 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
    161 	$(TARGET_LIBGCC) \
    162 	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
    163 	$(TARGET_CRTEND_O)
    164 endef
    165