1
0

prep_env.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/sh
  2. ## Copyright (c) 2014 Minoca Corp. All Rights Reserved.
  3. ##
  4. ## Script Name:
  5. ##
  6. ## prep_env.sh
  7. ##
  8. ## Abstract:
  9. ##
  10. ## This script prepares the build environment.
  11. ##
  12. ## Author:
  13. ##
  14. ## Evan Green 18-Jun-2014
  15. ##
  16. ## Environment:
  17. ##
  18. ## Minoca Build
  19. ##
  20. set -e
  21. if test -z "$SRCROOT"; then
  22. SRCROOT=`pwd`/src
  23. fi
  24. if test -z "$ARCH"; then
  25. echo "ARCH must be set."
  26. exit 1
  27. fi
  28. export TMPDIR=$PWD
  29. export TEMP=$TMPDIR
  30. echo PATH=$PATH
  31. echo -n Current Directory is
  32. pwd
  33. set
  34. SAVED_IFS="$IFS"
  35. IFS=':'
  36. ##
  37. ## Find the bin root.
  38. ##
  39. BINROOT=
  40. for path in $PATH; do
  41. if test -x $path/ld; then
  42. BINROOT=$path
  43. break
  44. fi
  45. done
  46. if test -z $BINROOT; then
  47. echo "Failed to find BINROOT."
  48. exit 1
  49. fi
  50. ##
  51. ## Find swiss too.
  52. ##
  53. SWISSPATH=
  54. for path in $PATH; do
  55. if test -x $path/swiss; then
  56. SWISSPATH=$path
  57. break
  58. fi
  59. done
  60. if test -z $SWISSPATH; then
  61. echo "Failed to find SWISSPATH."
  62. exit 1
  63. fi
  64. IFS="$SAVED_IFS"
  65. ##
  66. ## Link the binutils apps to their full names as the OS makefile invokes them
  67. ## that way.
  68. ##
  69. if test $ARCH = x86; then
  70. TRIO=i686-pc-minoca
  71. if test "x$VARIANT" = "xq"; then
  72. TRIO=i586-pc-minoca
  73. fi
  74. elif test $ARCH = armv7; then
  75. TRIO=arm-none-minoca
  76. elif test $ARCH = armv6; then
  77. TRIO=arm-none-minoca
  78. else
  79. echo Unknown arch $ARCH.
  80. exit 1
  81. fi
  82. for app in ar as ld objcopy strip; do
  83. if ! test -x $BINROOT/$TRIO-$app; then
  84. ln -s $BINROOT/$app $BINROOT/$TRIO-$app
  85. fi
  86. done
  87. ##
  88. ## Link the swiss binaries as parts of third-party need to find them directly.
  89. ##
  90. for app in `$SWISSPATH/swiss --list`; do
  91. if ! test -x $BINROOT/$app; then
  92. ln -s $SWISSPATH/swiss $BINROOT/$app
  93. fi
  94. done