# Installing LessTif

by The LessTif Core Team

## Introduction

This document details configuring, compiling, and installing LessTif on various platforms.

The original version of this document is written in HTML; the LessTif build process uses one of the text mode web browsers lynx or links to convert it into plain text. Both the HTML and the plain text formats should be in a distribution.

Readers that are going to install a binary version of LessTif can jump to the according section immediately. It also explains where to get the binary, i.e. pre-compiled distributions.

## Table of contents

- Building LessTif
  - Prerequisites (What you need to compile LessTif)
  - Configuring LessTif
    - LessTif from CVS
    - LessTif source distribution
    - Getting configure to find everything
    - Using configure options to tune the build
  - Compiling LessTif
  - Platform specific issues
    - Digital Unix, OSF
    - HP/UX
    - OS/2
    - Solaris
    - Windows
- Installing LessTif Binaries
  - LessTif built from source
  - Binary distributions of LessTif
  - Platform specific issues
    - FreeBSD
    - Linux
    - OS/2
  - After LessTif (Getting shared libraries to work)
- Xlt and Xbae

## Building LessTif

### Prerequisites (What you need to compile LessTif)

To build LessTif from the sources you need a number of installed software packages and utilities. You can find pointers to most of these tools on our links page. Below we also specify which versions of the auto* tools (=automake, autoconf, libtool) are required.

- an ANSI C89 (or better) development system including a suitable compiler such as gcc and a C library
- the make build tool
- automake
- autoconf
- libtool
- X Window System (X11 Release 6 or higher; R5 might still work as well)
- yacc, lex (GNU implementations are fine)

The auto* tools are not always mandatory, as well as yacc & lex. See below for details.

A large variety of systems fulfill these requirements as our (incomplete!) list of supported platforms shows. And installing the missing software shouldn't be too hard (except for the compiler and X11, of course ;-)

### Configuring LessTif

Configuration of LessTif is now handled by automake, autoconf and libtool . They are GNU development tools which the LessTif developers use to generate the distribution's build scripts and makefiles. Normally this shouldn't bother you. The end result is that there are a bunch of Makefile.in files, and a "configure" script.

If you obtained a copy of LessTif from CVS, then you need to perform some additional steps which will create the configure script and all the Makefile.in files.

configure is a shell script which is meant to be run by people who compile LessTif (you, probably). It looks at your system and figures out how exactly to compile. It may need a little help through command-line options, see below.

### LessTif from CVS

If you obtained your LessTif sources directly from CVS, you'll have to perform some of the steps which the LessTif developers normally perform when creating a distribution. (So, if you did get a real distribution you don't need to do this and you can go on to the next section.)

The following table lists the current versions of the auto* tools which we use:

Tool | Version
--- | ---
automake | 1.4, 1.4-p2 or 1.4-p5 (all intermediate versions suck)
autoconf | 2.13 (2.50 seems to work as well; but will fail for many other packages!)
libtool | 1.3.5

We have four different places where you need to run the auto* commands. These are

- $LESSTIF (the main directory)
- $LESSTIF/lib/Xlt (a directory tree containing a set of add-on widgets)
- $LESSTIF/lib/Xbae (a directory tree containing the Xbae add-on widgets)
- $LESSTIF/test (large number of tests for our libraries)

In each of these places, you need to run a few commands like described e.g. in the autoconf manual. You can find it at the automake web page.

The whole process of running the auto tools and make is now automated by the CVSMake script which is present in LessTif's top directory. Use of CVSMake is recommended! Don't bother us if you run the auto* tools in your own way and run into problems afterwards ...
Note that due to a bug in current versions of those tools you may see an error message while running CVSMake. If things run well afterwards you may ignore this, of course! (so please try to continue first!)

CVSMake needs to be run in the top source directory of LessTif, it figures out which directories need its attention (information from the configure.in), and then does its thing. After running CVSMake, the source tree should be ready for running the configure command.

The CVSMake scripts now feature some command line flags which may be useful.

