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
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
))
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
))
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
))
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 \
41 --disable-libsanitizer \
42 --disable-install-libiberty \
44 --disable-libmudflap \
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 \
61 ifeq ($(ADK_TARGET_WITH_NPTL
),y
)
62 ifeq ($(ADK_TARGET_LIB_WITHOUT_THREADS
),)
63 GCC_FINAL_CONFOPTS
+= --enable-tls
--enable-threads
--enable-libatomic
65 GCC_FINAL_CONFOPTS
+= --disable-tls
--disable-threads
--disable-libatomic
68 GCC_FINAL_CONFOPTS
+= --disable-tls
--disable-threads
--disable-libatomic
71 ifeq ($(ADK_TARGET_BINFMT_FLAT
)$(ADK_TARGET_USE_STATIC_LIBS
),y
)
72 GCC_FINAL_CONFOPTS
+= --disable-shared
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++'
78 GCC_FINAL_CONFOPTS
+= --enable-shared
='libstdc++,libgcc'
82 ifeq ($(ADK_TOOLCHAIN_WITH_SSP
),y
)
83 GCC_FINAL_CONFOPTS
+= --enable-libssp
85 GCC_FINAL_CONFOPTS
+= --disable-libssp
88 ifeq ($(ADK_TOOLCHAIN_WITH_LTO
),y
)
89 GCC_CONFOPTS
+= --enable-lto
91 GCC_CONFOPTS
+= --disable-lto
95 # architecture specific
97 ifneq ($(ADK_TARGET_GCC_CPU
),)
98 GCC_CONFOPTS
+= --with-cpu
=$(ADK_TARGET_GCC_CPU
)
101 ifneq ($(ADK_TARGET_GCC_ARCH
),)
102 GCC_CONFOPTS
+= --with-arch
=$(ADK_TARGET_GCC_ARCH
)
105 ifneq ($(ADK_TARGET_FLOAT
),)
106 GCC_CONFOPTS
+= --with-float
=$(ADK_TARGET_FLOAT
)
109 ifneq ($(ADK_TARGET_FPU
),)
110 GCC_CONFOPTS
+= --with-fpu
=$(ADK_TARGET_FPU
)
113 ifeq ($(ADK_TARGET_ARCH_ARM_WITH_THUMB
),y
)
114 GCC_CONFOPTS
+= --with-mode
=thumb
117 ifeq ($(ADK_TARGET_ARCH_METAG
),y
)
118 GCC_CONFOPTS
+= --enable-meta-default
121 ifeq ($(ADK_CPU_CF
),y
)
122 GCC_CONFOPTS
+= --enable-multilib
--with-arch
=cf
125 ifeq ($(ADK_TARGET_ARCH_M68K
)$(ADK_TARGET_ARCH_X86_64
)$(ADK_TARGET_ARCH_X86
),)
126 GCC_FINAL_CONFOPTS
+= --disable-biarch
--disable-multilib
129 ifeq ($(ADK_TARGET_ARCH_SH
),y
)
130 ifeq ($(ADK_TARGET_LITTLE_ENDIAN
),y
)
131 GCC_CONFOPTS
+= --with-endian
=little
133 GCC_CONFOPTS
+= --with-endian
=big
135 ifeq ($(ADK_CPU_SH2
),y
)
136 GCC_FINAL_CONFOPTS
+= --with-multilib-list
=m2
138 ifeq ($(ADK_CPU_SH2A
),y
)
139 GCC_FINAL_CONFOPTS
+= --with-multilib-list
=m2a
141 ifeq ($(ADK_CPU_SH3
),y
)
142 GCC_FINAL_CONFOPTS
+= --with-multilib-list
=m3
144 ifeq ($(ADK_CPU_SH4
),y
)
145 GCC_FINAL_CONFOPTS
+= --with-multilib-list
=m4
,m4-nofpu
147 ifeq ($(ADK_CPU_SH4A
),y
)
148 GCC_FINAL_CONFOPTS
+= --with-multilib-list
=m4a
,m4a-nofpu
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
156 GCC_FINAL_CONFOPTS
+= --disable-biarch
--disable-multilib
160 ifeq ($(ADK_TARGET_ARCH_X86_64
),y
)
161 ifneq ($(ADK_TARGET_ABI_X32
),)
162 GCC_FINAL_CONFOPTS
+= --with-abi
=x32
164 GCC_FINAL_CONFOPTS
+= --disable-biarch
--disable-multilib
168 ifeq ($(ADK_TARGET_ARCH_PPC
),y
)
169 GCC_CONFOPTS
+= --with-long-double-64
--enable-secureplt
172 ifneq ($(ADK_TARGET_MIPS_ABI
),)
173 GCC_CONFOPTS
+= --with-abi
=${ADK_TARGET_MIPS_ABI}
176 ifeq (${ADK_MAKE_PARALLEL},y
)
177 GCC_MAKEOPTS
+= -j
${ADK_MAKE_JOBS}
180 ifeq ($(ADK_TARGET_WITHOUT_CXX
),y
)
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
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
)
209 $(SED
) '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD
)/gcc
/configure
210 cd
$(GCC_BUILD_DIR_MINIMAL
); \
211 PATH
='$(TARGET_PATH)' \
214 CFLAGS
="-O0 -g0 -fomit-frame-pointer" \
215 CXXFLAGS
="-O0 -g0 -fomit-frame-pointer" \
216 $(WRKBUILD
)/configure \
218 --enable-languages
=c \
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
230 $(WRKBUILD
)/.headers
: $(GCC_BUILD_DIR_MINIMAL
)/.compiled
231 PATH
='$(TARGET_PATH)' $(MAKE
) -C
$(GCC_BUILD_DIR_MINIMAL
) install-gcc
234 $(GCC_BUILD_DIR_INITIAL
)/.configured
:
235 mkdir
-p
$(GCC_BUILD_DIR_INITIAL
)
236 cd
$(GCC_BUILD_DIR_INITIAL
); \
237 PATH
='$(TARGET_PATH)' \
240 CFLAGS
="-O0 -g0 -fomit-frame-pointer" \
241 CXXFLAGS
="-O0 -g0 -fomit-frame-pointer" \
242 $(WRKBUILD
)/configure \
244 ${GCC_FINAL_CONFOPTS} \
245 --enable-languages
=c \
248 --with-sysroot
=$(STAGING_TARGET_DIR
)
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
256 $(WRKBUILD
)/.configured
: $(GCC_BUILD_DIR_INITIAL
)/.compiled
257 PATH
='$(TARGET_PATH)' $(MAKE
) -C
$(GCC_BUILD_DIR_INITIAL
) install-gcc
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
264 $(WRKBUILD
)/.configured
: $(GCC_BUILD_DIR_INITIAL
)/.compiled
265 PATH
='$(TARGET_PATH)' $(MAKE
) -C
$(GCC_BUILD_DIR_INITIAL
) install-gcc install-target-libgcc
269 $(GCC_BUILD_DIR_FINAL
)/.configured
:
270 mkdir
-p
$(GCC_BUILD_DIR_FINAL
)
271 cd
$(GCC_BUILD_DIR_FINAL
); \
272 PATH
='$(TARGET_PATH)' \
275 CFLAGS_FOR_TARGET
='$(TARGET_CFLAGS)' \
276 CXXFLAGS_FOR_TARGET
='$(TARGET_CXXFLAGS)' \
277 $(WRKBUILD
)/configure \
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
287 $(WRKBUILD
)/.compiled
: $(GCC_BUILD_DIR_FINAL
)/.configured
288 cd
$(GCC_BUILD_DIR_FINAL
); \
289 PATH
='$(TARGET_PATH)' \
290 $(MAKE
) ${GCC_MAKEOPTS} all
293 $(WRKBUILD
)/.installed
: $(WRKBUILD
)/.compiled
294 cd
$(GCC_BUILD_DIR_FINAL
); \
295 PATH
='$(TARGET_PATH)' \
297 # remove duplicate tools, convert hardlinks to symlinks
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}; \
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)
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)
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
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
335 include ${ADK_TOPDIR}/mk
/toolchain.mk