1998-04-09 01:45:30 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# runfg -- front end for setting up the FG_ROOT env variable and launching
|
|
|
|
# the fg executable.
|
|
|
|
#
|
|
|
|
# Written by Curtis Olson, started September 1997.
|
|
|
|
#
|
|
|
|
# Copyright (C) 1997 - 1998 Curtis L. Olson - curt@me.umn.edu
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
$prefix = "@prefix@";
|
|
|
|
# print "-> $prefix\n";
|
|
|
|
|
|
|
|
# potential names of Flight Gear executable to try
|
1999-10-15 00:11:52 +00:00
|
|
|
@files = ( "fgfs", "fgfs.exe" );
|
1998-04-09 01:45:30 +00:00
|
|
|
|
1998-08-03 22:16:42 +00:00
|
|
|
# search for the executable
|
1998-04-09 01:45:30 +00:00
|
|
|
# potential paths where the executable may be found
|
|
|
|
@paths = ( ".", "Simulator/Main", $prefix );
|
|
|
|
|
|
|
|
$savepath = "";
|
|
|
|
$savefile = "";
|
|
|
|
|
|
|
|
foreach $path (@paths) {
|
|
|
|
foreach $file (@files) {
|
|
|
|
# print "'$savepath'\n";
|
|
|
|
if ( $savepath eq "" ) {
|
|
|
|
# don't search again if we've already found one
|
|
|
|
# print "checking $path" . "bin/$file and $path" . "$file\n";
|
|
|
|
if ( -x "$path/bin/$file" ) {
|
1998-08-03 22:16:42 +00:00
|
|
|
$saveprefix = $path;
|
1998-04-09 01:45:30 +00:00
|
|
|
$savepath = "$path/bin";
|
|
|
|
$savefile = "$file";
|
|
|
|
} elsif ( -x "$path/$file" ) {
|
1998-08-03 22:16:42 +00:00
|
|
|
$saveprefix = $path;
|
1998-04-09 01:45:30 +00:00
|
|
|
$savepath = "$path";
|
|
|
|
$savefile = "$file";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
# print "skipping $path/bin/$file and $path/$file\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
die "Cannot locate program.\n" if ( $savepath eq "" );
|
|
|
|
|
|
|
|
|
1998-08-03 22:16:42 +00:00
|
|
|
# search for the "FlightGear" root directory
|
1998-08-25 16:59:08 +00:00
|
|
|
@paths = ( $prefix, $saveprefix, $ENV{HOME} );
|
1998-04-09 01:45:30 +00:00
|
|
|
|
1998-08-03 22:16:42 +00:00
|
|
|
$fg_root = "";
|
|
|
|
|
|
|
|
foreach $path (@paths) {
|
|
|
|
# print "trying $path\n";
|
|
|
|
|
|
|
|
if ( $fg_root eq "" ) {
|
|
|
|
if ( -d "$path/FlightGear" ) {
|
|
|
|
$fg_root = "$path/FlightGear";
|
2004-06-06 19:31:42 +00:00
|
|
|
} elsif ( -d "$path/share/FlightGear" ) {
|
|
|
|
$fg_root = "$path/share/FlightGear";
|
1998-08-03 22:16:42 +00:00
|
|
|
}
|
1998-04-09 01:45:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-03 22:16:42 +00:00
|
|
|
die "Cannot locate FG root directory (data)\n" if ( $fg_root eq "" );
|
|
|
|
|
1998-04-09 01:45:30 +00:00
|
|
|
# run Flight Gear
|
1998-08-03 22:16:42 +00:00
|
|
|
print "Running $savepath/$savefile --fg-root=$fg_root @ARGV\n";
|
|
|
|
exec("$savepath/$savefile --fg-root=$fg_root @ARGV");
|
1998-04-09 01:45:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|