mark boards as experimental
[openadk.git] / toolchain / gcc / Makefile
blob24b871025384ccdf978515f5d5739a31586e9b4d
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 include $(ADK_TOPDIR)/rules.mk
5 include ../rules.mk
6 include Makefile.inc
7 include $(ADK_TOPDIR)/mk/os.mk
9 # disable SSP for libstdc++
10 ifeq ($(ADK_TARGET_LIB_MUSL),y)
11 TARGET_CFLAGS:= $(filter-out -fstack-protector-all,$(TARGET_CFLAGS))
12 TARGET_CXXFLAGS:= $(filter-out -fstack-protector-all,$(TARGET_CXXFLAGS))
13 endif
15 # disable lto for gcc
16 TARGET_CFLAGS:= $(filter-out -flto,$(TARGET_CFLAGS))
17 TARGET_CXXFLAGS:= $(filter-out -flto,$(TARGET_CXXFLAGS))
19 ifeq ($(ADK_TARGET_ARCH_XTENSA),y)
20 TARGET_CFLAGS:= $(filter-out -mtext-section-literals,$(TARGET_CFLAGS))
21 TARGET_CXXFLAGS:= $(filter-out -mtext-section-literals,$(TARGET_CXXFLAGS))
22 endif
24 # for uClinux, we need to filter out some flags
25 ifeq ($(ADK_TARGET_UCLINUX),y)
26 TARGET_CFLAGS:= $(filter-out -msep-data,$(TARGET_CFLAGS))
27 TARGET_CXXFLAGS:= $(filter-out -msep-data,$(TARGET_CXXFLAGS))
28 endif
30 GCC_CONFOPTS:= --prefix=$(TOOLCHAIN_DIR)/usr \
31 --with-bugurl="http://www.openadk.org/" \
32 --build=$(GNU_HOST_NAME) \
33 --host=$(GNU_HOST_NAME) \
34 --target=$(GNU_TARGET_NAME) \
35 --with-gmp=$(STAGING_HOST_DIR)/usr \
36 --with-mpfr=$(STAGING_HOST_DIR)/usr \
37 --with-libelf=$(STAGING_HOST_DIR)/usr \
38 --disable-__cxa_atexit \
39 --with-gnu-ld \
40 --with-gnu-as \
41 --disable-libsanitizer \
42 --disable-install-libiberty \
43 --disable-libitm \
44 --disable-libmudflap \
45 --disable-libgomp \
46 --disable-libcilkrts \
47 --disable-libquadmath \
48 --disable-libquadmath-support \
49 --disable-decimal-float \
50 --disable-libstdcxx-pch \
51 --disable-ppl-version-check \
52 --disable-cloog-version-check \
53 --with-system-zlib \
54 --without-ppl \
55 --without-cloog \
56 --without-isl \
57 --disable-nls
59 GCC_FINAL_CONFOPTS:=
61 ifeq ($(ADK_TARGET_WITH_NPTL),y)
62 ifeq ($(ADK_TARGET_LIB_WITHOUT_THREADS),)
63 GCC_FINAL_CONFOPTS+= --enable-tls --enable-threads --enable-libatomic
64 else
65 GCC_FINAL_CONFOPTS+= --disable-tls --disable-threads --disable-libatomic
66 endif
67 else
68 GCC_FINAL_CONFOPTS+= --disable-tls --disable-threads --disable-libatomic
69 endif
71 ifeq ($(ADK_TARGET_BINFMT_FLAT)$(ADK_TARGET_USE_STATIC_LIBS),y)
72 GCC_FINAL_CONFOPTS+= --disable-shared
73 else
74 # uClibc/glibc uses libgcc_s.so.1 for pthread_cancel with dlopen
75 ifeq (ADK_TARGET_LIB_MUSL),y)
76 GCC_FINAL_CONFOPTS+= --enable-shared='libstdc++'
77 else
78 GCC_FINAL_CONFOPTS+= --enable-shared='libstdc++,libgcc'
79 endif
80 endif
82 ifeq ($(ADK_TOOLCHAIN_WITH_SSP),y)
83 GCC_FINAL_CONFOPTS+= --enable-libssp
84 else
85 GCC_FINAL_CONFOPTS+= --disable-libssp
86 endif
88 ifeq ($(ADK_TOOLCHAIN_WITH_LTO),y)
89 GCC_CONFOPTS+= --enable-lto
90 else
91 GCC_CONFOPTS+= --disable-lto
92 endif
95 # architecture specific
97 ifneq ($(ADK_TARGET_GCC_CPU),)
98 GCC_CONFOPTS+= --with-cpu=$(ADK_TARGET_GCC_CPU)
99 endif
101 ifneq ($(ADK_TARGET_GCC_ARCH),)
102 GCC_CONFOPTS+= --with-arch=$(ADK_TARGET_GCC_ARCH)
103 endif
105 ifneq ($(ADK_TARGET_FLOAT),)
106 GCC_CONFOPTS+= --with-float=$(ADK_TARGET_FLOAT)
107 endif
109 ifneq ($(ADK_TARGET_FPU),)
110 GCC_CONFOPTS+= --with-fpu=$(ADK_TARGET_FPU)
111 endif
113 ifeq ($(ADK_TARGET_ARCH_ARM_WITH_THUMB),y)
114 GCC_CONFOPTS+= --with-mode=thumb
115 endif
117 ifeq ($(ADK_TARGET_ARCH_METAG),y)
118 GCC_CONFOPTS+= --enable-meta-default
119 endif
121 ifeq ($(ADK_CPU_CF),y)
122 GCC_CONFOPTS+= --enable-multilib --with-arch=cf
123 endif
125 ifeq ($(ADK_TARGET_ARCH_M68K)$(ADK_TARGET_ARCH_X86_64)$(ADK_TARGET_ARCH_X86),)
126 GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib
127 endif
129 ifeq ($(ADK_TARGET_ARCH_SH),y)
130 ifeq ($(ADK_TARGET_LITTLE_ENDIAN),y)
131 GCC_CONFOPTS+= --with-endian=little
132 else
133 GCC_CONFOPTS+= --with-endian=big
134 endif
135 ifeq ($(ADK_CPU_SH2),y)
136 GCC_FINAL_CONFOPTS+= --with-multilib-list=m2
137 endif
138 ifeq ($(ADK_CPU_SH2A),y)
139 GCC_FINAL_CONFOPTS+= --with-multilib-list=m2a
140 endif
141 ifeq ($(ADK_CPU_SH3),y)
142 GCC_FINAL_CONFOPTS+= --with-multilib-list=m3
143 endif
144 ifeq ($(ADK_CPU_SH4),y)
145 GCC_FINAL_CONFOPTS+= --with-multilib-list=m4,m4-nofpu
146 endif
147 ifeq ($(ADK_CPU_SH4A),y)
148 GCC_FINAL_CONFOPTS+= --with-multilib-list=m4a,m4a-nofpu
149 endif
150 endif
152 ifeq ($(ADK_TARGET_ARCH_X86),y)
153 ifeq ($(ADK_TARGET_KERNEL_64),y)
154 GCC_FINAL_CONFOPTS+= --enable-biarch --enable-targets=all --disable-multilib
155 else
156 GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib
157 endif
158 endif
160 ifeq ($(ADK_TARGET_ARCH_X86_64),y)
161 ifneq ($(ADK_TARGET_ABI_X32),)
162 GCC_FINAL_CONFOPTS+= --with-abi=x32
163 else
164 GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib
165 endif
166 endif
168 ifeq ($(ADK_TARGET_ARCH_PPC),y)
169 GCC_CONFOPTS+= --with-long-double-64 --enable-secureplt
170 endif
172 ifneq ($(ADK_TARGET_MIPS_ABI),)
173 GCC_CONFOPTS+= --with-abi=${ADK_TARGET_MIPS_ABI}
174 endif
176 ifeq (${ADK_MAKE_PARALLEL},y)
177 GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
178 endif
180 ifeq ($(ADK_TARGET_WITHOUT_CXX),y)
181 LANGUAGES:=c
182 else
183 LANGUAGES:=c,c++
184 endif
186 include ${ADK_TOPDIR}/mk/buildhlp.mk
188 GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
189 GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
190 GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
192 $(GCC_BUILD_DIR_MINIMAL)/.configured:
193 ifeq ($(ADK_TARGET_ARCH_XTENSA),y)
194 tar xf $(ADK_TOPDIR)/target/xtensa/overlay/xtensa_$(ADK_TARGET_XTENSA).tar \
195 --strip-components=1 -C $(WRKSRC) gcc
196 endif
197 mkdir -p $(GCC_BUILD_DIR_MINIMAL)
198 # these symlinks are very important, do not remove
199 rm -rf $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
200 mkdir -p $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)
201 (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
202 ln -s ../$(STAGING_HOST2TARGET)/usr/include sys-include)
203 rm -rf ${TOOLCHAIN_DIR}/usr/$(GNU_TARGET_NAME)/lib
204 (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
205 ln -s ../$(STAGING_HOST2TARGET)/lib lib)
206 ifeq ($(ADK_TARGET_ARCH_SH),y)
207 (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4)
208 endif
209 $(SED) '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
210 cd $(GCC_BUILD_DIR_MINIMAL); \
211 PATH='$(TARGET_PATH)' \
212 CC='$(HOST_CC)' \
213 CXX='$(HOST_CXX)' \
214 CFLAGS="-O0 -g0 -fomit-frame-pointer" \
215 CXXFLAGS="-O0 -g0 -fomit-frame-pointer" \
216 $(WRKBUILD)/configure \
217 ${GCC_CONFOPTS} \
218 --enable-languages=c \
219 --disable-libssp \
220 --disable-shared \
221 --disable-threads \
222 --disable-multilib \
223 --without-headers
224 touch $@
226 $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
227 PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
228 touch $@
230 $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
231 PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
232 touch $@
234 $(GCC_BUILD_DIR_INITIAL)/.configured:
235 mkdir -p $(GCC_BUILD_DIR_INITIAL)
236 cd $(GCC_BUILD_DIR_INITIAL); \
237 PATH='$(TARGET_PATH)' \
238 CC='$(HOST_CC)' \
239 CXX='$(HOST_CXX)' \
240 CFLAGS="-O0 -g0 -fomit-frame-pointer" \
241 CXXFLAGS="-O0 -g0 -fomit-frame-pointer" \
242 $(WRKBUILD)/configure \
243 ${GCC_CONFOPTS} \
244 ${GCC_FINAL_CONFOPTS} \
245 --enable-languages=c \
246 --disable-shared \
247 --disable-threads \
248 --with-sysroot=$(STAGING_TARGET_DIR)
249 touch $@
251 ifeq ($(ADK_TOOLCHAIN_GCC_4_2_4),y)
252 $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
253 PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc
254 touch $@
256 $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
257 PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc
258 touch $@
259 else
260 $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
261 PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
262 touch $@
264 $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
265 PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
266 touch $@
267 endif
269 $(GCC_BUILD_DIR_FINAL)/.configured:
270 mkdir -p $(GCC_BUILD_DIR_FINAL)
271 cd $(GCC_BUILD_DIR_FINAL); \
272 PATH='$(TARGET_PATH)' \
273 CC='$(HOST_CC)' \
274 CXX='$(HOST_CXX)' \
275 CFLAGS_FOR_TARGET='$(TARGET_CFLAGS)' \
276 CXXFLAGS_FOR_TARGET='$(TARGET_CXXFLAGS)' \
277 $(WRKBUILD)/configure \
278 ${GCC_CONFOPTS} \
279 ${GCC_FINAL_CONFOPTS} \
280 --enable-cxx-flags='-fPIC' \
281 --enable-languages=$(LANGUAGES) \
282 --with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
283 --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}'
284 PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) configure-host
285 touch $@
287 $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
288 cd $(GCC_BUILD_DIR_FINAL); \
289 PATH='$(TARGET_PATH)' \
290 $(MAKE) ${GCC_MAKEOPTS} all
291 touch $@
293 $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
294 cd $(GCC_BUILD_DIR_FINAL); \
295 PATH='$(TARGET_PATH)' \
296 $(MAKE) install
297 # remove duplicate tools, convert hardlinks to symlinks
298 set -e; \
299 cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/bin; \
300 for app in ar as c++ g++ gcc ld ld.gold ld.bfd nm objcopy objdump ranlib strip; do \
301 ln -sf ../../bin/$(GNU_TARGET_NAME)-$${app} $${app}; \
302 done;
303 (cd $(TOOLCHAIN_DIR)/usr/bin && \
304 ln -sf $(GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-gcc-${PKG_VERSION} && \
305 ln -sf $(GNU_TARGET_NAME)-g++ $(GNU_TARGET_NAME)-g++-${PKG_VERSION} \
307 ifeq ($(ADK_TARGET_USE_GOLD),y)
308 (cd $(TOOLCHAIN_DIR)/usr/bin && \
309 ln -sf $(GNU_TARGET_NAME)-ld.gold $(GNU_TARGET_NAME)-ld)
310 else
311 ifeq (ADK_TOOLCHAIN_BINUTILS_2_20_1),)
312 (cd $(TOOLCHAIN_DIR)/usr/bin && \
313 ln -sf $(GNU_TARGET_NAME)-ld.bfd $(GNU_TARGET_NAME)-ld)
314 endif
315 endif
316 cd $(STAGING_TARGET_DIR)/lib && \
317 ln -sf libstdc++.so.6.0.$(LIBSTDCXXVER) libstdc++.so && \
318 ln -sf libstdc++.so.6.0.$(LIBSTDCXXVER) libstdc++.so.6
319 # cleanup unneeded docs
320 rm -rf $(TOOLCHAIN_DIR)/usr/share
321 ifeq ($(ADK_TARGET_ARCH_M68K),y)
322 # create gcc wrapper for uClinux/m68k
323 echo "#!/bin/sh" > $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
324 echo "exec ${GNU_TARGET_NAME}-gcc \"\$$@\" -specs $(ADK_TOPDIR)/toolchain/gcc/m68k-uclinux-gcc.specs" >> $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
325 chmod a+x $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
326 endif
327 ifeq ($(ADK_TARGET_ARCH_ARM),y)
328 # create gcc wrapper for uClinux/arm
329 echo "#!/bin/sh" > $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
330 echo "exec ${GNU_TARGET_NAME}-gcc \"\$$@\" -specs $(ADK_TOPDIR)/toolchain/gcc/arm-uclinux-gcc.specs" >> $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
331 chmod a+x $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
332 endif
333 touch $@
335 include ${ADK_TOPDIR}/mk/toolchain.mk