oe-init-build-env 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. fi
  33. if [ -n "$BBSERVER" ]; then
  34. unset BBSERVER
  35. fi
  36. if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
  37. echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
  38. exit 1
  39. fi
  40. if [ -z "$OEROOT" ]; then
  41. OEROOT=$(dirname "$THIS_SCRIPT")
  42. OEROOT=$(readlink -f "$OEROOT")
  43. fi
  44. unset THIS_SCRIPT
  45. export OEROOT
  46. . $OEROOT/scripts/oe-buildenv-internal &&
  47. TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir || {
  48. unset OEROOT
  49. return 1
  50. }
  51. unset OEROOT
  52. [ -z "$BUILDDIR" ] || cd "$BUILDDIR"