oe-init-build-env 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. # OE Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. #
  20. # Normally this is called as '. ./oe-init-build-env <builddir>'
  21. #
  22. # This works in most shells (not dash), but not all of them pass the arguments
  23. # when being sourced. To workaround the shell limitation use "set <builddir>"
  24. # prior to sourcing this script.
  25. #
  26. if [ -n "$BASH_SOURCE" ]; then
  27. THIS_SCRIPT=$BASH_SOURCE
  28. elif [ -n "$ZSH_NAME" ]; then
  29. THIS_SCRIPT=$0
  30. else
  31. THIS_SCRIPT="$(pwd)/oe-init-build-env"
  32. if [ ! -e "$THIS_SCRIPT" ]; then
  33. echo "Error: $THIS_SCRIPT doesn't exist!" >&2
  34. echo "Please run this script in oe-init-build-env's directory." >&2
  35. exit 1
  36. fi
  37. fi
  38. if [ -n "$BBSERVER" ]; then
  39. unset BBSERVER
  40. fi
  41. if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
  42. echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" >&2
  43. exit 1
  44. fi
  45. if [ -z "$OEROOT" ]; then
  46. OEROOT=$(dirname "$THIS_SCRIPT")
  47. OEROOT=$(readlink -f "$OEROOT")
  48. fi
  49. unset THIS_SCRIPT
  50. export OEROOT
  51. . $OEROOT/scripts/oe-buildenv-internal &&
  52. TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir || {
  53. unset OEROOT
  54. return 1
  55. }
  56. unset OEROOT
  57. [ -z "$BUILDDIR" ] || cd "$BUILDDIR"