@echo off
cls
echo.
echo.
echo CINSTALL.BAT
echo ******************************************************************************
echo Installation of necessary minimum of emTeX for DOS:
echo   *) TeX and DVIDRV compilers;
echo   *) METAFONT and MFJob compilers and font sources;
echo   *) TeX packages (Plain, LaTeX 2.09, LaTeX 2e, AmSTeX, NFSS1, Babel);
echo   *) CyrTUG support:
echo      .) russification of TeX packages (hyphenation and fonts);
echo      .) batch-files for creation of TeX formats and METAFONT bases;
echo      .) batch-files for work with TeX and generation of fonts;
echo   *) TeX "Applications": Makeindx, BibTeX, TeXcad, PicTeX, DVIPS.
echo Disk space:
echo EmTeX:    Maximum: 20Mb-...; Optimal: 10-12Mb; Minimum (LaTeX 2.09): 6Mb.
echo TEXFONTS: 4-5Mb (all fonts in mostly used magnifications);
echo.
echo *** It could also work in DOS applications  under Windows 3.11/95---read emTeX
echo     documentation (readme.eng, help.eng etc).
echo     You can get more information about installation in file readme98.rus.
echo ******************************************************************************
echo Continue installation ?
echo Press Ctrl+Break to abort or any key to continue . . .
pause>nul

