%%
%% This file will generate fast loadable files and documentation
%% driver files from the doc files in this package when run through
%% LaTeX or TeX.
%%
%% Copyright 2012-2026 Javier Bezos and Johannes L. Braams.
%% Copyright 1989-2008 Johannes L. Braams and any individual authors
%% listed elsewhere in this file.  All rights reserved.
%% 
%% This file is part of the Babel system.
%% --------------------------------------
%% 
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is Javier Bezos.
%% 
%% The list of derived (unpacked) files belonging to the distribution
%% and covered by LPPL is defined by the unpacking scripts (with
%% extension .ins) which are part of the distribution.
%%
\def\filedate{2026/03/24}
\def\batchfile{babel.ins}
\input docstrip.tex

{\ifx\generate\undefined
\Msg{**********************************************}
\Msg{*}
\Msg{* This installation requires docstrip}
\Msg{* version 2.3c or later.}
\Msg{*}
\Msg{* An older version of docstrip has been input}
\Msg{*}
\Msg{**********************************************}
\errhelp{Move or rename old docstrip.tex.}
\errmessage{Old docstrip in input path}
\batchmode
\csname @@end\endcsname
\fi}

% Modify docstrip. A pseudo-guard is defined to set variables:
% <<name=value>>. These variables are used with <@name@> Two further
% pseudo-guards define "block" variables: <<*name>> and <</name>>
% delimite the lines to be retrieved with <@name@>. Note the verbatim
% guard is overridden, but it's not used here.  This is done in two
% passes: 1) with saving true, there is a dummy pass, generating
% nothing, but blocks are read and saved; 2) with saving false, blocks
% are always ignored, but replacing <@name@>.  While <@name@> can be
% used freely outside <<>>, it's only allowed inside <<>> if
% previously defined. Deeper nesting is not allowed.

\def\replaceVar#1<@#2{%
  #1%
  \ifx\endLine#2\else
    \expandafter\replaceVarX\expandafter#2%
  \fi}

\def\replaceVarX#1@>{\csname #1Var\endcsname\replaceVar}

\def\normalLine#1\endLine{%
  \advance\codeLinesPassed\@ne
  \maybeMsg{.}%
  \edef\inLine{\replaceVar#1<@\endLine}%
  \let\do\putline@do
  \ifcollect
    \xdef\varCollect{\varCollect^^J\inLine}%
  \else
    \activefiles
  \fi}

\newif\ifcollect
\newif\ifsaving

\def\verbOption<#1#2>>#3{%
  \ifx#1*%
    \maybeMsg{<<*#2>>}%
    \global\collecttrue
    \gdef\varCollect##1{}%
  \else\ifx#1/%
    \global\collectfalse
    \ifsaving
      \expandafter\ifx\csname #2Var\endcsname\relax
        \global\expandafter\let\csname #2Var\endcsname\varCollect
      \else
        \toks@\expandafter\expandafter\expandafter{%
          \csname #2Var\expandafter\endcsname\expandafter^^J%
          \varCollect}%
        \expandafter\xdef\csname #2Var\endcsname{\the\toks@}%
      \fi
    \fi
  \else
    \varOptionI#1#2>%
  \fi\fi}

\def\varOptionI#1=#2>{%
  \maybeMsg{<<#1=#2>>}%
  \ifsaving
    \expandafter\gdef\csname #1Var\endcsname{#2}%
  \fi}

% Preambles

\declarepreamble\mainpreamble
\endpreamble

\def\MetaPrefix{--}
\declarepreamble\luapreamble
\endpreamble
\let\MetaPrefix\DoubleperCent

\keepsilent
\askonceonly

\usedir{tex/generic/babel}

\usepreamble\mainpreamble

% Dummy, it just read "modules" to be used when generating
% the actual file. There must be a better way.
\savingtrue
\generate{\usepreamble\empty
          \usepostamble\empty
          \file{dummy.log}{\from{babel.dtx}{dummy}}}
\savingfalse

