<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN">
<article>

<title>Notes on Rebuilding XFree86/OS2 from Scratch
<author>Holger Veit
<date>Last modified 04 October 1998

<toc>

<sect>Preface
<p>
X11 and XFree86 were initially developed on Unix-based systems. Usually
Unix systems provide a rich number of tools and utilities to get certain
things done. Under OS/2, these tools are not installed, but ports are
available which are sometimes functionally equivalent to Unix utilities
with the same name, but also differ sometimes in a subtle way.
This guide will give you hints if you intend to rebuild the system
from scratch under OS/2.
<p>
Please also read <htmlurl name=README.OS2 url=OS2.html> for end-user
information, and set at least the environment variables described there.
<p>
At the current time, the most recent version available is XFree86-3.3.3.
This is a full and unrestricted version which comes with complete source 
code. 3.3.3 is not only a bugfix release, but also supports new hardware,
some of which might not even supported by OS/2 itself. See the RELEASE NOTES
document for details.

If you want to join the XFree86 developer team, e.g. to add support for
certain hardware, please send a request to BOD@XFree86.org. Please
think about such a step carefully before, though, since much work is 
involved. Please use the XFree86-3.3.3 source code as a test example how
to compile the system. The ability to manage that is a basic requirement
for becoming a developer.


<sect>Tools required
<p>

I have tried to reduce the number of external tools, but when looking back
it seems I were not very successful. At least I managed to get everything
working with the native CMD.EXE shell only. However, there is still plenty
of software required.
Most of this software is available from <tt/hobbes.nmsu.edu/ or <tt/ftp.leo.org/
via anonymous FTP. The following shopping list shows what you will need:

<itemize>
<item>gcc	EMX/gcc emx 0.9C patch4 or later
<item>gzip	GNU zip/unzip
<item>tar	GNU tar
<item>patch	Larry Wall's patch utility (attention: incompatible tool with same name in OS/2)
<item>install	BSD/GNU install
<item>rm,mv,cp	GNU file utilities
<item>tee,..	GNU shell utilities
<item>groff	GNU nroff/troff
<item>sed	GNU sed stream editor
<item>grep	GNU grep
<item>gawk	GNU awk
<item>make	GNU make 3.71/3.72 (use the one from X332prog.zip!)
<item>flex	GNU flex
<item>bison	GNU bison
<item>find	GNU find    (attention: incompatible tool with the same name in OS/2)
</itemize>

If there is no version number given, any new version will do. Particularly
critical is only EMX/gcc and GNU make. Note that the second GCC implementation
which might still be available from some archives is NOT compatible.

Furthermore, you need the XFree86 sources. These are available from 
the common XFree86 repositories. Look into a directory which is 
often named /pub/XFree86/3.3/source.

<sect>Compiling and Installing
<p>

You need about 300MB of free HPFS space for the whole system. This does not
include space for the postscript and troff documentation files. I have never
installed them. Nor did I install the test subtree.

<enum>
<item>Install all the above utilities. Refer to the corresponding documentation.
      Verify that everything works well, particularly EMX.
<item>It is a good idea to use the same or a similar structure I have.
      I have made a directory <tt>&bsol;x11</tt> on the partition for compiling and have
      put everything below this tree. I found that a clean tree occupies
      less than the half space of the disk, this gives me the opportunity to
      rename this tree to <tt>&bsol;x11old</tt> and copy a new version to the
      same disk to produce diffs. Last time the complete tree was
      arranged under the root directory <tt>xc</tt>, this would become 
      <tt>&bsol;x11&bsol;xc</tt> then.
<item>To unpack the files you would usually execute the command
      <verb>gzip -dc file.tar.gz | tar xvf -</verb> 
      in the <tt>&bsol;x11</tt> directory. At the end you will usually see the
      irritating, but non-fatal message "gzip: stdout Broken pipe". Ignore it.
<item>After that, is is likely necessary to apply some patches, either from
      the XConsortium or from the XFree86 project. Before you do this, enter
      <verb>
      chmod -R a+rw &bsol;x11&bsol;xc
      </verb> 
      to make certain files in the tree writable.
