oe-find-native-sysroot 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. #
  3. # Find a native sysroot to use - either from an in-tree Poky build or
  4. # from a toolchain installation. It then ensures the variable
  5. # $OECORE_NATIVE_SYSROOT is set to the sysroot's base directory, and sets
  6. # $PSEUDO to the path of the pseudo binary.
  7. #
  8. # This script is intended to be run within other scripts by source'ing
  9. # it, e.g:
  10. #
  11. # SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot`
  12. # . $SYSROOT_SETUP_SCRIPT
  13. #
  14. # This script will terminate execution of your calling program unless
  15. # you set a variable $SKIP_STRICT_SYSROOT_CHECK to a non-empty string
  16. # beforehand.
  17. #
  18. # Copyright (c) 2010 Intel Corp.
  19. #
  20. # This program is free software; you can redistribute it and/or modify
  21. # it under the terms of the GNU General Public License version 2 as
  22. # published by the Free Software Foundation.
  23. #
  24. # This program is distributed in the hope that it will be useful,
  25. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. # GNU General Public License for more details.
  28. #
  29. # You should have received a copy of the GNU General Public License along
  30. # with this program; if not, write to the Free Software Foundation, Inc.,
  31. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  32. if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
  33. BITBAKE=`which bitbake`
  34. if [ "x$BITBAKE" != "x" ]; then
  35. if [ "$UID" = "0" ]; then
  36. # Root cannot run bitbake unless sanity checking is disabled
  37. if [ ! -d "./conf" ]; then
  38. echo "Error: root cannot run bitbake by default, and I cannot find a ./conf directory to be able to disable sanity checking"
  39. exit 1
  40. fi
  41. touch conf/sanity.conf
  42. OECORE_NATIVE_SYSROOT=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '=' -f2 | cut -d '"' -f2`
  43. rm -f conf/sanity.conf
  44. else
  45. OECORE_NATIVE_SYSROOT=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '=' -f2 | cut -d '"' -f2`
  46. fi
  47. else
  48. echo "Error: Unable to locate your native sysroot."
  49. echo "Did you forget to source the Poky environment script?"
  50. if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then
  51. exit 1
  52. fi
  53. fi
  54. fi
  55. # Set up pseudo command
  56. if [ ! -e "$OECORE_NATIVE_SYSROOT/usr/bin/pseudo" ]; then
  57. echo "Error: Unable to find pseudo binary in $OECORE_NATIVE_SYSROOT/usr/bin/"
  58. if [ "x$POKY_DISTRO_VERSION" = "x" ]; then
  59. echo "Have you run 'bitbake meta-ide-support'?"
  60. else
  61. echo "This shouldn't happen - something is wrong with your toolchain installation"
  62. fi
  63. if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then
  64. exit 1
  65. fi
  66. fi
  67. PSEUDO="$OECORE_NATIVE_SYSROOT/usr/bin/pseudo"