2 # This file is part of reLyX
3 # Copyright (c) 1998-9 Amir Karger karger@post.harvard.edu
4 # You are free to use and modify this code under the terms of
5 # the GNU General Public Licence version 2 or later.
7 ############################# reLyX wrapper
10 $^W = 1; # same as 'perl -w'
12 # Variables to make global, so subroutines can use them
13 use vars qw($lyxdir $lyxname);
16 my $mainscript = "reLyXmain.pl";
18 # Do this in a BEGIN block so it's done before the 'use lib' below
20 # This points to LyX library dir, e.g. /usr/local/share/lyx
21 $lyxdir = "@LYX_DIR@";
22 # This is just "." if you compiled from the source directory
23 my $srcdir = "@srcdir@";
24 # This is the name of the program, usually just "lyx"
25 $lyxname = "@PACKAGE@";
26 # The name under which reLyX was invoked
28 # resolve any links to dirname
29 while (defined (readlink($name))) {$name = readlink($name)};
30 my $dir = &dirname($name);
32 # Create a list of possible directories to look in. Non-existent directories
33 # are OK, but empty or undefined values will make 'use lib' complain
35 # case 1: for developers, e.g. - reLyX and $mainscript in same directory
36 $maybe_dir[$i++] = ".";
37 # case 2: environment variable LYX_DIR_11x has been set
38 if (exists $ENV{LYX_DIR_11x}) { $maybe_dir[$i++] = "$ENV{LYX_DIR_11x}/reLyX"};
39 # case 3: ran make but not make install.
40 $maybe_dir[$i++] = "$dir/$srcdir";
41 # case 4: e.g., reLyX in /opt/bin, $mainscript in /opt/share/lyx/reLyX
42 $maybe_dir[$i++] = "$dir/../share/$lyxname/reLyX"; # case 4
43 # case 5: configure figured out where $mainscript is
44 $maybe_dir[$i++] = "$lyxdir/reLyX";
47 # Now put those directories into @INC
50 # Now run the script. Perl will look in @INC to find the script (and
51 # other modules that $mainscript calls)
52 require $mainscript; # require includes and runs the code...
55 ############################ end reLyX wrapper