if "%1"=="" goto usage
if "%2"=="" goto usage
for %%c in (c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) do if %%c==%1 goto s0
for %%c in (C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do if %%c==%1 goto s0
goto usage
:s0
for %%c in (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) do if %%c==%2 goto s1
for %%c in (A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do if %%c==%2 goto s1
goto usage

:s1
if "%emtexdir%"=="" set emtexdir=%1:\EMTEX
if "%dvidrvfonts%"=="" set dvidrvfonts=%1:\TEXFONTS
if "%emtex%"=="" set emtex=%1
if "%eminst%"=="" set eminst=%emtexdir%\INSTALL\LH
:: killing set_texr environments
set emtexopt=
set emtexed=
set texinput=
set save_texinput=
set dvidrvinput=
set virtfonts=
set mfjobopt=
set texconfig=
::set temporary environments
SET PC=******
SET MF=*****
SET FNT=***
SET MC=7
SET TeX=N
SET LA=N
SET LAe=N
SET AM=N
SET BA=N
SET NF=N
if "%NF%"=="" goto err

:s2
call insta.bat %1
if %PC%==error goto end

cls
echo.
echo 
echo !!! CHECK the file instb.bat between lines:
echo.
echo     rem **********************************************************************
echo.
echo whether you've got all necessary zip-files from that list on your floppy disks
echo or in  the current directory  of hard disk  and they all have exactly the same
echo names. Then start %0 again.
echo.
echo Continue installation ?
echo Press Ctrl+Break to abort or any key to continue . . .
pause>nul

:s3
if NOT exist %emtexdir%\*.* goto s4
dir /w /p %emtexdir%\*.*
cls
echo.
echo 
echo !!! You may have old version of emTeX.
echo     (directory %emtexdir% is not empty).
echo.
echo Continue installation ?
echo Press Ctrl+Break to abort or any key to continue . . .
pause>nul

:s4
if NOT exist %emtexdir%\BIN\*.* goto s5
cls
echo.
echo 
echo !!! You should already have installed emTeX.
echo     Continue installation of emTeX    -- 1
echo     Install CyrTUG-emTeX support only -- 2
echo     Quit installation                 -- 3
echo.
echo *** If you want to install only one/few packages choose 1.
%eminst%\ask.exe Enter number,123
echo.
if errorlevel 3 goto end
if errorlevel 2 set PC=cyr

:s5
cls
echo.
echo.
echo CHECK
echo     emTeX-drive:       %1:
echo     emTeX-directory:   %emtexdir%
echo     Font-directory:    %dvidrvfonts%
echo     Source-disk:       %2:
echo.
echo *** Name of emTeX-drive and emTeX-directory must have the same disk name!
echo.
echo     Font-directory  will placed  on the same  disk as emTeX-directory.  If you
echo     want to change  directory name/disk of Font-directory (not recommended!!!)
echo     move/rename it AFTER this installation then correct set_texr.bat in line:
echo.
echo     SET DVIDRVFONTS=%dvidrvfonts%
echo.
echo Continue installation ?
echo Press Ctrl+Break to abort or any key to continue . . .
pause>nul

:s6
set FNT=0
if NOT exist %dvidrvfonts%\*.* goto s7
if exist %dvidrvfonts%\PIXEL.FX\240DPI\*.pk set FNT=fx
if exist %dvidrvfonts%\fx_*.fli set FNT=fx
if exist %dvidrvfonts%\PIXEL.P6H\360DPI\*.pk set FNT=p6h
if exist %dvidrvfonts%\p6h_*.fli set FNT=p6h
if exist %dvidrvfonts%\PIXEL.LJ\300DPI\*.pk set FNT=lj
if exist %dvidrvfonts%\lj_*.fli set FNT=lj
if exist %dvidrvfonts%\PIXEL.LJH\600DPI\*.pk set FNT=ljh
if exist %dvidrvfonts%\ljh_*.fli set FNT=ljh
goto s8
:s7
md %dvidrvfonts% >nul

:s8
if NOT %PC%==cyr goto m0

:: Install CyrTUG-emTeX support only
set PC=0
for %%c in (tex,tex186,tex386) do if exist %emtexdir%\BIN\%%c.exe set PC=%%c
if %PC%==0 goto c3
if exist %emtexdir%\BIN\dvidrv.exe goto c1
goto cb
:c1
set MC=
for %%c in (scr,vik) do if exist %emtexdir%\BIN\dvi%%c.exe goto c2
goto c17
:c2
for %%c in (dot,hplj) do if exist %emtexdir%\BIN\dvi%%c.exe goto c3
:c17
set MC=7
for %%c in (scr,vik) do if exist %emtexdir%\BIN\dvi%%c%MC%.exe goto c27
goto cb
:c27
for %%c in (dot,hplj) do if exist %emtexdir%\BIN\dvi%%c%MC%.exe goto c3
goto cb
:c3
if NOT %FNT%==0 goto c4
set FNT=C
goto fn
:c4
set MF=0
for %%c in (mf,mf186,mf386) do if exist %emtexdir%\BIN\%%c.exe set MF=%%c
cls
echo.
echo.
echo CHECK Installed compilers
echo.
if %PC%==0 goto c5
echo     TeXing, viewing and printing support
echo     TeX: %PC%
echo     DVIDRV compilers
echo     view:
for %%c in (scr,vik) do if exist %emtexdir%\BIN\dvi%%c%MC%.exe echo            dvi%%c%MC%
echo     print:
for %%c in (dot,hplj) do if exist %emtexdir%\BIN\dvi%%c%MC%.exe echo            dvi%%c%MC%
for %%c in (tex,tex186) do if %PC%==%%c goto c41
set PC=C%PC%
if %PC%==Chtex386 set PC=Ctex386
goto c6
:c5
echo     TeXing, viewing and printing support will not installed
:c6
echo.
if %MF%==0 goto c7
echo     METAFONT generating fonts support
echo     METAFONT: %MF%
set MF=C%MF%
goto c8
:c7
echo     METAFONT support will not installed
:c8
echo.
if %FNT%==C goto c9
echo     Fonts: %FNT%
goto ca
:c9
echo     Fonts support will not installed
:ca
%eminst%\ask.exe Everything is allright (Yes No or Quit) ? (Y/N/Q),nNyYqQ
echo.
if errorlevel 5 goto end
if errorlevel 3 goto t0
if %FNT%==C set FNT=0
goto cb1

:cb
cls
echo.
echo 
echo !!! emTeX installation could not complete
:cb1
echo.
echo     Continue with emTeX installation ?
echo Press Ctrl+Break to abort or any key to continue . . .
pause>nul

:m0
set PC=0
cls
echo.
echo.
echo ??? What type of TeX compiler you want to use
echo     tex.exe/btex.exe (processor 8088 (XT))       -- 1
echo     tex186.exe/btex186 (processors 80186, 80286) -- 2
echo     tex386.exe/htex386.exe** (80386 and higher)  -- 3*
echo     None (package installation)                  -- 4
echo.
echo   * If you won't succeed with tex386.exe install tex186.exe.
echo  ** Huge tex is 32bit program
echo     (versions before 1998 could not run under Windows95).
%eminst%\ask.exe Enter number,1234
echo.
if errorlevel 4 goto m3
if errorlevel 3 goto m2
if errorlevel 2 goto m1

set PC=tex
goto m4
:m1
set PC=tex186
goto m4
:m2
set PC=tex386
goto m5
:m3
set PC=0
set MC=0
goto fn

:m4
if NOT exist %emtexdir%\BIN\%PC%.exe goto m6
cls
echo.
echo 
echo !!! %PC%.exe (b%PC%.exe) already installed.
goto m5a
:m5
if NOT exist %emtexdir%\BIN\%PC%.exe goto m6
cls
echo.
echo 
echo !!! %PC%.exe (h%PC%.exe) already installed.
:m5a
echo     Reinstall this compiler        -- 1
echo     Install another compiler       -- 2
echo     Skip compiler installation     -- 3
%eminst%\ask.exe Enter number,312
if errorlevel 3 goto m0
if errorlevel 2 goto m6
set PC=0

:m6
if exist %emtexdir%\BIN\dvidrv.exe goto m6a
goto m7
:m6a
set MC=7
for %%c in (scr,vik) do if exist %emtexdir%\BIN\dvi%%c%MC%.exe goto m6b
goto m6c
:m6b
for %%c in (dot,hplj) do if exist %emtexdir%\BIN\dvi%%c%MC%.exe goto m8
:m6c
set MC=
for %%c in (scr,vik) do if exist %emtexdir%\BIN\dvi%%c.exe goto m6d
goto m7
:m6d
for %%c in (dot,hplj) do if exist %emtexdir%\BIN\dvi%%c.exe goto m8

:m7
cls
echo.
echo ??? Do you have numeric coprocessor in your computer ? (Y/N)
echo     If you have *doubts* press N (Pentium* users press Y)
%eminst%\ask.exe  Enter letter,yYnN
echo.
if errorlevel 3 goto m7a
set MC=7
goto fn
:m7a
set MC=
goto fn

:m8
cls
echo.
echo 
echo !!! You have already installed DVIDRV drivers:
for %%c in (drv,scr%MC%,vik%MC%,dot%MC%,hplj%MC%) do if exist %emtexdir%\BIN\dvi%%c.exe echo     dvi%%c.exe
echo.
echo     Reinstall these compilers      -- 1
echo     Install another compilers      -- 2
echo     Skip compiler installation     -- 3
%eminst%\ask.exe Enter number,312
if errorlevel 3 goto m7
if errorlevel 2 goto fn
set MC=0

:fn
cls
echo.
echo.
echo ??? What fonts do you want to use ?
echo     9-pin matrix printer 240dpi (fx)   -- 1
echo     24-pin matrix printer 360dpi (p6h) -- 2
echo     Laser printer 300dpi (lj)          -- 3
echo     Laser printer 600dpi (ljh)         -- 4
echo     Other or none                      -- 5
echo.
if NOT %FNT%==*** echo     Checked fonts: %FNT%
%eminst%\ask.exe Enter number ,12345
echo.
if errorlevel 5  goto fn0
if errorlevel 4  goto fnljh
if errorlevel 3  goto fnlj
if errorlevel 2  goto fnp6h
set FNT=fx
goto f0
:fnp6h
set FNT=p6h
goto f0
:fnlj
set FNT=lj
goto f0
:fnljh
set FNT=ljh
goto f0
:fn0
if %FNT%==C goto c4
set FNT=0

:f0
echo.
echo ??? Do you want to install METAFONT and MFJob ?  (Y/N)
echo     (Press Y, if you ought to create fonts)
%eminst%\ask.exe Enter letter,yYnN
echo.
if errorlevel 3 goto f01
if %PC%==0 goto f0a
if %PC%==tex goto f0a1
if %PC%==tex186 goto f0a2
if %PC%==tex386 goto f0a3
:f01
set MF=0
goto m9
:f0a
if exist %emtexdir%\BIN\tex.exe goto f0a1
if exist %emtexdir%\BIN\tex186.exe goto f0a2
if exist %emtexdir%\BIN\tex386.exe goto f0a3
goto fw
:f0a1
set MF=mf
goto f0a4
:f0a2
set MF=mf186
goto f0a4
:f0a3
set MF=mf386
:f0a4
if NOT exist %emtexdir%\BIN\%MF%.exe goto m9
cls
echo.
echo 
echo !!! %MF%.exe already installed.
echo     Reinstall this compiler        -- 1
echo     Install another compiler       -- 2
echo     Skip compiler installation     -- 3
%eminst%\ask.exe Enter number,312
if errorlevel 3 goto f4
if errorlevel 2 goto m9
set MF=0
goto m9

:fw
cls
echo.
echo 
echo !!! Any TeX compiler won't (or didn't) installed.
echo ??? Do you *ought* to install METAFONT only ?
echo     Back to TeX compilers menu     -- 1
echo     Install METAFONT without TeX   -- 2
echo     Quit installation              -- 3
%eminst%\ask.exe Enter number,123
echo.
if errorlevel 3 goto end
if errorlevel 2 goto m0

:f4
set MF=0
cls
echo.
echo.
echo ??? What type of METAFONT compiler you want to use ?
echo     mf.exe (processor 8088 (XT))           -- 1
echo     mf186.exe (processors 80186, 80286)    -- 2
echo     mf386.exe (processor 80386 and higher) -- 3*
echo.
echo  * If you won't succeed with mf386.exe install mf186.exe.
%eminst%\ask.exe Enter number,123
echo.
if errorlevel 3 goto f0a3
if errorlevel 2 goto f0a2
goto f0a1

:m9
cls
echo.
echo.
echo CHECK Compilers
echo.
if %PC%==0 goto m92
if %PC%==tex386 goto m91
echo     TeX: %PC%.exe/b%PC%.exe
goto m93
:m91
echo     TeX: %PC%.exe/h%PC%.exe
goto m93
:m92
echo     TeX compilers will not installed
:m93
echo.
if "%MC%"=="0" goto m94
echo     DVIDRV compilers:
echo     view:  dviscr%MC%.exe
echo     print: dvihplj%MC%.exe
echo            dvidot%MC%.exe
echo     You might use either dvihplj%MC%.exe or dvidot%MC%.exe.
if "%MC%"=="7" echo       ("7" in command name means usage of numeric (math) coprocessor.)
goto m95
:m94
echo     DVIDRV compilers will not installed
:m95
echo.
if %MF%==0 goto m96
echo     METAFONT: %MF%.exe
if NOT %MF%==0 echo     METAFONT compiler's name should be a pair to TeX's one (%PC%.exe).
echo     (Big version of METAFONT will not installed.)
goto m97
:m96
echo     METAFONT compilers will not installed
:m97
echo.
if %FNT%==0 goto m98
echo     Fonts: %FNT%
goto m99
:m98
echo     Fonts will not installed
:m99
%eminst%\ask.exe Everything is allright (Yes No or Quit) ? (Y/N/Q),yYnNqQ
echo.
if errorlevel 5 goto end
if errorlevel 3 goto m0

:t0
if NOT %PC%==0 goto t0a
for %%c in (tex,btex,htex) do if exist %emtexdir%\BIN\%%c*.exe goto t0a
goto p0

:t0a
cls
set TeX=A
echo.
echo.
echo Installation of TeX packages
echo.
echo Checking Plain TeX installation ...
for %%c in (hyphen,plain,null,850_tex) do if NOT exist %emtexdir%\TEXINPUT\ETC\%%c.tex goto t21
echo 
%eminst%\ask.exe !!! Main (English) Plain TeX already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t21
if %TeX%==A goto t22
if %TeX%==M set TeX=N
goto t1
:t21
if %TeX%==M goto t0b
goto t23
:t22
set TeX=C
:t23
if NOT exist %emtexdir%\TEXINPUT\LH\*.* goto t0b
echo 
%eminst%\ask.exe !!! CyrTUG-emTeX russification of TeX already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t0b
if %TeX%==A set TeX=M
if %TeX%==C set TeX=N

:t0b
echo  ... done
::cls
echo.
echo.
echo ??? Do you want to install and/or russify any of them ?
echo     *) LaTeX 2.09 (and LaTeX 2.09 array package)
echo     *) LaTeX 2e   (and LaTeX 2e tools)
echo     *) AmSTeX 2.0
echo     *) Babel 3.6  (multilingual support)
echo     *) NFSS1
%eminst%\ask.exe Enter letter (Y/N),nNyY
echo.
if errorlevel 3 goto t1
if %TeX%==A set TeX=M
if %TeX%==C set TeX=N
goto p0

