6 rem Makefile for LaTeX2 "base" files
8 if not [%1] == [] goto init
13 echo make check [show] - run automated check system
14 echo make clean - clean out directory
15 echo make doc [show] - typeset all dtx files
16 echo make localinstall - locally install package
17 echo make savetlg ^<name^> - save test log for ^<name^>
18 echo make checktlg ^<name^> - check one test file ^<name^>
19 echo make unpack [show] - extract modules
20 echo make ctan [show] - build CTAN distribution
22 echo The "show" option enables display of the output
23 echo of the TeX runs in the terminal.
29 rem Avoid clobbering anyone else's variables
33 rem Safety precaution against awkward paths
37 rem The name of the module and the bundle it is part of
42 rem Unpacking information
44 rem set UNPACK=%MODULE%.ins
48 set AUXFILES=aux cmds fpl glo hd idx ilg ind log lvt tlg toc out lof lot bbl tlg-clean
49 set CLEAN=fc gz pdf sty dvi def drv ldf ist fd ps xyc cfg
52 rem Check system set up
54 set CHECKDIR=testfiles
55 set CHECKEXE=etex -interaction=nonstopmode -translate-file ./ascii.tcx -efmt=..\build\latex.fmt -output-format=dvi
58 rem Local installation settings
60 set INSTALLDIR=latex\%BUNDLE%\%MODULE%
61 set INSTALLFILES= *.cfg *.clo *.cls *.def *.dfu *.fd *.ist *.ltx *.sty *.tex *.err
63 rem Documentation typesetting set up (not using internal format for now, perhaps it should)
65 set TYPESETEXE=pdflatex -interaction=nonstopmode
67 rem Locations for the various support items required
70 set SCRIPTDIR=%MAINDIR%\scripts
71 set VALIDATE=%MAINDIR%\validate
73 set UNPACKDIR=%MAINDIR%\unpacked
74 set BUILDDIR=%MAINDIR%\build
75 set TESTDIR=%MAINDIR%\test
76 set SUPPORTDIR=%MAINDIR%\support
78 set DISTRIBDIR=%MAINDIR%\distrib
81 rem Set up redirection of output
85 if /i [%2] == [show] (
92 if /i [%1] == [check] goto check
93 if /i [%1] == [checktlg] goto checktlg
94 if /i [%1] == [clean] goto clean
95 if /i [%1] == [cleanall] goto clean
96 if /i [%1] == [doc] goto doc
97 if /i [%1] == [localinstall] goto localinstall
98 if /i [%1] == [savetlg] goto savetlg
99 if /i [%1] == [unpack] goto unpack
100 if /i [%1] == [ctan] goto ctan
106 if not exist %CHECKDIR%\nul goto end
108 rem Check for Perl, and give up if it is not found
111 if ERRORLEVEL 1 goto :EOF
113 rem Remove any old files, and then copy the test system into place
117 rem Unpack, allowing for using a 'trace' version or similar
121 rem next unpacks are needed if we want to process all test files
122 rem i.e. also those from the required portion, but I guess we really
123 rem better keep this separate
125 rem call ..\required\tools\make.bat unpack show
126 rem call ..\required\graphics\make.bat unpack show
127 rem call ..\required\cyrillic\make.bat unpack show
129 copy /y %SCRIPTDIR%\log2tlg %TESTDIR% > nul
130 copy /y %VALIDATE%\test2e.tex %TESTDIR% > nul
131 copy /y %VALIDATE%\test209.tex %TESTDIR% > nul
132 copy /y %VALIDATE%\ascii.tcx %TESTDIR% > nul
134 if exist %CHECKDIR%\helpers\nul (
135 copy /y %CHECKDIR%\helpers\* %TESTDIR% > nul
145 rem Copy all test files for which there is a matching reference log
147 for %%I in (%CHECKDIR%\*.lvt) do (
148 if exist %CHECKDIR%\%%~nI.tlg (
149 copy /y %CHECKDIR%\%%~nI.lvt %TESTDIR% > nul
150 copy /y %CHECKDIR%\%%~nI.tlg %TESTDIR% > nul
152 echo %CHECKDIR%\%%~nI.tlg missing
160 if [%2] == [] goto help
161 if not exist %CHECKDIR%\%2.lvt (
163 echo Check file %2.lvt not found!
170 rem Copy all test files for which there is a matching reference log
172 for %%I in (%CHECKDIR%\%2.lvt) do (
173 if exist %CHECKDIR%\%%~nI.tlg (
174 copy /y %CHECKDIR%\%%~nI.lvt %TESTDIR% > nul
175 copy /y %CHECKDIR%\%%~nI.tlg %TESTDIR% > nul
177 echo %CHECKDIR%\%%~nI.tlg missing
187 echo Running checks on
189 SET TEXINPUTS=.;%UNPACKDIR%;%BUILDDIR%
193 for %%I in (*.tlg) do (
195 for /l %%J in (1,1,%CHECKRUNS%) do (
196 %CHECKEXE% %%~nI.lvt <%SCRIPTDIR%\enter.txt %REDIRECT%
198 %PERLEXE% log2tlg %%~nI < %%~nI.log > %%~nI.new.log
200 rem del /q %%~nI.log > nul
201 ren %%~nI.log %%~nI.logfull > nul
202 ren %%~nI.new.log %%~nI.log > nul
204 rem remove empty lines from .tlg file
205 %PERLEXE% -n -e "/^\s*$/ || print" < %%~nI.tlg >%%~nI.clean.tlg
207 fc /n %%~nI.log %%~nI.clean.tlg > %%~nI.fc
210 for %%I in (*.fc) do (
211 for /f "skip=1 tokens=1" %%J in (%%~nI.fc) do (
222 echo Checks fails for
223 for %%I in (*.fc) do (
227 echo All checks passed
230 for %%I in (*.tlg) do (
231 if exist %%~nI.pdf del /q %%~nI.pdf
232 if exist %%~nI.dvi del /q %%~nI.dvi
242 del /q %DISTRIBDIR%\base\*
243 del /q %DISTRIBDIR%\unpacked\*
250 for %%I in (%NOCLEAN%) do (
251 copy /y %%I %%I.bak > nul
254 for %%I in (%CLEAN%) do (
255 if exist *.%%I del /q *.%%I
258 for %%I in (%NOCLEAN%) do (
259 copy /y %%I.bak %%I > nul
265 for %%I in (%AUXFILES%) do (
266 if exist *.%%I del /q *.%%I
269 if exist log2tlg del /q log2tlg
270 if exist test2e.tex del /q test2e.tex
271 if exist ascii.tcx del /q ascii.tcx
278 echo Typesetting (using normal TeX system on machine)
280 for %%I in (*.dtx) do (
283 %TYPESETEXE% -draftmode %%I %REDIRECT%
285 echo ! Compilation failed
289 makeindex -q -s l3doc.ist -o %%~nI.ind %%~nI.idx > nul
291 %TYPESETEXE% %%I %REDIRECT%
292 %TYPESETEXE% %%I %REDIRECT%
294 ) else echo %%I skipped
297 for %%I in (*.fdd) do (
300 %TYPESETEXE% -draftmode %%I %REDIRECT%
302 echo ! Compilation failed
306 makeindex -q -s l3doc.ist -o %%~nI.ind %%~nI.idx > nul
308 %TYPESETEXE% %%I %REDIRECT%
309 %TYPESETEXE% %%I %REDIRECT%
311 ) else echo %%I skipped
314 for %%I in (source2e.tex sample2e.tex lppl.tex small2e.tex) do (
317 %TYPESETEXE% -draftmode %%I %REDIRECT%
319 echo ! Compilation failed
323 makeindex -q -s l3doc.ist -o %%~nI.ind %%~nI.idx > nul
325 %TYPESETEXE% %%I %REDIRECT%
326 %TYPESETEXE% %%I %REDIRECT%
328 ) else echo %%I skipped
331 if "%PROBLEM%" == "true" (
333 echo There have been some problems!
343 echo Installing files
345 rem Find local root if possible
347 if not defined TEXMFHOME (
348 for /f "delims=" %%I in ('kpsewhich --var-value=TEXMFHOME') do @set TEXMFHOME=%%I
349 if "%TEXMFHOME%" == "" (
350 set TEXMFHOME=%USERPROFILE%\texmf
354 set INSTALLROOT=%TEXMFHOME%\tex\%INSTALLDIR%
356 if exist "%INSTALLROOT%\*.*" rmdir /q /s "%INSTALLROOT%"
357 mkdir "%INSTALLROOT%"
362 for %%I in (%INSTALLFILES%) do (
363 copy /y %%I "%INSTALLROOT%" > nul
376 if defined PERLEXE goto :EOF
378 rem This code is used to find out if Perl is available in the path
380 for /f "delims=; tokens=1,2*" %%I in ("%PATHCOPY%") do (
381 if exist %%I\perl.exe set PERLEXE=perl
385 if defined PERLEXE goto :EOF
387 rem No Perl found in the path, so try some standard locations
389 if not "%PATHCOPY%" == ";" goto perl-loop
391 if exist %SYSTEMROOT%\Perl\bin\perl.exe set PERLEXE=%SYSTEMROOT%\Perl\bin\perl
392 if exist %ProgramFiles%\Perl\bin\perl.exe set PERLEXE=%ProgramFiles%\Perl\bin\perl
393 if exist %SYSTEMROOT%\strawberry\Perl\bin\perl.exe set PERLEXE=%SYSTEMROOT%\strawberry\Perl\bin\perl
395 if defined PERLEXE goto :EOF
397 rem Failed to find Perl, give up and kill the entire batch process
400 echo This procedure requires Perl, but it could not be found.
408 if not exist %CHECKDIR%\%2.lvt (
410 echo Check file %2.lvt not found!
417 rem Copy the test file
419 copy /y %CHECKDIR%\%2.lvt %TESTDIR% > nul
422 echo Creating and copying %2.tlg
424 SET TEXINPUTS=.;%UNPACKDIR%;%BUILDDIR%
428 for /l %%I in (1,1,%CHECKRUNS%) do (
429 %CHECKEXE% %2.lvt %REDIRECT%
431 %PERLEXE% log2tlg %2 < %2.log > %2.tlg
435 copy /y %TESTDIR%\%2.tlg %CHECKDIR%\%2.tlg > nul
445 del /q %DISTRIBDIR%\base\*
446 del /q %DISTRIBDIR%\unpacked\*
448 for %%I in (*.cls *.dtx latexbug.el *.err *.fdd *.ins ltpatch.ltx README *.tex *.txt) do (
449 copy /y %%I %DISTRIBDIR%\base\%%I >nul
452 for %%I in (*.cls~ *.dtx~ *atexbug.el~ *.err~ *.fdd~ *.ins~ *tpatch.ltx~ *EADME~ *.tex~ *.txt~) do (
454 if exist %DISTRIBDIR%\base\%%I del /q %DISTRIBDIR%\base\%%I >nul
459 copy /y %UNPACKDIR%\* %DISTRIBDIR%\unpacked >nul
465 for %%I in (*.pdf) do (
466 copy /y %%I %DISTRIBDIR%\base\%%I >nul
481 echo ***************************************************
482 echo *** Copying kernel bootstrap sources ...
483 echo ***************************************************
486 for %%I in (*.dtx *.ins *.fdd ltpatch.ltx *.tex *.cls) do (
487 copy /y %%I %UNPACKDIR%\%%I >nul
490 rem getting rid of emacs ~ files
492 for %%I in (*.dtx *.ins *.fdd ltpatch.ltx *.tex *.cls) do (
493 if exist %UNPACKDIR%\%%I~ rm %UNPACKDIR%\%%I~
496 rem remove other files
497 for %%I in (ttcterrata.cls) do (
498 if exist %UNPACKDIR%\%%I del %UNPACKDIR%\%%I
502 rem unpack the distribution
503 rem Make sure that no external input files are read by setting TEXINPUTS
506 echo ***************************************************
507 echo *** Generating LaTeX2e kernel bootstrap files...
508 echo ***************************************************
513 etex -ini unpack.ins <%SCRIPTDIR%\yes.txt
516 for %%I in (*.dtx *.ins *.fdd ) do (
517 if exist %%I del %%I >nul
526 echo ***************************************************
527 echo *** Copying format support files...
528 echo ***************************************************
530 copy /y %SUPPORTDIR%\*.*
533 echo ***************************************************
534 echo *** Generating LaTeX2e kernel formats...
535 echo ***************************************************
538 SET TEXINPUTS=.;%UNPACKDIR%
540 etex -ini -etex latex.ltx <%SCRIPTDIR%\yes.txt
541 pdfetex -ini -etex -jobname=pdflatex "*pdflatex.ini" latex.ltx <%SCRIPTDIR%\yes.txt
550 rem echo base: PROBLEM="%PROBLEM%" and GLOBALPROBLEM="%GLOBALPROBLEM%"
552 endlocal & if "%PROBLEM%" == "true" set GLOBALPROBLEM=%PROBLEM%
554 rem If something like "make check show" was used, remove the "show"
556 if /i [%2] == [show] shift
559 if not [%1] == [] goto main