1 | #!/bin/bash |
---|
2 | # |
---|
3 | # surfex install script and documentation |
---|
4 | # --------------------------------------- |
---|
5 | # |
---|
6 | # Short Version of the Installation Intructions: |
---|
7 | # ---------------------------------------------- |
---|
8 | # (For longer installation instructions, see further down.) |
---|
9 | # |
---|
10 | # Run this script by typing the following into a shell: |
---|
11 | # ./INSTALL_WINDOWS |
---|
12 | # This writes a script called "surfex" to a directory contained in your bash path. |
---|
13 | # You can then start surfex by typing: |
---|
14 | # surfex |
---|
15 | # |
---|
16 | |
---|
17 | # |
---|
18 | # surfex: |
---|
19 | # ------- |
---|
20 | # |
---|
21 | # visualizing real algebraic surfaces using several visualization tools: |
---|
22 | # - raytracing: surf |
---|
23 | # - triangulation: (display: JavaView) |
---|
24 | # |
---|
25 | # main features: |
---|
26 | # - high quality output for printed publications and for the internet |
---|
27 | # - interactivity, in particular: intuitive rotation/scaling |
---|
28 | # |
---|
29 | # @version 0.89.07, 2006 / 11 / 23 |
---|
30 | # |
---|
31 | # @author Stephan Holzer, Oliver Labs |
---|
32 | # idea: Oliver Labs (2001) during the Dagstuhl workshop Algebra, Geometry, and Software Systems |
---|
33 | # this version is based on some older code by Richard Morris and Oliver Labs |
---|
34 | # |
---|
35 | # this file: Oliver Labs |
---|
36 | # |
---|
37 | # @address previous versions: |
---|
38 | # - (until Oct. 2005): department of mathematics, University of Mainz, Germany |
---|
39 | # - (until March 2006): RICAM at Linz, Austria |
---|
40 | # - since then: University of the Saarland (Saarbruecken, Germany) |
---|
41 | # |
---|
42 | # @web www.surfex.algebraicsurface.net |
---|
43 | # |
---|
44 | |
---|
45 | |
---|
46 | # |
---|
47 | # INSTALL_WINDOWS surfex on Linux/Unix/Mac OS X |
---|
48 | # ------------------------------------- |
---|
49 | # |
---|
50 | # - Requisites to be able to run "surfex" (all are freely available): |
---|
51 | # - required: Java, version >= 1.4.2 (www.java.sun.com) |
---|
52 | # - required: surf (www.surf.sourceforge.net) |
---|
53 | # - optional (for movies): convert (www.imagemagick.org) |
---|
54 | # |
---|
55 | # - Download surfex_<version>.tar.gz to a directory of your choice. |
---|
56 | # In the sequel, we will call this directory install_dir. |
---|
57 | # The current version of surfex should always be available from: |
---|
58 | # www.surfex.algebraicsurface.net |
---|
59 | # |
---|
60 | # - Uncompress the file, e.g. by typing the following into a shell: |
---|
61 | # tar -xzf surfex_<version>.tar.gz |
---|
62 | # |
---|
63 | # - This should have created a sub-directory called surfex_<version>. |
---|
64 | # Change to this directory, e.g. by typing the following into the shell: |
---|
65 | # cd surfex_<version> |
---|
66 | # |
---|
67 | # - Run the INSTALL_WINDOWS script, e.g. by typing the following into the shell: |
---|
68 | # ./INSTALL_WINDOWS |
---|
69 | # |
---|
70 | # - This produces a script, called "surfex" and copies it to a directory contained in your bash path. |
---|
71 | # |
---|
72 | |
---|
73 | # |
---|
74 | # The installation program: |
---|
75 | # ------------------------- |
---|
76 | |
---|
77 | echo |
---|
78 | |
---|
79 | mytmp=/tmp/tmp.txt |
---|
80 | mytmp2=/tmp/tmp2.txt |
---|
81 | failmsg="" |
---|
82 | |
---|
83 | my_java_prg=java.exe |
---|
84 | |
---|
85 | my_surf_prg=surf.exe |
---|
86 | my_surf_test="surf -n testsurf.pic" |
---|
87 | my_surf_out="testsurf.jpg" |
---|
88 | |
---|
89 | my_convert_prg=convert.exe |
---|
90 | my_convert_test="convert surfex_logo.png surfex_logo.gif" |
---|
91 | my_convert_out="surfex_logo.gif" |
---|
92 | |
---|
93 | # |
---|
94 | # try to locate the helper tools we need: |
---|
95 | # |
---|
96 | |
---|
97 | function findbinpath() { |
---|
98 | mybinpath="" |
---|
99 | |
---|
100 | # first, try to use the user's private bin directory for surfex: |
---|
101 | tstbinpath=~/bin |
---|
102 | echo $PATH | grep "$tstbinpath" >$mytmp |
---|
103 | if [ -s $mytmp ] && [ -a $tstbinpath ]; then return 0; fi |
---|
104 | |
---|
105 | echo |
---|
106 | echo |
---|
107 | echo ">>> $tstbinpath is not contained in your bash path." |
---|
108 | echo |
---|
109 | echo "This is the standard location for surfex." |
---|
110 | echo "Should INSTALL_WINDOWS add this directory to the bash path for you now?" |
---|
111 | echo "(Please, type 'yes' or 'no' and then press ENTER.)" |
---|
112 | read |
---|
113 | answer="$REPLY" |
---|
114 | echo |
---|
115 | echo "REPLY:$answer." |
---|
116 | echo |
---|
117 | if [ "$answer" == "yes" ] && ! [ -d $tstbinpath ]; then mkdir $tstbinpath; fi |
---|
118 | failmsg="$tstbinpath could not be created. |
---|
119 | Please solve this problem (probably you have to login as superuser (root), and then rerun INSTALL_WINDOWS." |
---|
120 | if [ "$answer" == "yes" ] && ! [ -d $tstbinpath ]; then failexit; fi |
---|
121 | if [ "$answer" == "yes" ] && [ -d $tstbinpath ]; then echo "export PATH=$tstbinpath:\$PATH" >>~/.bashrc ; fi |
---|
122 | if [ "$answer" == "yes" ] && [ -d $tstbinpath ]; then echo "export PATH=$tstbinpath:\$PATH" >>~/.profile ; fi |
---|
123 | if [ "$answer" == "yes" ] && [ -d $tstbinpath ]; then export PATH=$tstbinpath:$PATH; fi |
---|
124 | if [ "$answer" == "yes" ] && [ -d $tstbinpath ]; then return 0; fi |
---|
125 | |
---|
126 | # |
---|
127 | # if the user did not want to use the user's private bin directory: |
---|
128 | # |
---|
129 | echo "Okay, we try the directory /usr/local/bin then..."; |
---|
130 | tstbinpath=/usr/local/bin |
---|
131 | echo $PATH | grep "$tstbinpath" >$mytmp |
---|
132 | if [ -s $mytmp ]; then return 0; fi |
---|
133 | |
---|
134 | tstbinpath="" |
---|
135 | failmsg="We could not find a nice path in your bash path. |
---|
136 | You chose not to create ~/bin. |
---|
137 | So, please, solve the problem on your own or contact us via our website |
---|
138 | www.surfex.AlgebraicSurface.net." |
---|
139 | failexit |
---|
140 | } |
---|
141 | |
---|
142 | function copytopath() { |
---|
143 | # echo "copytopath()" |
---|
144 | if [ -e $knownpath ]; then |
---|
145 | echo $knownpath > $mytmp |
---|
146 | else |
---|
147 | echo "searching for $tstprg (this may take some time)..." |
---|
148 | find / -name $tstprg | sed 1q >$mytmp |
---|
149 | fi |
---|
150 | failmsg="" |
---|
151 | if [ -s $mytmp ]; then echo "$tstprg found"; else failexit; fi |
---|
152 | |
---|
153 | srcpath=`cat $mytmp` |
---|
154 | # just in case the x-bit is not set yet: |
---|
155 | chmod + $srcpath |
---|
156 | |
---|
157 | if [ -e $mytmp ]; then rm $mytmp; fi |
---|
158 | echo "at: $srcpath." |
---|
159 | # echo "look for a directory which is contained in your path:" |
---|
160 | # search for a nice path in the $PATH: |
---|
161 | findbinpath |
---|
162 | # if we found a writable one, then copy the program to that path: |
---|
163 | # echo "try: cp $srcpath $tstbinpath/." |
---|
164 | if [ -w $tstbinpath ]; then cp $srcpath $tstbinpath/; fi |
---|
165 | if [ -w $tstbinpath ]; then return 0; fi |
---|
166 | |
---|
167 | failmsg=">>> The directory '$tstbinpath' to which INSTALL_WINDOWS wants to copy $tstprg is not writable! |
---|
168 | Maybe you have to login as a superuser (root) to have the right to write to this directory. |
---|
169 | In that case, type 'su', enter the superuser password and rerun INSTALL_WINDOWS. |
---|
170 | " |
---|
171 | failexit |
---|
172 | } |
---|
173 | |
---|
174 | function maybecopytopath() { |
---|
175 | echo "How do you want to proceed? Type '1' or '2', followed by ENTER."; |
---|
176 | REPLY="" |
---|
177 | read |
---|
178 | answer="$REPLY" |
---|
179 | echo |
---|
180 | failmsg="Okay, you chose to exit INSTALL_WINDOWS, solve the problem on your own, and rerun INSTALL_WINDOWS then again." |
---|
181 | if [ "$answer" == "3" ]; then return 0; fi |
---|
182 | if [ "$answer" == "2" ]; then copytopath; else failexit; fi |
---|
183 | } |
---|
184 | |
---|
185 | function failexit() { |
---|
186 | echo |
---|
187 | # if a message was specified, then display it and exit: |
---|
188 | if [ -n "$failmsg" ]; then echo $failmsg; fi |
---|
189 | if [ -n "$failmsg" ]; then exit; fi |
---|
190 | |
---|
191 | # else display the standard message: |
---|
192 | echo ">>> surfex needs to find $tstprg to be able to work." |
---|
193 | echo ">>> Please install $tstprg and copy it to a directory" |
---|
194 | echo ">>> which is contained in your bash path." |
---|
195 | echo ">>> Your current path is: |
---|
196 | $PATH |
---|
197 | " |
---|
198 | echo ">>> Then run INSTALL_WINDOWS again." |
---|
199 | # rm $mytmp |
---|
200 | exit |
---|
201 | } |
---|
202 | |
---|
203 | |
---|
204 | echo " |
---|
205 | surfex INSTALL script |
---|
206 | ----------------------------- |
---|
207 | "; |
---|
208 | |
---|
209 | # |
---|
210 | # test if java is usable: |
---|
211 | # |
---|
212 | |
---|
213 | tstprg=$my_java_prg |
---|
214 | |
---|
215 | which $tstprg >$mytmp 2>/dev/null |
---|
216 | if [ -s $mytmp ]; then echo " |
---|
217 | $tstprg found. |
---|
218 | "; else echo " |
---|
219 | |
---|
220 | >>> $tstprg not found! |
---|
221 | |
---|
222 | This problem might be caused by two reasons: |
---|
223 | |
---|
224 | (1) Either you have not installed java (e.g. from www.java.sun.com) yet. |
---|
225 | In that case, quit INSTALL_WINDOWS, install java, and rerun INSTALL_WINDOWS. |
---|
226 | |
---|
227 | (2) Or $tstprg is not contained in your path yet. |
---|
228 | In that case, INSTALL_WINDOWS can try to solve this problem for you by copying $tstprg to a directory |
---|
229 | which is contained in your path. |
---|
230 | "; fi |
---|
231 | if ! [ -s $mytmp ]; then maybecopytopath; fi |
---|
232 | |
---|
233 | echo " |
---|
234 | ----------------------------- |
---|
235 | "; |
---|
236 | |
---|
237 | # |
---|
238 | # test if surf is usable: |
---|
239 | # |
---|
240 | |
---|
241 | tstprg=$my_surf_prg |
---|
242 | |
---|
243 | if [ -e $my_surf_out ]; then rm $my_surf_out; fi |
---|
244 | $my_surf_test >/dev/null |
---|
245 | |
---|
246 | if [ -s $my_surf_out ]; then echo " |
---|
247 | $my_surf_prg seems to work correctly. |
---|
248 | "; else echo " |
---|
249 | $my_surf_prg does not work correctly. |
---|
250 | Trying to find it in the Singular-Binary-Directory... |
---|
251 | "; |
---|
252 | |
---|
253 | which Singular >$mytmp 2>/dev/null |
---|
254 | |
---|
255 | if [ -s $mytmp ]; then |
---|
256 | echo "Singular found. |
---|
257 | Trying to find $my_surf_prg via the Singular start script... |
---|
258 | "; |
---|
259 | read SingPath <$mytmp |
---|
260 | sed -n '/BIN_DIR/p' $SingPath | sed -e 's/.*=//g' >$mytmp |
---|
261 | |
---|
262 | read SingPath <$mytmp |
---|
263 | knownpath=$SingPath/surf.exe |
---|
264 | if [ -e $knownpath ]; then |
---|
265 | echo "Probably found $my_surf_prg. Trying to copy it to a useful directory."; |
---|
266 | copytopath |
---|
267 | else |
---|
268 | echo " |
---|
269 | >>> surf.exe not found. |
---|
270 | If you have not installed the Singular-version which contains surf |
---|
271 | then, please, do this. |
---|
272 | surfex needs surf.exe to work. |
---|
273 | |
---|
274 | If you have already installed this Singular-version, but our install-script |
---|
275 | was not able to locate surf.exe, then, please, copy the file surf.exe to |
---|
276 | a directory (preferably the first) of your PATH. |
---|
277 | "; |
---|
278 | failmsg="Your current PATH is: |
---|
279 | $PATH |
---|
280 | "; |
---|
281 | failexit |
---|
282 | fi |
---|
283 | else |
---|
284 | echo " |
---|
285 | >>> Singular not found. |
---|
286 | "; |
---|
287 | failmsg=" |
---|
288 | Currently, surfex only works if Singular is installed correctly. |
---|
289 | "; |
---|
290 | failexit |
---|
291 | fi |
---|
292 | |
---|
293 | |
---|
294 | if [ -e /usr/lib/Singular/surf.exe ]; then |
---|
295 | echo "Found surf. Copying to a location contained in your PATH... |
---|
296 | " |
---|
297 | knownpath=/usr/lib/Singular/surf.exe |
---|
298 | copytopath |
---|
299 | |
---|
300 | # test again: |
---|
301 | $my_surf_test >/dev/null |
---|
302 | if [ -s $my_surf_out ]; then echo " |
---|
303 | $my_surf_prg seems to work correctly. |
---|
304 | "; else |
---|
305 | echo " |
---|
306 | >>> $my_surf_prg does not work as expected. |
---|
307 | |
---|
308 | "; |
---|
309 | failmsg="Please contact us via our website: |
---|
310 | www.surfex.AlgebraicSurface.net |
---|
311 | "; |
---|
312 | failexit |
---|
313 | fi |
---|
314 | else |
---|
315 | echo " |
---|
316 | >>> surf not found. |
---|
317 | Please, install the Singular-version which comes together with surf. |
---|
318 | |
---|
319 | If you have already installed this Singular-version then, please, copy the file |
---|
320 | surf.exe to a directory wihch is contained your PATH. |
---|
321 | "; |
---|
322 | failmsg="Your current PATH is: |
---|
323 | $PATH |
---|
324 | "; |
---|
325 | |
---|
326 | failexit |
---|
327 | fi |
---|
328 | fi |
---|
329 | |
---|
330 | echo " |
---|
331 | ----------------------------- |
---|
332 | "; |
---|
333 | |
---|
334 | |
---|
335 | # |
---|
336 | # test if convert is usable: |
---|
337 | # |
---|
338 | tstprg=$my_convert_prg |
---|
339 | |
---|
340 | if [ -e $my_convert_out ]; then rm $my_convert_out; fi |
---|
341 | $my_convert_test |
---|
342 | |
---|
343 | if [ -s $my_convert_out ]; then echo " |
---|
344 | $my_convert_prg seems to work correctly. |
---|
345 | "; else echo " |
---|
346 | $my_convert_prg does not work correctly. |
---|
347 | Trying to find the ImageMagick suite... |
---|
348 | "; |
---|
349 | which identify.exe >$mytmp 2>/dev/null |
---|
350 | |
---|
351 | if [ -s $mytmp ]; then |
---|
352 | echo "Probably found the ImageMagick suite. |
---|
353 | Trying to copy convert.exe from there. |
---|
354 | " |
---|
355 | sed -e 's/\/identify\.exe/\/convert.exe/' $mytmp >$mytmp2 |
---|
356 | read knownpath <$mytmp2 |
---|
357 | |
---|
358 | echo "knownpath:" |
---|
359 | echo $knownpath |
---|
360 | copytopath |
---|
361 | |
---|
362 | # test again: |
---|
363 | echo " |
---|
364 | test again... |
---|
365 | "; |
---|
366 | |
---|
367 | $my_convert_test |
---|
368 | if [ -s $my_convert_out ]; then echo " |
---|
369 | $my_convert_prg seems to work correctly. |
---|
370 | "; |
---|
371 | else |
---|
372 | echo " |
---|
373 | >>> $my_convert_prg does not work as expected. |
---|
374 | >>> Try to rerun INSTALL_WINDOWS once. This sometimes solves the problem. |
---|
375 | If not then, please, read the information below. |
---|
376 | |
---|
377 | Please, try to find the correct convert.exe file which is part of the |
---|
378 | ImageMagick suite by yourself and copy it to a directory where surfex |
---|
379 | can find it. |
---|
380 | E.g., the first directory which is contained in your PATH. |
---|
381 | Your current PATH is: |
---|
382 | $PATH |
---|
383 | |
---|
384 | If that does not work then, please, contact us via our website: |
---|
385 | www.surfex.AlgebraicSurface.net |
---|
386 | |
---|
387 | However, convert.exe is not needed for the basic features of surfex; |
---|
388 | it is mainly needed for producing movies of surfaces. |
---|
389 | So you might want to try out surfex without convert. |
---|
390 | "; |
---|
391 | |
---|
392 | failmsg=">>> Try to run INSTALL_WINDOWS once again. This sometimes solves the problem. |
---|
393 | If not then, please, read the the information above. |
---|
394 | "; |
---|
395 | |
---|
396 | echo $failmsg |
---|
397 | fi |
---|
398 | else |
---|
399 | echo " |
---|
400 | >>> convert and the ImageMagick-suite not found. |
---|
401 | |
---|
402 | Please, install the Image-Magick suite which comes together with the tool convert. |
---|
403 | |
---|
404 | If you have already installed convert but this install-tool could not find it |
---|
405 | then, please, copy the file convert.exe from the ImageMagick suite to a directory |
---|
406 | wihch is contained your PATH. |
---|
407 | Your current PATH is: |
---|
408 | $PATH |
---|
409 | |
---|
410 | If you already did this but you still see this message |
---|
411 | then you have there is probably another convert.exe contained in one of the directories |
---|
412 | of your PATH. |
---|
413 | In that case, copy convert.exe to a directory which is listed in your PATH before that directory, |
---|
414 | e.g., to the first directory listed in your PATH. |
---|
415 | |
---|
416 | "; |
---|
417 | |
---|
418 | failmsg="However, convert.exe is not needed for the basic features of surfex; |
---|
419 | it is mainly needed for producing movies of surfaces. |
---|
420 | So you might want to try out surfex without convert. |
---|
421 | "; |
---|
422 | |
---|
423 | echo $failmsg |
---|
424 | fi |
---|
425 | fi |
---|
426 | |
---|
427 | echo " |
---|
428 | ----------------------------- |
---|
429 | "; |
---|
430 | |
---|
431 | # |
---|
432 | # build the start script: |
---|
433 | # |
---|
434 | |
---|
435 | echo " |
---|
436 | building the surfex start script... |
---|
437 | "; |
---|
438 | |
---|
439 | cat surfex_start_part1 >surfex |
---|
440 | echo "surfex_dir=$PWD" >>surfex |
---|
441 | cat surfex_start_part2 >>surfex |
---|
442 | chmod +x surfex |
---|
443 | |
---|
444 | # copy surfex to a directory which is contained in the user's $PATH: |
---|
445 | findbinpath |
---|
446 | # if we found a writable one, then copy the program to that path: |
---|
447 | if [ -w $tstbinpath ]; then cp ./surfex $tstbinpath; fi |
---|
448 | failmsg="surfex could not be copied to $tstbinpath. |
---|
449 | Maybe you have to login as a superuser (root) to have the right to write to this directory. |
---|
450 | In that case, type 'su', enter the superuser password and then rerun INSTALL_WINDOWS. |
---|
451 | " |
---|
452 | if ! [ -w $tstbinpath ]; then failexit; fi |
---|
453 | |
---|
454 | echo " |
---|
455 | ------------------------------------------------------------------------------- |
---|
456 | This INSTALL_WINDOWS script has written the script \"surfex\" the directory $tstbinpath. |
---|
457 | This directory is contained in your bash path. |
---|
458 | |
---|
459 | To start surfex, you can now type: |
---|
460 | surfex |
---|
461 | or something like |
---|
462 | surfex -e \"x^3+(y-z)*(y+z)\" |
---|
463 | if you want to envoke surfex with a particular equation. |
---|
464 | Once you have done that, three windows should open up. |
---|
465 | To rotate the surface which you see in one of them, drag your mouse pointer |
---|
466 | over the green sphere. |
---|
467 | |
---|
468 | If this does not work, you might have to edit the file \"surfex\". |
---|
469 | Please, contact us if you do not manage to get surfex run on your system. |
---|
470 | " |
---|
471 | |
---|
472 | echo "We are happy to receive any kind of feedback, |
---|
473 | |
---|
474 | Stephan Holzer and Oliver Labs |
---|
475 | |
---|
476 | |
---|
477 | surfex comes without any warranty. For download, documentation, examples, etc., see: |
---|
478 | www.surfex.AlgebraicSurface.net |
---|
479 | ------------------------------------------------------------------------------- |
---|
480 | " |
---|
481 | # |
---|
482 | # Disclaimer: |
---|
483 | # ----------- |
---|
484 | # |
---|
485 | # surfex comes without any warranty. |
---|
486 | # Feel free to use and distribute surfex. |
---|
487 | # |
---|
488 | |
---|
489 | if [ -e $mytmp ]; then rm $mytmp; fi |
---|
490 | |
---|
491 | bash |
---|