home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vile-src.zip / vile-8.1 / mkprlenv.wnt < prev    next >
Text File  |  1998-10-01  |  5KB  |  166 lines

  1. # mkprlenv.wnt
  2. #
  3. # Purpose
  4. # =======
  5. # A makefile included by makefile.wnt when embedding perl in [win]vile.exe .
  6. # This particular makefile determines where perl has been installed in the
  7. # user's Win32 environment and copies win32-compat scripts to a directory
  8. # "known" to vile.  Scripts are copied from this directory:
  9. #
  10. #     .\perl
  11. #
  12. # to this directory:
  13. #
  14. #     %VILE_LIBRARY_PATH%\perl
  15. #
  16. # Preconditions:
  17. # ==============
  18. # 1) Installation of the [binary] perl Win32 port located at this URL:
  19. #
  20. #         http://www.perl.com/CPAN-local/ports/win32/Standard/x86/
  21. #
  22. # 2) The environment variable VILE_LIBRARY_PATH points to a writable
  23. #    "root" directory where vile's perl scripts will be installed.
  24. #
  25. # Supported Vile-Based Perl Scripts
  26. # =================================
  27. # Consult the macro $(PERL_SCRIPTS) in the file makefile.wnt to ascertain the
  28. # current list of vile-based perl scripts known to work in a Win32 environment.
  29. #
  30. # $Header: /usr/build/vile/vile/RCS/mkprlenv.wnt,v 1.3 1998/10/01 10:31:20 cmorgan Exp $
  31. #
  32.     perl <<
  33.         foreach $$dir (@INC)
  34.         {
  35.             $$lib="$$dir\\CORE\\perl.lib";
  36.             last if (-f $$lib);
  37.  
  38.         }
  39.         if (! $$lib)
  40.         {
  41.             print "error: cannot determine location of perl.lib\n";
  42. #
  43. #           Force nmake to abort.
  44. #
  45.             exit(1);
  46.         }
  47.         foreach $$dir (@INC)
  48.         {
  49.             $$inc="$$dir\\CORE";
  50.             last if (-f "$$inc\\perl.h");
  51.  
  52.         }
  53.         if (! $$inc)
  54.         {
  55.             print "error: cannot determine location of perl.h\n";
  56.             exit(1);
  57.         }
  58.         foreach $$dir (@INC)
  59.         {
  60.             $$utils="$$dir\\ExtUtils";
  61.             last if (-d $$utils);
  62.         }
  63.         if (! $$utils)
  64.         {
  65.             print
  66.                "error: cannot determine location of perl external utilities\n";
  67.             exit(1);
  68.         }
  69.         print
  70.  "Checking existence of directory specified by VILE_LIBRARY_PATH env var...\n";
  71.         $$root_dir=$$ENV{"VILE_LIBRARY_PATH"};
  72.         if (! $$root_dir)
  73.         {
  74.             print "error: Environment var VILE_LIBRARY_PATH does not exist\n";
  75.             print "error: Refer to the file 'mkprlenv.wnt' for further info\n";
  76.             exit(1);
  77.         }
  78.         else
  79.         {
  80.             if (-f $$root_dir)
  81.             {
  82.                 print "error: $$root_dir is a file!\n";
  83.                 exit(1);
  84.             }
  85.             elsif (! -d $$root_dir)
  86.             {
  87.                 print "error: \"$$root_dir\" is not a directory\n";
  88.                 exit(1);
  89.             }
  90.             else
  91.             {
  92. #               User specified a directory that exists.  First, strip
  93. #               trailing dos/unix path delimiters from dir.
  94. #
  95.                 $$root_dir =~ s!\\$$!!;
  96.                 $$root_dir =~ s!/$$!!;
  97. #
  98. #               Warp unix path delimiters to backslash (to be compatible
  99. #               with the DOS COPY command).
  100. #
  101.                 $$root_dir =~ s@/@\\@g;
  102. #
  103. #               The user's writable directory must have a subdirectory
  104. #               called "perl".  Create if it doesn't exist.
  105.                 $$script_dir = $$root_dir . "\\perl";
  106.                 if (-f $$script_dir)
  107.                 {
  108.                     print
  109.                 "error: script destination directory $$script_dir is a file!\n";
  110.                     exit(1);
  111.                 }
  112.                 if (! -d $$script_dir && ! mkdir($$script_dir, 0755))
  113.                 {
  114.                     print "error: can't create \"$$script_dir\": $$!\n";
  115.                     exit(1);
  116.                 }
  117. #
  118. #               And is this a writable directory?  The Win32 file
  119. #               semantics are so odd that we'll ignore stat() and simply
  120. #               attempt to create a junk file in this directory as a test
  121. #               of its accessibility.
  122. #
  123.                 $$test_file = "$$script_dir\\vile_perl_tst.txt";
  124.                 if (open(TEST_FD, "> $$test_file") == 0)
  125.                 {
  126.                     print
  127.                          "error: directory \"$$script_dir\" is not writable!\n";
  128.                     exit(1);
  129.                 }
  130.                 close TEST_FD;
  131.                 unlink "$$test_file";
  132. #
  133. #               Write out results.
  134. #
  135.                 if (open(SOME_FD, "> $(PERLCFG)") == 0)
  136.                 {
  137.                     print "error: creating $(PERLCFG): $$!\n";
  138.                     exit(1);
  139.                 }
  140.                 print SOME_FD "VILE_PERL_LIB=$$lib\n";
  141.                 print SOME_FD "VILE_PERL_INC=$$inc\n";
  142.                 print SOME_FD "VILE_PERL_UTILS=$$utils\n";
  143.                 close SOME_FD;
  144. #
  145. #               copy win32-compatible perl scripts to user-specified directory
  146. #
  147.                 @scripts = split ' ', "$(PERL_SCRIPTS)";
  148.                 foreach $$file (@scripts)
  149.                 {
  150.                     $$src  = "perl\\" . $$file;
  151.                     $$dest = "$$script_dir\\$$file";
  152.                     printf "copying $$src -> $$dest...\n";
  153.                     `copy $$src $$dest`;
  154.                 }
  155.             }
  156.         }
  157. <<
  158. # Change previous line to "<<KEEP" to inspect inline file contents.
  159. #
  160. # Delete things that are affected by the perl configuration before
  161. # going any further.
  162.     -del $(TARGET)
  163.     -del perl.c
  164. # Look ma, a recursive make
  165.     $(MAKE) -f makefile.wnt CFG=$(CFG) OPT=$(OPT)
  166.