global: Corrected absolute paths in bin/ symbolic links
[h316.git] / setup.sh
CommitLineData
f4c2dcf3 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
13write_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
19export H316=$H316
20export PATH=\$H316/bin:\$PATH
21EOF
22}
23
24write_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
31export H316=$H316
32echo "Now you are in the H316 build environment."
33bash --init-file \$H316/h316rc
34echo "Left H316 build environment."
35EOF
36chmod +x H316.sh
37}
38
39good_luck(){
40cat <<EOF
41
42***************************************************************
43
44Now the necessary environment for the H316 build system
45has been set up.
46
47You have one possibility:
48a) Source the h316rc file into your current shell!
49
50Then you can run
51 "make" or "make all"
52to build all the stuff inside. When make successfully finishes,
53you are ready to go.
54
55Have a lot of fun and good luck!
56(You should have installed GNU make, GCC, bash and friends!)
57
58***************************************************************
59
60EOF
61}
62
63
64echo -e "Determining H316 root directory."
65if [ ! -f bin/asm ]; then
66 echo "Error! This script MUST be run from H316 root directory!"
67 exit 1
68fi
69H316=$PWD
70echo -e "H316 root directory is: $H316.\n"
71
72echo -e "Generating SIMH simulator settings."
73
74search_simh=yes
75while [ ! "$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 \
96SIMH 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
104done
105
106echo "Generating simulator symlink:"
107rm -f $H316/bin/h316
108ln -sf $simh_set $H316/bin/h316
109echo -e "$simh_set => $H316/bin/h316\n"
110
111
112write_rc
113#write_script
114good_luck
115exit 0