gcc-cross-canadian.inc 6.8 KB

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