\generate{\file{babel.sty}{\from{babel.dtx}{package}}
          \file{babel.def}{\from{babel.dtx}{core}}
          \file{switch.def}{\from{babel.dtx}{kernel}}
          \file{hyphen.cfg}{\from{babel.dtx}{patterns}}
          \file{nil.ldf}{\from{babel.dtx}{nil}}
          \file{errbabel.def}{\from{babel.dtx}{errors}}
          \file{babel-ca-buddhist.tex}{\from{babel.dtx}{ca-buddhist}}
          \file{babel-ca-coptic.tex}{\from{babel.dtx}{ca-coptic}}
          \file{babel-ca-ethiopic.tex}{\from{babel.dtx}{ca-ethiopic}}
          \file{babel-ca-hebrew.tex}{\from{babel.dtx}{ca-hebrew}}
          \file{babel-ca-islamic.tex}{\from{babel.dtx}{ca-islamic}}
          \file{babel-ca-julian.tex}{\from{babel.dtx}{ca-julian}}
          \file{babel-ca-persian.tex}{\from{babel.dtx}{ca-persian}}
          \file{babel-ca-chinese.tex}{\from{babel.dtx}{ca-chinese}}
          \file{xebabel.def}{\from{babel.dtx}{xetex}}
          \file{luababel.def}{\from{babel.dtx}{luatex}}
          \file{txtbabel.def}{\from{babel.dtx}{texxet}}
          }

% Support for plain users
\generate{\file{plain.def}{\from{babel.dtx}{plain}}
          \file{bplain.tex}{\from{babel.dtx}{bplain}}
          \file{blplain.tex}{\from{babel.dtx}{blplain}}
         }
         
% MakeIndex style files

\usedir{makeindex/babel}

\generate{\file{bbind.ist}{\from{bbidxglo.dtx}{idx}}
          \file{bbglo.ist}{\from{bbidxglo.dtx}{glo}}}

% lua code

\def\MetaPrefix{--}
\usepreamble\luapreamble
\nopostamble
\generate{\file{babel-transforms.lua}{\from{babel.dtx}{transforms}}}
\generate{\file{babel-data-bidi.lua}{\from{babel.dtx}{bididata}}}
\generate{\file{babel-data-cjk.lua}{\from{babel.dtx}{cjkdata}}}
\generate{\file{babel-bidi-basic-r.lua}{\from{babel.dtx}{basic-r}}}
\generate{\file{babel-bidi-basic.lua}{\from{babel.dtx}{basic}}}

% Compatibility files

\def\compatfile#1{\file{#1.sty}{\from{bbcompat.dtx}{styfile,#1}}}

\generate{%
         \compatfile{esperanto}
         \compatfile{afrikaans}
         \compatfile{dutch}
         \compatfile{american}
         \compatfile{british}
         \compatfile{english}
         \compatfile{UKenglish}
         \compatfile{USenglish}
         \compatfile{germanb}
         \compatfile{austrian}
         \compatfile{ngermanb}
         \compatfile{naustrian}
         \compatfile{irish}
         \compatfile{scottish}
         \compatfile{welsh}
         \compatfile{breton}
         }
\generate{%
         \compatfile{francais}
         \compatfile{italian}
         \compatfile{portuges}
         \compatfile{spanish}
         \compatfile{catalan}
         \compatfile{galician}
         \compatfile{danish}
         \compatfile{norsk}
         \compatfile{swedish}
         \compatfile{finnish}
         \compatfile{magyar}
         \compatfile{greek}
         \compatfile{croatian}
         \compatfile{czech}
         \compatfile{slovak}
         \compatfile{polish}
         }
\generate{%
         \compatfile{estonian}
         \compatfile{romanian}
         \compatfile{slovene}
         \compatfile{russianb}
         \compatfile{ukraineb}
         \compatfile{turkish}
         \compatfile{lsorbian}
         \compatfile{usorbian}
         \compatfile{bahasa}
         \compatfile{hebrew}
         \compatfile{basque}
         \compatfile{latin}
         \compatfile{icelandic}
         \compatfile{serbian}
         \compatfile{bulgarian}
         }
\generate{%
         \compatfile{samin}
         \compatfile{interlingua}
         \compatfile{albanian}
         \compatfile{bahasam}
         }


\Msg{***********************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move all the files}
\Msg{* with names ending in .ldf, .sty, .def or .lua into a}
\Msg{* directory searched by TeX}
\Msg{*}
\Msg{* For making a format the following files have to be in a}
\Msg{* directory which is searched by IniTeX:}
\Msg{* \space\space hyphen.cfg}
\Msg{* \space\space language.dat}
\Msg{* \space\space and files with hyphenation patterns}
\Msg{*}
\Msg{* To produce source listings you can run babel.dtx}
\Msg{* through LuaLaTeX. Deja Vu fonts are required.}
\Msg{*}
\Msg{*}
\Msg{* Happy TeXing}
\Msg{*}
\Msg{***********************************************************}
