]> git.mxchange.org Git - flightgear.git/blob - Main/runfgfs.in
MSVC++ portability tweaks contributed by Bernie Bright.
[flightgear.git] / Main / runfgfs.in
1 #!/usr/bin/perl
2 #
3 # runfg -- front end for setting up the FG_ROOT env variable and launching 
4 #          the fg executable.
5 #
6 # Written by Curtis Olson, started September 1997.
7 #
8 # Copyright (C) 1997 - 1998  Curtis L. Olson  - curt@me.umn.edu
9 #
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.
14 #
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.
19 #
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.
23 #
24 # $Id$
25 # (Log is kept at end of this file)
26 #---------------------------------------------------------------------------
27
28
29 $prefix = "@prefix@";
30 # print "-> $prefix\n";
31
32 # potential names of Flight Gear executable to try
33 @files = ( "fg", "fg.exe" );
34
35 # search for the executable
36 # potential paths where the executable may be found
37 @paths = ( ".", "Simulator/Main", $prefix );
38
39 $savepath = "";
40 $savefile = "";
41
42 foreach $path (@paths) {
43     foreach $file (@files) {
44         # print "'$savepath'\n";
45         if ( $savepath eq "" ) {
46             # don't search again if we've already found one
47             # print "checking $path" . "bin/$file and $path" . "$file\n";
48             if ( -x "$path/bin/$file" ) {
49                 $saveprefix = $path;
50                 $savepath = "$path/bin";
51                 $savefile = "$file";
52             } elsif ( -x "$path/$file" ) {
53                 $saveprefix = $path;
54                 $savepath = "$path";
55                 $savefile = "$file";
56             }
57         } else {
58             # print "skipping $path/bin/$file and $path/$file\n";
59         }
60     }
61 }
62
63 die "Cannot locate program.\n" if ( $savepath eq "" );
64
65
66 # search for the "FlightGear" root directory
67 @paths = ( $prefix, $saveprefix, $ENV{HOME} );
68
69 $fg_root = "";
70
71 foreach $path (@paths) {
72     # print "trying $path\n";
73
74     if ( $fg_root eq "" ) {
75         if ( -d "$path/FlightGear" ) {
76             $fg_root = "$path/FlightGear";
77         } elsif ( -d "$path/lib/FlightGear" ) {
78             $fg_root = "$path/lib/FlightGear";
79         }
80     }
81 }
82
83 die "Cannot locate FG root directory (data)\n" if ( $fg_root eq "" );
84
85 # run Flight Gear
86 print "Running $savepath/$savefile --fg-root=$fg_root @ARGV\n";
87 exec("$savepath/$savefile --fg-root=$fg_root @ARGV");
88
89
90 #---------------------------------------------------------------------------
91 # $Log$
92 # Revision 1.2  1998/08/25 16:59:10  curt
93 # Directory reshuffling.
94 #
95 # Revision 1.1  1998/08/24 20:32:41  curt
96 # runfg.in renamed to runfgfs.in
97 #
98 # Revision 1.3  1998/08/03 22:16:42  curt
99 # Updated to be smarter about finding $FG_ROOT.
100 #
101 # Revision 1.2  1998/04/25 22:06:31  curt
102 # Edited cvs log messages in source files ... bad bad bad!
103 #
104 # Revision 1.1  1998/04/09 01:45:31  curt
105 # Moved to Main/ and incorperated with automake
106 #
107 # Revision 1.4  1998/03/09 22:52:38  curt
108 # Mod's to better support win32 if perl exists.
109 #
110 # Revision 1.3  1998/02/16 16:17:34  curt
111 # Minor tweaks.
112 #
113 # Revision 1.2  1998/01/27 00:47:43  curt
114 # Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
115 # system and commandline/config file processing code.
116 #
117 # Revision 1.1  1997/10/28 18:47:27  curt
118 # Initial revision.
119 #