If it's a Resource call AddResource().
[tangerine.git] / tools / sdk / AROS-SDK-Install
blobfe206f8447acbca45a8f3236487f3cb1ee898751
1 #!/bin/sh
3 export LC_ALL=C
5 CLR="\\0033[2J\\0033[01;01H"
6 B="\\033[1m"
7 N="\\033[0;39m"
8 R="\\033[1;31m"
9 G="\\033[1;32m"
10 OK="${G}OK.${N}"
11 FAILED="${R}FAILED.${N}"
13 echo -en \
14 "${CLR}Welcome to the ${B}AROS SDK${N} installation script!\n\n"
16 echo -en \
17 "You are about to be asked a few ${B}questions${N}, each with a ${B}default${N} answer. This answer is written in ${B}bold${N} characters and put inside square brakets; in order to select it just press <${B}ENTER${N}>, whilst to override it write your own answer and then press <${B}ENTER${N}>.\n\n"
19 echo -en \
20 "Remember that in order for the installation to be successful you need a ${B}gcc${N} compiler, and related ${B}binutils${N}, able to produce ${B}i386-elf${N} executables. If you are running an x86 version of Linux, or an x86 version of any of the *BSD operating system, or an x86 version of BeOS, chances are you already have the compiler installed.\n\n"
22 echo -en \
23 "You can even install the SDK on a non-x86 architecture, provided that the proper crosscompiler is installed in the system.\n\n"
25 echo -en \
26 "If you're ready to start the installation, press <${B}ENTER${N}>\n\n"
28 read
30 cc=`which gcc 2>/dev/null`
32 while true; do
33 echo -en "Name of the gcc compiler to use, or path to it [${B}${cc}${N}]: "
34 read cc_tmp
36 if test "$cc_tmp" != ""; then
37 cc_path=$cc_tmp
38 else
39 cc_path=$cc
42 echo -en "Trying ${B}$cc_path${N}... "
43 cc_path=`which $cc_path 2>/dev/null`
45 if test "$cc_path" != ""; then
46 cc_cpu=`$cc_path -dumpmachine 2>/dev/null | cut -f1 -d-`
47 else
48 cc_cpu=
51 case $cc_cpu in
52 i?86)
53 echo -e "$OK"
54 cc_cpu=i386
55 break
58 echo -e "$FAILED"
60 if test "$cc_path" == ""; then
61 echo -e "The compiler you specified doesn't seem to exist.\n"
62 else
63 echo -e "The compiler you specified has been configured for the" \
64 "${B}$cc_cpu${N} cpu which is not supported by this SDK.\n"
66 esac
67 done
68 cc=$cc_path
70 echo Checking where the compiler stores its own include files...
71 cc_os=`$cc -dumpmachine 2>/dev/null | cut -f2- -d-`
72 if echo $cc_os | grep freebsd >/dev/null; then
73 cc_include=/usr/include
74 else
75 cc_include=`dirname \`$cc -print-libgcc-file-name\``/include
77 echo -e "${B}$cc_include${N}"
79 #find out where is the compiler going to search for the verious tools
80 cc_programs_path=`gcc -print-search-dirs | grep "programs: =" | cut -c 12-`
82 tools_list="ld nm as ar objcopy objdump objcopy ranlib strip"
84 for tool in $tools_list; do
85 echo -en "Checking ${B}$tool${N}... "
87 tool1=`which \`$cc -print-prog-name=$tool\` 2>/dev/null`
89 if test "$tool1" != ""; then
90 echo -e $OK
91 export $tool=$tool1
92 else
93 echo -e $FAILED
94 echo -e "The compiler cannot access ${B}$tool${N}, or there's no ${B}$tool${N}" \
95 "installed. Make sure you have the correct binutils installed properly."
96 exit 1
98 done
100 echo -en "Checking whether ${B}ld${N} supports the ELF format... "
102 ld_emu_all="`$ld -V 2>/dev/null` none"
104 for ld_emu in $ld_emu_all; do
105 case $ld_emu in
106 elf_${cc_cpu})
107 break
109 esac
110 done
112 if test "$ld_emu" != "none"; then
113 echo -e $OK
114 else
115 echo -e $FAILED
116 echo -e "Ld doesnt support the ELF executable format." \
117 "You need to configure the binutils so that they can work on ELF objects."
118 exit 1
121 aros_sdk_path=/usr/local/aros-sdk
123 while true; do
124 echo -en "Directory in which to install the AROS SDK [${B}${aros_sdk_path}${N}]: "
125 read aros_sdk_path_tmp
127 if test "$aros_sdk_path_tmp" != ""; then
128 aros_sdk_path=$aros_sdk_path_tmp
131 while true; do
132 if ! test -a $aros_sdk_path; then
133 echo -en "The directory ${B}$aros_sdk_path${N} does not exist, "
134 echo -en "create it [${B}yes${N}]? "
135 read answer
137 if test "$answer" = "yes" -o "$answer" = ""; then
138 break 2
141 if test "$answer" = "no"; then
142 break 1
144 else
145 if ! test -d $aros_sdk_path; then
146 echo -e "${B}$aros_sdk_path${N} already exists but it's not a directory."
147 echo -e "Chose a new name or delete the existing ${B}$aros_sdk_path${N}"
148 break 1
149 else
150 break 2
153 done
154 done
156 echo Making directories...
157 all_dirs="$aros_sdk_path/${cc_cpu}-aros/include $aros_sdk_path/bin $aros_sdk_path/${cc_cpu}-aros/lib/gcc-lib $aros_sdk_path/${cc_cpu}-aros/bin"
159 for dir in $all_dirs; do
160 if ! test -d $dir; then
161 mkdir -p $dir;
163 done
165 if ! make -s -C tools/collect-aros \
166 COLLECT-AROS=$aros_sdk_path/${cc_cpu}-aros/lib/gcc-lib/collect-aros; then
167 exit 1;
170 echo Building scripts...
171 sed "s,@aros_sdk_path@,$aros_sdk_path,g; s,@ld_emu@,$ld_emu,g; s,@cc_include@,$cc_include,g; s,@cc_cpu@,$cc_cpu,g" scripts/specs.in > $aros_sdk_path/${cc_cpu}-aros/lib/gcc-lib/specs
173 sed "s,@aros_sdk_path@,$aros_sdk_path,g; s,@ld@,$ld,g; s,@nm@,$nm,g; s,@cc@,$cc,g; s,@objdump@,$objdump,g; s,@cc_cpu@,$cc_cpu,g; s,@strip@,$strip,g" scripts/aros-gcc.in > $aros_sdk_path/${cc_cpu}-aros/bin/gcc
174 chmod a+x $aros_sdk_path/${cc_cpu}-aros/bin/gcc
176 sed "s,@aros_sdk_path@,$aros_sdk_path,g; s,@ld@,$ld,g; s,@nm@,$nm,g; s,@cc@,$cc,g; s,@objdump@,$objdump,g; s,@cc_cpu@,$cc_cpu,g; s,@cc_programs_path@,$cc_programs_path,g" scripts/aros-ld.in > $aros_sdk_path/${cc_cpu}-aros/bin/ld
177 chmod a+x $aros_sdk_path/${cc_cpu}-aros/bin/ld
179 sed "s,@strip@,$strip,g" scripts/aros-strip.in > $aros_sdk_path/${cc_cpu}-aros/bin/strip
180 chmod a+x $aros_sdk_path/${cc_cpu}-aros/bin/strip
182 cat <<EOF > AROS-SDK-Uninstall
183 #!/bin/sh
184 echo -e "${R}ATTENTION!${N} The AROS SDK is about to be uninstalled."
186 while true; do
187 echo -en "Do you really want to proceed [${B}no${N}]? "
188 read answer
190 if test "\$answer" = "yes"; then
191 echo Uninstalling the AROS SDK...
192 rm -Rf $aros_sdk_path/${cc_cpu}-aros $aros_sdk_path/bin/i386-aros-* \$0
193 break
196 if test "\$answer" = "no" -o "\$answer" = ""; then
197 echo Nothing done
198 break;
200 done
203 chmod a+x AROS-SDK-Uninstall
205 echo Copying files...
206 ln -sf $as $aros_sdk_path/${cc_cpu}-aros/bin/as
207 ln -sf $ar $aros_sdk_path/${cc_cpu}-aros/bin/ar
208 ln -sf $nm $aros_sdk_path/${cc_cpu}-aros/bin/nm
209 ln -sf $objcopy $aros_sdk_path/${cc_cpu}-aros/bin/objcopy
210 ln -sf $objdump $aros_sdk_path/${cc_cpu}-aros/bin/objdump
211 ln -sf $ranlib $aros_sdk_path/${cc_cpu}-aros/bin/ranlib
213 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/gcc $aros_sdk_path/bin/${cc_cpu}-aros-gcc
214 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/ld $aros_sdk_path/bin/${cc_cpu}-aros-ld
215 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/ar $aros_sdk_path/bin/${cc_cpu}-aros-ar
216 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/as $aros_sdk_path/bin/${cc_cpu}-aros-as
217 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/nm $aros_sdk_path/bin/${cc_cpu}-aros-nm
218 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/objcopy $aros_sdk_path/bin/${cc_cpu}-aros-objcopy
219 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/objdump $aros_sdk_path/bin/${cc_cpu}-aros-objdump
220 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/ranlib $aros_sdk_path/bin/${cc_cpu}-aros-ranlib
221 ln -sf $aros_sdk_path/${cc_cpu}-aros/bin/strip $aros_sdk_path/bin/${cc_cpu}-aros-strip
223 cp -a $cc_cpu/lib/* $aros_sdk_path/${cc_cpu}-aros/lib/
224 cp -a $cc_cpu/include/* $aros_sdk_path/${cc_cpu}-aros/include/
226 echo -e "\nEverything done. Remember to add ${B}$aros_sdk_path/bin${N} to your ${B}PATH${N} environment variable before using the AROS SDK."