1 |
#!/usr/bin/perl -w |
2 |
use File::Basename; |
3 |
|
4 |
print "\nUse this script to create a new ascend executable\n\n"; |
5 |
|
6 |
# if called with incorrect number of parameters, print out usage |
7 |
# message |
8 |
if($#ARGV ne 2) |
9 |
{ |
10 |
print " |
11 |
Usage is: a4setup newDirectory pathToConfigure pathToTk |
12 |
where the parameters are as follows |
13 |
newDirectory: the directory tree in which the system |
14 |
will create the ascend executable. Its |
15 |
structure will parallel that of the |
16 |
directory tree containing the source code |
17 |
pathToConfigure: the relative path from here to the |
18 |
directory containing configure |
19 |
pathToTk: the absolute path to where tcl and tk |
20 |
are located on the computer |
21 |
|
22 |
An example use is: a4setup a4new/ unixAC213/ /usr/local/lib/tk\n\n"; |
23 |
die "Abandoning execution. Incorrect number of parameters.\n\n"; |
24 |
} |
25 |
|
26 |
# retrieve parameters |
27 |
$newDirectory = $ARGV[0]; |
28 |
$pathToConfigure = $ARGV[1]; |
29 |
$pathToTk = $ARGV[2]; |
30 |
chomp($newDirectory); |
31 |
chomp($pathToConfigure); |
32 |
chomp($pathToTk); |
33 |
|
34 |
# if directory already exists, ask if old version should be removed |
35 |
if (-e $newDirectory) |
36 |
{ |
37 |
print " |
38 |
WARNING: Subdirectory \"$newDirectory\" already exists. |
39 |
May I delete it (y or n)?: "; |
40 |
$ans = <STDIN>; |
41 |
chomp($ans); |
42 |
if($ans ne 'y') |
43 |
{ |
44 |
die "\nOkay, I am abandoning this attempt\n\n"; |
45 |
} |
46 |
|
47 |
system "rm -r $newDirectory"; |
48 |
} |
49 |
|
50 |
# create backbone of the parallel tree into which all files created |
51 |
# while compiling and linking are to be placed |
52 |
system "mkdir $newDirectory"; |
53 |
system "mkdir $newDirectory/trunk"; |
54 |
system "mkdir $newDirectory/trunk/base"; |
55 |
system "mkdir $newDirectory/trunk/base/generic"; |
56 |
system "mkdir $newDirectory/trunk/tcltk98"; |
57 |
|
58 |
# create symbolic links to point to ascend models and interface tcl code. |
59 |
# This linking is needed until interface code is compiled as a library - |
60 |
# something we will be doing later |
61 |
chdir "$newDirectory/trunk"; |
62 |
system "ln -s ..\/..\/$pathToConfigure\/..\/..\/models models"; |
63 |
chdir "tcltk98"; |
64 |
system "ln -s ..\/..\/..\/$pathToConfigure\/..\/..\/tcltk98\/TK TK"; |
65 |
chdir "../../.."; |
66 |
|
67 |
# locate prototype reconfig file - in same directory as a4setup |
68 |
open localBin, "which a4setup |"; |
69 |
$locBin = <localBin>; |
70 |
close localBin; |
71 |
($locBinPath) = (fileparse($locBin, ""))[1]; |
72 |
chomp($locBinPath); |
73 |
|
74 |
# copy prototype reconfig file into parallel tree and execute it |
75 |
system "cp $locBinPath\/a4reconfig__ $newDirectory\/trunk\/base\/generic\/reconfig"; |
76 |
print "\nDirectory tree just created\n"; |
77 |
system "ls -R $newDirectory"; |
78 |
print "\n\n"; |
79 |
chdir "$newDirectory/trunk/base/generic"; |
80 |
system "a4reconfig__ $pathToConfigure $pathToTk"; |
81 |
|
82 |
# compile new ascend executable |
83 |
system "make"; |
84 |
|
85 |
# done |
86 |
print "\n\nTo run ascend execute the following statement from this location |
87 |
|
88 |
$newDirectory/trunk/base/generic/bin/ascend4\n\n"; |