home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / lyx21041.zip / XFree86 / lib / X11 / lyx / reLyX / reLyX.cmd < prev    next >
OS/2 REXX Batch file  |  1999-10-29  |  2KB  |  57 lines

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