-->
Page 529
by Bill Ball
Page 530
This chapter introduces you to the OSF/Motif programming libraries. You'll learn about the different versions of Motif; how to install Red Hat's Motif 2.0.1 distribution; how Motif programs, or clients, work; how to write and compile a simple Motif client; how to use the programming utilities imake and xmkmf; and how to possibly save money by using a Motif clone, LessTif.
You'll need to have the GNU gcc compiler and associated headers, libraries, and utilities installed on your system. You'll also need to have X and Motif installed on your system if you want to run any Motif clients, including mwm. You do not have to run X in order to program with Motif, although it's a lot more fun to compile, run, and see a program in action.
First of all, you should understand that unlike the XFree86 distribution of X, Motif is not free. You must pay for a distribution. There are Motif distributions for Linux on the Intel, SPARC, or Alpha platforms. If you want to build Motif clients and distribute them, you'll need to purchase a version for your computer and operating system. And if you want other people to run your clients, you can build the clients in either shared library or static versions, for people who either have or don't have Motif.
If you're on a budget, or object to having to pay for a client license for Motif, don't despair. Later in this chapter in the section "LessTifAn Alternative Motif Clone," you'll learn about LessTif, a cost-free alternative to Motif.
Motif is a toolkit of source headers, libraries, a window manager, mwm, demonstration programs, and manual pages. Originally announced in 1988, designed by the Open Software Foundation (OSF) in 1989, and now owned and updated by The Open Group, Motif provides a rich selection of tools to build cross-platform, graphical-interface applications, or clients.
The idea behind Motif is to provide the tools to build consistent, usable, and portable
programs for the X Window System. Motif provides functions and system calls to build
client interfaces with the following (and almost anything you need to craft graphical interface
programs):
Page 531
In fact, there are more than 600 man pages included with each Motif distribution, documenting its clients, function calls, libraries, and window manager. Although you can use X functions to build clients with a Motif look, why not take advantage of all the work put into Motif?
A number of vendors supply Motif for Linux. This book is about Red Hat Linux, so I'll concentrate on the Red Hat distribution. Because the object, or philosophy, of OSF/Motif is to provide cross-platform, source-code level compatibility, you should be able to develop Motif clients on your Intel Linux system that will compile and run on any other computer with a Motif distribution installed.
There are a number of distributors selling Motif for Linux besides Red Hat. Some of these include the following:
In order to make an intelligent decision regarding which version of Motif to get, you should know a little about the history and direction of the standard. In 1996, The Open Group acquired the X Window System from the X Consortium, with the aim of integrating X, Motif, and the Common Desktop Environment (CDE). CDE represents the future of Motif, according to The Open Group, and offers graphical interface improvements, support for multiuser applications, and new networking features.
The X Consortium acquired the X Window System from the MIT X Consortium in 1993 and was responsible for the last several releases, the last of which is X11R6.3. Broadway, which is the codename for the next release of the X Window System, is slated to have improvements in
Page 532
network communications to support graphics and audio for use in World Wide Web browsers. The Open Group has pledged to release Broadway under the same terms as the current X Window System.
The current version of Motif is 2.1, although the current version of CDE, which is also 2.1, uses Motif 1.2.5, which was released to support CDE (and which contains fixes made to Motif 1.2 in Motif 2.0). Confused yet? Remember that OSF's aim is to merge X, Motif, and CDE. But what does this mean to the user, and what does this mean to the programmer?
For the user, especially the Red Hat Linux user, the choice is up to you! If you want the Motif 1.2.5 libraries, a drag-and-drop, industry-standard interface, and many other improvements, then CDE is the way to go. You should know that the Motif window manager, mwm, goes away in the CDE release, replaced by new terminal managers (based on dtwm).
But for the programmer, the choice might not be as clear. According to The Open Group, although Motif 2.0 and CDE may be used together, and Motif 2.0 is binary-compatible with Motif 1.2, "All of the important Motif 2.0 developer features will be available in CDEnext Motif" (the next version of CDE, to be based on Motif 2.0). This means that The Open Group recommends that programmers use Motif 2.0 now to get the latest programming features, which are not currently in CDE 2.1.
As mentioned before, because this is Red Hat Linux Unleashed, this chapter concentrates on the specifics of Red Hat's Motif distribution. Installing Red Hat Motif 2.0.1 is easy. First, make sure that there's enough room on your hard drive. You'll need about 20 megabytes for a full installation. If you just want to run just the Motif window manager, mwm, and other Motif clients, you can save about 15 megabytes and just install the Motif libraries and mwm.
There are two ways to install Motif from the Red Hat CD-ROM, but both require you to mount the disk to a convenient directory with
# mount -t iso9660 /dev/cdrom /mnt/cdrom
You can then launch the installation script with
# ./install-motif
Another way to install the software is to use the rpm command. The Red Hat folks have assembled the Motif software into the RPM (Red Hat Package Manager) packages discussed in the following sections.
This package contains the static libraries and
#include files, or headers, needed to build Motif clients. You'll also find the Motif User Interface Language compiler,
uil, and the Motif
function-call manual pages.