3 # runfg -- front end for setting up the FG_ROOT env variable and launching
6 # Written by Curtis Olson, started September 1997.
8 # Copyright (C) 1997 - 1998 Curtis L. Olson - curt@me.umn.edu
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #---------------------------------------------------------------------------
29 # print "-> $prefix\n";
31 # potential names of Flight Gear executable to try
32 @files = ( "fgfs", "fgfs.exe" );
34 # search for the executable
35 # potential paths where the executable may be found
36 @paths = ( ".", "Simulator/Main", $prefix );
41 foreach $path (@paths) {
42 foreach $file (@files) {
43 # print "'$savepath'\n";
44 if ( $savepath eq "" ) {
45 # don't search again if we've already found one
46 # print "checking $path" . "bin/$file and $path" . "$file\n";
47 if ( -x "$path/bin/$file" ) {
49 $savepath = "$path/bin";
51 } elsif ( -x "$path/$file" ) {
57 # print "skipping $path/bin/$file and $path/$file\n";
62 die "Cannot locate program.\n" if ( $savepath eq "" );
65 # search for the "FlightGear" root directory
66 @paths = ( $prefix, $saveprefix, $ENV{HOME} );
70 foreach $path (@paths) {
71 # print "trying $path\n";
73 if ( $fg_root eq "" ) {
74 if ( -d "$path/FlightGear" ) {
75 $fg_root = "$path/FlightGear";
76 } elsif ( -d "$path/lib/FlightGear" ) {
77 $fg_root = "$path/lib/FlightGear";
82 die "Cannot locate FG root directory (data)\n" if ( $fg_root eq "" );
85 print "Running $savepath/$savefile --fg-root=$fg_root @ARGV\n";
86 exec("$savepath/$savefile --fg-root=$fg_root @ARGV");
89 #---------------------------------------------------------------------------