home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / brama.zip / SETUP.CMD < prev   
OS/2 REXX Batch file  |  1995-05-10  |  6KB  |  211 lines

  1. /* **********************************************************************
  2. *  *               Installer for Build-o-Rama                                                *
  3. *  *                       Copyright Three Cat Software 1995 All Rights Reserved         *
  4. *  **********************************************************************
  5. *
  6. */
  7.  
  8.  
  9.    '@echo off'
  10.    trace off
  11.  
  12.    /* Parse Call Path Info
  13.    */
  14.    Parse Source . . callPath
  15.  
  16.    /* Load in function library
  17.    */
  18.    Call RxFuncAdd "SysLoadFuncs","RexxUtil","SysLoadFuncs"
  19.    Call SysLoadFuncs
  20.  
  21.    Call SysCls
  22.  
  23. sayit = '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *'
  24. SAY sayit
  25. SAY '            Build-o-Rama installation program                                  '
  26. SAY sayit
  27. SAY ' This program will ask you for an installation directory,'
  28. SAY ' and for the drive letter where Visual C++ is installed.'
  29. SAY ' The program will create a file called AUTOBILD.BAT in the '
  30. SAY ' installation directory that contains a CALL to the'
  31. SAY ' MSVCVARS.BAT file. If this file is not in the default'
  32. SAY ' location, you may need to edit AUTOBILD.BAT to provide'
  33. SAY ' the correct path. Also, if there are blank lines in your'
  34. SAY ' current AUTOEXEC.BAT, the entire file may not be copied.'
  35. SAY ' This will not affect Build-o-Rama unless there are entries'
  36. SAY ' in the file that must be present for command-line builds.'
  37. SAY ' The program will also create a file called OS2BILD.BAT,'
  38. SAY ' which is necessary to run the builds, and copy BUILDER.EXE'
  39. SAY ' (The WinOS/2 program), BILDRAMA.EXE (the OS/2 program),'
  40. SAY ' FISH.DLL (a Windows *.DLL), SEMASEND.EXE (a short DOS program)'
  41. SAY ' and BUILDER.HLP (The Windows help file),  REAME.TXT and LICENSE.TXT'
  42. SAY ' You should read README and the help file for general information.'
  43. SAY ' Thank you for using Build-o-Rama'
  44.  
  45.  
  46.    /* Strip program name
  47.    */
  48.    rcp = REVERSE(callPath)
  49.    callPathDir = REVERSE(substr(rcp,POS("\",rcp)+1))
  50.  
  51.    /* Create Queue to catch system error messages
  52.    */
  53.    rcode = RXQUEUE('delete', errq)
  54.    errq = RXQUEUE('create')
  55.    new = RXQUEUE('set', errq)
  56.  
  57.    /* Define stem of files to be copied
  58.    */
  59.    MaxCopyIndex = 7
  60.    Files. = ""
  61.    Files.0 = MaxCopyIndex
  62.    Files.1 = "BUILDER.EXE"
  63.    Files.2 = "BILDRAMA.EXE"
  64.    Files.3 = "FISH.DLL"
  65.    Files.4 = "BUILDER.HLP"
  66.    Files.5 = "SEMASEND.EXE"
  67.    Files.6 = "README.TXT"
  68.    Files.7 = "LICENSE.TXT"
  69.    CurDir = DIRECTORY()
  70.    SrcDir = callPathDir
  71.    if (SubStr(SrcDir,Length(SrcDir),1) \= "\") then
  72.      SrcDir = SrcDir||"\"
  73.      
  74.    BootDrive = GetBootDrive()
  75.    if (BootDrive == "") then
  76.      do
  77.       /* ;OS2 is a required somewhere in the path directory!
  78.       */
  79.       'helpmsg SYS0010 | RXQUEUE 'errq
  80.        call DumpErrMsg
  81.        call Done
  82.      end
  83.  
  84.    /* Verify Source Files
  85.    */
  86.    do i = 1 to MaxCopyIndex
  87.      rc = VerifySourcePath( SrcDir||Files.i )
  88.      if ( rc == 1 ) then
  89.        call Done
  90.    end
  91.  
  92.   /* get target directory for install */
  93.   SAY
  94.   SAY "Enter the target directory for Build-o-Rama" 
  95.   PARSE PULL NewDir
  96.   /* strip the trailing \ if needed */
  97.    rnp = REVERSE(NewDir)
  98.    if substr(rnp,1,1) = '\' then
  99.    do
  100.      NewDir = REVERSE(substr(rnp,POS("\",rnp)+1))
  101.    end
  102.      /* now see if this directory already exists */
  103.   call SysFileTree NewDir, 'exist', D
  104.   if ( exist.0 > 0 ) then
  105.   do
  106.     SAY "That directory exists, I don't need to create it"
  107.   end
  108.   else do
  109.           rc = SysMkDir(NewDir)
  110.           if ( rc > 0 ) then
  111.               do
  112.                 SAY "Couldn't create directory. Error code was" rc
  113.                 call Done    
  114.               end  
  115.   end
  116.   do t = 1 to Files.0
  117.          copystr = SrcDir||Files.t||' '||NewDir||'\'||Files.t
  118.          'copy 'copystr
  119.          if rc > 0 then
  120.          SAY 'Error in copying file '|Files.t
  121.          else
  122.          SAY Files.t||' copied to '||NewDir       
  123.   end
  124.   /* CREATE the OS2BILD.BAT file */
  125.   filepath = NewDir||'\'||'OS2BILD.BAT'
  126.   firstline = 'NMAKE.EXE %1 %2 %3 > \pipe\pipe1'
  127.   secondline = NewDir||'\SEMASEND.EXE VCDONE'
  128.  
  129.   CALL LINEOUT filepath,firstline,1
  130.   CALL LINEOUT filepath,secondline
  131.   CALL LINEOUT filepath
  132.   
  133.   /* find out where the msvc\bin directory is, so can copy MSVCVARS.BAT */
  134.   SAY
  135.   SAY "Enter the drive letter on which MSVC is installed. I need to copy the MSVCVARS.BAT"
  136.   PARSE PULL VCDrive
  137.   VCLetter = substr(VCDrive,1,1)
  138.   VCBatPath = VCLetter||':'||'\MSVC\BIN\MSVCVARS.BAT'
  139.   /* now get the existing autoexec */
  140.   autoExec = BootDrive||'\AUTOEXEC.BAT'
  141.   autoBildString =  NewDir||'\'||'AUTOBILD.BAT'
  142.   CALL LINEIN autoCopyString,1,0 /* open the existing Autoexec.bat */
  143.   DO UNTIL line = ''
  144.     line = LINEIN(autoExec) 
  145.         CALL LINEOUT autoBildString,line 
  146.   END 
  147. /* now add the call statement to MSVCVARS.BAT */
  148.  callItString = 'CALL '||VCBatPath 
  149.  CALL LINEOUT autoBildString,callItString
  150.  CALL LINEOUT autoBildString  /* close the file */
  151.  SAY
  152.  SAY 'Installation of Build-o-Rama is complete. You should add BUILDER.EXE to your '
  153.  SAY 'tools menu in Visual C++ for best results.'
  154.  
  155.  
  156. Done:
  157.    rc = RXQUEUE('delete', errq)
  158.    OriginalDir = DIRECTORY(CurDir)
  159.    exit
  160.  
  161. /* Procedures and Functions
  162. */
  163.  
  164. VerifySourcePath: Procedure Expose errq
  165.  
  166.    Parse Arg file;
  167.  
  168.    fExists = Stream(file,'c','query exists')
  169.    if (fExists == "")
  170.      then do
  171.            'helpmsg SYS002 | RXQUEUE 'errq
  172.             call DumpErrMsg
  173.             return 1
  174.           end
  175.  
  176. return 0
  177.  
  178. GetBootDrive: Procedure
  179.  
  180.    PathStr = VALUE("PATH",,"OS2ENVIRONMENT")
  181.    InsPathPos = POS(":\OS2",TRANSLATE(PathStr))
  182.    if (InsPathPos \= 0) then
  183.      do
  184.        bdrive = Substr(PathStr,InsPathPos-1,2)
  185.      end
  186.    else bdrive = ""
  187.  
  188. return bdrive
  189.  
  190.  
  191. DumpErrMsg: Procedure
  192.  
  193.    do while(QUEUED() \= 0)
  194.      parse pull line
  195.      if (POS("SYS",line) \= 0) then
  196.        fFound = 1
  197.      if ((line == "") & (fFound = 1)) then
  198.        do
  199.          /* Empty out queue
  200.          */
  201.          do while(QUEUED() \= 0)
  202.            parse pull line
  203.          end
  204.          leave
  205.        end
  206.      say line
  207.    end
  208.  
  209. return
  210.  
  211.