Install 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/bash
  2. # Install - GCC4TI source installation wizard
  3. # (created from TIGCC source installation wizard)
  4. #
  5. # Copyright (C) 2004 Kevin Kofler
  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, or (at your option)
  10. # 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 Foundation,
  19. # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. # Try to find a suitable dialog program
  21. if [ -z "$DIALOG" ]
  22. then xdpyinfo >/dev/null 2>/dev/null && { type kdialog >/dev/null 2>/dev/null && export DIALOG=kdialog || { type xdialog >/dev/null 2>/dev/null && export DIALOG=xdialog || { type gdialog >/dev/null 2>/dev/null && export DIALOG=gdialog || { type cdialog >/dev/null 2>/dev/null && export DIALOG=cdialog || { type dialog >/dev/null 2>/dev/null && export DIALOG=dialog || { export DIALOG=none; }; }; }; }; }; } || { type cdialog >/dev/null 2>/dev/null && export DIALOG=cdialog || { type dialog >/dev/null 2>/dev/null && export DIALOG=dialog || { export DIALOG=none; }; }; }
  23. fi
  24. # If we don't have a dialog program, present a simple bash interface
  25. if [ "$DIALOG" = none ]
  26. then
  27. echo "GCC4TI Installation Wizard"
  28. if [ -z "$TIGCC" ]
  29. then TIGCC="/usr/local/share/gcc4ti"
  30. fi
  31. echo -n "Destination directory ($TIGCC): "
  32. read TIGCCnew
  33. if [ ! -z "$TIGCCnew" ]
  34. then TIGCC="$TIGCCnew"
  35. fi
  36. export TIGCC
  37. if [ -z "$CC" ]
  38. then CC="gcc"
  39. fi
  40. echo -n "Bootstrap compiler ($CC): "
  41. read CCnew
  42. if [ ! -z "$CCnew" ]
  43. then CC="$CCnew"
  44. fi
  45. export CC
  46. # Check if this is Apple GCC
  47. if [ ! -z "`$CC -v 2>&1 | grep Apple`" ]
  48. then echo "Apple GCC detected, adding -no-cpp-precomp and -DHAVE_DESIGNATED_INITIALIZERS=0 to \$CC"
  49. export CC="$CC -no-cpp-precomp -DHAVE_DESIGNATED_INITIALIZERS=0"
  50. fi
  51. if [ -z "$CFLAGS" ]
  52. then CFLAGS="-Os -s -fno-exceptions -fomit-frame-pointer"
  53. fi
  54. echo -n "Optimization flags ($CFLAGS): "
  55. read CFLAGSnew
  56. if [ ! -z "$CFLAGSnew" ]
  57. then CFLAGS="$CFLAGSnew"
  58. fi
  59. export CFLAGS
  60. # Apply GCC4TI patch if desired
  61. echo -n "Apply GCC4TI patch [Y/n/c]? "
  62. read -n 1 ApplyGCC4TIPatch
  63. echo
  64. if [ "$ApplyGCC4TIPatch" = c -o "$ApplyGCC4TIPatch" = C ]
  65. then { echo Install: Canceled by user; exit 1; }
  66. fi
  67. if [ -z "$ApplyGCC4TIPatch" -o "$ApplyGCC4TIPatch" = y -o "$ApplyGCC4TIPatch" = Y ]
  68. then ./Install_step_1
  69. fi
  70. # Complete the installation
  71. ./Install_All_nopatch
  72. # Now offer to install environment variables
  73. echo -n "Add environment settings (\$TIGCC, \$PATH) to bashrc [Y/n]? "
  74. read -n 1 AddEnvSettings
  75. echo
  76. if [ -z "$AddEnvSettings" -o "$AddEnvSettings" = y -o "$AddEnvSettings" = Y ]
  77. then { $TIGCC/bin/envreg; echo "Done. You must restart bash for the new environment settings to take effect."; exit 0; }
  78. fi
  79. echo "Done. Make sure you set \$TIGCC to \"$TIGCC\" and add \$TIGCC/bin to your \$PATH before using GCC4TI."
  80. exit 0
  81. fi
  82. # cdialog and xdialog output to stderr by default.
  83. if [ "$DIALOG" = dialog -o "$DIALOG" = cdialog -o "$DIALOG" = xdialog ]
  84. then DIALOG="$DIALOG --stdout"
  85. fi
  86. # Now this is stupid. dialog REQUIRES size parameters (which can be "0 0" for
  87. # auto-sizing). kdialog does NOT like them.
  88. if [ "$DIALOG" = kdialog ]
  89. then DLGSIZE=""
  90. else DLGSIZE="0 0"
  91. fi
  92. # Now this is just as stupid. Zenity's gdialog script does NOT allow --,
  93. # everything else REQUIRES it for strings starting with a dash. It is also
  94. # broken with respect to escaping.
  95. if [ -z "`$DIALOG --version | grep zenity`" ]
  96. then DASHDASH="--";BACKSLASH=""
  97. else DASHDASH="";BACKSLASH="\\"
  98. fi
  99. if [ -z "$TIGCC" ]
  100. then TIGCC="/usr/local/share/gcc4ti"
  101. fi
  102. TIGCC="`$DIALOG --title "GCC4TI Installation Wizard" --inputbox "Destination directory:" $DLGSIZE $DASHDASH "$TIGCC"`"
  103. if [ $? != 0 ]
  104. then { echo Install: Canceled by user; exit 1; }
  105. fi
  106. export TIGCC
  107. if [ -z "$CC" ]
  108. then CC="gcc"
  109. fi
  110. CC="`$DIALOG --title "GCC4TI Installation Wizard" --inputbox "Bootstrap compiler:" $DLGSIZE $DASHDASH "$CC"`"
  111. if [ $? != 0 ]
  112. then { echo Install: Canceled by user; exit 1; }
  113. fi
  114. export CC
  115. # Check if this is Apple GCC
  116. if [ ! -z "`$CC -v 2>&1 | grep Apple`" ]
  117. then $DIALOG --title "GCC4TI Installation Wizard" --msgbox "Apple GCC detected, adding -no-cpp-precomp and -DHAVE_DESIGNATED_INITIALIZERS=0 to \$CC" $DLGSIZE
  118. export CC="$CC -no-cpp-precomp -DHAVE_DESIGNATED_INITIALIZERS=0"
  119. fi
  120. if [ -z "$CFLAGS" ]
  121. then CFLAGS="-Os -s -fno-exceptions -fomit-frame-pointer"
  122. fi
  123. CFLAGS="`$DIALOG --title "GCC4TI Installation Wizard" --inputbox "Optimization flags:" $DLGSIZE $DASHDASH "$CFLAGS"`"
  124. if [ $? != 0 ]
  125. then { echo Install: Canceled by user; exit 1; }
  126. fi
  127. export CFLAGS
  128. # Apply GCC4TI patch if desired
  129. $DIALOG --title "GCC4TI Installation Wizard" --yesno "Apply GCC4TI patch?" $DLGSIZE && ./Install_step_1
  130. # Complete the installation
  131. ./Install_All_nopatch
  132. # Now offer to install environment variables
  133. $DIALOG --title "GCC4TI Installation Wizard" --yesno "Add environment settings ($BACKSLASH\$TIGCC, $BACKSLASH\$PATH) to bashrc?" $DLGSIZE && { $TIGCC/bin/envreg; $DIALOG --title "GCC4TI Installation Wizard" --msgbox "Done. You must restart bash for the new environment settings to take effect." $DLGSIZE; exit 0; }
  134. $DIALOG --title "GCC4TI Installation Wizard" --msgbox "Done. Make sure you set $BACKSLASH\$TIGCC to $BACKSLASH\"$TIGCC$BACKSLASH\" and add $BACKSLASH\$TIGCC/bin to your $BACKSLASH\$PATH before using GCC4TI." $DLGSIZE