3. Install the Packages

3.1. Install OpenJade

3.1.1. openjade

Here is what to do, but remember to read the files that come with OpenJade to see if there are any things you want to do special for your platform:
		cd /usr/local
		tar -xvzf ~/openjade-1.3.tar.gz
		cd openjade-1.3
		./configure --prefix=/usr/local/openjade-1.3
		make
		make install
		-- once installed, the objects etc can be deleted
		make clean
	
The installation puts libraries in /usr/local/openjade-1.3/lib, so you might like to add it to /etc/ld.so.conf and run ldconfig. Add /usr/local/openjade-1.3/bin to your $PATH.

3.1.2. jadetex & pdfjadetex

As mentioned, jadetex and pdfjadetex are TeX macros that are packaged with OpenJade. They can be found in /usr/local/openjade-3.1/dsssl. A handy guide to installing these macros was prepared by Frank Atanassow Christoph and can be found at:

ftp://ftp.dante.de/tex-archive/macros/jadetex/install.pdf

http://www.comptechnews.com/~reaster/installjadetex.pdf

The following, is based on the instructions in install.pdf:

3.1.2.1. Create hugelatex (if needed)

The jadetex and pdfjadetex tex macros require more memory than a regular run of tex. The default tex memory limit configuration is often too limited. The tex configuration file, texmf.cnf, can be edited and variables which limit tex's memory use can be increased. But rather than just editing the texmf.cnf file to allow tex in all instances to have more memory, a custom tex context can be created, called hugelatex. If hugelatex is already configured on your system, you can skip this subsection (which hugelatex).

Verify that a working TeX is installed and find its directory:
		bash-2.04$ which tex
		/usr/share/texmf/bin/tex
		bash-2.04$ kpsewhich -expand-var='$TEXMFMAIN'
		/usr/share/texmf
		bash-2.04$
	

Using which should find the location of the tex program. If its not found, then you might need to install teTeX then return here. kpsewhich is a utility that comes with teTeX and finds the main tex directory if all goes well.

Now that the texmf directory is known, installation can begin:
		cd /usr/share/texmf
		cd tex/latex
		cp -r config config-temp
		cd config-temp
		tex -ini -progname=hugelatex tex.ini
		mv latex.fmt hugelatex.fmt
		mv hugelatex.fmt /usr/share/texmf/web2c
		cd ..
		rm -r config-temp
		cd /usr/share/texmf/bin
		ln -s tex hugelatex
		cd /usr/share/texmf/web2c
	
The web2c directory contains the texmf.cnf configuration file. Make a backup of this file: cp texmf.cnf texmf.cnf.orig. Edit the file using whatever editor you like, and add the following lines at the end:
		% hugelatex settings
		extra_mem_top.hugelatex = 8000000
		extra_mem_bot.hugelatex = 8000000
		hash_extra.hugelatex = 15000
		pool_size.hugelatex = 5000000
		string_vacancies.hugelatex = 45000
		max_strings.hugelatex = 55000
		pool_free.hugelatex = 47500
		nest_size.hugelatex = 500
		param_size.hugelatex = 1500
		save_size.hugelatex = 5000
		stack_size.hugelatex = 15000

		% jadetex
		extra_mem_top.jadetex = 8000000
		extra_mem_bot.jadetex = 8000000
		hash_extra.jadetex = 20000
		pool_size.jadetex = 5000000
		string_vacancies.jadetex = 45000
		max_strings.jadetex = 55000
		pool_free.jadetex = 47500
		nest_size.jadetex = 500
		param_size.jadetex = 1500
		save_size.jadetex = 5000
		stack_size.jadetex = 15000

		% pdfjadetex
		extra_mem_top.pdfjadetex = 8000000
		extra_mem_bot.pdfjadetex = 8000000
		hash_extra.pdfjadetex = 20000
		pool_size.pdfjadetex = 5000000
		string_vacancies.pdfjadetex = 45000
		max_strings.pdfjadetex = 55000
		pool_free.pdfjadetex = 47500
		nest_size.pdfjadetex = 500
		param_size.pdfjadetex = 1500
		save_size.pdfjadetex = 5000
		stack_size.pdfjadetex = 15000
	
Here, we've gone ahead and added entries for jadetex and pdfjadetex, which we'll be setting up below. You can play with these memory settings any way you like if you experience trouble with them.

After setting up hugelatex, like above, it may not work until the texhash program is called:
		root@comptechnews:~# texhash
		texhash: Updating /usr/share/texmf/ls-R...
		texhash: Updating /var/cache/fonts/ls-R...
		texhash: Done.
		root@comptechnews:~#
	

3.1.2.2. jadetex & pdfjadetex

Setting up jadetex and pdfjadetex is similar to hugelatex.
		cd /usr/local/openjade-1.3/dsssl
		make -f Makefile.jadetex install
		-- make creates and installs the .fmt
		-- files to /usr/share/texmf/web2c
		-- now create symlinks ...
		cd /usr/share/texmf/bin
		ln -s tex jadetex
		ln -s tex pdfjadetex
		-- finally, run texhash
		texhash
	