:t1
cls
for %%c in (LA,LAe,AM,BA,NF) do set %%c=A
echo.
echo.
%eminst%\ask.exe Do you need TeX formats to be RUSSIFIED ? (Y/N),nNyY
if errorlevel 3 goto t3
for %%c in (LA,LAe,AM,BA,NF) do set %%c=M
if %TeX%==A set TeX=M
if %TeX%==C set TeX=N

:t3
echo.
%eminst%\ask.exe Install LaTeX 2.09 ? (Y/N),nNyY
if errorlevel 3 goto t31
set LA=N
goto t3a
:t31
if NOT exist %emtexdir%\TEXINPUT\LATEX209\*.* goto t32
echo 
%eminst%\ask.exe !!! Main (English) LaTeX 2.09 already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t3a
if %LA%==A goto t31a
if %LA%==M set LA=N
goto t3a
:t31a
set LA=C
:t32
if %LA%==M goto t3a
for %%c in (LKYPC,LH) do if NOT exist %emtexdir%\TEXINPUT\LATEX209\%%c\*.* goto t3a
echo 
%eminst%\ask.exe !!! LaTeX 2.09 LH Russification already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t3a
set LA=N
:t3a
if NOT %LA%==N goto t3b
if NOT exist %emtexdir%\TEXINPUT\LATEX209\*.* goto t4
:t3b
echo.
%eminst%\ask.exe Install LaTeX 2.09 tools (array, tabularx, etc: for experts) ? (Y/N),yYnN
if errorlevel 3 goto t4
if NOT exist %emtexdir%\TEXINPUT\LATEX209\ARRAY\*.* goto t3c
echo 
%eminst%\ask.exe !!! LaTeX 2.09 array package already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t4
:t3c
set LA=%LA%T
if %LA%==NT set LA=T

