/**/

call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs


parse arg language texmf source options



if language = '049' then do

  msg.1  = 'msg:LaTeX2e Graphics'
  msg.2  = 'msg:LaTeX2e Graphics entpacke Dateien'
  msg.3  = 'msg:LaTeX2e Graphics graphics.ins'
  msg.10 = 'msg:LaTeX2e Graphics'
  msg.11 = 'Lauf'
  msg.12 = 'von'

end
else do

  msg.1  = 'msg:LaTeX2e Graphics'
  msg.2  = 'msg:LaTeX2e Graphics installing files'
  msg.3  = 'msg:LaTeX2e Graphics graphics.ins'
  msg.10 = 'msg:LaTeX2e Graphics'
  msg.11 = 'run'
  msg.12 = 'of'

end


say msg.1


bin      = texmf||'\os2tex\bin'
tfm      = texmf||'\fonts\tfm'
tex      = texmf||'\tex'
doc      = texmf||'\doc'
fmt      = bin

target   = texmf||'\tex\latex\graphics'

exec     = bin||'\tex.exe'

install = texmf||'\os2tex\install'



if Pos("InstallFiles", options) > 0 then do

   install||'\kdir '||target

   'md '||tex
   'md '||tex||'\latex'
   'md '||tex||'\latex\graphics'


   say msg.2


   call directory texmf||'\tex\latex'

   install||'\unzip '||source||'\l2graph.zip'



   say msg.3

   exec||' -pf '||bin||' -po '||target||' -pi '||target||';'||tex||'\latex\base;'||bin||' '||'graphics.ins'


   'md '||doc
   'md '||doc||'\latex'
   'md '||doc||'\latex\graphics'

   'copy '||target||'\grfguide.tex '||texmf||'\doc\latex\graphics'
   'copy '||target||'\*.ps '||texmf||'\doc\latex\graphics'

   'del '||target||'\grfguide.tex'
   'del '||target||'\*.ps'





   filename = texmf||'\tex\latex\graphics\color.cfg'
   call lineout filename, "\ExecuteOptions{dvips}"
   call lineout filename

   filename = texmf||'\tex\latex\graphics\graphics.cfg'
   call lineout filename, "\ExecuteOptions{dvips}"
   call lineout filename

end



if SysOS2Ver() = '2.30' then
  top = '48'
else
  top = '45'




if Pos("CreateObjects", options) > 0 then do

   classname = 'WPFolder'

   if language = '049' then
      objtitle  = 'Zusatzpakete/Styles'
   else
      objtitle  = 'Packages/Styles'

   location  = '<OS2TEX_DOC_FOLDER>'
   setup     = 'OBJECTID=<OS2TEX_MISC_FOLDER>;ICONVIEW=MINI,NONFLOWED;ALWAYSSORT=YES;ICONVIEWPOS=50,50,25,'||top
   duplicate = 'update'


   rc = SysCreateObject(classname,objtitle,location,setup,duplicate)

   if rc = 0 then do
      exit 1
   end

end



if Pos("InstallFiles", options) > 0 then do

   do i=1 to 2

      say msg.10' grfguide.dvi 'msg.11' 'i' 'msg.12' 2'
      exec||' -r -ff latex.fmt -pf '||texmf||'\os2tex\bin -po '||texmf||'\doc\latex\graphics -pi '||texmf||'\doc\latex\graphics;'||texmf||'\tex\latex -pt '||texmf||'\fonts\tfm grfguide.tex'

   end

end



if Pos("CreateObjects", options) > 0 then do

   classname = 'WPProgram'
   objtitle  = 'graphics [D. Carlisle]'
   location  = '<OS2TEX_MISC_FOLDER>'
   setup     = 'EXENAME='texmf'\os2tex\bin\dvi.exe;PROGTYPE=PM;STARTUPDIR='texmf'\os2tex\bin;OBJECTID=<OS2TEX_grfguide.dvi>;PARAMETERS='texmf'\doc\latex\graphics\grfguide.dvi'
   duplicate = 'replace'

   rc = SysCreateObject(classname,objtitle,location,setup,duplicate)

   if rc = 0 then do
      exit 1
   end

end



