home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / lyx21041.zip / XFree86 / lib / X11 / lyx / reLyX / reLyX.in < prev    next >
Text File  |  1999-03-21  |  2KB  |  56 lines

  1. #!@PERL@
  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.
  6.  
  7. ############################# reLyX wrapper
  8. use strict;
  9. use File::Basename;
  10. $^W = 1; # same as 'perl -w'
  11.  
  12. # Variables to make global, so subroutines can use them
  13. use vars qw($lyxdir $lyxname);
  14.  
  15. my (@maybe_dir);
  16. my $mainscript = "reLyXmain.pl"; 
  17.  
  18. # Do this in a BEGIN block so it's done before the 'use lib' below
  19. BEGIN{
  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
  27. my $name = $0;
  28. # resolve any links to dirname
  29. while (defined (readlink($name))) {$name = readlink($name)};
  30. my $dir = &dirname($name);
  31.  
  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
  34. my $i = 0;
  35. # case 1: for developers, e.g. - reLyX and $mainscript in same directory
  36. $maybe_dir[$i++] = ".";
  37. # case 2: environment variable LYX_DIR_12 has been set
  38. if (exists $ENV{LYX_DIR_10x}) { $maybe_dir[$i++] = "$ENV{LYX_DIR_10x}/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";
  45. } # end BEGIN block
  46.  
  47. # Now put those directories into @INC
  48. use lib @maybe_dir;
  49.  
  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...
  53.  
  54. exit;
  55. ############################ end reLyX wrapper
  56.