:t4
if %PC%==tex386 goto t40
for %%c in (tex386,htex386) do if exist %emtexdir%\BIN\%%c.exe goto t40
echo 
echo !!! LaTeX 2e can work only with tex386.exe/htex386.exe.
::echo     Continue or Skip (`S' strongly recommended) ? (C/S)
::%eminst%\ask.exe press letter,sScC
::echo.
::if errorlevel 3 goto t40
::set LAe=N
goto t5
:t40
echo.
%eminst%\ask.exe Install LaTeX 2e ? (Y/N),nNyY
if errorlevel 3 goto t41
set LAe=N
goto t4a
:t41
if NOT exist %emtexdir%\TEXINPUT\LATEX2E\*.* goto t43
echo 
%eminst%\ask.exe !!! Main (English) LaTeX 2e already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t4a
if %LAe%==A goto t42
if %LAe%==M set LAe=N
goto t4a
:t42
set LAe=C
:t43
if %LAe%==M goto t4a
if NOT exist %emtexdir%\TEXINPUT\LATEX2E\LH\*.* goto t4a
echo 
%eminst%\ask.exe !!! LaTeX 2e Russian/LH configuration already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t4a
set LAe=N
:t4a
if NOT %LAe%==N goto t4b
if NOT exist %emtexdir%\TEXINPUT\LATEX2E\*.* goto t5
:t4b
echo.
%eminst%\ask.exe Install LaTeX 2e tools (for experts) ? (Y/N),yYnN
if errorlevel 3 goto t5
if NOT exist %emtexdir%\TEXINPUT\LATEX2E\TOOLS\*.* goto t4c
echo 
%eminst%\ask.exe !!! LaTeX 2e tools already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t5
:t4c
set LAe=%LAe%T
if %LAe%==NT set LAe=T

:t5
cls
echo.
echo.
%eminst%\ask.exe Install AmSTeX ? (Y/N),yYnN
if errorlevel 3 goto t51
if NOT exist %emtexdir%\TEXINPUT\AMSTEX\*.* goto t6
echo 
%eminst%\ask.exe !!! Main (English) AmSTeX 2.0 already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t51
if %AM%==A set AM=C
if %AM%==M set AM=N
:t51
if NOT %AM%==N goto t52
if NOT exist %emtexdir%\TEXINPUT\AMSTEX\*.* goto t6
:t52
if NOT exist %emtexdir%\TEXINPUT\AMSTEX\LH\*.* goto t6
echo 
%eminst%\ask.exe !!! AmSTeX LH Russification (lhamsppt) already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t6
if %AM%==A set AM=M
if %AM%==C set AM=N

:t6
echo.
%eminst%\ask.exe Install Babel (multilingual package) ? (Y/N),yYnN
if errorlevel 3 goto t61
if NOT exist %emtexdir%\TEXINPUT\BABEL\*.* goto t6n
echo 
%eminst%\ask.exe !!! Main (English) Babel already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t6n
:t61
set BA=N

:t6n
echo.
%eminst%\ask.exe Install NFSS1 (not recommended) ? (Y/N),yYnN
if errorlevel 3 goto t61n
if NOT exist %emtexdir%\TEXINPUT\LATEX209\NFSS1\*.* goto t7
echo 
%eminst%\ask.exe !!! NFSS1 already installed. Overwrite ? (Y/N),nNyY
if errorlevel 3 goto t7
:t61n
set NF=N

:t7
cls
echo.
echo.
echo CHECK TeX packages
echo     Plain TeX      = %TeX%
echo     LaTeX 2.09     = %LA%
echo     LaTeX 2e       = %LAe%
echo     AmSTeX         = %AM%
echo     Babel          = %BA%
echo     NFSS1          = %NF%
echo.
echo.
echo A = Install Main (English) package + CyrTUG-emTeX Russification
echo M = Install Main (English) package only
echo C = Install CyrTUG-emTeX Russification only
echo T = Install additional packages (for LaTeXs)
%eminst%\ask.exe Everything is allright (Yes No or Quit) ? (Y/N/Q),yYnNqQ
echo.
if errorlevel 5 goto end
if errorlevel 3 goto t1

:p0
cls
echo.
echo.
%eminst%\ask.exe CHOOSE language for emTeX documents: English/German (E/G),gGeE
echo.

for %%c in (Ctex,Ctex186.Ctex386) do if %PC%==%%c goto pC
for %%c in (Cmf,Cmf186.Cmf386) do if %MF%==%%c goto pC
if %FNT%==C goto pC

if errorlevel 3 goto p1

if %PC%==0 goto p0b
for %%c in (first,tex,dvi2) do copy %eminst%\%%c.lsg %eminst%\%%c.ls
if %FNT%==0 goto p0a
copy %eminst%\dvi1m.lsg %eminst%\dvi1.ls
goto p0b
:p0a
copy %eminst%\dvi1f.lsg %eminst%\dvi1.ls
:p0b
if %MF%==0 goto p0c
for %%c in (mf,mfjob) do copy %eminst%\%%c.lsg %eminst%\%%c.ls
:p0c
if %PC%==tex386 goto p0d
if %MF%==mf386 goto p0d
goto p0e
:p0d
copy %eminst%\emxrsx.lsg %eminst%\emxrsx.ls
:p0e
copy %eminst%\texcad.lsg %eminst%\texcad.ls
goto p3

:p1
if %PC%==0 goto p1b
for %%c in (first,tex,dvi2) do copy %eminst%\%%c.lse %eminst%\%%c.ls
if %FNT%==0 goto p1a
copy %eminst%\dvi1m.lse %eminst%\dvi1.ls
goto p1b
:p1a
copy %eminst%\dvi1f.lse %eminst%\dvi1.ls
:p1b
if %MF%==0 goto p1c
for %%c in (mf,mfjob) do copy %eminst%\%%c.lse %eminst%\%%c.ls
:p1c
if %PC%==tex386 goto p1d
if %MF%==mf386 goto p1d
goto p1e
:p1d
copy %eminst%\emxrsx.lse %eminst%\emxrsx.ls
:p1e
copy %eminst%\texcad.lse %eminst%\texcad.ls

:p3
cls
echo.
if %PC%==0 goto p6
echo.
echo Writing to list files for TeX
echo emtex/bin/%PC%.exe >>%eminst%\tex.ls
echo emtex/btexfmts/tex.poo >>%eminst%\tex.ls
if %PC%==tex386 goto p31
echo emtex/texfmts/tex.poo >>%eminst%\tex.ls
echo emtex/bin/b%PC%.exe >>%eminst%\tex.ls
goto p5
:p31
echo emtex/bin/h%PC%.exe >>%eminst%\tex.ls
echo emtex/htexfmts/tex.poo >>%eminst%\tex.ls

:p5
if "%MC%"=="0" goto p6
echo.
echo Writing to list files for DVIDRV -- viewing/printing programs
if NOT "%MC%"=="7" goto p51
echo emtex/bin/dviscr7.exe >>%eminst%\dvi2.ls
echo emtex/bin/dvihplj7.exe >>%eminst%\dvi2.ls
echo emtex/bin/dvidot7.exe >>%eminst%\dvi2.ls
goto p6
:p51
echo emtex/bin/dviscr.exe >>%eminst%\dvi1.ls
echo emtex/bin/dvihplj.exe >>%eminst%\dvi1.ls
echo emtex/bin/dvidot.exe >>%eminst%\dvi1.ls

:p6
if %MF%==0 goto p7
echo.
echo Writing to list file for METAFONT
echo emtex/bin/%MF%.exe >>%eminst%\mf.ls
if %MF%==mf386 goto p61
echo emtex/mfbases/mf.poo >>%eminst%\mf.ls
goto p7
:p61
echo emtex/bmfbases/mf.poo >>%eminst%\mf.ls

:p7
if %PC%==0 goto p7a1
goto p7a
:p7a1
if %MF%==0 goto pC0a
:p7a
echo.
echo Creating list files for fonts
if %PC%==0 goto p71
if %MF%==0 goto p72
echo (metrics/sources)
for %%c in (fontcm,fontltx) do copy %eminst%\%%c.lsf+%eminst%\%%c.lsm %eminst%\%%c.ls
for %%c in (fontams,fontemsy) do copy %eminst%\%%c.lsf+%eminst%\%%c.lsm %eminst%\%%c.ls
goto p73
:p71
echo (sources)
for %%c in (fontcm,fontltx,fontams,fontemsy) do copy %eminst%\%%c.lsf %eminst%\%%c.ls
goto pC0a
:p72
echo (metrics)
for %%c in (fontcm,fontltx,fontams,fontemsy) do copy %eminst%\%%c.lsm %eminst%\%%c.ls
:p73
if NOT %LAe%==N echo emtex/texinput/amsfonts/*.*>>%eminst%\fontams.ls
goto pC0a


::CyrTUG support
:pC
if errorlevel 3 goto pC0
copy %eminst%\texcad.lsg %eminst%\texcad.ls
goto pC0a
:pC0
copy %eminst%\texcad.lse %eminst%\texcad.ls
:pC0a
echo.
echo Creating list file for CyrTUG-emTeX package
echo bin/*.*>>%eminst%\cyrtug.ls
echo data/*.*>>%eminst%\cyrtug.ls

:pC1
if NOT exist %emtexdir%\TEXINPUT\RUSSIAN\*.*  echo texinput/russian/*.*>>%eminst%\cyrtug.ls
if NOT exist %emtexdir%\TEXINPUT\LH-RUTEX\*.* echo texinput/lh-rutex/*.*>>%eminst%\cyrtug.ls
if NOT exist %emtexdir%\TEXINPUT\RUHYPHEN\*.*   echo texinput/ruhyphen/*.*>>%eminst%\cyrtug.ls

:pC2
for %%c in (N,T) do if %LA%==%%c goto pC3
if NOT exist %emtexdir%\DOC\LH-PACK\LKYPC\*.*  echo doc/lh-pack/lkypc/*.*>>%eminst%\cyrtug.ls

:pC3
for %%c in (N,T) do if %LAe%==%%c goto pC4
if NOT exist %emtexdir%\DOC\LH-PACK\L2KYPC\*.* echo doc/lh-pack/l2kypc/*.*>>%eminst%\cyrtug.ls

:pC4
for %%c in (N,T) do if %BA%==%%c goto p8
if NOT exist %emtexdir%\DOC\BABEL\RUSBABEL\*.* echo doc/babel/rusbabel/*.*>>%eminst%\cyrtug.ls
if NOT exist %emtexdir%\TEXINPUT\T2\*.* echo texinput/t2/*.*>>%eminst%\cyrtug.ls

:p8
%eminst%\instd.bat %1 %2

:err
cls
echo.
echo ERROR
echo     You must *QUIT* the Norton Comander or another Commands Shell and repeat:
echo     e.g.: %0 c a
pause
goto end

:usage
cls
echo.
echo Usage:  %0  disk_to  disk_from
echo  e.g.:
echo         %0  c  a
echo         %0  c  d
echo.
echo disk_from may be both floppy and hard disk
echo.
echo WARNING: You must *QUIT* the Norton Comander or another Commands Shell.
pause

:end
echo 
echo See you again . . .
