setenv.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ##
  2. ## Small script to set the correct environment variables needed for building
  3. ## Minoca OS. Source this into your current environment by running:
  4. ## . ./setenv.sh
  5. ##
  6. if [ "`basename -- $0`" = "setenv.sh" ]; then
  7. echo "Error: This script is meant to be sourced, not run. Use: '. $0' to \
  8. source it into your current environment"
  9. fi
  10. if [ -z "$SRCROOT" ]; then
  11. cd ..
  12. export SRCROOT=$PWD
  13. cd - > /dev/null
  14. fi
  15. if [ -z "$ARCH" ]; then
  16. if [ "`uname -s`" = "Minoca" ]; then
  17. case "`uname -m`" in
  18. i586) export ARCH=x86 VARIANT=q ;;
  19. i686) export ARCH=x86 ;;
  20. armv6) export ARCH=armv6 ;;
  21. armv7) export ARCH=armv7 ;;
  22. *) export ARCH=x86 ;;
  23. esac
  24. else
  25. export ARCH=x86
  26. fi
  27. fi
  28. if [ -z "$DEBUG" ]; then
  29. export DEBUG=dbg
  30. fi
  31. if ! echo "$PATH" | grep -q "$SRCROOT/$ARCH$VARIANT$DEBUG/tools/bin"; then
  32. OLDPATH="$PATH"
  33. PATH="$SRCROOT/$ARCH$VARIANT$DEBUG/tools/bin:$OLDPATH"
  34. fi
  35. ##
  36. ## Perform some sanity checks on the environment.
  37. ##
  38. if ! [ -d "$SRCROOT/os" ]; then
  39. echo "Warning: I don't see the os repository at $SRCROOT/os."
  40. fi
  41. case "$ARCH$VARIANT" in
  42. x86q) target=i586-pc-minoca ;;
  43. x86) target=i686-pc-minoca ;;
  44. armv[67]) target=arm-none-minoca ;;
  45. x64) target=x86_64-none-minoca ;;
  46. *) echo "Warning: Unknown architecture $ARCH$VARIANT."
  47. esac
  48. tools="awk
  49. $target-ld
  50. $target-ar
  51. $target-gcc
  52. $target-g++
  53. iasl
  54. m4
  55. make"
  56. failed_tools=
  57. for tool in $tools; do
  58. if ! which $tool > /dev/null 2>&1 && \
  59. ! which $tool.exe > /dev/null 2>&1; then
  60. failed_tools="$failed_tools $tool"
  61. fi
  62. done
  63. if [ "$failed_tools" ]; then
  64. if [ -d "$SRCROOT/third-party" ]; then
  65. echo "Warning: Failed to find tools$failed_tools. You may need to \
  66. run 'make tools' in $SRCROOT/third-party."
  67. else
  68. echo "Warning: Failed to find tools$failed_tools. You may need to \
  69. download the latest Minoca toolchain for your build OS, or rebuild the tools
  70. from source by grabbing the third-party repository and running 'make tools'."
  71. fi
  72. else
  73. echo "Minoca build environment for $ARCH$VARIANT."
  74. fi
  75. unset target tools failed_tools