<item>There should be a file <tt>added-XXX</tt> accompanying the patch file
      which lists the files that are newly created. The patch program has
      a problem with creating new directories, so we need to create them
      on advance. For each <tt/added-XXX/ file you find, execute from
      <tt>&bsol;x11</tt> <verb>xc&bsol;config&bsol;util&bsol;added added-XXX</verb>
      If there is no <tt>added-XXX</tt> file available, you can make one with
      the following instructions:
      <verb>
      grep "&bsol;*&bsol;*&bsol;* xc/" patchfile >added-file
      </verb>
      Edit <tt/added-file/ with a text editor and remove the <tt/*** / at
      the beginning and the time stamp at the end (search for a TAB and
      erase to the end of the line). You get a list of file paths, one in a
      line, which is the input to the added utility.
<item>After that you can apply the patches in the right order. Usually this
      is done by a command
      <verb>
      patch -p -E <patchfile 2>&1 | tee patchlog
      </verb>
      from the <tt>&bsol;x11</tt> directory. Be aware to use the right
      patch - OS/2 has a utility with the same name and different functionality.
      Don't use the recommended <tt/-s/ option, this makes <tt/patch/ quiet,
      and you won't see problems in the patchlog file. Use
      <verb>
      find &bsol;x11 -name *.rej -print 
      find &bsol;x11 -name *# -print
      </verb>
      to find any rejects and unapplied patches (attention: yet another OS/2
      program with wrong functionality). Normally there shouldn't
      be any problems of this kind, else you have made a mistake. Finally
      remove the original files with
      <verb>
      find &bsol;x11 -name *.orig -print -exec rm {} ;
      </verb>
<item>Go to the <tt>xc/config/cf</tt> directory and edit the <tt>xf86site.def</tt>
      file to match your requirements (you probably don't want to compile
      all X servers). Certain changes must be set to the following values:
      <itemize>
      <item>Disable if not already done any PC98 server; PC98 (Japanese XFree86)
            does not work yet. Porters from Japan are welcome!
      <item><tt>&num;define WacomSupport            NO
            &num;define ElographicsSupport      NO</tt>
            Both options are not yet supported.
      <item>Tcl* and Tk* don't need to be set explicitly. Reasonable defaults
            are in the other config files, provided you have a complete 
            XFree86/OS2 binary tree with the tcl/tk runtime support installed.
      <item><tt>&num;define BuildDynamicLoading   NO</tt>
	    This does not work.
      </itemize>
<item>Go to the directory <tt>xc&bsol;util&bsol;compress</tt> and 
      <tt>make compress.exe</tt> there. Install the program produced 
      there in your path. I stumbled more than once on half-ported
      compress programs on OS/2 ftp servers that are defective w.r.t.
      reading and writing stdin/stdout. In some stage (font compression)
      otherwise you will get a core dump of mkfontdir, because all
      compressed fonts are corrupt.
<item>Set the environment variable <tt/X11ROOT/ to something different than
      it is; otherwise the installation process will overwrite your
      original XFree86/OS2 installation. If you have not set this variable,
      go back to the prefix section of this document: you have forgotten
      something.
<item>Copy the file <tt>xc/config/util/buildos2.cmd</tt> into the <tt/xc/
      directory. If this is a second or later attempt, you might need to
      copy the saved toplevel Makefile.os2 back to Makefile.
<item>Execute this <tt/buildos2.cmd/ command in the <tt/xc/ directory;
      it will produce a logfile <tt>buildxc.log</tt> in this directory.
<item>Go have a bucket of coffee, or better, buy new coffee - in Colombia!
      The compile will need between 2 and 20 hours, depending on your
      selections, and the horse power of your hardware.
<item>When finished, view the logfile for errors, and fix the problems if
      there are some. I have managed to compile the whole system
      flawlessly, so there is at least one configuration that works.
<item>Finally, from the <tt/xc/ dir, execute
      <verb>
      xmake install
      xmake install.man
      </verb>
<item>There are a few minor glitches in the installation:
<enum>
<item>The xdm and linkkit directories will fail in compile and installation.
      This is no problem and has no effect on the rest of the system.
<item>The imake.exe which is installed in <tt/&bsol;XFree86&bsol;bin/ is usually defective.
      The one which was built initially and installed in the root directory
      of the drive where you have the source tree is okay. So simply copy
      this <tt/&bsol;imake.exe/ to the <tt/&bsol;XFree86&bsol;bin/ directory 
      manually. Some day this might be fixed.
<item><tt/XF86Setup/ is not ported yet and won't work with the tcl/tk port
      available for XFree86/OS2. My idea was to replace this by some native
      installation tool, which I didn't find the time to do yet. Feel free
      to spend a bit of time to play with XF86Setup if you like.
</enum>
</enum>

Well, you see, this was quite easy :-)




<verb>
$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml,v 3.4.2.4 1998/10/11 12:35:56 hohndel Exp $





$XConsortium: OS2note.sgml /main/1 1996/02/24 10:08:59 kaleb $
</verb>

</article>
