| 1 | #!/bin/bash |
| 2 | |
| 3 | # |
| 4 | # This script produces a h316rc file which has to be sourced by |
| 5 | # the user's shell. |
| 6 | # |
| 7 | # Usage: Just run and answer the questions. Then use |
| 8 | # the h316rc file by typing ". h316rc". You |
| 9 | # can also include that into your .bashrc etc. |
| 10 | # All paths in the file will be absolut. |
| 11 | |
| 12 | |
| 13 | write_rc(){ |
| 14 | echo "Writing out configuration file." |
| 15 | rm -f h316rc |
| 16 | touch h316rc || echo "Error! Could not write to h316rc." |
| 17 | cat > h316rc <<EOF |
| 18 | # h316rc generated by Hachti's install.sh |
| 19 | export H316=$H316 |
| 20 | export PATH=\$H316/bin:\$PATH |
| 21 | EOF |
| 22 | } |
| 23 | |
| 24 | write_script(){ |
| 25 | echo "Writing out start script." |
| 26 | rm -f H316.sh |
| 27 | touch H316.sh || echo "Error! Could not write to H316.sh." |
| 28 | cat > H316.sh <<EOF |
| 29 | #!/bin/bash |
| 30 | # H316.sh generated by Hachti's install.sh |
| 31 | export H316=$H316 |
| 32 | echo "Now you are in the H316 build environment." |
| 33 | bash --init-file \$H316/h316rc |
| 34 | echo "Left H316 build environment." |
| 35 | EOF |
| 36 | chmod +x H316.sh |
| 37 | } |
| 38 | |
| 39 | good_luck(){ |
| 40 | cat <<EOF |
| 41 | |
| 42 | *************************************************************** |
| 43 | |
| 44 | Now the necessary environment for the H316 build system |
| 45 | has been set up. |
| 46 | |
| 47 | You have one possibility: |
| 48 | a) Source the h316rc file into your current shell! |
| 49 | |
| 50 | Then you can run |
| 51 | "make" or "make all" |
| 52 | to build all the stuff inside. When make successfully finishes, |
| 53 | you are ready to go. |
| 54 | |
| 55 | Have a lot of fun and good luck! |
| 56 | (You should have installed GNU make, GCC, bash and friends!) |
| 57 | |
| 58 | *************************************************************** |
| 59 | |
| 60 | EOF |
| 61 | } |
| 62 | |
| 63 | |
| 64 | echo -e "Determining H316 root directory." |
| 65 | if [ ! -f bin/asm ]; then |
| 66 | echo "Error! This script MUST be run from H316 root directory!" |
| 67 | exit 1 |
| 68 | fi |
| 69 | H316=$PWD |
| 70 | echo -e "H316 root directory is: $H316.\n" |
| 71 | |
| 72 | echo -e "Generating SIMH simulator settings." |
| 73 | |
| 74 | search_simh=yes |
| 75 | while [ ! "$simh_set" ]; do |
| 76 | |
| 77 | if [ "$search_simh" ]; then |
| 78 | simh=`which h316` |
| 79 | fi |
| 80 | search_simh="" |
| 81 | |
| 82 | if [ "$simh" ]; then |
| 83 | echo -e "Using SIMH executable: $simh" |
| 84 | echo -ne "Is that correct? [Y/n]:" |
| 85 | read answer |
| 86 | echo |
| 87 | if [ "$answer" == "n" ]; then |
| 88 | simh="" |
| 89 | else |
| 90 | simh_set=$simh |
| 91 | fi |
| 92 | fi |
| 93 | |
| 94 | if [ ! "$simh" ]; then |
| 95 | echo -ne "Please specify absolute path to \ |
| 96 | SIMH h316 executable:" |
| 97 | read simh |
| 98 | echo |
| 99 | if [ ! -x "$simh" ]; then |
| 100 | echo "Error! Not an executable: $simh"; |
| 101 | simh="" |
| 102 | fi |
| 103 | fi |
| 104 | done |
| 105 | |
| 106 | echo "Generating simulator symlink:" |
| 107 | rm -f $H316/bin/h316 |
| 108 | ln -sf $simh_set $H316/bin/h316 |
| 109 | echo -e "$simh_set => $H316/bin/h316\n" |
| 110 | |
| 111 | |
| 112 | write_rc |
| 113 | #write_script |
| 114 | good_luck |
| 115 | exit 0 |