blob: 54e4881059012f0fcfb11913b39536c7063fa45e [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit cross-canadian
2
3SUMMARY = "GNU cc and gcc C compilers (cross-canadian for ${TARGET_ARCH} target)"
4PN = "gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}"
5
6DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-${HOST_PREFIX}libc-for-gcc nativesdk-gettext"
7
8GCCMULTILIB = "--enable-multilib"
9
10require gcc-configure-common.inc
11
12EXTRA_OECONF_PATHS = "\
13 --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
14 --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
15 --with-sysroot=/not/exist \
16 --with-build-sysroot=${STAGING_DIR_TARGET} \
17"
18# We have to point gcc at a sysroot but we don't need to rebuild if this changes
19# e.g. we switch between different machines with different tunes.
20EXTRA_OECONF_PATHS[vardepsexclude] = "TUNE_PKGARCH"
21TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
22get_gcc_float_setting[vardepvalue] = ""
23
24#
25# gcc-cross looks and finds these in ${exec_prefix} but we're not so lucky
26# for the sdk. Hardcoding the paths ensures the build doesn't go canadian or worse.
27#
28export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
29export AS_FOR_TARGET = "${TARGET_PREFIX}as"
30export DLLTOOL_FOR_TARGET = "${TARGET_PREFIX}dlltool"
31export CC_FOR_TARGET = "${TARGET_PREFIX}gcc"
32export CXX_FOR_TARGET = "${TARGET_PREFIX}g++"
33export GCC_FOR_TARGET = "${TARGET_PREFIX}gcc"
34export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
35export LIPO_FOR_TARGET = "${TARGET_PREFIX}lipo"
36export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
37export OBJDUMP_FOR_TARGET = "${TARGET_PREFIX}objdump"
38export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
39export STRIP_FOR_TARGET = "${TARGET_PREFIX}strip"
40export WINDRES_FOR_TARGET = "${TARGET_PREFIX}windres"
41
42#
43# We need to override this and make sure the compiler can find staging
44#
45export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET}"
46
47do_configure () {
48 export CC_FOR_BUILD="${BUILD_CC}"
49 export CXX_FOR_BUILD="${BUILD_CXX}"
50 export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}"
51 export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
52 export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
53 export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
54 export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
55 export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
56 export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
57 export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
58 oe_runconf
59}
60
61do_compile () {
62 oe_runmake all-host configure-target-libgcc
63}
64
65# Having anything auto depending on gcc-cross-sdk is a really bad idea...
66EXCLUDE_FROM_SHLIBS = "1"
67
68PACKAGES = "${PN}-dbg ${PN} ${PN}-doc"
69
70FILES_${PN} = "\
71 ${exec_prefix}/bin/* \
72 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/* \
73 ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
74 ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \
75 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib* \
76 ${gcclibdir}/${TARGET_SYS}/${BINV}/include \
77 ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
78 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
79 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.* \
80 ${includedir}/c++/${BINV} \
81 ${prefix}/${TARGET_SYS}/bin/* \
82 ${prefix}/${TARGET_SYS}/lib/* \
83 ${prefix}/${TARGET_SYS}/usr/include/* \
84"
85INSANE_SKIP_${PN} += "dev-so"
86
87FILES_${PN}-dbg += " \
88 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/.debug \
89 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/plugin/.debug \
90"
91
92FILES_${PN}-doc = "\
93 ${infodir} \
94 ${mandir} \
95 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
96"
97
98EXEEXT = ""
99
100# Compute how to get from libexecdir to bindir in python (easier than shell)
101BINRELPATH = "${@os.path.relpath(d.expand("${bindir}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
102
103do_install () {
104 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h )
105 oe_runmake 'DESTDIR=${D}' install-host
106
107 # Cleanup some of the ${libdir}{,exec}/gcc stuff ...
108 rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
109 rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
110 rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
111
112 # We care about g++ not c++
113 rm -f ${D}${bindir}/*c++
114
115 # We don't care about the gcc-<version> copies
116 rm -f ${D}${bindir}/*gcc-?.?*
117
118 # We use libiberty from binutils
119 rm -f ${D}${prefix}/${TARGET_SYS}/lib/libiberty.a
120 # Not sure where the strange paths come from
121 rm -f ${D}${libdir}/../lib/libiberty.a
122 rm -f ${D}${libdir}/libiberty.a
123
124 # Cleanup empty directories which are not shipped
125 # we use rmdir instead of 'rm -f' to ensure the non empty directories are not deleted
126 # ${D}${libdir}/../lib only seems to appear with SDKMACHINE=i686
127 local empty_dirs="${D}${libdir}/../lib ${D}${prefix}/${TARGET_SYS}/lib ${D}${prefix}/${TARGET_SYS} ${D}${includedir}"
128 for i in $empty_dirs; do
129 [ -d $i ] && rmdir --ignore-fail-on-non-empty $i
130 done
131
132 # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
133 # found.
134 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
135 install -d $dest
136 suffix=${EXEEXT}
137 for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
138 if [ "$t" = "g77" -o "$t" = "gfortran" ] && [ ! -e ${D}${bindir}/${TARGET_PREFIX}$t$suffix ]; then
139 continue
140 fi
141
142 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t$suffix $dest$t$suffix
143 done
144 t=real-ld
145 ln -sf ${BINRELPATH}/${TARGET_PREFIX}ld$suffix $dest$t$suffix
146
147 # libquadmath headers need to be available in the gcc libexec dir
148 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
149 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
150 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
151
152 chown -R root:root ${D}
153
154 cross_canadian_bindirlinks
155}
156
157ELFUTILS = "nativesdk-elfutils"
158DEPENDS += "nativesdk-gmp nativesdk-mpfr nativesdk-libmpc ${ELFUTILS} nativesdk-zlib"
159RDEPENDS_${PN} += "nativesdk-mpfr nativesdk-libmpc ${ELFUTILS}"
160
161SYSTEMHEADERS = "/usr/include"
162SYSTEMLIBS = "${target_base_libdir}/"
163SYSTEMLIBS1 = "${target_libdir}/"
164
165EXTRA_OECONF += "--enable-poison-system-directories"
166
167EXTRA_OECONF += "\
168 --with-mpfr=${STAGING_DIR_HOST}${layout_exec_prefix} \
169 --with-mpc=${STAGING_DIR_HOST}${layout_exec_prefix} \
170"
171
172EXTRA_OECONF_append_libc-baremetal = " --without-headers"
173EXTRA_OECONF_remove_libc-baremetal = "--with-sysroot=/not/exist"
174EXTRA_OECONF_remove_libc-baremetal = "--with-build-sysroot=${STAGING_DIR_TARGET}"
175
176# gcc 4.7 needs -isystem
177export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET} -isystem=${target_includedir}"