This Makefile uses hugelatex, so hugelatex must have been setup already. When tex is run as hugelatex, jadetex, or pdfjadetex, is gets it's program name (context) from argv[0] in the environment. Then, it scans texmf.cnf, and uses any context-specific settings it finds. The format (.fmt) files in /usr/share/texmf/web2c are also loaded based on the context.

Jadetex takes a tex file generated from openjade, and outputs a dvi. pdfjadetex takes a tex file generated from openjade, and outputs a pdf. The dvips program takes the dvi and outputs a postscript ps file.

3.2. DocBook SGML DTD

3.2.1. Unpack the DocBook SGML DTD

The DocBook DTD is just some sgml text files, so there is nothing to compile. Just unzip them somewhere:
		-- DocBook DTD V4.1 in
		-- /usr/local/share/sgml/docbook/4.1
		cd /usr/local/share
		mkdir sgml; cd sgml
		mkdir docbook; cd docbook
		mkdir 4.1; cd 4.1
		unzip -a ~/docbk41.zip
	
If you install doctools-1.2 from the XFree86 distribution, it will put some older versions of DocBook DTD, like 2.4.1/ and 3.0/ in subdirectories of docbook.

There are some differences between the different versions of the DocBook DTD. The xxissues.txt files document those issues. Tags have been added, removed, and renamed between the versions.

If you need to use DocBook DTD V3.1, it is available from the same place where V4.1 is downloaded. V3.1 is used a lot, so its a good idea to get it and install it in a 3.1/ subdirectory.

3.2.2. Unpack the ISO8879 Entities

For each DocBook DTD version unpacked, go into its directory and unpack the iso8879-entities.tar.gz file:
		cd /usr/local/share/sgml/docbook/4.1
		tar -xvzf ~/iso8879-entities.tar.gz
	
In each DocBook directory, there should be a docbook.cat file or a catalog file, or both. If both are present, they are likely to be identical. If only docbook.cat is present, go ahead and make a symlink:
		-- if needed
		cd /usr/local/share/sgml/docbook/4.1
		ln -s docbook.cat catalog
	

3.3. DocBook DSSSL

Installation of the DocBook DSSSL, which works for all versions of DocBook, is just a matter of unzipping it somwhere.
		cd /usr/local/share/sgml
		mkdir dsssl; cd dsssl
		unzip -a ~/db160.zip

		-- if you downloaded the ldp.dsl stylesheet
		-- customization, copy it to
		cd docbook
		cp ~/ldp.dsl html
		cp ~/ldp.dsl print
		-- copy into both directories
	
That's all there is to installing the DSSSL, except for the setup of the $SGML_CATALOG_PATH discussed later. Don't forget to straighten out the file modes and owner/group of these unpacked files - often they are scrambled and inappropriate.

3.4. sgmltools-lite

If you like it, you can install the sgmltools-lite, but it is optional. It's installation is the standard:
		cd /usr/src
		tar -xvzf ~/sgmltools-lite-3.0.2.tar.gz
		cd sgmltools-lite-3.0.2
		./configure
		make install
	
This installs the sgmltools python script to /usr/local/bin. Note that it uses python, so if you don't have it, then this package is useless.

One tweak that has to be done to make the sgmltools script work, is you have have to edit it and set the path to openjade: vi `which sgmltools`. Consult it's docs to learn more about it.

3.5. htmldoc

Preferrably you downloaded a binary distribution of htmldoc for your platform. The installation is straightforward: just unpack it and run the setup. Read the docs in the package for more info.

If you downloaded the source, installation is autoconf style. Just run the configure script, make, make install. If all goes well, it will install in /usr/bin.

When generating pdf and ps files from html using htmldoc, it is desireable to suppress generation of the header-navigation and footer-navigation links that are at the top and bottom of every html page. These navigation features look ugly in this case. To suppress them, a custom dsl stylesheet file is used.

The stylesheet below also directs openjade to output everything as one chunck of data to standard out. This output is piped to htmldoc.

Figure 1. htmldoc.dsl - custom DSSSL DocBook stylesheet

<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY % html "IGNORE">
<![%html;[
<!ENTITY % print "IGNORE">
<!ENTITY docbook.dsl SYSTEM "docbook.dsl" CDATA dsssl>
]]>
<!ENTITY % print "INCLUDE">
<![%print;[
<!ENTITY docbook.dsl SYSTEM "docbook.dsl" CDATA dsssl>
]]>
]>

<style-sheet>

<style-specification id="htmldoc" use="docbook">
<style-specification-body>

