gcc-cross-canadian.inc 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. inherit cross-canadian
  2. SUMMARY = "GNU cc and gcc C compilers (cross-canadian for ${TARGET_ARCH} target)"
  3. PN = "gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}"
  4. DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${HOST_PREFIX}gcc-crosssdk virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-libc nativesdk-gettext flex-native virtual/libc"
  5. GCCMULTILIB = "--disable-multilib"
  6. GCCTHREADS = "no"
  7. require gcc-configure-common.inc
  8. EXTRA_OECONF_PATHS = "\
  9. --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
  10. --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
  11. --with-sysroot=/not/exist \
  12. --with-build-sysroot=${STAGING_DIR_TARGET} \
  13. --with-long-double-128 \
  14. --disable-__cxa_atexit \
  15. --disable-nls \
  16. --disable-tm-clone-registry \
  17. --disable-shared \
  18. --enable-static \
  19. --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
  20. "
  21. # We have to point gcc at a sysroot but we don't need to rebuild if this changes
  22. # e.g. we switch between different machines with different tunes.
  23. EXTRA_OECONF_PATHS[vardepsexclude] = "TUNE_PKGARCH"
  24. TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
  25. get_gcc_float_setting[vardepvalue] = ""
  26. #
  27. # gcc-cross looks and finds these in ${exec_prefix} but we're not so lucky
  28. # for the sdk. Hardcoding the paths ensures the build doesn't go canadian or worse.
  29. #
  30. export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
  31. export AS_FOR_TARGET = "${TARGET_PREFIX}as"
  32. export DLLTOOL_FOR_TARGET = "${TARGET_PREFIX}dlltool"
  33. export CC_FOR_TARGET = "${TARGET_PREFIX}gcc"
  34. export CXX_FOR_TARGET = "${TARGET_PREFIX}g++"
  35. export GCC_FOR_TARGET = "${TARGET_PREFIX}gcc"
  36. export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
  37. export LIPO_FOR_TARGET = "${TARGET_PREFIX}lipo"
  38. export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
  39. export OBJDUMP_FOR_TARGET = "${TARGET_PREFIX}objdump"
  40. export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
  41. export STRIP_FOR_TARGET = "${TARGET_PREFIX}strip"
  42. export WINDRES_FOR_TARGET = "${TARGET_PREFIX}windres"
  43. #
  44. # We need to override this and make sure the compiler can find staging
  45. #
  46. export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET}"
  47. do_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. do_compile () {
  61. oe_runmake all-host configure-target-libgcc
  62. (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h)
  63. }
  64. PACKAGES = "${PN}-dbg ${PN} ${PN}-doc"
  65. FILES:${PN} = "\
  66. ${exec_prefix}/bin/* \
  67. ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/* \
  68. ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
  69. ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \
  70. ${gcclibdir}/${TARGET_SYS}/${BINV}/lib* \
  71. ${gcclibdir}/${TARGET_SYS}/${BINV}/include \
  72. ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
  73. ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
  74. ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.* \
  75. ${libdir}/bfd-plugins/*.so \
  76. ${includedir}/c++/${BINV} \
  77. ${prefix}/${TARGET_SYS}/bin/* \
  78. ${prefix}/${TARGET_SYS}/lib/* \
  79. ${prefix}/${TARGET_SYS}${target_includedir}/* \
  80. "
  81. INSANE_SKIP:${PN} += "dev-so"
  82. FILES:${PN}-doc = "\
  83. ${infodir} \
  84. ${mandir} \
  85. ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
  86. "
  87. EXEEXT = ""
  88. # Compute how to get from libexecdir to bindir in python (easier than shell)
  89. BINRELPATH = "${@os.path.relpath(d.expand("${bindir}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
  90. # linker plugin path
  91. LIBRELPATH = "${@os.path.relpath(d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"), d.expand("${libdir}/bfd-plugins"))}"
  92. do_install () {
  93. ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h )
  94. oe_runmake 'DESTDIR=${D}' install-host
  95. # Cleanup some of the ${libdir}{,exec}/gcc stuff ...
  96. rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
  97. rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
  98. rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
  99. # We care about g++ not c++
  100. rm -f ${D}${bindir}/*c++
  101. # We don't care about the gcc-<version> copies
  102. rm -f ${D}${bindir}/*gcc-${BINV}*
  103. # Cleanup empty directories which are not shipped
  104. # we use rmdir instead of 'rm -f' to ensure the non empty directories are not deleted
  105. # ${D}${libdir}/../lib only seems to appear with SDKMACHINE=i686
  106. local empty_dirs="${D}${libdir}/../lib ${D}${prefix}/${TARGET_SYS}/lib ${D}${prefix}/${TARGET_SYS} ${D}${includedir}"
  107. for i in $empty_dirs; do
  108. [ -d $i ] && rmdir --ignore-fail-on-non-empty $i
  109. done
  110. # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
  111. # found.
  112. dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
  113. install -d $dest
  114. suffix=${EXEEXT}
  115. for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
  116. if [ "$t" = "g77" -o "$t" = "gfortran" ] && [ ! -e ${D}${bindir}/${TARGET_PREFIX}$t$suffix ]; then
  117. continue
  118. fi
  119. ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t$suffix $dest$t$suffix
  120. done
  121. t=real-ld
  122. ln -sf ${BINRELPATH}/${TARGET_PREFIX}ld$suffix $dest$t$suffix
  123. # libquadmath headers need to be available in the gcc libexec dir
  124. install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
  125. cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
  126. cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
  127. # install LTO linker plugins where binutils tools can find it
  128. install -d ${D}${libdir}/bfd-plugins
  129. ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
  130. chown -R root:root ${D}
  131. cross_canadian_bindirlinks
  132. for i in linux ${CANADIANEXTRAOS}
  133. do
  134. for v in ${CANADIANEXTRAVENDOR}
  135. do
  136. d=${D}${bindir}/../${TARGET_ARCH}$v-$i
  137. install -d $d
  138. for j in ${TARGET_PREFIX}gcc${EXEEXT} ${TARGET_PREFIX}g++${EXEEXT}
  139. do
  140. p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
  141. case $i in
  142. *musl*)
  143. rm -rf $d/$p
  144. echo "#!/usr/bin/env sh" > $d/$p
  145. echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p
  146. chmod 0755 $d/$p
  147. ;;
  148. *)
  149. ;;
  150. esac
  151. done
  152. done
  153. done
  154. }
  155. ELFUTILS = "nativesdk-elfutils"
  156. DEPENDS += "nativesdk-gmp nativesdk-mpfr nativesdk-libmpc ${ELFUTILS} nativesdk-zlib"
  157. RDEPENDS:${PN} += "nativesdk-mpfr nativesdk-libmpc ${ELFUTILS}"
  158. SYSTEMHEADERS = "${target_includedir}/"
  159. SYSTEMLIBS = "${target_base_libdir}/"
  160. SYSTEMLIBS1 = "${target_libdir}/"
  161. EXTRA_OECONF += "--enable-poison-system-directories"
  162. EXTRA_OECONF:remove:elf = "--with-sysroot=/not/exist"
  163. EXTRA_OECONF:remove:eabi = "--with-sysroot=/not/exist"
  164. EXTRA_OECONF:append:elf = " --without-headers --with-newlib"
  165. EXTRA_OECONF:append:eabi = " --without-headers --with-newlib"
  166. # gcc 4.7 needs -isystem
  167. export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET} -isystem=${target_includedir}"