## C.3. Building ksh

Building any of the packages from source code is pretty straightforward. The full details, with a FAQ and notes, are given on the AT&T web site. Here is a walk-through of the steps. We show the steps for the ast-open package, but they're identical for the other source code packages.

1. Make sure you have a C compiler for your system. An ANSI/ISO C compiler is preferred, but a K&R compiler will work too. Getting a C compiler if you don't have one is beyond the scope of this book; contact your local system administrator.

2. Download the package(s) you wish to build into an otherwise empty directory. Here, we build the ast-open package from October 31, 2001:

   >     $ ls
   >     INIT.2001-10-31.tgz  ast-open.2001-10-31.tgz

3. Make the directory lib/package/tgz and move the files there:

   >     $ mkdir lib lib/package lib/package/tgz
   >     $ mv *.tgz lib/package/tgz

4. Extract the INIT package manually:

   >     $ gzip -d < lib/package/tgz/INIT.2001-10-31.tgz | tar -xvpf -
   >     \r\v\vNOTICE -- LICENSED SOFTWARE -- SEE README FOR DETAILS\r\v\v
   >     README
   >     src/Makefile
   >     src/cmd/Makefile
   >     src/lib/Makefile
   >     ...

   If you don't have gzip, use the ratz program, as described earlier.

5. Initialize the list of available packages:

   >     $ bin/package read
   >     \r\v\vNOTICE -- LICENSED SOFTWARE -- SEE README FOR DETAILS\r\v\v
   >     README
   >     src/Makefile
   >     src/cmd/Makefile
   >     src/lib/Makefile
   >     src/Mamfile
   >     ...

6. Start the compilation. This step is quite verbose and will take a while. Exactly how long depends upon the speed of your system and compiler, and upon which package you are building:

   >     $ bin/package make
   >     package: initialize the /home/arnold/ast-open/arch/linux.i386 view
   >     package: update /home/arnold/ast-open/arch/linux.i386/bin/proto
   >     package: update /home/arnold/ast-open/arch/linux.i386/bin/mamake
   >     package: update /home/arnold/ast-open/arch/linux.i386/bin/ratz
   >     package: update /home/arnold/ast-open/arch/linux.i386/bin/release
   >     ...

7. Install the created files. This can be done with the command `bin/package install` `directory` where directory is the location to place things in.

   Alternatively, if all you're interested in is the ksh binary, you can just copy it. The compiled binary will be in a directory named arch/ARCH/bin, where ARCH represents your architecture, such as linux.i386:

   >     cp arch/linux.i386/bin/ksh $HOME/bin/ksh93

8. Enjoy!

Copyright © 2003 O'Reilly & Associates. All rights reserved.