3 rem Makefile for LaTeX2 "babel" files
5 if not [%1] == [] goto init
10 echo make check [show] - run automated check system
11 echo make clean - clean out directory
12 echo make doc [show] - typeset all dtx files
13 echo make localinstall - locally install package
14 echo make savetlg ^<name^> - save test log for ^<name^>
15 echo make unpack [show] - extract modules
17 echo The "show" option enables display of the output
18 echo of the TeX runs in the terminal.
24 rem Avoid clobbering anyone else's variables
28 rem Safety precaution against awkward paths
32 rem The name of the module and the bundle it is part of
37 rem Unpacking information
39 set UNPACK=%MODULE%.ins
43 set AUXFILES=aux cmds fpl glo hd idx ilg ind log lvt tlg toc out lof bbl
44 set CLEAN=fc gz pdf sty dvi def drv ldf ist fd ps xyc cfg
47 rem Check system set up
49 set CHECKDIR=testfiles
50 set CHECKEXE=latex -translate-file ./ascii.tcx
52 set CHECKUNPACK=%UNPACK%
54 rem Local installation settings
56 set INSTALLDIR=latex\%BUNDLE%\%MODULE%
57 set INSTALLFILES=*.sty *.ldf *.def *.tex *.fd *.cfg
59 rem Documentation typesetting set up
61 set TYPESETEXE=pdflatex -interaction=nonstopmode
63 rem Locations for the various support items required
66 set SCRIPTDIR=%MAINDIR%\scripts
67 set VALIDATE=%MAINDIR%\validate
69 rem Set up redirection of output
73 if /i [%2] == [show] (
80 if /i [%1] == [check] goto check
81 if /i [%1] == [clean] goto clean
82 if /i [%1] == [cleanall] goto clean
83 if /i [%1] == [doc] goto doc
84 if /i [%1] == [localinstall] goto localinstall
85 if /i [%1] == [savetlg] goto savetlg
86 if /i [%1] == [unpack] goto unpack
92 if not exist %CHECKDIR%\nul goto end
94 rem Check for Perl, and give up if it is not found
97 if ERRORLEVEL 1 goto :EOF
99 rem Unpack, allowing for using a 'trace' version or similar
101 for %%I in (%CHECKUNPACK%) do (
102 (echo y & echo y) | tex %%I %REDIRECT%
105 rem Remove any old files, and copy the test system into place
107 for %%I in (fc lvt tlg) do (
108 if exist *.%%I del /q *.%%I
111 copy /y %SCRIPTDIR%\log2tlg > nul
112 copy /y %VALIDATE%\test2e.tex > nul
113 copy /y %VALIDATE%\ascii.tcx > nul
115 rem Copy all test files for which there is a matching reference log
117 for %%I in (%CHECKDIR%\*.lvt) do (
118 if exist %CHECKDIR%\%%~nI.tlg (
119 copy /y %CHECKDIR%\%%~nI.lvt > nul
120 copy /y %CHECKDIR%\%%~nI.tlg > nul
125 echo Running checks on
127 for %%I in (*.tlg) do (
129 for /l %%J in (1,1,%CHECKRUNS%) do (
130 %CHECKEXE% %%~nI.lvt %REDIRECT%
132 %PERLEXE% log2tlg %%~nI < %%~nI.log > %%~nI.new.log
133 del /q %%~nI.log > nul
134 ren %%~nI.new.log %%~nI.log > nul
135 fc /n %%~nI.log %%~nI.tlg > %%~nI.fc
138 for %%I in (*.fc) do (
139 for /f "skip=1 tokens=1" %%J in (%%~nI.fc) do (
149 echo Checks fails for
150 for %%I in (*.fc) do (
154 echo All checks passed
157 for %%I in (*.tlg) do (
158 if exist %%~nI.pdf del /q %%~nI.pdf
165 for %%I in (%NOCLEAN%) do (
166 copy /y %%I %%I.bak > nul
169 for %%I in (%CLEAN%) do (
170 if exist *.%%I del /q *.%%I
173 for %%I in (%NOCLEAN%) do (
174 copy /y %%I.bak %%I > nul
180 for %%I in (%AUXFILES%) do (
181 if exist *.%%I del /q *.%%I
184 if exist log2tlg del /q log2tlg
185 if exist test2e.tex del /q test2e.tex
186 if exist ascii.tcx del /q ascii.tcx
195 for %%I in (*.dtx) do (
197 %TYPESETEXE% -draftmode %%I %REDIRECT%
199 echo ! Compilation failed
202 makeindex -q -s gind.ist -o %%~nI.ind %%~nI.idx > nul
204 %TYPESETEXE% %%I %REDIRECT%
205 %TYPESETEXE% %%I %REDIRECT%
216 echo Installing files
218 rem Find local root if possible
220 if not defined TEXMFHOME (
221 for /f "delims=" %%I in ('kpsewhich --var-value=TEXMFHOME') do @set TEXMFHOME=%%I
222 if "%TEXMFHOME%" == "" (
223 set TEXMFHOME=%USERPROFILE%\texmf
227 set INSTALLROOT=%TEXMFHOME%\tex\%INSTALLDIR%
229 if exist "%INSTALLROOT%\*.*" rmdir /q /s "%INSTALLROOT%"
230 mkdir "%INSTALLROOT%"
232 for %%I in (%INSTALLFILES%) do (
233 copy /y %%I "%INSTALLROOT%" > nul
244 if defined PERLEXE goto :EOF
246 rem This code is used to find out if Perl is available in the path
248 for /f "delims=; tokens=1,2*" %%I in ("%PATHCOPY%") do (
249 if exist %%I\perl.exe set PERLEXE=perl
253 if defined PERLEXE goto :EOF
255 rem No Perl found in the path, so try some standard locations
257 if not "%PATHCOPY%" == ";" goto perl-loop
259 if exist %SYSTEMROOT%\Perl\bin\perl.exe set PERLEXE=%SYSTEMROOT%\Perl\bin\perl
260 if exist %ProgramFiles%\Perl\bin\perl.exe set PERLEXE=%ProgramFiles%\Perl\bin\perl
261 if exist %SYSTEMROOT%\strawberry\Perl\bin\perl.exe set PERLEXE=%SYSTEMROOT%\strawberry\Perl\bin\perl
263 if defined PERLEXE goto :EOF
265 rem Failed to find Perl, give up and kill the entire batch process
268 echo This procedure requires Perl, but it could not be found.
278 if [%2] == [] goto help
279 if not exist %CHECKDIR%\%2.lvt (
281 echo Check file %2.lvt not found!
286 for %%I in (%CHECKUNPACK%) do (
287 (echo y & echo y) | tex %%I %REDIRECT%
290 copy /y %SCRIPTDIR%\log2tlg > nul
291 copy /y %VALIDATE%\test2e.tex > nul
292 copy /y %VALIDATE%\ascii.tcx > nul
293 copy /y %CHECKDIR%\%2.lvt > nul
296 echo Creating and copying %2.tlg
298 for /l %%I in (1,1,%CHECKRUNS%) do (
299 %CHECKEXE% %2.lvt %REDIRECT%
301 %PERLEXE% log2tlg %2 < %2.log > %2.tlg
302 copy /y %2.tlg %CHECKDIR%\%2.tlg > nul
310 for %%I in (%UNPACK%) do (
311 (echo y & echo y) | tex %%I %REDIRECT%
318 rem If something like "make check show" was used, remove the "show"
320 if /i [%2] == [show] shift
323 if not [%1] == [] goto main