isar-buildenv-internal 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. # Isar-Core Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. # Copyright (C) 2016 ilbers GmbH
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. # It is assumed ISARROOT is already defined when this is called
  21. if [ -z "$ISARROOT" ]; then
  22. echo >&2 "Error: ISARROOT is not defined!"
  23. return 1
  24. fi
  25. if [ -z "$BDIR" ]; then
  26. if [ -z "$1" ]; then
  27. BDIR="build"
  28. else
  29. BDIR="$1"
  30. if [ "$BDIR" = "/" ]; then
  31. echo >&2 "Error: / is not supported as a build directory."
  32. return 1
  33. fi
  34. # Remove any possible trailing slashes. This is used to work around
  35. # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
  36. # and hence "readlink -f new_dir_to_be_created/" returns empty.
  37. BDIR=$(echo $BDIR | sed -re 's|/+$||')
  38. BDIR=$(readlink -f "$BDIR")
  39. if [ -z "$BDIR" ]; then
  40. PARENTDIR=$(dirname "$1")
  41. echo >&2 "Error: the directory $PARENTDIR does not exist?"
  42. return 1
  43. fi
  44. fi
  45. if [ -n "$2" ]; then
  46. BITBAKEDIR="$2"
  47. fi
  48. fi
  49. if [ "${BDIR#/}" != "$BDIR" ]; then
  50. BUILDDIR="$BDIR"
  51. else
  52. BUILDDIR="$(pwd)/$BDIR"
  53. fi
  54. unset BDIR
  55. export BUILDDIR
  56. export BITBAKEDIR="${ISARROOT}/bitbake"
  57. export SCRIPTSDIR="${ISARROOT}/scripts"
  58. export TESTSUITEDIR="${ISARROOT}/testsuite"
  59. for newpath in "$BITBAKEDIR/bin" "$SCRIPTSDIR"; do
  60. # Remove any existences of $newpath from $PATH
  61. PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
  62. # Add $newpath to $PATH
  63. PATH="$newpath:$PATH"
  64. done
  65. unset newpath
  66. export PATH
  67. BBPATH="${BUILDDIR}"
  68. export BBPATH
  69. BB_ENV_EXTRAWHITE="BUILDDIR BITBAKEDIR SCRIPTSDIR TESTSUITEDIR http_proxy https_proxy ftp_proxy no_proxy GNUPGHOME"
  70. export BB_ENV_EXTRAWHITE