Change Eclipse configuration
[jabaws.git] / website / archive / binaries / mac / src / tcoffee / install
1 #!/usr/bin/env perl
2 #Version 2.01 (25/02/03)
3 use Cwd;
4 use Env;
5 use File::Path;
6 use FileHandle;
7 use strict;
8
9
10 our (%MODE, %PG, %ENV_SET, %SUPPORTED_OS);
11
12
13 our $EXIT_SUCCESS=0;
14 our $EXIT_FAILURE=1;
15 our $INTERNET=0;
16
17 #our $CP="cp -d ";
18 our $CP="cp "; #was causing a crash on MacOSX
19 our $SILENT=">/dev/null 2>/dev/null";
20 our $WEB_BASE="http://www.tcoffee.org";
21 our $TCLINKDB_ADDRESS="$WEB_BASE/Resources/tclinkdb.txt";
22 our $OS=get_os();
23 our $ROOT=&get_root();
24 our $CD=cwd();
25 our $CDIR=$CD;
26 our $HOME=$ENV{'HOME'};
27
28 our $OSNAME=$ENV{'OSNAME'};
29 our $OSARCH=$ENV{'OSARCH'};
30 our $REPO_ROOT="";
31
32 our $TCDIR;
33 our $TCCACHE;
34 our $TCTMP;
35 our $TCM;
36 our $TCMETHODS;
37 our $TCPLUGINS;
38 our $PLUGINS_DIR="";
39 our $INSTALL_DIR="";
40
41 ###########   DEFINITIONS ##############################
42 #
43 #
44 our $CXX="g++";
45 our $CXXFLAGS="";
46
47 our $CPP="g++";
48 our $CPPFLAGS="";
49
50 our $CC="gcc";
51 our $CFLAGS="";
52
53 our $FC="f77";
54 our $FFLAGS="";
55
56 my $install="all";
57 my $default_update_action="no_update";
58 ########################################################
59 my @required_applications=("wget_OR_curl");
60 ########### Mode Definitions ##############################
61 #
62 #
63 my @smode=("all", "clean", "install");
64
65 ########################################################
66 &initialize_PG();
67
68 #Parse The Command Line
69 my $cl=join( " ", @ARGV);
70 if ($#ARGV==-1 || ($cl=~/-h/) ||($cl=~/-H/) )
71   {
72      print "\n!!!!!!! ./install  t_coffee             --> installs t_coffee only";
73      print "\n!!!!!!! ./install  all                  --> installs all the modes [mcoffee, expresso, psicoffee,rcoffee..]";
74      print "\n!!!!!!! ./install  [mcoffee|rcoffee|..] --> installs the specified mode";
75      print "\n!!!!!!! ./install  -h                   --> print usage\n\n";
76      if ( $#ARGV==-1){exit ($EXIT_FAILURE);}
77    }
78      
79 if (($cl=~/-h/) ||($cl=~/-H/) )
80   {
81     my $m;
82     print "\n\n!!!!!!! advanced mode\n";
83     foreach $m ((keys (%MODE)),@smode)
84       {
85         print "!!!!!!!       ./install $m\n";
86       }
87     
88     print "!!!!!!! ./install [target:package|mode|] [-update|-force|-exec=dir|-dis=dir|-root|-tclinkdb=file|-] [CC=|FCC=|CXX=|CFLAGS=|CXXFLAGS=]\n";
89     print "!!!!!!! ./install clean    [removes all executables]\n";
90     print "!!!!!!! ./install [optional:target] -update               [updates package already installed]\n";
91     print "!!!!!!! ./install [optional:target] -force                [Forces recompilation over everything]\n";
92     
93     print "!!!!!!! ./install [optional:target] -root                 [You are running as root]\n";
94     print "!!!!!!! ./install [optional:target] -exec=/foo/bar/       [address for the T-Coffee executable]\n";
95     print "!!!!!!! ./install [optional:target] -dis=/foo/bar/        [Address where distributions should be stored]\n";
96     print "!!!!!!! ./install [optional:target] -tclinkdb=foo|update  [file containing all the packages to be installed]\n";
97     print "!!!!!!! ./install [optional:target] -clean                [clean everything]\n";
98     print "!!!!!!! ./install [optional:target] -plugins              [plugins directory]\n";
99     print "!!!!!!! ./install [optional:target] -tcdir=/foor/bar      [base path where T-Coffee will be installed]\n";
100     print "!!!!!!! ./install [optional:target] -repo=/path/to/repo   [binaries repository root directory]\n";
101     print "!!!!!!! mode:";
102     foreach $m (keys(%MODE)){print "$m ";}
103     print "\n";
104     print "!!!!!!! Packages:";
105     foreach $m (keys (%PG)){print "$m ";}
106     print "\n";
107     
108     print "\n\n";
109     exit ($EXIT_FAILURE);
110   }
111
112
113
114 # parse compiler flags
115 my (@argl)=($cl=~/(\S+=[^=]+)\s\w+=/g);
116 push (@argl, ($cl=~/(\S+=[^=]+\S)\s*$/g));
117
118 foreach $a (@argl)
119   {
120     if ( ($cl=~/CXX=(.*)/)){$CXX=$1;}
121     if ( ($cl=~/-CC=(.*)/    )){$CC=$1;}
122     if ( ($cl=~/-FC=(.*)/    )){$FC=$1;}
123     if ( ($cl=~/-CFLAGS=(.*)/)){$CFLAGS=$1;}
124     if ( ($cl=~/-CXXFLAGS=(.*)/)){$CXXFLAGS=$1;}
125   }
126 #parse install flags
127 our ($ROOT_INSTALL, $NO_QUESTION, $default_update_action,$BINARIES_ONLY,$force, $default_update_action, $INSTALL_DIR, $PLUGINS_DIR, $DISTRIBUTIONS,$tclinkdb, $proxy, $clean);
128 if ( ($cl=~/-root/)){$ROOT_INSTALL=1;}
129 if ( ($cl=~/-no_question/)){$NO_QUESTION=1;}
130 if ( ($cl=~/-update/)){$default_update_action="update";}
131 if ( ($cl=~/-binaries/)){$BINARIES_ONLY=1;}
132 if ( ($cl=~/-force/)){$force=1;$default_update_action="update"}
133 if ( ($cl=~/-exec=\s*(\S+)/)){$INSTALL_DIR=$1;}
134 if ( ($cl=~/-plugins=\s*(\S+)/)){$PLUGINS_DIR=$1;}
135 if ( ($cl=~/-dis=\s*(\S+)/)){$DISTRIBUTIONS=$1;}
136
137 if ( ($cl=~/-tclinkdb=\s*(\S+)/)){$tclinkdb=$1;}
138 if ( ($cl=~/-proxy=\s*(\S+)/)){$proxy=$1;}
139 if ( ($cl=~/-clean/)){$clean=1;}
140 if ( ($cl=~/-repo=\s*(\S+)/)){ $REPO_ROOT=$1; }
141 if ( ($cl=~/-tcdir=\s*(\S+)/)){ $TCDIR=$1; }
142 #automated update
143 if ($tclinkdb){&update_tclinkdb ($tclinkdb);}
144
145
146 if( $REPO_ROOT ne "" ) {
147         if( $OSNAME eq "" ) { print "You have specified the repository folder but the required \"OSNAME\" enviroment variable is missing. \n"; exit 1; } 
148         if( $OSARCH eq "" ) { print "You have specified the repository folder but the required \"OSARCH\" enviroment variable is missing. \n"; exit 1; } 
149 }
150
151 #Prepare the T-Coffee directory structure
152
153 if(!$TCDIR) { $TCDIR="$HOME/.t_coffee"; }
154 &add_dir ($TCDIR);
155 &add_dir ($TCCACHE="$TCDIR/cache");
156 &add_dir ($TCTMP="$CDIR/tmp");
157 &add_dir ($TCM="$TCDIR/mcoffee");
158 &add_dir ($TCMETHODS="$TCDIR/methods");
159 &add_dir ($TCPLUGINS="$TCDIR/plugins/$OS");
160
161 #Prepare the Installation Structure
162
163 our $BASE="$CD/bin";
164 our $BIN="$BASE/binaries/$OS";
165 our $DOWNLOAD_DIR="$BASE/download";
166 our $DOWNLOAD_FILE="$DOWNLOAD_DIR/files";
167 our $TMP="$BASE/tmp";
168
169 &add_dir($BASE);
170 &add_dir($BIN);
171 &add_dir($DOWNLOAD_DIR);
172 &add_dir($DOWNLOAD_FILE);
173 if (!$DISTRIBUTIONS){$DISTRIBUTIONS="$DOWNLOAD_DIR/distributions";}
174 &add_dir ($DISTRIBUTIONS);
175 &add_dir ($TMP);
176
177
178 #set the directory for the plugins 
179 if    (!$PLUGINS_DIR && !$ROOT_INSTALL){$PLUGINS_DIR=$TCPLUGINS;}
180 elsif (!$PLUGINS_DIR &&  $ROOT_INSTALL){$PLUGINS_DIR="/usr/local/bin/";}
181
182 #set the directory for t_coffee
183 if    (!$INSTALL_DIR && !$ROOT_INSTALL){$INSTALL_DIR="$HOME/bin/";mkpath ($INSTALL_DIR);}
184 elsif (!$INSTALL_DIR &&  $ROOT_INSTALL){$INSTALL_DIR="/usr/local/bin/";}
185
186 #prepare mcoffee files [Only if vanilla installation]
187 if (-d "mcoffee"){`cp mcoffee/* $TCM`;}
188
189
190 #prepare the environement
191 our $ENV_FILE="$TCDIR/t_coffee_env";
192 &env_file2putenv ($ENV_FILE);
193 &set_proxy($proxy);
194 my ($target, $p, $r);
195 $target=$p;
196
197 foreach $p (  ((keys (%PG)),(keys(%MODE)),(@smode)) )
198   {
199     if ($ARGV[0] eq $p && $target eq ""){$target=$p;}
200   }
201 if ($target eq ""){exit ($EXIT_FAILURE);}
202
203
204 # Check the basic requirements are met
205 foreach $r (@required_applications)
206   {
207     my @app_list;
208     my $i;
209     $i=0;
210     
211     @app_list=split (/_OR_/, $r);
212     foreach my $pg (@app_list)
213       {
214         $i+=&pg_is_installed ($pg);
215       }
216     if ($i==0)
217       {
218       print "One of the following packages must be installed to proceed: ";
219       foreach my $pg (@app_list)
220         {
221           print ("$pg ");
222         }
223       die;
224     }
225   }
226
227
228 # Set the mains paths and create directories
229 # distrib_dir/install/bin
230 # distrib_dir/install/Downloads
231 # distrib_dir/install/Downloads/Files
232 # distrib_dir/install/Downloads/Distributions
233 # distrib_dir/tmp
234
235 #Directory structure of the installation WITHIN the distribution dir
236
237
238
239 #sign the license
240 &sign_license_ni();
241
242
243 #Configure the copilers and their optins
244 $PG{C}{compiler}=get_C_compiler($CC);
245 $PG{Fortran}{compiler}=get_F_compiler($FC);
246 $PG{CXX}{compiler}=$PG{CPP}{compiler}=$PG{GPP}{compiler}=get_CXX_compiler($CXX);
247 if ($CXXFLAGS){$PG{CPP}{options}=$PG{GPP}{options}=$PG{CXX}{options}=$CXXFLAGS;}
248 if ($CFLAGS){$PG{C}{options}=$CFLAGS;}
249 foreach my $c (keys(%PG))
250   {
251     my $arguments;
252     if ($PG{$c}{compiler})
253       {
254         $arguments="$PG{$c}{compiler_flag}=$PG{$c}{compiler} ";
255         if ($PG{$c}{options})
256           {
257             $arguments.="$PG{$c}{options_flag}=$PG{$c}{options} ";
258           }
259         $PG{$c}{arguments}=$arguments;
260       }
261   }
262
263 # select the list of packages to update
264 if ($PG{$target}){$PG{$target}{install}=1;}
265 else
266   {
267     foreach my $pg (keys(%PG))
268       {
269         if ( $target eq "all" || ($PG{$pg}{mode}=~/$target/))
270           {
271             $PG{$pg} {install}=1;
272           }
273       }
274   }
275
276 foreach my $pg (keys(%PG))
277   {
278     if (!$PG{$pg}{update_action}){$PG{$pg}{update_action}=$default_update_action;}
279     elsif ($PG{$pg}{update_action} eq "never"){$PG{$pg}{install}=0;}
280     if ( $force && $PG{$pg}{install})
281       {
282         `rm $BIN/$pg $BIN/$pg.exe $SILENT`;
283       }
284     if ($PG{$pg}{update_action} eq "update" && $PG{$pg}{install}){$PG{$pg}{update}=1;}
285   }
286
287 #Execute the target: install/remove all the selected components
288 if (($target=~/clean/))
289   {
290     print "------- cleaning executables -----\n";
291     `rm bin/* $SILENT`;
292     exit ($EXIT_SUCCESS);
293   }
294
295 if ( !$PG{$target}){print "------- Installing T-Coffee Modes\n";}
296
297 #1 - Installing various modes
298 foreach my $m (keys(%MODE))
299   {
300     if ( $target eq "all" || $target eq $m)
301       {
302         print "\n------- The installer will now install the $m components $MODE{$m}{description}\n";
303         foreach my $pg (keys(%PG))
304           {
305             if ( $PG{$pg}{mode} =~/$m/ && $PG{$pg}{install})
306               {
307                 if ($PG{$pg}{touched}){print "------- $PG{$pg}{dname}: already processed\n";}
308                 else {$PG{$pg}{success}=&install_pg($pg);$PG{$pg}{touched}=1;}
309               }
310           }
311       }
312   }
313
314 #2 - Installing Various Packages
315 if ( $PG{$target}){print "------- Installing Individual Package\n";}
316 foreach my $pg (keys (%PG))
317   {
318     
319     if ( $PG{$pg}{install} && !$PG{$pg}{touched})
320       {
321         print "\n------- Install $pg\n";
322         $PG{$pg}{success}=&install_pg($pg);$PG{$pg}{touched}=1;
323       }
324   }
325 print "------- Finishing The installation\n";
326 my $final_report=&install ($INSTALL_DIR);
327
328 print "\n";
329 print "*********************************************************************\n";
330 print "********              INSTALLATION SUMMARY          *****************\n";
331 print "*********************************************************************\n";
332 print "------- SUMMARY package Installation:\n";
333 print "-------   Executable Installed in: $PLUGINS_DIR\n";
334
335 foreach my $pg (keys(%PG))
336   {
337     if ( $PG{$pg}{install})
338       {
339         my $bin_status=($PG{$pg}{from_binary} && $PG{$pg}{success})?"[from binary]":"";
340         if     ( $PG{$pg}{new} && !$PG{$pg}{old})                     {print "*------        $PG{$pg}{dname}: installed $bin_status\n"; $PG{$pg}{status}=1;}
341         elsif  ( $PG{$pg}{new} &&  $PG{$pg}{old})                     {print "*------        $PG{$pg}{dname}: updated $bin_status\n"  ; $PG{$pg}{status}=1;} 
342         elsif  (!$PG{$pg}{new} &&  $PG{$pg}{old} && !$PG{$pg}{update}){print "*------        $PG{$pg}{dname}: previous\n" ; $PG{$pg}{status}=1;}
343         elsif  (!$PG{$pg}{new} &&  $PG{$pg}{old} &&  $PG{$pg}{update}){print "*------        $PG{$pg}{dname}: failed update (previous installation available)\n";$PG{$pg}{status}=0;}
344         else                                                          {print "*------        $PG{$pg}{dname}: failed installation\n";$PG{$pg}{status}=0;}
345       }
346   }
347 my $failure;
348
349 if ( !$PG{$target}){print "*------ SUMMARY mode Installation:\n";}
350 foreach my $m (keys(%MODE))
351   {
352   
353     if ( $target eq "all" || $target eq $m)
354       {
355         my $succesful=1;
356         foreach my $pg (keys(%PG))
357           {
358             if (($PG{$pg}{mode}=~/$m/) && $PG{$pg}{install} && $PG{$pg}{status}==0)
359               {
360                 $succesful=0;
361                 print "*!!!!!!       $PG{$pg}{dname}: Missing\n";
362               }
363           }
364         if ( $succesful)
365           {
366             $MODE{$m}{status}=1;
367             print "*------       MODE $MODE{$m}{dname} SUCCESSFULLY installed\n";
368           }
369         else
370           {
371             $failure++;
372             $MODE{$m}{status}=0;
373             print "*!!!!!!       MODE $MODE{$m}{dname} UNSUCCESSFULLY installed\n";
374           }
375       }
376   }
377
378     
379       
380 if ($clean==1 && ($BASE=~/install4tcoffee/) ){print "*------ Clean Installation Directory: $BASE\n";`rm -rf $BASE`;}
381 #failure if one program was not well installed
382 foreach my $pg (keys(%PG)){if ($PG{$pg}{install} && $PG{$pg}{status}==0){exit ($EXIT_FAILURE);}}
383
384 if ($failure)
385   {
386     print "*********************************************************************\n";
387     print "********     SOME PACKAGES FAILED TO INSTALL        *****************\n";
388     print "*********************************************************************\n";
389     print "\nSome of the reported failures may be due to connectivity problems";
390     print "\nRerun the installation and the installer will specifically try to install the missing packages";
391     print "\nIf this Fails, go to the original website and install the package manually";
392   }
393
394 print "*********************************************************************\n";
395 print "********              FINALIZE YOUR INSTALLATION    *****************\n";
396 print "*********************************************************************\n";
397 print "------- Your executables are in:\n"; 
398 print "-------       $PLUGINS_DIR:\n";
399 print "------- Add this directory to your path with the following command:\n";
400 print "-------       export PATH=$PLUGINS_DIR:\$PATH\n";
401 print "------- Make this permanent by adding this line to the file:\n";
402 print "-------       $HOME/.bashrc\n";
403 exit ($EXIT_SUCCESS);  
404   
405 #################################################################################
406 #                                                                               #
407 #                                                                               #
408 #                                                                               #
409 #                   GENERIC INSTALLATION                                        #
410 #                                                                               #
411 #                                                                               #
412 #                                                                               #
413 #################################################################################
414 sub get_CXX_compiler
415   {
416     my $c=@_[0];
417     my (@clist)=("g++");
418     
419     return get_compil ($c, @clist);
420  }
421 sub get_C_compiler
422   {
423     my $c=@_[0];
424     my (@clist)=("gcc", "cc", "icc");
425     
426     return get_compil ($c, @clist);
427  }
428
429 sub get_F_compiler
430   {
431     my ($c)=@_[0];
432     my @clist=("f77", "g77","g95", "gfortran", "ifort");
433     return get_compil ($c, @clist);
434   } 
435        
436 sub get_compil
437   {
438     my ($fav,@clist)=(@_);
439     
440     #return the first compiler found installed in the system. Check first the favorite
441     foreach my $c ($fav,@clist)
442       {
443         if  (&pg_is_installed ($c)){return $c;}
444       }
445     return "";
446   }
447 sub exit_if_pg_not_installed
448   {
449     my (@arg)=(@_);
450     
451     foreach my $p (@arg)
452       {
453         if ( !&pg_is_installed ($p))
454           {
455             print "!!!!!!!! The $p utility must be installed for this installation to proceed [FATAL]\n";
456             die;
457           }
458       }
459     return 1;
460   }
461 sub set_proxy
462   {
463     my ($proxy)=(@_);
464     my (@list,$p);
465     
466     @list= ("HTTP_proxy", "http_proxy", "HTTP_PROXY", "ALL_proxy", "all_proxy","HTTP_proxy_4_TCOFFEE","http_proxy_4_TCOFFEE");
467     
468     if (!$proxy)
469       {
470         foreach my $p (@list)
471           {
472             if ( ($ENV_SET{$p}) || $ENV{$p}){$proxy=$ENV{$p};}
473           }
474       }
475     foreach my $p(@list){$ENV{$p}=$proxy;}
476   }
477         
478 sub check_internet_connection
479   {
480     my $internet;
481     
482     if ( -e "x"){unlink ("x");}
483     if     (&pg_is_installed    ("wget")){`wget www.google.com -Ox >/dev/null 2>/dev/null`;}
484     elsif  (&pg_is_installed    ("curl")){`curl www.google.com -ox >/dev/null 2>/dev/null`;}
485     else
486       {
487         printf stderr "\nERROR: No pg for remote file fetching [wget or curl][FATAL]\n";
488         exit ($EXIT_FAILURE);
489       }
490     
491     if ( !-e "x" || -s "x" < 10){$internet=0;}
492     else {$internet=1;}
493     if (-e "x"){unlink "x";}
494     return $internet;
495   }
496 sub url2file
497   {
498     my ($cmd, $file,$wget_arg, $curl_arg)=(@_);
499     my ($exit,$flag, $pg, $arg);
500     
501     if ($INTERNET || check_internet_connection ()){$INTERNET=1;}
502     else
503       {
504         print STDERR "ERROR: No Internet Connection [FATAL:install.pl]\n";
505         exit ($EXIT_FAILURE);
506       }
507     
508     if     (&pg_is_installed    ("wget")){$pg="wget"; $flag="-O";$arg="--tries=2 --connect-timeout=10 $wget_arg";}
509     elsif  (&pg_is_installed    ("curl")){$pg="curl"; $flag="-o";$arg=$curl_arg;}
510     else
511       {
512         printf stderr "\nERROR: No pg for remote file fetching [wget or curl][FATAL]\n";
513         exit ($EXIT_FAILURE);
514       }
515     
516     
517     if (-e $file){unlink($file);}
518     $exit=system "$pg $cmd $flag$file $arg";
519     return $exit;
520   }
521
522 sub pg_is_installed
523   {
524     my ($p, $dir)=(@_);
525     my ($r,$m, $ret);
526     my ($supported, $language, $compil);
527     
528   
529     if ( $PG{$p})
530       {
531         $language=$PG{$p}{language2};
532         $compil=$PG{$language}{compiler};
533       }
534     
535     if ( $compil eq "CPAN")
536       {
537         if ( system ("perl -M$p -e 1")==$EXIT_SUCCESS){$ret=1;}
538         else {$ret=0;}
539       }
540     elsif ($dir)
541       {
542         if (-e "$dir/$p" || -e "$dir/$p\.exe"){$ret=1;}
543         else {$ret=0;}
544       }
545     elsif (-e "$PLUGINS_DIR/$p" || -e "$PLUGINS_DIR/$p.exe"){$ret=1;}
546     else
547       {
548         $r=`which $p 2>/dev/null`;
549         if ($r eq ""){$ret=0;}
550         else {$ret=1;}
551       }
552    
553     return $ret;
554   }
555 sub install
556   {
557     my ($new_bin)=(@_);
558     my ($copied, $report);
559
560     
561     if (!$ROOT_INSTALL)
562       {
563         
564         if (-e "$BIN/t_coffee"){`$CP $BIN/t_coffee $INSTALL_DIR`};
565         `cp $BIN/* $PLUGINS_DIR`;
566         $copied=1;
567       }
568     else
569       {
570         $copied=&root_run ("You must be root to finalize the installation", "$CP $BIN/* $INSTALL_DIR $SILENT");
571       }
572     
573      
574   if ( !$copied)
575     {
576       $report="*!!!!!! Installation unsuccesful. The executables have been left in $BASE/bin\n";
577     }
578   elsif ( $copied && $ROOT)
579     {
580       $report="*------ Installation succesful. Your executables have been copied in $new_bin and are on your PATH\n";
581     }
582   elsif ( $copied && !$ROOT)
583     {
584       $report= "*!!!!!! T-Coffee and associated packages have been copied in: $new_bin\n";
585       $report.="*!!!!!! This address is NOT in your PATH sytem variable\n";
586       $report.="*!!!!!! You can do so by adding the following line in your ~/.bashrc file:\n";
587       $report.="*!!!!!! export PATH=$new_bin:\$PATH\n";
588     }
589   return $report;
590 }
591
592 sub sign_license_ni
593   {
594     my $F=new FileHandle;
595     open ($F, "license.txt");
596     while (<$F>)
597       {
598         print "$_";
599       }
600     close ($F);
601     
602     return;
603   }
604 #################################################################################
605 #                                                                               #
606 #                                                                               #
607 #                                                                               #
608 #                   INDIVIDUAL MULTIPLE SEQUENCE ALIGNMNT PACKAGES INSTALLATION #
609 #                                                                               #
610 #                                                                               #
611 #                                                                               #
612 #################################################################################
613
614 sub install_pg
615   {
616     my ($pg)=(@_);
617     my ($report, $previous, $language, $compiler, $return);
618     
619     if (!$PG{$pg}{install}){return 1;}
620     
621     $previous=&pg_is_installed ($pg);
622     
623     if ($PG{$pg}{update_action} eq "no_update" && $previous)
624       {
625         $PG{$pg}{old}=1;
626         $PG{$pg}{new}=0;
627         $return=1;
628       }
629     else
630       {
631         $PG{$pg}{old}=$previous;
632         
633         if ($PG{$pg} {language2} eq "Perl"){&install_perl_package ($pg);}
634         elsif ($BINARIES_ONLY && &install_binary_package ($pg)){$PG{$pg}{from_binary}=1;}
635         elsif (&install_source_package ($pg)){;}
636         else 
637           {
638             
639             if (!&supported_os($OS))
640               {
641                 print "!!!!!!!! $pg compilation failed, binary unsupported for $OS\n"; 
642               }
643             elsif (!($PG{$pg}{from_binary}=&install_binary_package ($pg)))
644               {
645                 print "!!!!!!!! $pg compilation and  binary installation failed\n";
646               }
647           }
648         $PG{$pg}{new}=$return=&pg_is_installed ($pg,$BIN);
649       }
650
651     
652     return $return;
653   }
654 sub install_perl_package
655   {
656     my ($pg)=(@_);
657     my ($report, $language, $compiler);
658     
659     $language=$PG{$pg} {language2};
660     $compiler=$PG{$language}{compiler};
661     
662     if (!&pg_is_installed ($pg))
663       {
664         if ( $OS eq "windows"){`perl -M$compiler -e 'install $pg'`;}
665         elsif ( $ROOT eq "sudo"){system ("sudo perl -M$compiler -e 'install $pg'");}
666         else {system ("su root -c perl -M$compiler -e 'install $pg'");}
667       }
668     return &pg_is_installed ($pg);
669   }
670
671
672
673 sub install_source_package
674   {
675     my ($pg)=(@_);
676     my ($report, $download, $arguments, $language, $address, $name, $ext, $main_dir, $distrib);
677     my $wget_tmp="$TMP/wget.tmp";
678     my (@fl);
679     if ( -e "$BIN/$pg" || -e "$BIN/$pg.exe"){return 1;}
680     
681     #
682     # check if the module exists in the repository cache 
683     #
684         if( repo_load($pg) ) {
685                 return 1;
686         }
687     
688     if ($pg eq "t_coffee")  {return   &install_t_coffee ($pg);}
689     elsif ($pg eq "TMalign"){return   &install_TMalign ($pg);}
690     
691     chdir $DISTRIBUTIONS;
692     
693     $download=$PG{$pg}{source};
694     
695     if (($download =~/tgz/))
696       {
697         ($address,$name,$ext)=($download=~/(.+\/)([^\/]+)(\.tgz).*/);
698       }
699     elsif (($download=~/tar\.gz/))
700       {
701         ($address,$name,$ext)=($download=~/(.+\/)([^\/]+)(\.tar\.gz).*/);
702       }
703     elsif (($download=~/tar/))
704       {
705         ($address,$name,$ext)=($download=~/(.+\/)([^\/]+)(\.tar).*/);
706       }
707     else
708       {
709         ($address,$name)=($download=~/(.+\/)([^\/]+)/);
710         $ext="";
711       }
712     $distrib="$name$ext";
713     
714     if ( !-d $pg){mkdir $pg;}
715     chdir $pg;
716    
717     #get the distribution if available
718     if ( -e "$DOWNLOAD_DIR/$distrib")
719       {
720         `$CP $DOWNLOAD_DIR/$distrib .`;
721       }
722     #UNTAR and Prepare everything
723     if (!-e "$name.tar" && !-e "$name")
724       {
725         &check_rm ($wget_tmp);
726         print "\n------- Downloading/Installing $pg\n";
727         
728         if (!-e $distrib && &url2file ("$download", "$wget_tmp")==$EXIT_SUCCESS)
729           {
730             
731             `mv $wget_tmp $distrib`;
732             `$CP $distrib $DOWNLOAD_DIR/`;
733           }
734
735         if (!-e $distrib)
736           {
737             print "!!!!!!! Download of $pg distribution failed\n";
738             print "!!!!!!! Check Address: $PG{$pg}{source}\n";
739             return 0;
740           }
741         print "\n------- unzipping/untaring $name\n";
742         if (($ext =~/z/))
743           { 
744             &flush_command ("gunzip $name$ext");
745             
746           }
747         if (($ext =~/tar/) || ($ext =~/tgz/))
748           {
749             &flush_command("tar -xvf $name.tar");
750           }
751       }
752     #Guess and enter the distribution directory
753     @fl=ls($p);
754     foreach my $f (@fl)
755       {
756         if (-d $f)
757           {
758             $main_dir=$f;
759           }
760       }
761     if (-d $main_dir)
762           
763       {
764         chdir $main_dir;}
765     else
766       {
767         print "Error: $main_dir does not exist";
768       }
769     print "\n------- Compiling/Installing $pg\n";
770     `make clean $SILENT`;
771     
772     
773     #
774     # SAP module
775     #
776     if ($pg eq "sap")
777       {
778         if (-e "./configure")
779           {
780             #new sap distribution
781             if ($OS eq "macosx")
782               {
783                 &replace_line_in_file ("./src/galloc.h", "malloc.h",  "");
784                 &replace_line_in_file ("./src/pdbprot.h", "malloc.h", "");
785                 &replace_line_in_file ("./src/pdbprot.c", "malloc.h", "");
786               }
787             
788             &flush_command ("./configure");
789             &flush_command ("make clean");
790             &flush_command ("make");
791             &check_cp ("./src/$pg", "$BIN");
792             repo_store("./src/$pg");
793           }
794         else
795           {
796             #old style distribution
797             `rm *.o sap  sap.exe ./util/aa/*.o  ./util/wt/.o $SILENT`;
798             &flush_command ("make $arguments sap");
799             &check_cp ($pg, "$BIN");
800             repo_store($pg);
801           }
802       }
803     
804     #
805     # CLUSTALW2 module
806     #
807     elsif ($pg eq "clustalw2")
808       {
809         &flush_command("./configure");
810         &flush_command("make $arguments");
811         &check_cp ("./src/$pg", "$BIN");
812         repo_store("./src/$pg");
813       }
814     
815     #
816     # FSA module
817     # 
818     elsif ($pg eq "fsa")
819       {
820         &flush_command("./configure --prefix=$BIN");
821         &flush_command("make $arguments");
822         &flush_command ("make install");
823
824         repo_store("fsa", "$BIN/bin");
825         `mv $BIN/bin/* $BIN`;
826         `rmdir $BIN/bin`;
827       }
828     
829     #
830     # CLUSTALW module
831     #
832     elsif ($pg eq "clustalw")
833       {
834         &flush_command("make $arguments clustalw");
835         `$CP $pg $BIN $SILENT`;
836         repo_store($pg);
837       }
838     
839     #
840     # MAFFT module
841     #
842     elsif ($pg eq "mafft")
843       {
844         my $base=cwd();
845         my $c;
846         
847         #compile core
848         mkpath ("./mafft/bin");
849         mkpath ("./mafft/lib");
850         chdir "$base/core";
851         `make clean $SILENT`;
852         &flush_command ("make $arguments");
853         &flush_command ("make install LIBDIR=../mafft/lib BINDIR=../mafft/bin");
854         
855         #compile extension
856         chdir "$base/extensions";
857         `make clean $SILENT`;
858         &flush_command ("make $arguments");
859         &flush_command ("make install LIBDIR=../mafft/lib BINDIR=../mafft/bin");
860         
861         #put everything in mafft and copy the compiled stuff in bin
862         chdir "$base";
863         if ($ROOT_INSTALL)
864           {
865             &root_run ("You Must be Root to Install MAFFT\n", "mkdir /usr/local/mafft/;$CP mafft/lib/* /usr/local/mafft;$CP mafft/lib/mafft* /usr/local/bin ;$CP mafft/bin/mafft /usr/local/bin/; ");
866           }
867         else
868           {
869             `$CP mafft/lib/*  $BIN`;
870             `$CP mafft/bin/mafft  $BIN`;
871           }
872         `tar -cvf mafft.tar mafft`;
873         `gzip mafft.tar`;
874         `mv mafft.tar.gz $BIN`;
875         
876         repo_store("mafft/bin/mafft", "mafft/lib/", "$BIN/mafft.tar.gz");
877       }
878       
879     #
880     # DIALIGN-TX module
881     #
882     elsif ( $pg eq "dialign-tx" )
883       {
884         my $f;
885         my $base=cwd();
886
887         chdir "./source";
888         if ($OS eq "macosx"){&flush_command ("cp makefile.MAC_OS makefile");}
889
890         &flush_command (" make CPPFLAGS='-O3 -funroll-loops' all");
891         
892         chdir "..";
893         &check_cp ("./source/$pg", "$BIN");
894         repo_store("./source/$pg");
895       }
896       
897     #
898     # DIALIGN-T module 
899     # (is the same as dialign-tx, but it is mantained for backward name compatibility with tcoffee)
900     #
901     elsif ( $pg eq "dialign-t" )
902       {
903         my $f;
904         my $base=cwd();
905
906         chdir "./source";
907         if ($OS eq "macosx"){&flush_command ("cp makefile.MAC_OS makefile");}
908
909         &flush_command (" make CPPFLAGS='-O3 -funroll-loops' all");
910         
911         chdir "..";
912         &check_cp ("./source/dialign-tx", "$BIN/dialign-t");
913         repo_store("$BIN/dialign-t");   
914       }      
915       
916     #
917     # POA module
918     #
919     elsif ($pg eq "poa")
920       {
921         &flush_command ("make $arguments poa");
922         &check_cp ("$pg", "$BIN");
923         repo_store("$pg");
924       }
925      
926      
927     #
928     # PROBCONS module
929     #
930     elsif ( $pg eq "probcons")
931       {
932         &add_C_libraries("./ProbabilisticModel.h", "list", "cstring");
933         
934         `rm *.exe $SILENT`;
935         &flush_command ("make $arguments probcons");
936         &check_cp("$pg", "$BIN/$pg");
937         repo_store("$pg");
938       }
939       
940     #
941     # PROBCONS RNA module
942     #
943     elsif ( $pg eq "probconsRNA")
944       {
945         &add_C_libraries("./ProbabilisticModel.h", "list", "cstring");
946         &add_C_libraries("./Main.cc", "iomanip", "cstring","climits");
947         `rm *.exe $SILENT`;
948         &flush_command ("make $arguments probcons");
949         &check_cp("probcons", "$BIN/$pg");
950         repo_store("$BIN/$pg");
951       }
952
953         #
954         # MUSCLE module
955         #
956     elsif (  $pg eq "muscle")
957       { 
958         `rm *.o muscle muscle.exe $SILENT`;
959         if ($OS eq "macosx" || $OS eq "linux")
960           {
961             &replace_line_in_file ("./Makefile", "LDLIBS = -lm -static",  "LDLIBS = -lm");
962           }
963         elsif ($OS eq "windows")
964           {
965             &replace_line_in_file ("./intmath.cpp",  "double log2e",      "double cedric_log");
966             &replace_line_in_file ("./intmath.cpp",  "double log2",       "double log_notuse");
967             &replace_line_in_file ("./intmath.cpp",  "double cedric_log", "double log2e");
968           }
969         &flush_command ("make $arguments all");
970         &check_cp("$pg", "$BIN");
971         repo_store("$pg");      
972       }
973       
974      #
975      # MUS4 module
976      #
977      elsif (  $pg eq "mus4")
978       {
979         `rm *.o muscle muscle.exe $SILENT`;
980         &flush_command ("./mk");
981         &check_cp("$pg", "$BIN");
982         repo_store("$pg");      
983       }
984       
985     #
986     # PCMA module
987     #
988     elsif ( $pg eq "pcma")
989       {
990         if ($OS eq "macosx")
991           {
992             &replace_line_in_file ("./alcomp2.c", "malloc.h",  "");
993           }
994         &flush_command ("make $arguments pcma");
995         &check_cp("$pg", "$BIN");
996         repo_store("$pg");      
997       }
998       
999     #
1000     # KALIGN module
1001     #
1002     elsif ($pg eq "kalign")
1003       {
1004         &flush_command ("./configure");
1005         &flush_command("make $arguments");
1006         &check_cp ("$pg",$BIN);
1007         repo_store("$pg");      
1008       }
1009       
1010     #
1011     # AMAP module
1012     #
1013     elsif ( $pg eq "amap")
1014       {
1015         &add_C_libraries("./Amap.cc", "iomanip", "cstring","climits");  
1016         `make clean $SILENT`;
1017         &flush_command ("make $arguments all");
1018         &check_cp ("$pg", $BIN);
1019         repo_store("$pg");      
1020       }
1021       
1022     #
1023     # PRODA module
1024     #
1025     elsif ( $pg eq "proda")
1026       {
1027         &add_C_libraries("AlignedFragment.h", "vector", "iostream", "cstring","cstdlib");
1028         &add_C_libraries("Main.cc", "vector", "climits");       
1029         &add_C_libraries("Sequence.cc", "stdlib.h", "cstdio");  
1030         &flush_command ("make $arguments all");
1031         &check_cp ("$pg", $BIN);
1032         repo_store("$pg");      
1033       }
1034       
1035     #
1036     # PRANK module
1037     #
1038     elsif ( $pg eq "prank")
1039       {
1040         &flush_command ("make $arguments all");
1041         &check_cp ("$pg", $BIN);
1042         repo_store("$pg");      
1043       }
1044       
1045     #
1046     # !!!! MUSTANG module
1047     #
1048      elsif ( $pg eq "mustang")
1049       {
1050         &flush_command ("rm ./bin/*");
1051         &flush_command ("make $arguments all");
1052
1053         if ( $OS=~/windows/){&flush_command("cp ./bin/* $BIN/mustang.exe");}
1054         else {&flush_command("cp ./bin/* $BIN/mustang");}
1055         
1056         repo_store("$BIN/mustang");
1057       }
1058
1059         #
1060         # RNAplfold module
1061         #
1062     elsif ( $pg eq "RNAplfold")
1063       {
1064         &flush_command("./configure");
1065         &flush_command ("make $arguments all");
1066         &check_cp("./Progs/RNAplfold", "$BIN");
1067         &check_cp("./Progs/RNAalifold", "$BIN");
1068         &check_cp("./Progs/RNAfold", "$BIN");
1069         
1070         repo_store("./Progs/RNAplfold", "./Progs/RNAalifold", "./Progs/RNAfold");
1071       }
1072       
1073     #
1074     # !!! RETREE module
1075     #
1076     elsif ( $pg eq "retree")
1077       {
1078         chdir "src";
1079         &flush_command ("make $arguments all");
1080         &flush_command ("make put");
1081         system "cp ../exe/* $BIN";
1082         
1083         repo_store("retree", "../exe");
1084       }
1085         
1086     chdir $CDIR;
1087     return &pg_is_installed ($pg, $BIN);
1088   }
1089
1090 sub install_t_coffee
1091   {
1092     my ($pg)=(@_);
1093     my ($report,$cflags, $arguments, $language, $compiler) ;
1094     #1-Install T-Coffee
1095     chdir "t_coffee_source";
1096     &flush_command ("make clean");
1097     print "\n------- Compiling T-Coffee\n";
1098     $language=$PG{$pg} {language2};
1099     $arguments=$PG{$language}{arguments};
1100     if (!($arguments =~/CFLAGS/)){$arguments .= " CFLAGS=-O2 ";}
1101
1102     if ( $CC ne ""){&flush_command ("make -i $arguments t_coffee");}
1103     &check_cp ($pg, $BIN);
1104     
1105     chdir $CDIR;
1106     return &pg_is_installed ($pg, $BIN);
1107   }
1108 sub install_TMalign
1109   {
1110     my ($pg)=(@_);
1111     my $report;
1112     chdir "t_coffee_source";
1113     print "\n------- Compiling TMalign\n";
1114     `rm TMalign TMalign.exe $SILENT`;
1115     if ( $FC ne ""){&flush_command ("make -i $PG{Fortran}{arguments} TMalign");}
1116     &check_cp ($pg, $BIN);
1117     repo_store($pg);
1118
1119     if ( !-e "$BIN/$pg" && pg_has_binary_distrib ($pg))
1120       {
1121         print "!!!!!!! Compilation of $pg impossible. Will try to install from binary\n";
1122         return &install_binary_package ($pg);
1123       }
1124     chdir $CDIR;
1125     return &pg_is_installed ($pg, $BIN);
1126   }
1127
1128 sub pg_has_binary_distrib
1129   {
1130     my ($pg)=(@_);
1131     if ($PG{$pg}{windows}){return 1;}
1132     elsif ($PG{$pg}{osx}){return 1;}
1133     elsif ($PG{$pg}{linux}){return 1;}
1134     return 0;
1135   }
1136 sub install_binary_package
1137   {
1138     my ($pg)=(@_);
1139     my ($base,$report,$name, $download, $arguments, $language, $dir);
1140     my $isdir;
1141     &input_os();
1142     
1143     if (!&supported_os($OS)){return 0;}
1144     if ( $PG{$pg}{binary}){$name=$PG{$pg}{binary};}
1145     else 
1146       {
1147         $name=$pg;
1148         if ( $OS eq "windows"){$name.=".exe";}
1149       }
1150     
1151     $download="$WEB_BASE/Packages/Binaries/$OS/$name";
1152     
1153     $base=cwd();
1154     chdir $TMP;
1155     
1156     if (!-e $name)
1157       {
1158         `rm x $SILENT`;
1159         if ( url2file("$download","x")==$EXIT_SUCCESS)
1160           {
1161             `mv x $name`;
1162           }
1163       }
1164     
1165     if (!-e $name)
1166       {
1167         print "!!!!!!! $PG{$pg}{dname}: Download of $pg binary failed\n";
1168         print "!!!!!!! $PG{$pg}{dname}: Check Address: $download\n";
1169         return 0;
1170       }
1171     print "\n------- Installing $pg\n";
1172     
1173     if ($name =~/tar\.gz/)
1174       {
1175         `gunzip  $name`;
1176         `tar -xvf $pg.tar`;
1177         chdir $pg;
1178         if ( $pg eq "mafft")
1179           {
1180             if ($ROOT_INSTALL)
1181               {
1182                 &root_run ("You Must be Roor to Install MAFFT\n", "$CP mafft/bin/* /usr/local/mafft;mkdir /usr/local/mafft/; $CP mafft/lib/* /usr/local/bin/");
1183               }
1184             else
1185               {
1186                 `$CP $TMP/$pg/bin/* $BIN $SILENT`;
1187                 `$CP $TMP/$pg/lib/* $BIN $SILENT`;
1188               }
1189           }
1190         else
1191           {
1192             if (-e "$TMP/$pg/data"){`$CP $TMP/$pg/data/* $TCM $SILENT`;}
1193             if (!($pg=~/\*/)){`rm -rf $pg`;}
1194           }
1195       }
1196     else
1197       {
1198         &check_cp ("$pg", "$BIN");
1199         `chmod u+x $BIN/$pg`; 
1200         unlink ($pg);
1201       }
1202     chdir $base;
1203     $PG{$pg}{from_binary}=1;
1204     return &pg_is_installed ($pg, $BIN);
1205   }
1206
1207 ################################################################################
1208 #                                                                               #
1209 #                                                                               #
1210 #                                                                               #
1211 #                   Simple Utilities                                            #
1212 #                                                                               #
1213 #                                                                               #
1214 #                                                                               #
1215 #################################################################################
1216 sub add_dir 
1217   {
1218     my $dir=@_[0];
1219     
1220     if (!-e $dir && !-d $dir)
1221       {
1222         my @l;
1223         umask (0000);
1224         @l=mkpath ($dir,{mode => 0777});
1225         
1226       }
1227     else
1228       {
1229         return 0;
1230       }
1231   }
1232 sub check_rm 
1233   {
1234     my ($file)=(@_);
1235     
1236     if ( -e $file)
1237       {
1238         return unlink($file);
1239       }
1240     return 0;
1241   }
1242 sub check_cp
1243   {
1244     my ($from, $to)=(@_);
1245     if ( !-e $from && -e "$from\.exe"){$from="$from\.exe";}
1246     if ( !-e $from){return 0;}
1247         
1248     `$CP $from $to`;
1249     return 1;
1250   }
1251
1252 #  
1253 # Cache the specified package 
1254 #  
1255 # - path (mandatory): the source path to be cached 
1256 # - pg (optional): the package name
1257
1258 sub repo_store 
1259 {
1260    # check that all required data are available
1261    if( $REPO_ROOT eq "" ) { return; }
1262
1263
1264     # extract the package name from the specified path
1265     my $pg =`basename $_[0]`;
1266     chomp($pg);
1267         
1268     my $VER = $PG{$pg}{version};
1269     my $CACHE = "$REPO_ROOT/$pg/$VER/$OSNAME-$OSARCH"; 
1270     
1271     print "-------- Storing package: \"$pg\" to path: $CACHE\n";
1272     
1273     # clean the cache path if exists and create it again
1274     `rm -rf $CACHE`;
1275     `mkdir -p $CACHE`;
1276     
1277         for my $path (@_) {
1278
1279             # check if it is a single file 
1280                 if( -f $path ) {
1281                 `cp $path $CACHE`;
1282                 }
1283                 # .. or a directory, in this case copy all the content 
1284                 elsif( -d $path ) {
1285                         opendir(IMD, $path);
1286                         my @thefiles= readdir(IMD);
1287                         closedir(IMD);
1288                         
1289                         for my $_file (@thefiles) {
1290                                 if( $_file ne "." && $_file ne "..") {
1291                                 `cp $path/$_file $CACHE`;
1292                                 }
1293                         }
1294                 } 
1295         }          
1296     
1297         
1298 }   
1299
1300 #
1301 # Retrieve a target object from the build binary repository
1302 # - pg (mandatory): a know target package name, it will be used to access to the $PG packages map
1303 #
1304 sub repo_load 
1305 {
1306     my ($pg)=(@_);
1307
1308     # check that all required data are available
1309     if( $REPO_ROOT eq "" ) { return 0; }
1310
1311     my $VER = $PG{$pg}{version};
1312     my $CACHE = "$REPO_ROOT/$pg/$VER/$OSNAME-$OSARCH"; 
1313     if( !-e "$CACHE/$pg" ) {
1314                 print "-------- Module \"$pg\" NOT found on repository cache.\n";
1315         return 0;
1316     }
1317     
1318     print "-------- Module \"$pg\" found on repository cache. Using copy on path: $CACHE\n";
1319     `cp $CACHE/* $BIN`;
1320     return 1;
1321 }
1322
1323 sub check_file_list_exists 
1324   {
1325     my ($base, @flist)=(@_);
1326     my $f;
1327
1328     foreach $f (@flist)
1329       {
1330         if ( !-e "$base/$f"){return 0;}
1331       }
1332     return 1;
1333   }
1334 sub ls
1335   {
1336     my $f=@_[0];
1337     my @fl;
1338     chomp(@fl=`ls -1 $f`);
1339     return @fl;
1340   }
1341 sub flush_command
1342   {
1343     my $command=@_[0];
1344     my $F=new FileHandle;
1345     open ($F, "$command|");
1346     while (<$F>){print "    --- $_";}
1347     close ($F);
1348   }    
1349
1350 sub input_installation_directory
1351   {
1352     my $dir=@_[0];
1353     my $new;
1354     
1355     print "------- The current installation directory is: [$dir]\n";
1356     print "??????? Return to keep the default or new value:";
1357    
1358     if ($NO_QUESTION==0)
1359       {
1360         chomp ($new=<stdin>);
1361         while ( $new ne "" && !input_yes ("You have entered $new. Is this correct? ([y]/n):"))
1362           {
1363             print "???????New installation directory:";
1364             chomp ($new=<stdin>);
1365           }
1366         $dir=($new eq "")?$dir:$new;
1367         $dir=~s/\/$//;
1368       }
1369     
1370     if ( -d $dir){return $dir;}
1371     elsif (&root_run ("You must be root to create $dir","mkdir $dir")==$EXIT_SUCCESS){return $dir;}
1372     else
1373       {
1374         print "!!!!!!! $dir could not be created\n";
1375         if ( $NO_QUESTION)
1376           {
1377             return "";
1378           }
1379         elsif ( &input_yes ("??????? Do you want to provide a new directory([y]/n)?:"))
1380           {
1381             return input_installation_directory ($dir);
1382           }
1383         else
1384           {
1385             return "";
1386           }
1387       }
1388     
1389   }
1390 sub input_yes
1391   {
1392     my $question =@_[0];
1393     my $answer;
1394
1395     if ($NO_QUESTION==1){return 1;}
1396     
1397     if ($question eq ""){$question="??????? Do you wish to proceed ([y]/n)?:";}
1398     print $question;
1399     chomp($answer=lc(<STDIN>));
1400     if (($answer=~/^y/) || $answer eq ""){return 1;}
1401     elsif ( ($answer=~/^n/)){return 0;}
1402     else
1403       {
1404         return input_yes($question);
1405       }
1406   }
1407 sub root_run
1408   {
1409     my ($txt, $cmd)=(@_);
1410     
1411     if ( system ($cmd)==$EXIT_SUCCESS){return $EXIT_SUCCESS;}
1412     else 
1413       {
1414         print "------- $txt\n";
1415         if ( $ROOT eq "sudo"){return system ("sudo $cmd");}
1416         else {return system ("su root -c \"$cmd\"");}
1417       }
1418   }
1419 #analyze environement
1420 sub get_root
1421   {
1422     if (&pg_is_installed ("sudo")){return "sudo";}
1423     else {return "su";}
1424   }
1425
1426 sub get_os
1427   {
1428     my $raw_os=`uname`;
1429     my $os;
1430
1431     $raw_os=lc ($raw_os);
1432     
1433     if ($raw_os =~/cygwin/){$os="windows";}
1434     elsif ($raw_os =~/linux/){$os="linux";}
1435     elsif ($raw_os =~/osx/){$os="macosx";}
1436     elsif ($raw_os =~/darwin/){$os="macosx";}
1437     else
1438       {
1439         $os=$raw_os;
1440       }
1441     return $os;
1442   }
1443 sub input_os
1444   {
1445     my $answer;
1446     if ($OS) {return $OS;}
1447     
1448     print "??????? which os do you use: [w]indows, [l]inux, [m]acosx:?";
1449     $answer=lc(<STDIN>);
1450
1451     if (($answer=~/^m/)){$OS="macosx";}
1452     elsif ( ($answer=~/^w/)){$OS="windows";}
1453     elsif ( ($answer=~/^linux/)){$OS="linux";}
1454     
1455     else
1456       {
1457         return &input_os();
1458       }
1459     return $OS;
1460   }
1461
1462 sub supported_os
1463   {
1464     my ($os)=(@_[0]);
1465     return $SUPPORTED_OS{$os};
1466   }
1467     
1468     
1469 ################################################################################
1470 #                                                                               #
1471 #                                                                               #
1472 #                                                                               #
1473 #                  update/initialize links                                      #
1474 #                                                                               #
1475 #                                                                               #
1476 #                                                                               #
1477 #################################################################################
1478
1479
1480 sub update_tclinkdb 
1481   {
1482     my $file =@_[0];
1483     my $name;
1484     my $F=new FileHandle;
1485     my ($download, $address, $name, $l, $db);
1486     
1487     if ( $file eq "update"){$file=$TCLINKDB_ADDRESS;}
1488     
1489     if ( $file =~/http:\/\// || $file =~/ftp:\/\//)
1490       {
1491         ($address, $name)=($download=~/(.*)\/([^\/]+)$/);
1492         `rm x $SILENT`;
1493         if (&url2file ($file,"x")==$EXIT_SUCCESS)
1494           {
1495             print "------- Susscessful upload of $name";
1496             `mv x $name`;
1497             $file=$name;
1498           }
1499       }
1500     open ($F, "$file");
1501     while (<$F>)
1502       {
1503         my $l=$_;
1504         if (($l =~/^\/\//) || ($db=~/^#/)){;}
1505         elsif ( !($l =~/\w/)){;}
1506         else
1507           {
1508             my @v=split (/\s+/, $l);
1509             if ( $l=~/^MODE/)
1510               {
1511                 $MODE{$v[1]}{$v[2]}=$v[3];
1512               }
1513             elsif ($l=~/^PG/)
1514               {
1515                 $PG{$v[1]}{$v[2]}=$v[3];
1516               }
1517           }
1518       }
1519     close ($F);
1520     &post_process_PG();
1521     return;
1522   }
1523
1524
1525
1526 sub initialize_PG
1527   {
1528 #TclinkdbStart End tag for the list updating
1529
1530 $PG{"t_coffee"}{"4_TCOFFEE"}="TCOFFEE";
1531 $PG{"t_coffee"}{"type"}="sequence_multiple_aligner";
1532 $PG{"t_coffee"}{"ADDRESS"}="http://www.tcoffee.org";
1533 $PG{"t_coffee"}{"language"}="C";
1534 $PG{"t_coffee"}{"language2"}="C";
1535 $PG{"t_coffee"}{"source"}="http://www.tcoffee.org/Packages/T-COFFEE_distribution.tar.gz";
1536 $PG{"t_coffee"}{"update_action"}="always";
1537 $PG{"t_coffee"}{"mode"}="tcoffee,mcoffee,rcoffee,expresso,3dcoffee";
1538 $PG{"clustalw2"}{"4_TCOFFEE"}="CLUSTALW2";
1539 $PG{"clustalw2"}{"type"}="sequence_multiple_aligner";
1540 $PG{"clustalw2"}{"ADDRESS"}="http://www.clustal.org";
1541 $PG{"clustalw2"}{"language"}="C++";
1542 $PG{"clustalw2"}{"language2"}="CXX";
1543 $PG{"clustalw2"}{"source"}="http://www.clustal.org/download/2.0.10/clustalw-2.0.10-src.tar.gz";
1544 $PG{"clustalw2"}{"mode"}="mcoffee,rcoffee";
1545 $PG{"clustalw2"}{"version"}="2.0.10";
1546 $PG{"clustalw"}{"4_TCOFFEE"}="CLUSTALW";
1547 $PG{"clustalw"}{"type"}="sequence_multiple_aligner";
1548 $PG{"clustalw"}{"ADDRESS"}="http://www.clustal.org";
1549 $PG{"clustalw"}{"language"}="C";
1550 $PG{"clustalw"}{"language2"}="C";
1551 $PG{"clustalw"}{"source"}="http://www.clustal.org/download/1.X/ftp-igbmc.u-strasbg.fr/pub/ClustalW/clustalw1.82.UNIX.tar.gz";
1552 $PG{"clustalw"}{"mode"}="mcoffee,rcoffee";
1553 $PG{"clustalw"}{"version"}="1.82";
1554 $PG{"dialign-t"}{"4_TCOFFEE"}="DIALIGNT";
1555 $PG{"dialign-t"}{"type"}="sequence_multiple_aligner";
1556 $PG{"dialign-t"}{"ADDRESS"}="http://dialign-tx.gobics.de/";
1557 $PG{"dialign-t"}{"DIR"}="/usr/share/dialign-tx/";
1558 $PG{"dialign-t"}{"language"}="C";
1559 $PG{"dialign-t"}{"language2"}="C";
1560 $PG{"dialign-t"}{"source"}="http://dialign-tx.gobics.de/DIALIGN-TX_1.0.2.tar.gz";
1561 $PG{"dialign-t"}{"mode"}="mcoffee";
1562 $PG{"dialign-t"}{"binary"}="dialign-t";
1563 $PG{"dialign-t"}{"version"}="1.0.2";
1564 $PG{"dialign-tx"}{"4_TCOFFEE"}="DIALIGNTX";
1565 $PG{"dialign-tx"}{"type"}="sequence_multiple_aligner";
1566 $PG{"dialign-tx"}{"ADDRESS"}="http://dialign-tx.gobics.de/";
1567 $PG{"dialign-tx"}{"DIR"}="/usr/share/dialign-tx/";
1568 $PG{"dialign-tx"}{"language"}="C";
1569 $PG{"dialign-tx"}{"language2"}="C";
1570 $PG{"dialign-tx"}{"source"}="http://dialign-tx.gobics.de/DIALIGN-TX_1.0.2.tar.gz";
1571 $PG{"dialign-tx"}{"mode"}="mcoffee";
1572 $PG{"dialign-tx"}{"binary"}="dialign-tx";
1573 $PG{"dialign-tx"}{"version"}="1.0.2";
1574 $PG{"poa"}{"4_TCOFFEE"}="POA";
1575 $PG{"poa"}{"type"}="sequence_multiple_aligner";
1576 $PG{"poa"}{"ADDRESS"}="http://www.bioinformatics.ucla.edu/poa/";
1577 $PG{"poa"}{"language"}="C";
1578 $PG{"poa"}{"language2"}="C";
1579 $PG{"poa"}{"source"}="http://downloads.sourceforge.net/poamsa/poaV2.tar.gz";
1580 $PG{"poa"}{"DIR"}="/usr/share/";
1581 $PG{"poa"}{"FILE1"}="blosum80.mat";
1582 $PG{"poa"}{"mode"}="mcoffee";
1583 $PG{"poa"}{"binary"}="poa";
1584 $PG{"poa"}{"version"}="2.0";
1585 $PG{"probcons"}{"4_TCOFFEE"}="PROBCONS";
1586 $PG{"probcons"}{"type"}="sequence_multiple_aligner";
1587 $PG{"probcons"}{"ADDRESS"}="http://probcons.stanford.edu/";
1588 $PG{"probcons"}{"language2"}="CXX";
1589 $PG{"probcons"}{"language"}="C++";
1590 $PG{"probcons"}{"source"}="http://probcons.stanford.edu/probcons_v1_12.tar.gz";
1591 $PG{"probcons"}{"mode"}="mcoffee";
1592 $PG{"probcons"}{"binary"}="probcons";
1593 $PG{"probcons"}{"version"}="1.12";
1594 $PG{"mafft"}{"4_TCOFFEE"}="MAFFT";
1595 $PG{"mafft"}{"type"}="sequence_multiple_aligner";
1596 $PG{"mafft"}{"ADDRESS"}="http://align.bmr.kyushu-u.ac.jp/mafft/online/server/";
1597 $PG{"mafft"}{"language"}="C";
1598 $PG{"mafft"}{"language"}="C";
1599 $PG{"mafft"}{"source"}="http://align.bmr.kyushu-u.ac.jp/mafft/software/mafft-6.603-with-extensions-src.tgz";
1600 $PG{"mafft"}{"windows"}="http://align.bmr.kyushu-u.ac.jp/mafft/software/mafft-6.603-mingw.tar";
1601 $PG{"mafft"}{"mode"}="mcoffee,rcoffee";
1602 $PG{"mafft"}{"binary"}="mafft.tar.gz";
1603 $PG{"mafft"}{"version"}="6.603";
1604 $PG{"muscle"}{"4_TCOFFEE"}="MUSCLE";
1605 $PG{"muscle"}{"type"}="sequence_multiple_aligner";
1606 $PG{"muscle"}{"ADDRESS"}="http://www.drive5.com/muscle/";
1607 $PG{"muscle"}{"language"}="C++";
1608 $PG{"muscle"}{"language2"}="GPP";
1609 $PG{"muscle"}{"source"}="http://www.drive5.com/muscle/downloads3.7/muscle3.7_src.tar.gz";
1610 $PG{"muscle"}{"windows"}="http://www.drive5.com/muscle/downloads3.7/muscle3.7_win32.zip";
1611 $PG{"muscle"}{"linux"}="http://www.drive5.com/muscle/downloads3.7/muscle3.7_linux_ia32.tar.gz";
1612 $PG{"muscle"}{"mode"}="mcoffee,rcoffee";
1613 $PG{"muscle"}{"version"}="3.7";
1614 $PG{"mus4"}{"4_TCOFFEE"}="MUS4";
1615 $PG{"mus4"}{"type"}="sequence_multiple_aligner";
1616 $PG{"mus4"}{"ADDRESS"}="http://www.drive5.com/muscle/";
1617 $PG{"mus4"}{"language"}="C++";
1618 $PG{"mus4"}{"language2"}="GPP";
1619 $PG{"mus4"}{"source"}="http://www.drive5.com/muscle/muscle4.0_src.tar.gz";
1620 $PG{"mus4"}{"mode"}="mcoffee,rcoffee";
1621 $PG{"mus4"}{"version"}="4.0";
1622 $PG{"pcma"}{"4_TCOFFEE"}="PCMA";
1623 $PG{"pcma"}{"type"}="sequence_multiple_aligner";
1624 $PG{"pcma"}{"ADDRESS"}="ftp://iole.swmed.edu/pub/PCMA/";
1625 $PG{"pcma"}{"language"}="C";
1626 $PG{"pcma"}{"language2"}="C";
1627 $PG{"pcma"}{"source"}="ftp://iole.swmed.edu/pub/PCMA/pcma.tar.gz";
1628 $PG{"pcma"}{"mode"}="mcoffee";
1629 $PG{"pcma"}{"version"}="1.0";
1630 $PG{"kalign"}{"4_TCOFFEE"}="KALIGN";
1631 $PG{"kalign"}{"type"}="sequence_multiple_aligner";
1632 $PG{"kalign"}{"ADDRESS"}="http://msa.cgb.ki.se";
1633 $PG{"kalign"}{"language"}="C";
1634 $PG{"kalign"}{"language2"}="C";
1635 $PG{"kalign"}{"source"}="http://msa.cgb.ki.se/downloads/kalign/current.tar.gz";
1636 $PG{"kalign"}{"mode"}="mcoffee";
1637 $PG{"kalign"}{"version"}="1.0";
1638 $PG{"amap"}{"4_TCOFFEE"}="AMAP";
1639 $PG{"amap"}{"type"}="sequence_multiple_aligner";
1640 $PG{"amap"}{"ADDRESS"}="http://bio.math.berkeley.edu/amap/";
1641 $PG{"amap"}{"language"}="C++";
1642 $PG{"amap"}{"language2"}="CXX";
1643 $PG{"amap"}{"source"}="http://amap-align.googlecode.com/files/amap.2.0.tar.gz";
1644 $PG{"amap"}{"mode"}="mcoffee";
1645 $PG{"amap"}{"version"}="2.0";
1646 $PG{"proda"}{"4_TCOFFEE"}="PRODA";
1647 $PG{"proda"}{"type"}="sequence_multiple_aligner";
1648 $PG{"proda"}{"ADDRESS"}="http://proda.stanford.edu";
1649 $PG{"proda"}{"language"}="C++";
1650 $PG{"proda"}{"language2"}="CXX";
1651 $PG{"proda"}{"source"}="http://proda.stanford.edu/proda_1_0.tar.gz";
1652 $PG{"proda"}{"mode"}="mcoffee";
1653 $PG{"proda"}{"version"}="1.0";
1654 $PG{"fsa"}{"4_TCOFFEE"}="FSA";
1655 $PG{"fsa"}{"type"}="sequence_multiple_aligner";
1656 $PG{"fsa"}{"ADDRESS"}="http://fsa.sourceforge.net/";
1657 $PG{"fsa"}{"language"}="C++";
1658 $PG{"fsa"}{"language2"}="CXX";
1659 $PG{"fsa"}{"source"}="http://sourceforge.net/projects/fsa/files/fsa-1.15.3.tar.gz/download/";
1660 $PG{"fsa"}{"mode"}="mcoffee";
1661 $PG{"fsa"}{"version"}="1.15.3";
1662 $PG{"prank"}{"4_TCOFFEE"}="PRANK";
1663 $PG{"prank"}{"type"}="sequence_multiple_aligner";
1664 $PG{"prank"}{"ADDRESS"}="http://www.ebi.ac.uk/goldman-srv/prank/";
1665 $PG{"prank"}{"language"}="C++";
1666 $PG{"prank"}{"language2"}="CXX";
1667 $PG{"prank"}{"source"}="http://www.ebi.ac.uk/goldman-srv/prank/src/prank/prank.src.100303.tgz";
1668 $PG{"prank"}{"mode"}="mcoffee";
1669 $PG{"prank"}{"version"}="100303";
1670 $PG{"sap"}{"4_TCOFFEE"}="SAP";
1671 $PG{"sap"}{"type"}="structure_pairwise_aligner";
1672 $PG{"sap"}{"ADDRESS"}="http://mathbio.nimr.mrc.ac.uk/wiki/Software";
1673 $PG{"sap"}{"language"}="C";
1674 $PG{"sap"}{"language2"}="C";
1675 $PG{"sap"}{"source"}="http://mathbio.nimr.mrc.ac.uk/download/sap-1.1.1.tar.gz";
1676 $PG{"sap"}{"mode"}="expresso,3dcoffee";
1677 $PG{"sap"}{"version"}="1.1.1";
1678 $PG{"TMalign"}{"4_TCOFFEE"}="TMALIGN";
1679 $PG{"TMalign"}{"type"}="structure_pairwise_aligner";
1680 $PG{"TMalign"}{"ADDRESS"}="http://zhang.bioinformatics.ku.edu/TM-align/TMalign.f";
1681 $PG{"TMalign"}{"language"}="Fortran";
1682 $PG{"TMalign"}{"language2"}="Fortran";
1683 $PG{"TMalign"}{"source"}="http://zhang.bioinformatics.ku.edu/TM-align/TMalign.f";
1684 $PG{"TMalign"}{"linux"}="http://zhang.bioinformatics.ku.edu/TM-align/TMalign_32.gz";
1685 $PG{"TMalign"}{"mode"}="expresso,3dcoffee";
1686 $PG{"TMalign"}{"version"}="1.0";
1687 $PG{"mustang"}{"4_TCOFFEE"}="MUSTANG";
1688 $PG{"mustang"}{"type"}="structure_pairwise_aligner";
1689 $PG{"mustang"}{"ADDRESS"}="http://www.cs.mu.oz.au/~arun/mustang";
1690 $PG{"mustang"}{"language"}="C++";
1691 $PG{"mustang"}{"language2"}="CXX";
1692 $PG{"mustang"}{"source"}="http://ww2.cs.mu.oz.au/~arun/mustang/mustang_v3.2.1.tgz";
1693 $PG{"mustang"}{"mode"}="expresso,3dcoffee";
1694 $PG{"mustang"}{"version"}="3.2.1";
1695 $PG{"lsqman"}{"4_TCOFFEE"}="LSQMAN";
1696 $PG{"lsqman"}{"type"}="structure_pairwise_aligner";
1697 $PG{"lsqman"}{"ADDRESS"}="empty";
1698 $PG{"lsqman"}{"language"}="empty";
1699 $PG{"lsqman"}{"language2"}="empty";
1700 $PG{"lsqman"}{"source"}="empty";
1701 $PG{"lsqman"}{"update_action"}="never";
1702 $PG{"lsqman"}{"mode"}="expresso,3dcoffee";
1703 $PG{"align_pdb"}{"4_TCOFFEE"}="ALIGN_PDB";
1704 $PG{"align_pdb"}{"type"}="structure_pairwise_aligner";
1705 $PG{"align_pdb"}{"ADDRESS"}="empty";
1706 $PG{"align_pdb"}{"language"}="empty";
1707 $PG{"align_pdb"}{"language2"}="empty";
1708 $PG{"align_pdb"}{"source"}="empty";
1709 $PG{"align_pdb"}{"update_action"}="never";
1710 $PG{"align_pdb"}{"mode"}="expresso,3dcoffee";
1711 $PG{"fugueali"}{"4_TCOFFEE"}="FUGUE";
1712 $PG{"fugueali"}{"type"}="structure_pairwise_aligner";
1713 $PG{"fugueali"}{"ADDRESS"}="http://www-cryst.bioc.cam.ac.uk/fugue/download.html";
1714 $PG{"fugueali"}{"language"}="empty";
1715 $PG{"fugueali"}{"language2"}="empty";
1716 $PG{"fugueali"}{"source"}="empty";
1717 $PG{"fugueali"}{"update_action"}="never";
1718 $PG{"fugueali"}{"mode"}="expresso,3dcoffee";
1719 $PG{"dalilite.pl"}{"4_TCOFFEE"}="DALILITEc";
1720 $PG{"dalilite.pl"}{"type"}="structure_pairwise_aligner";
1721 $PG{"dalilite.pl"}{"ADDRESS"}="built_in";
1722 $PG{"dalilite.pl"}{"ADDRESS2"}="http://www.ebi.ac.uk/Tools/webservices/services/dalilite";
1723 $PG{"dalilite.pl"}{"language"}="Perl";
1724 $PG{"dalilite.pl"}{"language2"}="Perl";
1725 $PG{"dalilite.pl"}{"source"}="empty";
1726 $PG{"dalilite.pl"}{"update_action"}="never";
1727 $PG{"dalilite.pl"}{"mode"}="expresso,3dcoffee";
1728 $PG{"probconsRNA"}{"4_TCOFFEE"}="PROBCONSRNA";
1729 $PG{"probconsRNA"}{"type"}="RNA_multiple_aligner";
1730 $PG{"probconsRNA"}{"ADDRESS"}="http://probcons.stanford.edu/";
1731 $PG{"probconsRNA"}{"language"}="C++";
1732 $PG{"probconsRNA"}{"language2"}="CXX";
1733 $PG{"probconsRNA"}{"source"}="http://probcons.stanford.edu/probconsRNA.tar.gz";
1734 $PG{"probconsRNA"}{"mode"}="mcoffee,rcoffee";
1735 $PG{"probconsRNA"}{"version"}="1.0";
1736 $PG{"sfold"}{"4_TCOFFEE"}="CONSAN";
1737 $PG{"sfold"}{"type"}="RNA_pairwise_aligner";
1738 $PG{"sfold"}{"ADDRESS"}="http://selab.janelia.org/software/consan/";
1739 $PG{"sfold"}{"language"}="empty";
1740 $PG{"sfold"}{"language2"}="empty";
1741 $PG{"sfold"}{"source"}="empty";
1742 $PG{"sfold"}{"update_action"}="never";
1743 $PG{"sfold"}{"mode"}="rcoffee";
1744 $PG{"RNAplfold"}{"4_TCOFFEE"}="RNAPLFOLD";
1745 $PG{"RNAplfold"}{"type"}="RNA_secondarystructure_predictor";
1746 $PG{"RNAplfold"}{"ADDRESS"}="http://www.tbi.univie.ac.at/~ivo/RNA/";
1747 $PG{"RNAplfold"}{"language"}="C";
1748 $PG{"RNAplfold"}{"language2"}="C";
1749 $PG{"RNAplfold"}{"source"}="http://www.tbi.univie.ac.at/~ivo/RNA/ViennaRNA-1.7.2.tar.gz";
1750 $PG{"RNAplfold"}{"mode"}="rcoffee,";
1751 $PG{"RNAplfold"}{"version"}="1.7.2";
1752 $PG{"retree"}{"4_TCOFFEE"}="PHYLIP";
1753 $PG{"retree"}{"type"}="RNA_secondarystructure_predictor";
1754 $PG{"retree"}{"ADDRESS"}="http://evolution.gs.washington.edu/phylip/";
1755 $PG{"retree"}{"language"}="C";
1756 $PG{"retree"}{"language2"}="C";
1757 $PG{"retree"}{"source"}="http://evolution.gs.washington.edu/phylip/download/phylip-3.69.tar.gz";
1758 $PG{"retree"}{"mode"}="trmsd,";
1759 $PG{"retree"}{"version"}="3.69";
1760 $PG{"hmmtop"}{"4_TCOFFEE"}="HMMTOP";
1761 $PG{"hmmtop"}{"type"}="protein_secondarystructure_predictor";
1762 $PG{"hmmtop"}{"ADDRESS"}="www.enzim.hu/hmmtop/";
1763 $PG{"hmmtop"}{"language"}="C";
1764 $PG{"hmmtop"}{"language2"}="C";
1765 $PG{"hmmtop"}{"source"}="empty";
1766 $PG{"hmmtop"}{"update_action"}="never";
1767 $PG{"hmmtop"}{"mode"}="tcoffee";
1768 $PG{"gorIV"}{"4_TCOFFEE"}="GOR4";
1769 $PG{"gorIV"}{"type"}="protein_secondarystructure_predictor";
1770 $PG{"gorIV"}{"ADDRESS"}="http://mig.jouy.inra.fr/logiciels/gorIV/";
1771 $PG{"gorIV"}{"language"}="C";
1772 $PG{"gorIV"}{"language2"}="C";
1773 $PG{"gorIV"}{"source"}="http://mig.jouy.inra.fr/logiciels/gorIV/GOR_IV.tar.gz";
1774 $PG{"gorIV"}{"update_action"}="never";
1775 $PG{"gorIV"}{"mode"}="tcoffee";
1776 $PG{"wublast.pl"}{"4_TCOFFEE"}="EBIWUBLASTc";
1777 $PG{"wublast.pl"}{"type"}="protein_homology_predictor";
1778 $PG{"wublast.pl"}{"ADDRESS"}="built_in";
1779 $PG{"wublast.pl"}{"ADDRESS2"}="http://www.ebi.ac.uk/Tools/webservices/services/wublast";
1780 $PG{"wublast.pl"}{"language"}="Perl";
1781 $PG{"wublast.pl"}{"language2"}="Perl";
1782 $PG{"wublast.pl"}{"source"}="empty";
1783 $PG{"wublast.pl"}{"update_action"}="never";
1784 $PG{"wublast.pl"}{"mode"}="psicoffee,expresso,accurate";
1785 $PG{"blastpgp.pl"}{"4_TCOFFEE"}="EBIBLASTPGPc";
1786 $PG{"blastpgp.pl"}{"type"}="protein_homology_predictor";
1787 $PG{"blastpgp.pl"}{"ADDRESS"}="built_in";
1788 $PG{"blastpgp.pl"}{"ADDRESS2"}="http://www.ebi.ac.uk/Tools/webservices/services/blastpgp";
1789 $PG{"blastpgp.pl"}{"language"}="Perl";
1790 $PG{"blastpgp.pl"}{"language2"}="Perl";
1791 $PG{"blastpgp.pl"}{"source"}="empty";
1792 $PG{"blastpgp.pl"}{"update_action"}="never";
1793 $PG{"blastpgp.pl"}{"mode"}="psicoffee,expresso,accurate";
1794 $PG{"blastcl3"}{"4_TCOFFEE"}="NCBIWEBBLAST";
1795 $PG{"blastcl3"}{"type"}="protein_homology_predictor";
1796 $PG{"blastcl3"}{"ADDRESS"}="ftp://ftp.ncbi.nih.gov/blast/executables/LATEST";
1797 $PG{"blastcl3"}{"language"}="C";
1798 $PG{"blastcl3"}{"language2"}="C";
1799 $PG{"blastcl3"}{"source"}="empty";
1800 $PG{"blastcl3"}{"update_action"}="never";
1801 $PG{"blastcl3"}{"mode"}="psicoffee,expresso,3dcoffee";
1802 $PG{"blastall"}{"4_TCOFFEE"}="blastall";
1803 $PG{"blastall"}{"type"}="protein_homology_predictor";
1804 $PG{"blastall"}{"ADDRESS"}="ftp://ftp.ncbi.nih.gov/blast/executables/LATEST";
1805 $PG{"blastall"}{"language"}="C";
1806 $PG{"blastall"}{"language2"}="C";
1807 $PG{"blastall"}{"source"}="empty";
1808 $PG{"blastall"}{"update_action"}="never";
1809 $PG{"blastall"}{"mode"}="psicoffee,expresso,3dcoffee";
1810 $PG{"legacy_blast.pl"}{"4_TCOFFEE"}="NCBIBLAST";
1811 $PG{"legacy_blast.pl"}{"type"}="protein_homology_predictor";
1812 $PG{"legacy_blast.pl"}{"ADDRESS"}="ftp://ftp.ncbi.nih.gov/blast/executables/LATEST";
1813 $PG{"legacy_blast.pl"}{"language"}="C";
1814 $PG{"legacy_blast.pl"}{"language2"}="C";
1815 $PG{"legacy_blast.pl"}{"source"}="empty";
1816 $PG{"legacy_blast.pl"}{"update_action"}="never";
1817 $PG{"legacy_blast.pl"}{"mode"}="psicoffee,expresso,3dcoffee";
1818 $PG{"SOAP::Lite"}{"4_TCOFFEE"}="SOAPLITE";
1819 $PG{"SOAP::Lite"}{"type"}="library";
1820 $PG{"SOAP::Lite"}{"ADDRESS"}="http://cpansearch.perl.org/src/MKUTTER/SOAP-Lite-0.710.08/Makefile.PL";
1821 $PG{"SOAP::Lite"}{"language"}="Perl";
1822 $PG{"SOAP::Lite"}{"language2"}="Perl";
1823 $PG{"SOAP::Lite"}{"source"}="empty";
1824 $PG{"blastpgp"}{"update_action"}="never";
1825 $PG{"SOAP::Lite"}{"mode"}="none";
1826 $PG{"XML::Simple"}{"4_TCOFFEE"}="XMLSIMPLE";
1827 $PG{"XML::Simple"}{"type"}="library";
1828 $PG{"XML::Simple"}{"ADDRESS"}="http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm";
1829 $PG{"XML::Simple"}{"language"}="Perl";
1830 $PG{"XML::Simple"}{"language2"}="Perl";
1831 $PG{"XML::Simple"}{"source"}="empty";
1832 $PG{"XML::Simple"}{"mode"}="psicoffee,expresso,accurate";
1833 $MODE{"tcoffee"}{"name"}="tcoffee";
1834 $MODE{"rcoffee"}{"name"}="rcoffee";
1835 $MODE{"3dcoffee"}{"name"}="3dcoffee";
1836 $MODE{"mcoffee"}{"name"}="mcoffee";
1837 $MODE{"expresso"}{"name"}="expresso";
1838 $MODE{"trmsd"}{"name"}="trmsd";
1839 $MODE{"accurate"}{"name"}="accurate";
1840 $MODE{"seq_reformat"}{"name"}="seq_reformat";
1841 #TclinkdbEnd End tag for the list updating
1842
1843 ########### Compilers ##############################
1844 #
1845 #
1846
1847 $PG{C}{compiler}="gcc";
1848 $PG{C}{compiler_flag}="CC";
1849 $PG{C}{options}="";
1850 $PG{C}{options_flag}="CFLAGS";
1851 $PG{C}{type}="compiler";
1852
1853 $PG{"CXX"}{compiler}="g++";
1854 $PG{"CXX"}{compiler_flag}="CXX";
1855 $PG{"CXX"}{options}="";
1856 $PG{"CXX"}{options_flag}="CXXFLAGS";
1857 $PG{CXX}{type}="compiler";
1858
1859 $PG{"CPP"}{compiler}="g++";
1860 $PG{"CPP"}{compiler_flag}="CPP";
1861 $PG{"CPP"}{options}="";
1862 $PG{"CPP"}{options_flag}="CPPFLAGS";
1863 $PG{CPP}{type}="compiler";
1864
1865 $PG{"GPP"}{compiler}="g++";
1866 $PG{"GPP"}{compiler_flag}="GPP";
1867 $PG{"GPP"}{options}="";
1868 $PG{"GPP"}{options_flag}="CFLAGS";
1869 $PG{GPP}{type}="compiler";
1870
1871 $PG{Fortran}{compiler}="g77";
1872 $PG{Fortran}{compiler_flag}="FCC";
1873 $PG{Fortran}{type}="compiler";
1874
1875 $PG{Perl}{compiler}="CPAN";
1876 $PG{Perl}{type}="compiler";
1877
1878 $SUPPORTED_OS{macox}="Macintosh";
1879 $SUPPORTED_OS{linux}="Linux";
1880 $SUPPORTED_OS{windows}="Cygwin";
1881
1882
1883
1884 $MODE{t_coffee}{description}=" for regular multiple sequence alignments";
1885 $MODE{rcoffee} {description}=" for RNA multiple sequence alignments";
1886
1887 $MODE{psicoffee} {description}=" for Homology Extended multiple sequence alignments";
1888 $MODE{expresso}{description}=" for very accurate structure based multiple sequence alignments";
1889 $MODE{"3dcoffee"}{description}=" for multiple structure alignments";
1890 $MODE{mcoffee} {description}=" for combining alternative multiple sequence alignment packages\n------- into a unique meta-package. The installer will upload several MSA packages and compile them\n
1891 ";
1892
1893
1894 &post_process_PG();
1895 return;
1896 }
1897
1898 sub post_process_PG
1899   {
1900     my $p;
1901     
1902     %PG=&name2dname (%PG);
1903     %MODE=&name2dname(%MODE);
1904     foreach $p (keys(%PG)){if ( $PG{$p}{type} eq "compiler"){$PG{$p}{update_action}="never";}}
1905     
1906   }
1907
1908 sub name2dname
1909   {
1910     my (%L)=(@_);
1911     my ($l, $ml);
1912     
1913     foreach my $pg (keys(%L))
1914       {
1915         $l=length ($pg);
1916         if ( $l>$ml){$ml=$l;}
1917       }
1918     $ml+=1;
1919     foreach my $pg (keys(%L))
1920       {
1921         my $name;
1922         $l=$ml-length ($pg);
1923         $name=$pg;
1924         for ( $b=0; $b<$l; $b++)
1925           {
1926             $name .=" ";
1927           }
1928         $L{$pg}{dname}=$name;
1929       }
1930     return %L;
1931   }
1932
1933 sub env_file2putenv
1934   {
1935     my $f=@_[0];
1936     my $F=new FileHandle;
1937     my $n;
1938     
1939     open ($F, "$f");
1940     while (<$F>)
1941       {
1942         my $line=$_;
1943         my($var, $value)=($_=~/(\S+)\=(\S*)/);
1944         $ENV{$var}=$value;
1945         $ENV_SET{$var}=1;
1946         $n++;
1947       }
1948     close ($F);
1949     return $n;
1950   }
1951
1952 sub replace_line_in_file
1953   {
1954     my ($file, $wordin, $wordout)=@_;
1955     my $O=new FileHandle;
1956     my $I=new FileHandle;
1957     my $l;
1958     if (!-e $file){return;}
1959     
1960     system ("mv $file $file.old");
1961     open ($O, ">$file");
1962     open ($I, "$file.old");
1963     while (<$I>)
1964       {
1965         $l=$_;
1966         if (!($l=~/$wordin/)){print $O "$l";}
1967         elsif ( $wordout ne ""){$l=~s/$wordin/$wordout/g;print $O "$l";}
1968       }
1969     close ($O);
1970     close ($I);
1971     return;
1972   }
1973
1974 sub add_C_libraries
1975   {
1976    my ($file,$first,@list)=@_;
1977    
1978     my $O=new FileHandle;
1979     my $I=new FileHandle;
1980     my ($l,$anchor);
1981     if (!-e $file){return;}
1982    
1983     $anchor="#include <$first>";
1984          
1985     system ("mv $file $file.old");
1986     open ($O, ">$file");
1987     open ($I, "$file.old");
1988     while (<$I>)
1989       {
1990         $l=$_;
1991         print $O "$l";
1992         if (!($l=~/$anchor/))
1993            {
1994             
1995             foreach my $lib (@list)
1996                {
1997                   print $O "#include <$lib>\n";
1998                }
1999            }
2000       }
2001     close ($O);
2002     close ($I);
2003     return;
2004     }