Appendix C. Building ksh from Source Code

This appendix describes how to download binaries for ksh93, as well as how to download the source code for ksh93 and build a working version. You should do this if your system does not have ksh93 at all or if you need any of the features that are only available in the most recent releases.

Korn Shell Web Sites

The starting place for all things related to the Korn shell is http://www.kornshell.com, maintained by David Korn, with links grouped by the following topics:

Information

Clicking this link leads to a one-page overview on the Korn shell.

Software

Clicking this link leads to pointers to the AT&T download site (see the next section), some sample code, an online article for dtksh, and a link for tksh. These last two are described in Appendix A.

Documentation

This link leads to a page with pointers to online info, including general information, man pages for both ksh88 and ksh93, books and references on the Korn shell, and papers about the Korn shell from various conferences.

Resources

A list of links to other WWW resources for ksh and many of the other shells described in Appendix A, such as bash and dtksh.

Fun

David G. Korn, the programmer, meets KoRN, the rock group. ‘Nuff said.

What You Can Download

http://www.research.att.com/sw/download is the starting point for actually downloading the ksh software. The software is covered by an Open Source-style license. The current version of the license is at http://www.research.att.com/sw/license/ast-open.html. This license is reproduced in Appendix D. You should read and understand it first; if its terms aren’t acceptable to you, you should not download the software source code or binaries from the AT&T web site.

The software on the AT&T web site is available in different “packages,” most of which have names prefixed with “ast,” which stands for “Advanced Software Tools.” The source packages come as gziped tar files, using the .tgz file name suffix. Choose one or more of the following packages to download:

ratz

A standalone executable program for reading gziped tar files. Use this if you don’t have gzip on your system and don’t want to go to the trouble to first download and build gzip. You may download source code for this package or a binary executable for any of the architectures listed in Table C-1.

ksh

This is the fastest way to get a ksh93 executable. Versions are available for the architectures listed in Table C-1.

INIT

This package must be downloaded when building any of the following source packages. It contains the files and directory structures that the AST tools and build system rely upon.

ast-ksh

This package builds just the support infrastructure (libraries, environment test programs, etc.) for ksh and the ksh executable. It is the simplest thing to build.

ast-base

This package builds everything in the ast-ksh package and a few additional basic AST tools. In particular, it includes pax, an archiving tool that combines features from tar(1) and cpio(1), and nmake, a significantly enhanced version of the standard Unix make(1) program. It also includes the sfio (Safe Fast I/O) and ast libraries, which you can use for your own programs.

ast-open

This package builds everything in the ast-base package and many additional tools. Note particularly that tksh (see Appendix A) is included in this package.

Each of the packages (except INIT) is also available as prebuilt binaries. Table C-1 lists the available architectures for these packages. Locale translations for some locales for some of the programs are also available.

Table C-1. Supported architectures for AST programs
NameOS/Architecture
darwin.ppc

Apple’s MacOS X (a.k.a. Darwin) for the Motorola Power PC

hp.pa

Hewlett-Packard HP-UX for HP Precision Architecture

ibm.risc

IBM’s AIX for RS/6000

linux.i386

GNU/Linux on Intel 80386 and higher

linux.s390

GNU/Linux on the IBM S/390 mainframe

mvs.390

IBM’s MVS on the IBM S/390 mainframe

netbsd.i386

NetBSD on Intel 80386 and higher (see http://www.netbsd.org)

openbsd.i386

OpenBSD on Intel 80386 and higher (see http://www.openbsd.org)

osf.alpha

OSF/1 on the Compaq (nee Digital) Alpha processor

sgi.mips3

Silicon Graphics (SGI) Irix on the MIPS processor

sol.sun4

Solaris 5.4 on the Sun SPARC architecture

sol6.sun4

Solaris 5.6 on the Sun SPARC architecture

sol7.i386

Solaris 7 on Intel 80386 and higher

sol7.sun4

Solaris 7 on the Sun SPARC architecture

sol8.sun4

Solaris 8 on the Sun SPARC architecture

sun4

SunOS 4.x on the Sun SPARC architecture

unixware.i386

UnixWare (the latest official version of System V) on Intel 80386 and higher

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 -
    
    vvNOTICE -- LICENSED SOFTWARE -- SEE README FOR DETAILS
    vv
    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
    
    vvNOTICE -- LICENSED SOFTWARE -- SEE README FOR DETAILS
    vv
    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!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.172.249