Building Projects With Imake
Imake is tool for configuring the X Window System and its components for different platforms and compilers. Imake allows you to create a generic description of how your project should be built and leaves the system-specific details to centralized configuration files.
Put simply, Imake is built on the idea of applying the C preprocessor to Makefiles, rather than C programs. Much of the redundancy in common Makefiles has been turned into preprocessor macros, which have the same effect macros have in C programs—making things easier.
Imake should have come with your installation of X. If you run one of the common distributions of Linux, you need to check that some of the “development” packages are installed. For instance, I run Red Hat 4.0 on my system, and the Imake system is contained in the XFree86-devel RPM.
If you aren't sure if you have Imake installed or have it configured properly, it is easy to check. Just run these commands:
touch Imakefile xmkmf
There should now be a new file called Makefile in the current directory. There is quite a bit of “stuff” in the new Makefile, mostly generic rules and information generated from the configuration files.
If you've gotten this far, Imake is installed and configured just fine. Now, you should be able to run make and get output. For example on my Red Hat 4.2 system, I type make and get the following output:
make: Nothing to be done for 'emptyrule'.
Besides containing many programs, there are several programs that Imake depends on to function properly. However, most of them are basic things like bash, mv, rm and so on. If these basic programs are missing, you have more severe problems than whether Imake works properly. Still, there are a couple of major components that aren't vital to a working Linux system that are vital to Imake.
make isn't necessarily vital to the functioning of Imake, but the generated Makefiles are absolutely useless by themselves. If you don't have make, you should install GNU make. For more advanced uses of Imake, it is good to have a thorough understanding of how make works. At the end of this article are some references for more information on make.
Obviously, for a Makefile generation program to be useful, you need a compiler. However, that is not the only reason for having GCC installed. Imake relies on an external C preprocessor, installed in /lib/cpp by default. If you have GCC installed and configured, you should also have cpp (the C preprocessor) installed.
In case you don't have a /lib/cpp file, the simplest way to solve the problem is to make a symbolic (soft) link (use ln) from it to GCC's cpp executable. For example, on my system, /lib/cpp is a symbolic link to /usr/lib/gcc-lib/i486-linux/2.7.2/cpp.
The major user-visible component of the Imake system is the file Imakefile, in which the project-specific information needed by Imake to build your project is kept.
At a basic level Imakefile consists of rule invocations, variable definitions and variable invocations. The first, rule invocations, resemble C-function calls. The second resemble C-variable assignments. These two should be familiar to anyone who has used macros in C code. On the other hand, variable invocations are nothing like their C counterparts, but should be familiar to anyone who has done any work with plain make. Here's a simple example:
VARIABLE = value ARule(arg1,arg2,$(VARIABLE))
As with programming in general, there are many of syntax pitfalls with Imake. The following two sections describe a few of the problems to keep in mind.
Imake (actually, the underlying C preprocessor) is fairly strict about how the various rules must be invoked. First, there must be absolutely no extraneous white space around the commas between arguments. For example, this rule is incorrect:
ARule(arg1, arg2, arg3)
and this version is correct:
ARule(arg1,arg2,arg3)To confuse things even more, in some cases, it is valid for the argument to have space. For example, many rules take a list of files as one of the arguments, where each file is delimited by a space. Typically, this is fairly intuitive, and several of the examples later in this article show the most common cases.
The second problem with argument passing in Imake is empty arguments. Not all arguments are necessary for every rule, but the C preprocessor breaks if an argument is left out or has no value. To solve the problem, Imake provides the macro NullParameter to allow empty arguments in a rule. For example:
ARule(arg1,NullParameter,arg3)
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- Fun with ethtool
- Linux-Based X Terminals with XDMCP
- Readers' Choice Awards 2011
- 100% disappointed with the decision to go all digital.
- Parallel Programming with NVIDIA CUDA
- You Need A Budget
- Validate an E-Mail Address with PHP, the Right Way
- The Linux powered LAN Gaming House
- The Linux RAID-1, 4, 5 Code
- Python for Android






4 hours 11 min ago
4 hours 22 min ago
10 hours 26 min ago
13 hours 50 min ago
14 hours 57 min ago
15 hours 8 min ago
20 hours 12 min ago
20 hours 35 min ago
20 hours 37 min ago
23 hours 57 sec ago