blob: 79cf49d646efe92a5ca60fd1428d07d6300529be [file] [log] [blame]
Shin-ichiro KAWASAKIff328a92009-07-09 17:51:25 +09001# Configuration for Linux on SuperH.
2# Included by combo/select.make
3
4# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
5ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),)
6$(combo_target)TOOLS_PREFIX := \
7 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/sh-4.3.3/bin/sh-linux-gnu-
8endif
9
10$(combo_target)CC := $($(combo_target)TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
11$(combo_target)CXX := $($(combo_target)TOOLS_PREFIX)c++$(HOST_EXECUTABLE_SUFFIX)
12$(combo_target)AR := $($(combo_target)TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
13$(combo_target)OBJCOPY := $($(combo_target)TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
14$(combo_target)LD := $($(combo_target)TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
15
16$(combo_target)NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
17
18TARGET_sh_release_CFLAGS := -O2 \
19 -fomit-frame-pointer \
20 -fstrict-aliasing \
21 -funswitch-loops \
22 -finline-limit=300
23
24# When building for debug, compile everything as superh.
25TARGET_sh_debug_CFLAGS := $(TARGET_sh_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing
26
27$(combo_target)GLOBAL_CFLAGS += \
28 -fpic \
29 -ffunction-sections \
30 -funwind-tables \
31 -fstack-protector \
32 -include $(call select-android-config-h,linux-sh)
33
34$(combo_target)GLOBAL_CPPFLAGS += \
35 -fno-use-cxa-atexit \
36 -fvisibility-inlines-hidden
37
38$(combo_target)RELEASE_CFLAGS := \
39 -DSK_RELEASE -DNDEBUG \
40 -O2 -g \
41 -Wstrict-aliasing=2 \
42 -finline-functions \
43 -fno-inline-functions-called-once \
44 -fgcse-after-reload \
45 -frerun-cse-after-loop \
46 -frename-registers \
47 -fno-builtin
48
49libc_root := bionic/libc
50libm_root := bionic/libm
51libstdc++_root := bionic/libstdc++
52libthread_db_root := bionic/libthread_db
53
54
55## on some hosts, the target cross-compiler is not available so do not run this command
56ifneq ($(wildcard $($(combo_target)CC)),)
57# We compile with the global cflags to ensure that
58# any flags which affect libgcc are correctly taken
59# into account.
60LIBGCC_FILENAME := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name)
61LIBGCC_EH_FILENAME := $(subst libgcc,libgcc_eh,$(LIBGCC_FILENAME))
62$(combo_target)LIBGCC := $(LIBGCC_EH_FILENAME) $(LIBGCC_FILENAME)
63endif
64
65# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
66# symlinks located in out/ to point to the appropriate kernel
67# headers. see 'config/kernel_headers.make' for more details
68#
69ifneq ($(CUSTOM_KERNEL_HEADERS),)
70 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
71 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
72else
73 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
74 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
75endif
76KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
77
78$(combo_target)C_INCLUDES := \
79 $(libc_root)/arch-sh/include \
80 $(libc_root)/include \
81 $(libstdc++_root)/include \
82 $(KERNEL_HEADERS) \
83 $(libm_root)/include \
84 $(libm_root)/include/arch/sh \
85 $(libthread_db_root)/include
86
87TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
88TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
89TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
90TARGET_SOBEGIN := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o
91TARGET_SOEND := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o
92
93TARGET_STRIP_MODULE:=false
94
95$(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
96
97$(combo_target)CUSTOM_LD_COMMAND := true
98define transform-o-to-shared-lib-inner
99$(TARGET_CXX) \
100 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/shlelf.xsc \
101 -Wl,--gc-sections -Wl,-z,norelro \
102 -Wl,-shared,-Bsymbolic \
103 $(TARGET_GLOBAL_LD_DIRS) \
104 $(TARGET_SOBEGIN) \
105 $(PRIVATE_ALL_OBJECTS) \
106 -Wl,--whole-archive \
107 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
108 -Wl,--no-whole-archive \
109 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
110 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
111 -o $@ \
112 $(PRIVATE_LDFLAGS) \
113 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
114 $(TARGET_LIBGCC) \
115 $(TARGET_SOEND)
116endef
117
118define transform-o-to-executable-inner
119$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
120 -Wl,-dynamic-linker,/system/bin/linker \
121 -Wl,--gc-sections -Wl,-z,norelro \
122 -Wl,-z,nocopyreloc \
123 -o $@ \
124 $(TARGET_GLOBAL_LD_DIRS) \
125 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
126 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
127 $(TARGET_CRTBEGIN_DYNAMIC_O) \
128 $(PRIVATE_ALL_OBJECTS) \
129 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
130 $(PRIVATE_LDFLAGS) \
131 $(TARGET_LIBGCC) \
132 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
133 $(TARGET_CRTEND_O)
134endef
135
136define transform-o-to-static-executable-inner
137$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
138 -Wl,--gc-sections -Wl,-z,norelro \
139 -o $@ \
140 $(TARGET_GLOBAL_LD_DIRS) \
141 $(TARGET_CRTBEGIN_STATIC_O) \
142 $(PRIVATE_LDFLAGS) \
143 $(PRIVATE_ALL_OBJECTS) \
144 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
145 $(TARGET_LIBGCC) \
146 $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
147 $(TARGET_CRTEND_O)
148endef