
      README file for the DJGPP port of TeX and related programs
      ----------------------------------------------------------

I.  General
    -------

    This is a port of the tex-k 7.0 distribution to DJGPP v2.01.
    Tex-k is maintained by Karl Berry <kb@mail.tug.org>.  The original
    tex-k distribution is on CTAN mirror sites; primary locations are:

      `ftp://ftp.cdrom.com/pub/tex/ctan'  (California, USA)
      `ftp://ftp.dante.de/tex-archive'    (Germany)
      `ftp://ftp.tex.ac.uk/tex-archive'   (England)

    (``CTAN'' means ``Comprehensive TeX Archive Network''.)  Tex-k is
    stored on CTAN in several files:

       systems/web2c/texmflib.tar.gz
       systems/web2c/web.tar.gz
       systems/web2c/web2c.tar.gz
       dviware/dvipsk.tar.gz
       dviware/dviljk.tar.gz

    The ported binaries are split into several zip files:

      tmfl72.zip   -- the minimal TeX and Metafont library, required
      webc70b.zip  -- Web2c, TeX and related programs, optional
      kpse30b.zip  -- Kpathsea path-search library, optional
      dvlj26b.zip  -- DVI drivers for LaserJet printers, optional
      dvps566b.zip -- DVI driver for PostScript printers, optional
      dvga09b.zip  -- DVI previewer for VGA adapters, optional
      dvdj09b.zip  -- DVI drivers for DeskJet printers, optional

    `dvlj26b.zip' includes drivers for LaserJet (dvilj), LaserJet 2P
    (dvilj2p) and LaserJet 4 or later (dvilj4) printers; most people
    will only need one of these programs, for whatever printer they
    have.

    `dvdj09b.zip' includes drivers for DeskJet 500 (dvi500), 500C
    (dvi500c) and 550C (dvi550c) printers (dvi500c and dvi550c are
    actually just ``symlinks'' to dvi500).

    If you'd like to download the entire binary distribution, just
    grab all these files and install them as described in section II
    below.  Note that some files appear in more than one zip archive,
    so it is normal to get prompts from your unzip program asking
    whether to overwrite existing files.

    Typically, if you only want to work with TeX and print DVI files,
    you will need some, but not all, of the *b.zip files marked as
    ``optional'' above.  However, since certain parts of tex-k require
    other parts at run time, it is not enough to download only the
    package that you need.  For example, if you only need to be able
    to print DVI files on LaserJet printers, `dvlj26b.zip' alone will
    not do, as it lacks the basic fonts used to generate missing fonts
    on the fly.

    One way to describe the dependencies between the various parts of
    tex-k is to list the main tasks that it allows you to perform and
    tell which programs do you need to install for every task.  The
    following matrix shows that:

                              tmfl  webc  kpse  dvlj  dvps  dvdj  dvga
     -----------------------------------------------------------------
     Generate DVI files	       +     +
     Print DVI on LJ printer   +      		  +
     Print DVI on DJ printer   +      			      +
     Print DVI on PS printer   +      			+
     Preview TeX documents     +      				    +
     Develop with Kpathsea     +      	    +
     Print TeX documents       +     +		  ?	?     ?     +
     Literate programming	     +
     -----------------------------------------------------------------
     Approximate disk space    8M    7M    3M    8M    3M    2M    2M

     (A question mark `?' means you need one of the marked packages,
     depending on the type of your printer.)

    The above table also lists the necessary disk space for each
    package; if you install all of them, you will need about 27Mbytes.
    (These numbers may vary depending on your disk cluster size.)

    Some other related tasks are printing Texinfo docs or converting
    Texinfo documentation to PostScript format.  For these, you will
    need the `texindex' program and the `texi2dvi' shell script from
    the GNU Texinfo package (available in v2gnu/txiNNNb.zip from DJGPP
    archives), and the packages required to print a DVI file on your
    type of printer, as listed in the above matrix.  A modified
    version of `texi2dvi' script that will work on MS-DOS is included
    in webcNNb.zip archive (the original script has some Unixisms
    built into it).

    The Web2c distribution (webcNNb.zip file) also includes Knuth's
    `tangle' and `weave' programs.  These will probably be unused
    unless you want to experiment with so-called ``Literate
    programming'' whereby the sources and the formatted docs of a
    program are produced from a single master file written in a
    special language called `Web'.  (These programs are here because
    TeX, MetaFont and other programs were themselves written by Donald
    Knuth in Web.)  If you are interested in this, check out some of
    the news groups devoted to literate programming.

    The sources are also divided into several zip files:

      webc70s.zip -- original Knuth's programs and Web-to-C converter
      kpse30s.zip -- Kpathsea[rch] library for generic path searching
      dvps566s.zip-- Dvipsk sources
      dvlj26s.zip -- Dviljk sources
      dvdj09s.zip -- sources for DeskJet drivers and the VGA previewer


II. Installation of the binary packages
    -----------------------------------

    - Unzip the downloaded archives from the root of your DJGPP
      installation tree.  If you are doing this on Windows 9x, use an
      unzip program that supports long filenames.  Don't forget the
      `-d' switch if you are using PKUNZIP.

    - Add the following to your DJGPP.ENV, in it's common part (i.e.,
      *before* any program-specific sections):

      +TEXMF=%DJDIR%/share/texmf
      +TEXMFCNF=.;$SELFAUTODIR/share/texmf/web2c;%DJDIR%/share/texmf/web2c

      The default value of these variables built into all the programs
      assumes DJGPP is installed in C:\DJGPP on your system; you can
      leave DJGPP.ENV unchanged if that is indeed so.

      The reason I suggest to define TEXMF for all programs is that
      the tex-k package includes almost 50 programs, most of which
      need to know the value of TEXMF (otherwise, they won't be able
      to find fonts and other required files), and it can be very
      inconvenient to add a section in DJGPP.ENV for every program in
      the package.

    - Add the following (large) fragment to your `info/dir' file:

TeX
* DVI-to-Postscript: (dvips).        Translating TeX DVI files to PostScript.
* Web2c: (web2c).                    TeX, Metafont, and companion programs.
* bibtex: (web2c)bibtex invocation.             Maintaining bibliographies.
* dmp: (web2c)dmp invocation.                   Troff->MPX (MetaPost pictures).
* dvicopy: (web2c)dvicopy invocation.           Virtual font expansion
* dvitomp: (web2c)dvitomp invocation.           DVI to MPX (MetaPost pictures).
* dvitype: (web2c)dvitype invocation.           DVI to human-readable text.
* gftodvi: (web2c)gftodvi invocation.           Generic font proofsheets.
* gftopk: (web2c)gftopk invocation.             Generic to packed fonts.
* gftype: (web2c)gftype invocation.             GF to human-readable text.
* inimf: (web2c)inimf invocation.               Initial Metafont.
* inimpost: (web2c)inimpost invocation.         Initial MetaPost.
* initex: (web2c)initex invocation.             Initial TeX.
* makempx: (web2c)makempx invocation.           MetaPost label typesetting.
* mf: (web2c)mf invocation.                     Creating typeface families.
* mft: (web2c)mft invocation.                   Prettyprinting Metafont source.
* mltex: (web2c)MLTeX.                          Multi-lingual TeX.
* mpost: (web2c)mpost invocation.               Creating technical diagrams.
* mpto: (web2c)mpto invocation.                 MetaPost label extraction.
* newer: (web2c)newer invocation.               Compare modification times.
* patgen: (web2c)patgen invocation.             Creating hyphenation patterns.
* pktogf: (web2c)pktogf invocation.             Packed to generic fonts.
* pktype: (web2c)pktype invocation.             PK to human-readable text.
* pltotf: (web2c)pltotf invocation.             Property list to TFM.
* pooltype: (web2c)pooltype invocation.         Display WEB pool files.
* tangle: (web2c)tangle invocation.             WEB to Pascal.
* tex: (web2c)tex invocation.                   Typesetting.
* tftopl: (web2c)tftopl invocation.             TFM -> property list.
* vftovp: (web2c)vftovp invocation.             Virtual font -> virtual pl.
* virmf: (web2c)virmf invocation.               Virgin Metafont.
* virmpost: (web2c)virmpost invocation.         Virgin MetaPost.
* virtex: (web2c)virtex invocation.             Virgin TeX.
* vptovf: (web2c)vptovf invocation.             Virtual pl -> virtual font.
* weave: (web2c)weave invocation.               WEB to TeX.
* afm2tfm: (dvips)Invoking afm2tfm.  Making Type 1 fonts available to TeX.
* dvips: (dvips)Invoking Dvips.      DVI-to-PostScript translator.
* Kpathsea: (kpathsea).              File lookup along search paths.
* kpsewhich: (kpathsea)Invoking kpsewhich.      TeX file searching.
* MakeTeXMF: (kpathsea)MakeTeX scripts.         MF source generation.
* MakeTeXPK: (kpathsea)MakeTeX scripts.         PK bitmap generation.
* MakeTeXTeX: (kpathsea)MakeTeX scripts.        TeX source generation.
* MakeTeXTFM: (kpathsea)MakeTeX scripts.        TeX font metric generation.
* MakeTeXls-R: (kpathsea)Filename database.     Update ls-R.


    - If you are new to TeX and TeX-related issues, be sure to read
      the docs!  At the very least, you should read about the main
      programs that you will be invoking, like `tex', `dvips',
      `dvilj4' etc.  Another suggested reading is the Kpathsea docs
      which describes the way the programs search for their files, and
      is therefore the place to look for ways to customize your
      installation.  (Note: `dvilj' programs are only documented in a
      man page `dvilj.1' which unzips into your `info' subdirectory.
      Use a pager such as `less' to read it.)

    - If you are familiar with TeX (or if you feel you are, after
      reading the above docs), you might consider editing the
      configuration files to customize the programs.

      The most important configuration file is %TEXMF%/web2c/texmf.cnf
      which defines default values for many variables and search
      paths.  It is extensively commented and will give you some ideas
      about customization possibilities.  If you do change this file,
      it is recommended to remove the word ``original'' from its first
      line, so that if you build a new version of tex-k, the
      installation process won't overwrite your customized file.

      Dvips has its own configuration file in %TEXMF%/dvips/config.ps;
      this lists some default options and settings other than the
      pathnames from texmf.cnf.  Other, printer-specific configuration
      files are also there (look for the *.cfg files) and in the
      `dvips/volker' subdirectory.

    - Make sure your system allows at least 50 files to be open
      simultaneously.  Edit the FILES= setting of your CONFIG.SYS if
      you need, and reboot the computer to let the new setting be in
      effect.

    - If you installed kpse30b.zip to develop programs which use the
      Kpathsea library, and your DJGPP library version is 2.01,
      compile the patched library functions in the gnu/texk-7.0/djgpp
      directory and put them into your library:

		gcc -c -O3 gnu/texk-7.0/djgpp/*.c
		ar rvs c:/djgpp/lib/libc.a gnu/texk-7.0/djgpp/*.o

      (change "c:/djgpp" to the root of DJGPP installation on your
      system). 

    - That's it!  Tex-k is now installed and ready for work.  If you
      have any problems, check out the "Troubleshooting" section
      below.

    The following are some general notes about the binary
    distribution:

    - Tex-k on Unix uses a few shell scripts for certain jobs.  A
      notable example is the MakeTeX* scripts that are used to
      generate missing fonts on the fly.  The binary packages come
      with both thes original shell scripts and with programs that
      replace them.  The replacement programs don't require you to
      install Bash and auxiliary utilities such as `cat', `cp', `mv'
      etc., and also run faster.  However, if you would like to stick
      to the original, rename or delete `maketex.exe', `makempx.exe'
      and `dvihp.exe', remove the .sh extension from the bin/*.sh
      files, and the tex-k programs will call shell scripts like on
      Unix.

    - The first few times when you run the DVI drivers, they will
      create several fonts on the fly.  This is normal behavior and
      should not alarm you, since the distribution comes without any
      gf or pk fonts whatsoever.  The generated fonts are left on your
      system for future jobs, so as you process more and more
      documents, the probability of bumping into a missing font will
      get lower.

    - DviVGA is really a quick hack (it was not part of the original
      tex-k package).  It doesn't support any high-resolution SVGA
      modes; the magnification is fixed when you invoke the program
      and you can't change it while it runs; the text at default
      magnification is barely readable; and the user interface leaves
      a lot to be desired.  (You can change magnification by using
      the `-m' command-line option: 1000 means the default, larger
      numbers magnify.  However, note that each non-default
      magnification will cause fonts to be generated for suitable DPI
      values.)  For now, DviVGA is provided as a stop-gap for those
      who have no other way of viewing DVI files; volunteers are
      welcome to add features.

      As an alternative for viewing DVI files, consider installing a
      port of Ghostscript and GhostView for Windows that will allow
      you to view PostScript files (you can use Dvips to generate
      PostScript from DVI).

    - If your printer is not one of those for which a DVI driver is
      included in this package, install Ghostscript and pipe the
      output of `dvips' to it.  Ghostscript supports many more
      different printers beyond LaserJet and DeskJet.


III.Building the packages from sources
    ----------------------------------

    - The following tools are REQUIRED to build and install tex-k
      programs (the parentheses list filenames of binary distributions
      you can download from DJGPP archives if you don't have a
      particular package):

        Bash (bsh1147b.zip)
	Fileutils (fil316b.zip)
	Textutils (txt122b.zip)
	Grep (grep20b.zip)
	Patch (pat24b.zip)
	Sh-utils (shl112b.zip)
	Sed (sed118b.zip)
	Diffutils (dif2721b.zip)
	Findutils (find41b.zip)
	Ed (ed-02b.zip)
	Gawk (gwk303b.zip)
	Bison (bsn125b.zip)
	Flex (flx254b.zip)
	cpio (only for installing the VF fonts, see below)

      All of these are available from the v2gnu directory on the usual
      DJGPP sites.

    - tmfl72.zip and kpse30s.zip are required to build any part of the
      package.  In addition, you will need to download the sources of
      the programs you need to build (e.g., dvps566s.zip for Dvips).
      You will also need about 65M bytes of disk space to build the
      full package.

    - unzip the downloaded archives from the root of your DJGPP
      installation tree.  If you are doing this on Windows 9x, use an
      unzip program that supports long filenames.  Don't forget the
      `-d' switch if you are using PKUNZIP.

      This will create the `gnu/texk-7.0' directory and unpack the
      sources into the relevant subdirectories.  It will also create
      the `share/texmf' directory and unpack the contents of Texmflib
      library there.

    - For the port to work correctly, it needs patched versions of a
      few library functions.  The patched sources are supplied in the
      djgpp subdirectory of the kpseNNs.zip distribution.  Before
      compiling tex-k, you need to compile the *.c files in the djgpp
      subdirectory and put them into your libc.a:

		  gcc -c -O3 *.c
		  ar rvs c:/djgpp/lib/libc.a *.o

      (Change "c:/djgpp" to the correct pathname of your DJGPP
      installation.)

    - At this point, I suggest you to read the file
      `kpathsea/INSTALL.txt'.  It includes a detailed yet very
      readable description of the various options available to you at
      build and installation time.

    - Make sure your TMPDIR environment variable points to a drive
      with enough free space.  Many DJGPP installations set this
      variable to a RAM disk for performance reasons.  Since RAM disks
      tend to be small (a few Megabytes), a complex shell script may
      fill it by temporary files, typically from pipes and `command`
      expansions, after which point programs run by that shell will
      start to fail.  The tex-k build process runs some very long and
      complicated shell scripts which require around 4MB of free space
      on TMPDIR filesystem (it failed for me when I had only 2.5MB).
      If you cannot enlarge your RAM disk, point TMPDIR to a real disk
      (the effect on the overall build time is insignificant, since
      GCC will have hard time compiling some of the larger programs
      with -O2 switch).  TMPDIR is usually set on the DJGPP.ENV file,
      but you can override it by setting TMPDIR from the DOS prompt.

    - The source distribution comes pre-configured for DJGPP v2.01.
      To build, chdir to the texk-7.0 directory and issue this command
      to build the programs:

		   make

      Building the full tex-k package takes a while (about 1.5 hours
      on a 486/DX2-66, 30 minutes on a Pentium-166), so you might go
      for a cup of coffee while it compiles.  The bulk of this time is
      for building programs in `web2c' subdirectory, so if you don't
      need TeX, Metafont and related programs, I suggest you not to
      download webcNNs.zip.

      (Please note that I haven't tried to build parts of the
      distribution, I only built all of the programs at once.  So if
      you have any problems building, please report them to me.)

      The command "make" will by default build the kpathsea library,
      the LJ4 and PostScript DVI drivers (`dvilj4' and `dvips') and
      TeX, MetaFont and related programs in `web2c' directory.  If you
      need other DVI drivers, you will need to issue these additional
      commands:

        To build DVI drivers for other LaserJet printers:

		   cd dviljk
		   make all  (or e.g. "make dvilj2p" if you need a
			       driver for LaserJet 2P only)

	To build DVI drivers for DeskJet 500/550C printers and the DVI
	previewer for VGA display:

		   cd dvidjk
		   make

	To build the programs that replace MakeTeX... shell scripts
	from the original package:

		   cd kpathsea
		   make MakeTeXprogs

    - You might want to reconfigure the package, for instance if you
      want to build it with other built-in default pathnames, or if
      changes in the DJGPP library require different HAVE_XXX macros
      to be defined before you recompile.  To this end, you need to
      run the `configure' script in the texk-7.0 directory.  The
      easiest way to do that is by calling the `djgpp/configure.bat'
      batch file, which sets some environment variables and then
      invokes Bash to run the script with necessary arguments.  (You
      can edit the batch file if you want to run the script with
      different arguments.)  The command is this:

		djgpp\configure

    - It is possible to configure and build tex-k from a directory
      other than where the sources reside (useful when you cannot
      write to that directory, like if it's on a CD-ROM).  In that
      case, you need to invoke `configure.bat' with a single argument
      which is the full pathname of the source directory.  For
      example:

		f:\gnu\texk-7.0\djgpp\configure f:/gnu/texk-7.0

      Note that you MUST use Unix-style forward slashes in the
      argument you pass to `configure.bat', or else it will fail.

    - The configure script will run for a while and recursively
      configure the programs in subdirectories.

      Due to a bug in the original distribution, the file
      `web2c/c-auto.h' generated by the configuration scripts has an
      error that you will need to correct manually.  Launch your
      editor, load that file and locate the line which begins with the
      string "#define EDITOR".  You need to change this line so it
      looks like this:

	    #define EDITOR "emacs +%d %s"

      Also, edit the top-level Makefile so that DEFS includes this:

	    -DEDITOR=\"emacs +%d %s\"

      (Sorry, this bug is non-trivial to correct, but I reported it to
      Karl Berry, who maintains tex-k.)  If you would like the default
      editor to be something other than Emacs, change this line
      accordingly ("+%d" is replaced by the line number and "%s" by
      the filename).

    - After running `configure', just say "make" as explained above.

    - If you have changed some of the programs in the package, it is a
      good idea to run tests on them.  The Makefile in the web2c
      directory has a large number of xxx-check targets, where xxx is
      the name of a program; you can run these one by one by going
      into web2c and saying like so:

		 make gftopk-check

      Some of the tests appear to fail (`diff' prints some actual
      differences between the test results and the reference files
      that come with the package.  In most cases, this is normal
      behavior (the programs were changed since the canonical results
      were computed); the file `web2c/tests/check.log' includes the
      output you should see for each test.  If your results coincide
      with `check.log' (except for the version of the package that the
      programs print), you are doing fine.

    - Before installing, if you already have a previous version of
      tex-k installed, review your `texmf.cnf' configuration file (in
      %TEXMF%/web2c directory).  If you have changed it from the
      original, you might want the installation process to leave it
      alone and not overwrite it with the fresh copy from the
      distribution.  In that case, edit `texmf.cnf' and remove the
      word "original" from its first line.  This tells the
      installation process to refrain from replacing that file.

      Note that `texmf.cnf' file distributed with the binary packages
      was edited to make it suitable for DJGPP, but the word
      "original" was NOT removed from it!

    - To install the programs, say "make install" in the top
      directory.  This will create missing directories and copy the
      programs and auxiliary files to their places.  If you run "make"
      without reconfiguring the package, the "install" targets assume
      that DJGPP is rooted at C:\DJGPP and put everything there; you
      can then move the files to their proper places, like so:

		    cp -Rp c:/djgpp/* d:/gnu/djdir
		    rm -rf c:/djgpp

      (This assumes that DJGPP is actually installed in D:\GNU\DJDIR;
      if not, change the last `cp' argument as appropriate.)

      If you have built additional programs (like the `dvivga'
      previewer), you will need to install them manually, since the
      default "install" targets won't install them.

      You might want to install the ``virtual fonts'' so you will be
      able to use the built-in LJ4 fonts with `dvilj4'.  See the file
      `dviljk/README.fonts' for details.  Note that these fonts can be
      only used if you print with the `dvihp.exe' program or `dvihp'
      shell script, and only with LJ4 (or better) printers.  Type
      "make install-fonts" to install these fonts (you will need a
      port of `cpio' program for this to work).

IV. Troubleshooting
    ---------------

    I do NOT intend here to replace the various chapters in the docs
    which explain how to solve problems and report bugs.  Please read
    the docs whenever you see any seemingly abnormal behavior.  What's
    below is intended to mention a few DOS- and DJGPP-specific
    problems that you might see, and how to get around them.

    First, a word of warning.  Tex-k is a tremendously large and
    complex package, with dozens of different programs, some of them
    with many different options.  While porting it, I've made a good-
    faith effort to test everything I could, including using it to
    generate printed versions of various TeX and Texinfo documents.
    However, since this is the first DJGPP port, some bugs must be
    still there.  The operation of the programs on Windows 9x is
    almost untested, so some LFN-related problems might lurk.  Please
    treat this port accordingly and report possible bugs to the DJGPP
    news group (comp.os.msdos.djgpp) first.

    One possible problem you could see is due to insufficient number
    of available file handles.  `Dvilj' is particularly prone to this
    problem.  If you ever see an error message to the effect that a
    program has no more handles, edit your CONFIG.SYS and enlarge the
    FILES= setting there.

    Another related problem manifests itself by an error message like
    so:

        c:\djgpp\bin/mf.exe: cannot open

    This usually happen when a DVI driver finds a missing font and
    invokes the MetFont program to generate them on the fly.  Due to
    peculiarities of file handles inheritance from parent to child
    processes, the child process can sometimes fail to start because
    the stub cannot open the .exe file.  I think I've fixed these
    problems, so you shouldn't see such messages, but if you do,
    please report the details.

    If the font-creation fails, a file named `missfont.log' is created
    in the current directory, with the commands you should issue to
    make these fonts.  Many times, invoking that file as a batch file
    will create the missing fonts, so you could then invoke the DVI
    driver again and it will work.