(declare-characteristic preserve-sdata?
  ;; this is necessary because right now jadetex does not understand
  ;; symbolic entities, whereas things work well with numeric entities.
  "UNREGISTERED::James Clark//Characteristic::preserve-sdata?"
  #f)

(define %header-navigation%
  ;; Should navigation links be added to the top of each page?
  #f)

(define %footer-navigation%
  ;; Should navigation links be added to the bottom of each page?
  #f)

(define %generate-legalnotice-link%
  ;; put the legal notice in a separate file
  #t)

(define %admon-graphics-path%
  ;; use graphics in admonitions, set their
  "../images/")

(define %admon-graphics%
  #f)

(define %funcsynopsis-decoration%
  ;; make funcsynopsis look pretty
  #t)

(define nochunks
  ;; dont make multiple files, output all to stdout
  #t)

(define %root-filename%
  ;; The filename of the root HTML document (e.g, "index").
  "index")

(define %html-ext%
  ;; Default extension for HTML output files
  ".htm")

(define %generate-article-toc%
  ;; Should a Table of Contents be produced for Articles?
  ;; If true, a Table of Contents will be generated for each 'Article'.
  #t)

(define %generate-part-toc%
  #f)

(define %generate-article-titlepage%
  #t)

(define (chunk-skip-first-element-list)
  ;; forces the Table of Contents on separate page
  '())

(define %shade-verbatim%
  #t)

(define %use-id-as-filename%
  ;; Use ID attributes as name for component HTML files?
  #f)

(define %graphic-default-extension%
  "gif")

(define %section-autolabel%
  ;; For enumerated sections (1.1, 1.1.1, 1.2, etc.)
  #t)

(define (toc-depth nd)
  ;; more depth, 2 levels, to toc, instead of flat hierarchy
  2)

</style-specification-body>
</style-specification>

<external-specification id="docbook" document="docbook.dsl">

</style-sheet>
	
This file can be downloaded at the link below:

http://www.comptechnews.com/~reaster/htmldoc.dsl

Install the file to the same place where ldp.dsl is installed: in the html/ directory of the Modular DocBook Stylesheets, which was installed at /usr/local/share/sgml/dsssl/docbook in Section 3.3 above.

3.6. DocBook2X and SGMLS.pm (sgmlspl)

3.6.1. sgmlspl

Before the spec files from DocBook2X are of any use, the SGMLS.pm module for perl5 has to be installed, assuming that perl5 is installed. The installation of this module is not as automated as most perl module installs. It uses a Makefile that has to be edited first before running make.
		cd /usr/src
		tar -xvzf ~/SGMLSpm-1.03ii.tar.gz
		cd SGMLSpm
		-- Edit Makfile
		vi Makefile
		-- In the user options of the Makefile
		-- set everything correct for
		-- your system.
		-- Example:
		--	PERL = /usr/bin/perl
		--	BINDIR = /usr/local/bin
		--	PERL5DIR = /usr/lib/perl5/site_perl
		--	MODULEDIR = ${PERL5DIR}/SGMLS
		--	SPECDIR = ${PERL5DIR}
		--	HTMLDIR= /usr/local/apache/htdocs
		make install
	
sgmlspl gets copied to /usr/local/bin.

3.6.2. docbook2X (docbook2man-spec.pl)

DocBook2X contains no program to compile or install, though it has some scripts you might want to look at, so all there is to do is unpack it somwhere.
		cd /usr/local/share/sgml
		tar -xvzf ~/docbook2X-0.6.0.tar.gz
		cd docbook2X
	
In the unpacked directory is the docbook2man-spec.pl and a patch file for it that corrects a few things. Applying the patch is optional but recommended.
		patch docbook2man-spec.pl docbook2man-spec.pl.patch
	
Later, in Using DocBook, you will see how to use sgmlspl and docbook2man-spec.pl to generate a manpage from a refentry docbook document.

3.7. $SGML_CATALOG_FILES

The $SGML_CATALOG_FILES environment variable is used by openjade (and other SGML software) to locate DTDs and DSL (stylesheets). SGML software cannot function without finding these files, which have been unpacked to various directories. Given the setup as done so far, here is how $SGML_CATALOG_FILES can be set in /etc/profile:
##########################################################################################
# SGML DocBook - openjade sgmltools-lite
JADE_HOME=/usr/local/openjade-1.3
SGML_SHARE=/usr/local/share/sgml

PATH=$PATH:$JADE_HOME/bin

# DSSSL stylesheets
#       Norm Walsh's Modular DocBook Stylesheets
SGML_CATALOG_FILES=$SGML_SHARE/dsssl/docbook/catalog
#       OpenJade stylesheets
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$JADE_HOME/dsssl/catalog
#       sgmltools-lite's stylesheets
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/stylesheets/sgmltools/sgmltools.cat

# DocBook DTD
#       From OASIS-Open.org
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/docbook/3.1/catalog
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/docbook/4.1/catalog
#       These old ones were installed with doctools-1.2 from XFree86.org
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/docbook/2.4.1/catalog
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/docbook/3.0/catalog

# sgmltools-lite catalogs for LinuxDoc
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/dtd/sgmltools/catalog

export JADE_HOME SGML_SHARE PATH SGML_CATALOG_FILES
##########################################################################################
	
Save your profile, logout and then log back in to take effect.

Installation is complete! In the next section, we'll test the installation and convert some test DocBook files.