Install 5.4 KB

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