- `local` - if applied to the toplevel CVSMake it won't run recurse into the non-core directories (`lib/Xbae/`, `lib/Xlt/`, `test/`)
- `nodist` - enables generation of dependencies in Makefiles. This does only work on systems which are supported by GNU automake/libtool.

Note that you may get a warning about the INSTALL file missing in some cases. Don't worry, it is now a generated file. If you have Lynx/links on your system, it'll convert doc/INSTALL.html (this document) into INSTALL. This only happens during the build process (and we're now in the configuration phase which is before the build); that's why you can get this message. By the way: it's harmless.

The commands above are also the commands that you need to run if you have modified some of the makefiles yourself.

Once you've done all the above, you can continue with the next section.

### LessTif source distribution

To configure LessTif for your system, just type 'configure'. This should do a reasonable job of locating the stuff it needs, and gives rather verbose output should something fail.

The configure script has a lot of command line options which you might need or want to use for two main reasons :

- the configure program doesn't work (well) for you
- you want to tune the LessTif build process

You can type

            configure --help

to get the list of all options, with a short description of each. We'll cover most if not all of the options in the next sections of this document.

#### Getting configure to find everything

configure identifies a large number of aspects of your computer system and it influences the compilation of LessTif based on that. autoconf and automake are tools which allow the LessTif developers to specify all of that in a fairly simple manner. Some of the things identified by configure are :

- where is the X distribution (include files, libraries)
- do you have X extension libraries like libXp, ...
- do you have ANSI C compatible include files
- do you have the lynx/links, yacc, lex programs
- what is the type of the return value of the signal system call
- ...

Two things that configure looks for on your machine are:

- X11R5/R6/R6.x headers and libraries
- Motif® headers and libraries (optional)

Now many people who have Motif® on their system don't use LessTif. Hmm. Wonder why that is. Anyway, it wouldn't make much sense if you needed Motif® in order to build LessTif. The good news is : you don't need it. The only reason why you can tell configure where to find Motif® is so it can configure the Makefiles under test/ to be capable of building LessTif as well as Motif® tests.

configure will tell you where it has found them if it found them. If it didn't find X, you'll have to specify the path on configure's command line. Use these two options:

    --x-includes
    --x-libraries

And to specify the Motif® stuff, use these:

    --with-motif-includes
    --with-motif-libraries

To specify the location of the various bits, you have to set these flags equal to something. An example on how to do this is:

    configure --x-includes=/usr/local/X11R6/include

The other flags behave identically.

### Using configure options to tune the build

As of LessTif 0.87.2 the build system is capable of building multiple LessTif libraries. The purpose of this is to have several libraries that are compatible with several releases of OSF/Motif®.

This was introduced because an increasing number of people are using Motif 2.* functions, and the binary releases of LessTif only supported the 1.2 version of Motif.

Note that the 2.x compatible parts of LessTif are still less complete as the 1.2 part when compared to the full feature/API set of OSF/Motif® 2.x.

##### Choosing which version to compile

--enable-build-12
  build Motif-1.2 compatible version (enabled by default)
--enable-build-20
  build Motif-2.0 compatible version (enabled by default)
--enable-build-21
  build Motif-2.1 compatible version

##### Choosing which version to install as default

--enable-default-12
  install Motif-1.2 compatible version as default
--enable-default-20
  install Motif-2.0 compatible version as default
--enable-default-21
  install Motif-2.1 compatible version as default

##### Other options

--enable-shared
  build shared libraries [default=yes]
--enable-static
  build static libraries [default=no]
--with-dmalloc
  use dmalloc (see dmalloc.com)
--enable-maintainer-mode
  enable make rules and dependencies not useful (and sometimes confusing) to the casual installer
--enable-debug
  build LessTif with debugging options (-g)(default)
--enable-verbose
  configure LessTif to be verbose (default)
--enable-nonstandard-conversions
  include nonstandard conversions
--enable-production
  build a production version (doesn't include `_LtDebug*()` calls which print all kinds of debugging info depending on some environment variables)
--prefix=XXX
  tell configure where LessTif should be installed by "make install"

### Compiling LessTif

After configuring LessTif, just typing 'make' should build all the libraries, clients, and (optionally) tests for LessTif. To build libraries or other things only, just cd to the directory in which you want to build things, and type 'make'. Dependencies have been set up so that the libraries will be recompiled if they are old (or haven't been compiled yet), so typing make from within a test directory will rebuild what needs to be rebuilt.

Some combinations of compilers and libraries may have code generation bugs. For example, gcc-2.7.0 on a Solaris platform has known problems if the library is compiled with an optimization greater than -O (-O1). If you see weird problems when you debug library code, try a lower (or no) optimization. For the vast majority who compile with the default flags (-g for GNU-C), this is not an issue.

### Platform specific issues

Here we collect various hints and workarounds which help in building on the specific platforms. Many are a bit outdated, since we usually try to get fixes in our configuration system to avoid such workarounds. However they may still be useful to resolve similar problems!

- Digital Unix, OSF
  Building on Digital Unix from scratch/CVS using the system's CC compiler is known to work after installing GNU flex 2.5.4 and starting configure like

      CC="cc -std1" LEX="/usr/local/bin/flex" ./configure

  Building releases (i.e. source distributions) doesn't require an installation of flex, and versions from 0.92.32 should even work without specifying the "-std1" compiler flag.
- HP/UX
  On an HP/UX system that we have access to, the commands that we used to configure LessTif are :

          CC="cc -Ae"
          export CC
          configure --disable-static

- OS/2
  If you want to build LessTif for XFree86 OS/2 you have to use OS/2 specific Makefiles since a build based on the auto*-tools/libtool is not (yet?) possible. They are available from http://homepages.tu-darmstadt.de/~st002279/os2/lesstif.html.
  Those Makefiles have only preliminary support for the "install" target, but this should be a trivial task to fix. Also they don't support building any of the supplied example programs in our test/ tree or for the Xbae/Xlt libraries. If you want to easily build some of them check out the REXX script "ble.cmd" in `scripts/OS2`.
  Further OS/2-specific problems are addressed within our FAQ.
- Solaris
  On a Sun Solaris 2.6 SPARC with the SUNWspro compiler. In order to get past an undefined _Xconst in lesstif-0.88.1/lib/Xm/AtomMgr.c, I hacked in the following lines at the front of lesstif-0.88.1/include/LTconf.h:

      	#define FUNCPROTO 1
      	#include <X11/Xfuncproto.h>

  (This might be obsolete as of recent releases of the 0.92.x series)
- Windows
  On windows using Cygwin, U/WIN or Interix, LessTif must be built as static libraries.
  Because, one of the biggest issues with X on Win32 is the moronic DLL format. Specifically - it is not possible to export data from a Win32 DLL in a form that can be used to statically initialize another global variable. Data access from a DLL requires at least one pointer indirection, and hence executable code. This is why X11R6 doesn't have DLLs for Xt/Xmu/Xaw (and Motif) on Win32.

  LessTif compiles almost out of the box under Cygwin. However you will need to install XFree86 4.x or higher from http://xfree86.cygwin.com

  For U/WIN you will need to install GCC, libtools, automake, and autoconf etc. Please check the URL ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/uwin/.

  For Interix, you will need GCC from Microsoft Interix URL. After installing GCC, download automake, autoconf and libtools, compile and install them.

## Installing LessTif Binaries

### LessTif built from source

Installing LessTif is as easy as typing 'make install' - given you managed to build it as described above!
Check out the related options for configure which control where LessTif gets installed.

### Binary distributions of LessTif

Binary versions of LessTif are built and made available as a service to people who want to use LessTif without having to compile it themselves. As we're concentrating on developing and improving LessTif itself, we consider binary releases to be a side product, which we only generate once in a while - generally at each minor release. Our release policy is detailed in release-policy.html.

Binary versions usually exist for Linux (various versions), FreeBSD and OS/2, others may be created occasionally as well.
Check out our Download page for more details.

### Platform specific issues

#### FreeBSD

Starting with the 0.80a (0.80 pre-release), the FreeBSD binary distribution is provided as a pkg_add installable file.

Pkg_add(8) is FreeBSD's installation tool.

Installation of LessTif with pkg_add creates a directory /usr/lesstif, under which all of LessTif is placed. As the file /usr/lesstif/README explains, you should put /usr/lesstif/bin in your $path, add /usr/lesstif/lib to your LD_LIBRARY_PATH or to the options of ldconfig in /etc/rc, and point your compiler to include files and libraries by adding

        -I/usr/lesstif/include -L/usr/lesstif/lib

to its command line. See also below.

#### Linux

From Matthew Simpson (matthewsimpson@home.com)

LessTif Binary Installation

The following procedure worked for installing the binary version 0.82 LessTif onto my Redhat 4.2 Linux system. I did not have a previous installation of either the source or binary LessTif, so this works from scratch. I am documenting this days later, so please correct as needed. The binary installation is simple:

1. After downloading the binary distribution, log in as root and place the file in /usr
2. gunzip it: `gunzip lesstif-0.82-linux.tar.gz`
3. untar it: `tar -xvf lesstif-0.82-linux.tar` The result will be this directory: `/usr/lesstif`
4. Remove the tar file if desired: `rm lesstif-0.82-linux.tar`
5. Edit `/etc/ld.so.conf` and add the following line for the untarred LessTif library:

       /usr/lesstif/lib

6. Run this: `ldconfig`

   LessTif Window Manager:

   To ignore your default window manager and instead load mwm, make or copy these files as yourself or root (whichever you use) to your home directory:

7. Put a .xinitrc file in your home directory. Add this to the last line, replacing the call to any other window manager:

       eval "exec /usr/lesstif/bin/mwm"

   Or for better tracking, use this line instead:

       eval "exec /usr/lesstif/bin/mwm" -debug >"$HOME"/.MWM-errors 2>&1

   (The redirections rules for `>` and `2>&1` syntax are specific to sh, which is what my startx script uses. The rules are slightly different for tcsh.) This will dump any errors to a file in your home directory called `.MWM-errors`. If no errors occur, this file will not get created. If this file already exists, new errors will be appended to it. To get a new file each time you log in or start X, add this to your `.login` or `startx` file:

       rm -f $HOME/.MWM-errors

   To automatically execute your window manager upon login, add this to the end of your .login file (this is using tcsh syntax):

       if ( ! -e /tmp/.X0-lock ) then
       echo "Starting X Windows..."
       rm -f $HOME/.MWM-errors
       startx
       endif

8. Copy this:
   `cp /usr/lesstif/lib/X11/app-defaults/Mwm .`
   This is where you set your personal app-defaults. Uncomment the lines mentioned at the end of this file to get some pretty borders. Here are some other things I changed: Double clicking an icon was set too fast. To slow it down:
   `Mwm*doubleClickTime: 1000`
   To allow automatic window focus whenever the mouse pointer hits it:
   `Mwm*keyboardFocusPolicy: pointer`
9. Copy this to your home directory:
   `cp /usr/lesstif/lib/X11/mwm/system.mwmrc .mwmrc`
   (Note that you should rename it from system.mwmrc to .mwmrc) This is where you set up your personal root menus. If you use XFree86, look in `/usr/X11R6/bin` for most of the already-installed applications you like to execute through the root window pull-down menus. More menus and sub-menus can be added as desired. Since `/usr/X11R6/bin` is in your path, you need not type the full path names into `.mwmrc`. Applications in other directories will need paths or soft links set up.

   When setting up these two files I did not have a LessTif mwm manual page available. However, if you have Unix and Motif® available at work (such as on SGI products), just do a `man mwm` and print it out for reference. Most will apply to LessTif mwm. (Even though SGI uses their own version called 4Dwm, they still provide the mwm manual pages with the IRIX 6.2 release.)

10. run `startx`

Hope this helps someone. These directions may be over simplified, but I wanted to be specific. Thanks for LessTif. I am learning M*tif but have a long way to go.

Matt Simpson

#### OS/2

The OS/2 binary distribution is provided as an InfoZip file. Put it into your `X11ROOT` directory and unzip the archive. This installs all libraries and executables (Xm.dll, Xm_20.dll, mwm.exe, ...). It puts everything in place to be used within a valid XFree86 OS/2 configuration, so you don't have to adjust anything manually.

### After LessTif (Getting shared libraries to work)

Shared library configuration differs from system to system. Here is the lowdown on getting them to work on the systems that support them.

- Linux
  There are two ways to have shared libraries available under linux:
  - Use the `LD_LIBRARY_PATH` environment variable.
  - Use `ldconfig`.
  The second option is only available to those with superuser access, so if you don't, or you specifically want to use the library that was just built (for running the tests), use the LD_LIBRARY_PATH variable.

  The `LD_LIBRARY_PATH` variable is to contain a colon separated list of paths to be searched for shared libraries. This variable is consulted before the information compiled by ldconfig, so even if you have LessTif already installed on your system you can use this variable to force the use of the newly built library.

  An example setting for `LD_LIBRARY_PATH`:

      $ LD_LIBRARY_PATH=/home/toshok/lesstif/libXm:/home/toshok/lesstif/libMrm
      $ export LD_LIBRARY_PATH

  If you have superuser access and want LessTif to be installed for system- wide use, make sure the directory to which the libraries were installed is listed in `/etc/ld.so.conf`. Then (as root) type

      ldconfig -v

  to make them available.

  If you're not sure which library is being used (either the system-wide installed one, or one you've just compiled), use the 'ldd' command. After generating an executable linked dynamically with LessTif, type `ldd <executable-name>`. This will output a list of the paths to all the shared libraries this executable depends on.

- HPUX 9
  Nothing additional needs to be done. Just make sure the linker can find the libraries when generating the executable (the -L flag).
- NetBSD/FreeBSD/OpenBSD
  Same as for Linux.

## Xlt and Xbae

The Xlt and Xbae widget sets are two widget sets that come with LessTif distributions but that aren't part of the Motif® clone.
If you first want to learn what they really are, check out the according pages for Xlt and Xbae. Then you can read on here how to build and/or install them.

### With and without LessTif

They can be built both inside a LessTif source tree or independently, e.g. on a system that has commercial Motif®. Both Xlt and Xbae are built in exactly the same way, so there's no need to make a distinction between them here.

The LessTif distribution is created such that the basic distribution (the LessTif libraries, and the standard clients) are always part of the distribution. The other parts - the tests, Xlt, and Xbae - are all optional, and they can be used without LessTif around.

What does this mean ? Well, quite simply it means you can use the Xbae widget set without having to use LessTif. Or the Xlt widget set.

Or, the other way around: if you want to use the LessTif library but have no interest in any of the three optional pieces, then you can just not install them. This is true for source distributions, binary distributions may combine one or more of the optional bits as a convenience to users who are not application developers.

### How to build them

There's no magic involved in compiling or installing Xbae or Xlt. Compilation is driven by the GNU auto* tools, as such it should be similar to the compilation of many other freely available software packages.

Our CVS repository contains only sources however, we try to avoid storing generated files in it. This means that files that can be generated by either libtool, automake, or autoconf, are not part of the CVS.

If you grab a development snapshot e.g. a copy through anonymous CVS, then you'll have to use these tools to generate some files which would normally be present in a LessTif distribution.

CVSMake makes all this a lot easier though.

### Quirks in the build

If you see something like

    libtool: link: warning: cannot determine absolute directory name of `../../../../lib/Xm/.libs'
    libtool: link: passing it literally to the linker, although it might fail

this means you've built Xbae outside of a LessTif source tree. Don't worry about it.