-->
Page 541
How about nearly a two-megabyte difference? If you're going to build Motif clients, you'll want to use the shared libraries (usually a default) because, as you can see, you'd quickly run out of room on your hard drive.
Although I don't have enough room to discuss the User Interface Language (UIL), if you want to quickly and easily build your program's interface, you might want to learn this language, and its compiler, uil. For details on using the compiler and language, read the uil and UIL man pages. A number of the Motif demonstration programs use UIL, so you can read source code examples.
There are also many commercial graphical interface builders that enable you to draw and design your interface, test it, and then, with the click of a button, write out the Motif source code. See the Motif FAQ for more information. (Pointers for the FAQ are at the end of this chapter in the section "For More Information.")
If you're serious about learning Motif programming, you'll need to have several good books and lots of program examples. If you want a basic introduction, you can also try some on the online tutorials or peruse code examples. Try one of these sites:
You should be familiar with Todd Brunhoff's imake utility and Jim Fulton's xmkmf command if you've created or built programs for the X Window System. Like the make command, these commands help you save time, prevent errors, and organize your programming tasks by automating the building process.
imake, a C preprocessor interface to make, uses configuration files found under the /usr/X11R6/lib/X11/config directory. These files include linux.cf, lnxLib.rules, lnxLib.tmpl, lnxdoc.rules, and lnxdoc.tmpl.
Page 542
The xmkmf command, which creates a Makefile from an Imakefile, is a simple shell script that runs imake, telling it where to find the specifics about your system and which command-line parameters need to be passed to your compiler, assembler, linker, and even man-page formatter. Note that you should never run imake by itself; always use the xmkmf script instead.
Typically, after unpacking the source for an X or Motif program, you use the xmkmf command and then the make command to build your program. Another of the reasons many programmers use imake is to ensure portability. Assuming the imake file is written properly, the xmkmf command will work on nearly any UNIX system, and that includes Linux.
imake works by reading an Imakefile. In turn, the Imakefile contains directions for the cpp compiler preprocessor, whose output is then fed back into imake, which in turn, generates the Makefile for your program. The magic of imake is that it simplifies the job of creating Makefiles for every possible computer or operating system your program could be built on or run under.
For example, here's a simple Imakefile for our sample program, skeleton.c:
INCLUDES = -I. DEPLIBS = XmClientDepLibs LOCAL_LIBRARIES = XmClientLibs SRCS= skeleton.c OBJS= skeleton.o PROGRAMS = skel NormalLibraryObjectRule() MComplexProgramTarget(skeleton,$(LOCAL_LIBRARIES),$(SYSLIBS))
To use this listing, type it in your favorite text editor (such as nedit) and save the text as Imakefile. Then, use the two commands
# xmkmf # make
to build the program. This will also save you a lot of time if you use the edit-compile-run-edit cycle of programming, as you won't have to retype the compiler command line shown earlier in this chapter (# gcc -o skel skeleton.c -L/usr/X11R6/lib -lXm -lXpm -lXt -lXext -lX11).
Much of the success of Linux is a direct result of the generosity of the thousands of programmers who chose to distribute their software either for free or under the GNU Public License. Motif, as you already know, is not freeware, nor is it distributed under the GPL. As Red Hat Linux users, we're spoiled by the ability to examine program source or make changes as we see fit.
Want the source to Motif for your computer's operating system? It will cost you $17,000 at the time of this writing. If you're interested in building a distribution of Motif for Linux, you can get the price list by browsing to http://www.opengroup.org/tech/desktop/ordering/ motif.price.list.htm.
Page 543
For those of us who like source code or want to build Motif-compliant clients without paying for a distribution, there's an alternative: LessTif. This is a Motif clone, designed to be compatible with Motif 1.2. Distributed under the terms of the GNU GPL, LessTif currently builds 26 different Motif clients (probably many more by the time you read this).
You can find a copy of the current LessTif distribution for Linux at http://www.lesstif.org.
The current distribution doesn't require that you use imake or xmkmf, and it comes with shared and static libraries. If you're a real Motif hacker and you're interested in the internals of graphical interface construction and widget programming, you should read the details of how LessTif is constructed. You can get a free copy of Harold Albrecht's book, Inside LessTif, at http://www.igpm.rwth-aachen.de/~albrecht/hungry.html .
If you're interested in finding answers to common questions about Motif, read Ken Lee's Motif FAQ, which is posted regularly to the newsgroup comp.windows.x.motif. Without a doubt, this is the best source of information on getting started with Motif, but it won't replace a good book on Motif programming. You can find the FAQ on the newsgroup, or at ftp://ftp.rahul.net/pub/kenton/faqs/Motif-FAQ.
An HTML version can be found at http://www.rahul.net/kenton/faqs/Motif-FAQ.html.
For information on how to use imake, read Paul DuBois' Software Portability with imake from O'Reilly & Associates.
For Motif 1.2 programming and reference material, read Dan Heller and Paula M. Ferguson's Motif Programming Manual and Paula M. Ferguson and David Brennan's Motif Reference Manual, both from O'Reilly & Associates.
For the latest news about Motif or CDE, check The Open Group's site at http://www.opengroup.org.
For the latest information, installation, or programming errata about Red Hat's Motif distribution, see http://www.redhat.com.
For the latest binaries of LessTif, programming hints, and a list of Motif 1.2-compatible functions and Motif clients that build under the latest LessTif distribution, see http://www.lesstif.org.
For official information on Motif 1.2 from OSF, the following titles (from Prentice-Hall) might help: