root/juggler/trunk/configure.pl

Revision 20974, 25.0 kB (checked in by patrick, 8 months ago)

Copyright update.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/bin/env perl
2
3 # ************** <auto-copyright.pl BEGIN do not edit this line> **************
4 #
5 # VR Juggler is (C) Copyright 1998-2008 by Iowa State University
6 #
7 # Original Authors:
8 #   Allen Bierbaum, Christopher Just,
9 #   Patrick Hartling, Kevin Meinert,
10 #   Carolina Cruz-Neira, Albert Baker
11 #
12 # This library is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU Library General Public
14 # License as published by the Free Software Foundation; either
15 # version 2 of the License, or (at your option) any later version.
16 #
17 # This library is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 # Library General Public License for more details.
21 #
22 # You should have received a copy of the GNU Library General Public
23 # License along with this library; if not, write to the
24 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 # Boston, MA 02111-1307, USA.
26 #
27 # *************** <auto-copyright.pl END do not edit this line> ***************
28
29 use 5.005;
30
31 use strict 'vars';
32 use vars qw($base_dir $module $PRELUDE $FEATURE_ARGS $PACKAGE_ARGS $PROLOGUE
33             $LAST_ARG_GROUP $OS $Win32 $CFG_LOAD_FUNC);
34 use vars qw(%MODULES);
35
36 use Cwd qw(chdir getcwd);
37 use File::Basename;
38 use File::Path;
39 use Getopt::Long;
40 use Pod::Usage;
41
42 BEGIN
43 {
44    $base_dir = (fileparse("$0"))[1];
45    $base_dir =~ s|/+$||;
46 }
47
48 use lib("$base_dir");
49 use JugglerConfigure;
50
51 # Subroutine prototypes.
52 sub mergeArgArrays($$);
53 sub loadDefaultArgs($);
54 sub generateTopLevelMakefile(;$);
55 sub generateModuleMakefiles($);
56 sub generatePreMakefile($);
57 sub generateReconfig($@);
58 sub listModules();
59 sub printHelp();
60 sub getConfigureHelp($$);
61 sub parseOutput($$);
62 sub getPlatform();
63
64 %MODULES = ();
65
66 my $all_help      = 0;
67 my $cfg           = "juggler.cfg";
68 my $user_cfg      = '';
69 $module           = '';
70 my $script_help   = 0;
71 my $manual        = 0;
72 my $mod_list      = 0;
73 my $args_file     = 'acdefaults.cfg';
74 my $args_mod_file = 'acdefaults.pl';
75 my $user_args     = '';
76 my $user_args_mod = '';
77 my $no_user_args  = 0;
78
79 $PRELUDE        = 0;
80 $FEATURE_ARGS   = 1;
81 $PACKAGE_ARGS   = 2;
82 $PROLOGUE       = 3;
83 $LAST_ARG_GROUP = 4;
84
85 $CFG_LOAD_FUNC = undef;
86 $OS            = '';
87
88 my @save_argv = @ARGV;
89
90 Getopt::Long::Configure('pass_through');
91 GetOptions('help|?' => \$script_help, 'cfg=s' => \$user_cfg,
92            'module=s' => \$module, 'all-help' => \$all_help,
93            'manual' => \$manual, 'modlist' => \$mod_list,
94            'args=s' => \$user_args, 'argsmod=s' => \$user_args_mod,
95            'noargs' => \$no_user_args, 'os=s' => \$OS)
96    or pod2usage(2);
97
98 # Print the help output and exit if --help was on the command line.
99 pod2usage(1) if $script_help;
100 pod2usage(-exitstatus => 0, -verbose => 2) if $manual;
101
102 die "ERROR: No configuration given\n" unless $cfg || $user_cfg;
103
104 my $inst_prefix = '/usr/local';
105 my $arg;
106 foreach $arg ( @ARGV )
107 {
108    if ( $arg =~ /--prefix=(.*)$/ )
109    {
110       $inst_prefix = "$1";
111    }
112 }
113
114 $Win32 = 1 if $ENV{'OS'} && $ENV{'OS'} =~ /Windows/;
115
116 # On Windows, the command-line arguments can confuse the Cygwin shell.  For
117 # example, the character used to separate paths is ';', but the shell sees
118 # that as a statement separator.  We can deal with this by ensuring that the
119 # shell interprets command-line arguments as literal strings (i.e., by
120 # putting quotes around each argument).
121 if ( $Win32 )
122 {
123    die "Absolute Cygwin paths confuse Visual C++.  Use a relative path.\n"
124       if $0 =~ /^\//;
125
126    for ( my $i = 0; $i <= $#save_argv; $i++ )
127    {
128       $save_argv[$i] = "\"$save_argv[$i]\"";
129    }
130
131    for ( my $i = 0; $i <= $#ARGV; $i++ )
132    {
133       $ARGV[$i] = "\"$ARGV[$i]\"";
134    }
135 }
136
137 my $cfg_load = ("$user_cfg" eq "") ? "$base_dir/$cfg" : "$user_cfg";
138 %MODULES = JugglerConfigure::parseConfigFile("$cfg_load");
139
140 listModules() && exit(0) if $mod_list;
141 printHelp() && exit(0) if $all_help;
142
143 {
144    my $cache_file_set = 0;
145
146    foreach ( @ARGV )
147    {
148       if ( /-cache-f/ )
149       {
150          $cache_file_set = 1;
151          last;
152       }
153    }
154
155    # Unless the user passed --noargs, try to find default argument values.
156    unless ( $no_user_args )
157    {
158       my $args_mod = ("$user_args_mod" eq "") ? "$base_dir/$args_mod_file"
159                                               : "$user_args_mod";
160
161       # Figure out what argument file to load, if any.  If the user specified
162       # a file name on the command line, it will be in $user_args.  Otherwise,
163       # we fall back on $base_dir/$args_file.
164       my $args_load = ("$user_args" eq "") ? "$base_dir/$args_file"
165                                            : "$user_args";
166
167       if ( -r "$args_mod" )
168       {
169          require "$args_mod";
170
171          if ( $CFG_LOAD_FUNC )
172          {
173             my @default_args = &$CFG_LOAD_FUNC();
174             mergeArgArrays(\@ARGV, \@default_args);
175          }
176       }
177       elsif ( -r "$args_load" )
178       {
179          loadDefaultArgs("$args_load");
180       }
181    }
182
183    if ( ! $cache_file_set )
184    {
185       my $cwd = getcwd();
186       push(@ARGV, "--cache-file=$cwd/config.cache");
187    }
188
189    # Configure the module named on the command line.
190    if ( $module )
191    {
192       die "ERROR: No such module $module in $cfg!\n"
193          unless defined($MODULES{"$module"});
194
195       generateReconfig("$module", @save_argv);
196       generateModuleMakefiles("$module");
197       generateTopLevelMakefile("$module");
198    }
199    # If no module was named on the command line but we do have a default
200    # module, configure it.
201    elsif ( $JugglerConfigure::DEFAULT_MODULE &&
202            defined($MODULES{"$JugglerConfigure::DEFAULT_MODULE"}) )
203    {
204       generateReconfig("$JugglerConfigure::DEFAULT_MODULE", @save_argv);
205       generateModuleMakefiles("$JugglerConfigure::DEFAULT_MODULE");
206       generateTopLevelMakefile("$JugglerConfigure::DEFAULT_MODULE");
207    }
208    # If neither of the above will do, just configure every module we know
209    # about from the input file.
210    else
211    {
212       generateReconfig('', @save_argv);
213
214       foreach ( keys(%MODULES) )
215       {
216          generateModuleMakefiles("$_");
217       }
218
219       generateTopLevelMakefile();
220    }
221
222    my $gnu_make = 'gmake';
223
224    # Do a quick check to try to find GNU make.  If we don't find it, then we
225    # will just assume that GNU make is 'gmake' and that the user knows what
226    # he or she is doing.
227    foreach ( 'make', 'gmake' )
228    {
229       my $result = open(MAKE, "$_ -v 2>&1 |");
230       next unless $result;
231       my @output = <MAKE>;
232       close(MAKE);
233
234       if ( grep(/GNU Make/, @output) )
235       {
236          $gnu_make = $_;
237          last;
238       }
239    }
240
241    print <<EOF;
242  
243  GNU make is required to build the Juggler Suite.
244  On your system, GNU make is the command $gnu_make.
245  To build and install everything into $inst_prefix,
246  run the following:
247  
248     $gnu_make build install
249  
250  To make a developer build and installation in
251  ./instlinks, (debug only), simply run the following:
252
253     $gnu_make
254
255  To make an optimized build in ./instlinks, run the
256  following:
257
258     $gnu_make optim
259
260 EOF
261 }
262
263 exit(0);
264
265 # =============================================================================
266 # Subroutines follow.
267 # =============================================================================
268
269 sub mergeArgArrays ($$)
270 {
271    my $dest_list   = shift;
272    my $source_list = shift;
273
274    foreach ( @$source_list )
275    {
276       # Strip leading and trailing whitespace.
277       s/^\s+//;
278       s/\s+$//;
279       next if /^$/;   # Just to be safe...
280       
281       # Only add the argument if it is not already on the command line.
282       m/^(--[^=]+)/;
283       push(@$dest_list, "$_") unless grep(/$1/, @$dest_list);
284    }
285 }
286
287 sub loadDefaultArgs ($)
288 {
289    my $args_load = shift;
290
291    if ( open(ARGS_FILE, "$args_load") )
292    {
293       print "Loading default arguments from $args_load ...\n";
294       my $args_contents = '';
295
296       while ( <ARGS_FILE> )
297       {
298          s/#.*$//;           # Strip comments
299          next if /^\s*$/;    # Skip blank lines
300          $args_contents .= "$_";
301       }
302
303       close(ARGS_FILE) or warn "WARNING: Could not close $args_load: $!\n";
304
305       my $platform = getPlatform();
306
307       while ( "$args_contents" ne '' )
308       {
309          my @args_list = ();
310
311          # Read in the arguments for all platforms.
312          if ( $args_contents =~ /^\s*all\s*{(.+?)}\s*/si )
313          {
314             @args_list     = split(m|$/|, "$1");
315             $args_contents = $';
316          }
317          # Read in the arguments for the current platform.
318          elsif ( $args_contents =~ /^\s*$platform\s*{(.+?)}\s*/sio )
319          {
320             @args_list     = split(m|$/|, "$1");
321             $args_contents = $';
322          }
323          # Skip a platform that does not match $platform.
324          elsif ( $args_contents =~ /^\s*(\S+)\b\s*{(.+?)}\s*/s )
325          {
326             print "Skipping $1\n";
327             $args_contents = $';
328          }
329
330          mergeArgArrays(\@ARGV, \@args_list);
331       }
332    }
333    else
334    {
335       warn "WARNING: Coult not read from $args_load: $!\n";
336    }
337 }
338
339 sub generateTopLevelMakefile(;$)
340 {
341    my $gen_module = shift || '';
342
343    open(INPUT, "$base_dir/Makefile.in")
344       or die "ERROR: Could not read from $base_dir/Makefile.in: $!\n";
345
346    my $input_file;
347    while ( <INPUT> )
348    {
349       $input_file .= "$_";
350    }
351
352    close(INPUT);
353
354    my $modules;
355    my @module_array;
356
357    if ( $gen_module )
358    {
359       foreach ( $MODULES{"$gen_module"}->getDependencies() )
360       {
361          $modules .= $_->getPath() . " ";
362       }
363    }
364    else
365    {
366       my $mod_name;
367       foreach $mod_name ( keys(%MODULES) )
368       {
369          my $temp_mod;
370          foreach $temp_mod ( $MODULES{"$mod_name"}->getDependencies() )
371          {
372             $modules .= $temp_mod->getPath() . " ";
373          }
374       }
375    }
376
377    warn "WARNING: No modules defined!\n" unless $modules;
378
379    my $cwd = getcwd();
380    chdir("$base_dir");
381    $input_file =~ s/\@JUGGLER_PROJECTS\@/$modules/g;
382
383    if ( $Win32 )
384    {
385       # Get the Win32-friendly versions of these paths.  Then change the \'s
386       # to /'s just to be safe.
387       my $win_pwd = `cygpath -w $ENV{'PWD'}`;
388       my $win_cwd = `cygpath -w $cwd`;
389       chomp($win_pwd);
390       chomp($win_cwd);
391
392       $win_pwd =~ s/\\/\//g;
393       $win_cwd =~ s/\\/\//g;
394
395       $input_file =~ s/\@JUGGLERROOT_ABS\@/$win_pwd/g;
396       $input_file =~ s/\@topdir\@/$win_cwd/g;
397    }
398    else
399    {
400       $input_file =~ s/\@JUGGLERROOT_ABS\@/$ENV{'PWD'}/g;
401       $input_file =~ s/\@topdir\@/$cwd/g;
402    }
403
404    chdir("$cwd");
405
406    print "Generating Makefile\n";
407    open(OUTPUT, "> Makefile") or die "ERROR: Could not create Makefile: $!\n";
408    print OUTPUT "$input_file";
409    close(OUTPUT) or warn "WARNING: Failed to save Makefile: $!\n";
410 }
411
412 sub generateModuleMakefiles($)
413 {
414    my $module_name = shift;
415
416    die "ERROR: No module $module_name defined\n"
417       unless defined($MODULES{"$module_name"});
418
419    my $cwd = getcwd();
420
421    chdir("$base_dir");
422    my $root_srcdir = getcwd();
423    chdir("$cwd");
424
425    my $depencency;
426    foreach $depencency ( $MODULES{"$module_name"}->getDependencies() )
427    {
428       my $mod_path = $depencency->getPath();
429
430       mkpath("$mod_path", 0, 0755) unless -d "$mod_path";
431
432       # Do not try to proceed with $dependency unless we can chdir to
433       # $mod_path.
434       unless ( -e "$root_srcdir/$mod_path/Makefile.pre.in" )
435       {
436          warn "WARNING: Missing $root_srcdir/$mod_path/Makefile.pre.in!\n";
437          next;
438       }
439
440       generatePreMakefile("$mod_path/Makefile.pre");
441    }
442 }
443
444 sub generatePreMakefile($)
445 {
446    my $output_file_name = shift;
447
448    my $cwd = getcwd();
449
450    chdir("$base_dir");
451    my $root_srcdir = getcwd();
452    my $input_file_name  = "$root_srcdir/$output_file_name.in";
453    chdir("$cwd");
454
455    open(INPUT, "$input_file_name")
456       or die "ERROR: Could not read from $input_file_name: $!\n";
457
458    my $input_file;
459    while ( <INPUT> )
460    {
461       $input_file .= "$_";
462    }
463
464    close(INPUT);
465
466    my $srcdir = (fileparse("$input_file_name"))[1];
467    $srcdir =~ s|/+$||;
468
469    my $configure_args = join(" ", @ARGV);
470
471    # Use ksh to run configure if we are on Solaris.  Otherwise, use the default
472    # shell.
473    my $shell = ((getPlatform() =~ /solaris/i) ? 'ksh' : '$(SHELL)');
474
475    $input_file =~ s/\@srcdir\@/$srcdir/g;
476    $input_file =~ s/\@top_srcdir\@/$root_srcdir/g;
477    $input_file =~ s/\@CONFIGURE_ARGS\@/$configure_args/g;
478    $input_file =~ s/\@CFG_SHELL\@/$shell/g;
479
480    print "Generating $output_file_name\n";
481    open(OUTPUT, "> $output_file_name")
482       or die "ERROR: Could not create $output_file_name: $!\n";
483    print OUTPUT "$input_file";
484    close(OUTPUT) or warn "WARNING: Failed to save $output_file_name: $!\n";
485 }
486
487 sub generateReconfig ($@)
488 {
489    my $gen_module = shift;
490    my @arg_list   = @_;
491
492    my $modules;
493
494    open(RECONFIG, "> reconfig");
495
496    print RECONFIG "#!/bin/sh\n";
497    print RECONFIG "if [ \"x\$1\" != \"x-q\" ]; then\n";
498
499    if ( $gen_module )
500    {
501       foreach ( $MODULES{"$gen_module"}->getDependencies() )
502       {
503          print RECONFIG "   (cd " . $_->getPath() .
504                         " && rm -f config.status config.log)\n";
505       }
506    }
507    else
508    {
509       my $mod_name;
510       foreach $mod_name ( keys(%MODULES) )
511       {
512          foreach ( $MODULES{"$mod_name"}->getDependencies() )
513          {
514             print RECONFIG "   (cd " . $_->getPath() .
515                            " && rm -f config.status config.cache config.log)\n";
516          }
517       }
518    }
519
520    print RECONFIG "   rm -f config.cache\n";
521    print RECONFIG "fi\n";
522
523    # Print the command to run this script again.  The actual output will be
524    # the exec shell command followed by the full path to the Perl
525    # interpreter used to run this script; the same path to the script that
526    # the user entered; and the full argument list given on the command line.
527    print RECONFIG "exec $^X $0 ", "@arg_list \n";
528    close(RECONFIG);
529    chmod(0755, "reconfig");
530 }
531
532 sub listModules ()
533 {
534    my $mod_name;
535    foreach $mod_name ( keys(%MODULES) )
536    {
537       print "$mod_name";
538
539 #      if ( $#{$MODULES{"$mod_name"}} != -1 )
540 #      {
541 #         print " (Requires:";
542 #
543 #         my $dep_ref;
544 #         foreach $dep_ref ( @{$MODULES{"$mod_name"}} )
545 #         {
546 #            print " ${$dep_ref}{'path'}";
547 #         }
548 #
549 #         print ")";
550 #      }
551
552       print "\n";
553    }
554
555    return 1;
556 }
557
558 sub printHelp ()
559 {
560    my @help_output = ();
561
562    # Initialize the references that are contained within @help_output.
563    my $i;
564    for ( $i = 0; $i < $LAST_ARG_GROUP; $i++ )
565    {
566       $help_output[$i] = {};
567    }
568
569    if ( $module )
570    {
571       getConfigureHelp("$module", \@help_output);
572    }
573    elsif ( $JugglerConfigure::DEFAULT_MODULE &&
574            defined($MODULES{"$JugglerConfigure::DEFAULT_MODULE"}) )
575    {
576       getConfigureHelp("$JugglerConfigure::DEFAULT_MODULE", \@help_output);
577    }
578    else
579    {
580       foreach ( keys(%MODULES) )
581       {
582          getConfigureHelp("$_", \@help_output);
583       }
584    }
585
586    for ( $i = 0; $i < $LAST_ARG_GROUP; $i++ )
587    {
588       SWITCH:
589       {
590          if ( $i == $PRELUDE )
591          {
592             last SWITCH;
593          }
594
595          if ( $i == $FEATURE_ARGS )
596          {
597             print "Optional Features:\n";
598             last SWITCH;
599          }
600
601          if ( $i == $PACKAGE_ARGS )
602          {
603             print "\nOptional Packages:\n";
604             last SWITCH;
605          }
606
607          if ( $i == $PROLOGUE )
608          {
609             print "\n";
610             last SWITCH;
611          }
612       }
613
614       foreach ( sort(keys(%{$help_output[$i]})) )
615       {
616          print "${$help_output[$i]}{$_}";
617       }
618    }
619
620    print "\n";
621
622    print "Modules that may be built:\n";
623    foreach ( keys(%MODULES) )
624    {
625       print "\t$_\n";
626    }
627
628    print "\nDefault module is $JugglerConfigure::DEFAULT_MODULE\n"
629       if $JugglerConfigure::DEFAULT_MODULE;
630
631    return 1;
632 }
633
634 sub getConfigureHelp ($$)
635 {
636    my $mod_name    = shift;
637    my $arg_arr_ref = shift;
638
639    my $configure_count = 0;
640
641    foreach ( $MODULES{"$mod_name"}->getDependencies() )
642    {
643       next unless -x "$base_dir/$$_{'path'}/configure";
644
645       $configure_count++;
646       open(CFG_OUTPUT, "$base_dir/$$_{'path'}/configure --help |");
647
648       my $cfg_output;
649       while ( <CFG_OUTPUT> )
650       {
651          $cfg_output .= "$_";
652       }
653
654       close(CFG_OUTPUT);
655
656       parseOutput("$cfg_output", $arg_arr_ref);
657    }
658
659    die "ERROR: No configure scripts found!  Please run autogen.sh\n" .
660        "       (found in $base_dir) first.\n"
661       if $configure_count == 0;
662 }
663
664 sub parseOutput ($$)
665 {
666    my $string      = shift;
667    my $arg_arr_ref = shift;
668
669    while ( $string !~ /^\s*$/s )
670    {
671       # Match everything up to the list of optional features.  This forms the
672       # prelude of the help output.
673       if ( $string =~ /^(Usage:.*)(Optional Features:)/s )
674       {
675          $string = "$2$'";
676          ${$$arg_arr_ref[$PRELUDE]}{'all'} = "$1";
677       }
678       # Handle the --enable and --disable list of options.
679       elsif ( $string =~ /^(Optional Features:.*)(Optional Packages:)/s )
680       {
681          $string = "$2$'";
682
683          my @param_list = split(/\n/, "$1");
684
685          # Loop over all the lines of output in the "Optional Features" block.
686          my $i;
687          for ( $i = 0; $i <= $#param_list; $i++ )
688          {
689             if ( $param_list[$i] =~ /(--(enable|disable)\S+)/ )
690             {
691                my $param = "$1";
692
693                # If $param does not exist in the hash of feature arguments,
694                # we need to add it.
695                if ( ! exists(${$$arg_arr_ref[$FEATURE_ARGS]}{"$param"}) )
696                {
697                   # Add the first line of information for $param.
698                   my $param_info = "$param_list[$i]\n";
699
700                   # If the following lines are a continuation of the info for
701                   # $param, add them to $param_info as well.
702                   while ( $i + 1 <= $#param_list &&
703                           $param_list[$i + 1] !~ /--(enable|disable)/ )
704                   {
705                      $param_info .= "$param_list[$i + 1]\n";
706                      $i++;
707                   }
708
709                   # Store the complete information block for $param.
710                   ${$$arg_arr_ref[$FEATURE_ARGS]}{"$param"} = "$param_info";
711                }
712             }
713          }
714       }
715       # Handle the --with and --without list of options.
716       elsif ( $string =~ /^(Optional Packages:.*)(Some influential)/s )
717       {
718          $string = "$2$'";
719
720          my @param_list = split(/\n/, "$1");
721
722          # Loop over all the lines of output in the "Optional Packages" block.
723          my $i;
724          for ( $i = 0; $i <= $#param_list; $i++ )
725          {
726             if ( $param_list[$i] =~ /(--with\S+)/ )
727             {
728                my $param = "$1";
729
730                # If $param does not exist in the hash of package arguments,
731                # we need to add it.
732                if ( ! exists(${$$arg_arr_ref[$PACKAGE_ARGS]}{"$param"}) )
733                {
734                   # Add the first line of information for $param.
735                   my $param_info = "$param_list[$i]\n";
736
737                   # If the following lines are a continuation of the info for
738                   # $param, add them to $param_info as well.
739                   while ( $i + 1 <= $#param_list &&
740                           $param_list[$i + 1] !~ /--with/ )
741                   {
742                      $param_info .= "$param_list[$i + 1]\n";
743                      $i++;
744                   }
745
746                   # Store the complete information block for $param.
747                   ${$$arg_arr_ref[$PACKAGE_ARGS]}{"$param"} = "$param_info";
748                }
749             }
750          }
751       }
752       # We'll keep everything after the line beginning with "Some influential"
753       # to form the prologue of the help output.
754       elsif ( $string =~ /^(Some influential.*)$/s )
755       {
756          $string = "$'";   # This should be the empty string.
757          ${$$arg_arr_ref[$PROLOGUE]}{'all'} = "$1";
758       }
759       # Match anything else and strip it from the output.
760       elsif ( $string =~ /^.*$/m )
761       {
762          $string = $';
763       }
764
765       $string =~ s/^\s*//s;
766    }
767 }
768
769 sub getPlatform ()
770 {
771    my $platform = "unknown";
772
773    # Prefer the user-defined platform type over any auto-detected value.
774    if ( "$OS" ne '' )
775    {
776       $platform = "$OS";
777    }
778    elsif ( defined($ENV{'OS'}) )
779    {
780       $platform = "$ENV{'OS'}";
781    }
782    elsif ( defined($ENV{'OSTYPE'}) )
783    {
784       $platform = "$ENV{'OSTYPE'}";
785    }
786    elsif ( defined($ENV{'OS_TYPE'}) )
787    {
788       $platform = "$ENV{'OS_TYPE'}";
789    }
790    elsif ( defined($ENV{'HOSTTYPE'}) )
791    {
792       $platform = "$ENV{'HOSTTYPE'}";
793    }
794    # As a last resort, fall back on the use of uname(1).
795    else
796    {
797       chomp($platform = `uname -s`);
798    }
799
800    # XXX: This is a hack to deal with weird OS strings such as "linux-gnu".
801    # We just make the platform be "linux" unless the user set the platform
802    # type on the command line.
803    $platform = 'linux' if ! $OS && $platform =~ /linux/i;
804
805    return $platform;
806 }
807
808 sub getHostname ()
809 {
810    my $hostname = '';
811
812    if ( defined($ENV{'HOSTNAME'}) )
813    {
814       $hostname = "$ENV{'HOSTNAME'}";
815    }
816    else
817    {
818       chomp($hostname = `hostname`);
819    }
820
821    return $hostname;
822 }
823
824 __END__
825
826 =head1 NAME
827
828 configure.pl
829
830 =head1 SYNOPSIS
831
832 This script acts as the "glue" for a collection of Autoconf-based configure
833 scripts.  Based on a configuration file, it is capable of building a
834 dependency tree and running the configure scripts in the correct order such
835 that the dependencies are satisfied correctly.  Note that all modules must
836 be capable of having dependencies satisfied based entirely on the results
837 of running a dependent module's configure script.
838
839 =head1 DESCRIPTION
840
841 (Still need to write this...)
842
843 =head1 OPTIONS
844
845 =over 8
846
847 =item B<--help>
848
849 Print usage information of this script alone and exit.
850
851 =item B<--all-help>
852
853 Print usage information for all the known configure scripts.  The
854 knowledge of configure scripts comes from the configuration file.  The<