IMAKE(1)
β¨ IMAKE(1) β¨
okay so bestie, let me tell you about imake β it's literally the C preprocessor interface to the make utility and it's giving iconic build system energy π
πΈ SYNOPSIS πΈ
imake [ -Ddefine ] [ -Idir ] [ -Udefine ] [ -Ttemplate ] [ -f filename ]
[ -C filename ] [ -s filename ] [ -e ] [ -v ]
π¦ DESCRIPTION π¦
So imake generates Makefiles from a template, a set of cpp macro functions, and a per-directory input file called an Imakefile. It's literally the moment when you can keep all your machine dependencies β compiler options, alternate command names, special make rules β completely separate from the descriptions of the various items to be built. no cap, it's a whole vibe π
π OPTIONS π
The following command line options may be passed to imake:
-Ddefineβ This one gets passed directly to cpp, bestie. It's typically used to set directory-specific variables. For example, the X Window System used this flag to setTOPDIRto the name of the directory containing the top of the core distribution andCURDIRto the name of the current directory, relative to the top. slay π-Idirectoryβ Also passed directly to cpp. It's typically used to indicate the directory in which the imake template and configuration files may be found. it's giving "where my files at" energy π₯-Udefineβ Passed directly to cpp too. It's typically used to unset variables when debugging imake configuration files. not me using this to debug my entire life π-Ttemplateβ This option specifies the name of the master template file (which is usually located in the directory specified with-I) used by cpp. The default isImake.tmpl. the way this is the blueprint of the whole operation π-f filenameβ Specifies the name of the per-directory input file. The default isImakefile. periodt.-C filenameβ Specifies the name of the.cfile that is constructed in the current directory. The default isImakefile.c. lowkey important for the cpp vibes π-s filenameβ Specifies the name of the make description file to be generated but make should not be invoked. If the filename is a dash (-), the output is written to stdout. The default is to generate, but not execute, aMakefile. so you get the Makefile but make doesn't run it β it's giving "look but don't touch" π«Ά-eβ This option indicates that imake should execute the generated Makefile. The default is to leave this to the user. so like,-esays "go ahead bestie, run it" β¨-vβ This option indicates that imake should print the cpp command line that it's using to generate the Makefile. for the girlies who need to see the receipts π
π§ HOW IT WORKS π§
Okay so here's the tea, bestie. imake invokes cpp with any -I or -D flags passed on the command line and passes the name of a file containing the following 3 lines:
#define IMAKE_TEMPLATE "Imake.tmpl"
#define INCLUDE_IMAKEFILE <Imakefile>
#include IMAKE_TEMPLATE
where Imake.tmpl and Imakefile may be overridden by the -T and -f command options, respectively. it's giving customization energy π
The IMAKE_TEMPLATE typically reads in a file containing machine-dependent parameters (specified as cpp symbols), a site-specific parameters file, a file defining variables, a file containing cpp macro functions for generating make rules, and finally the Imakefile (specified by INCLUDE_IMAKEFILE) in the current directory. The Imakefile uses the macro functions to indicate what targets should be built β imake takes care of generating the appropriate rules. it's literally the main character of build systems π
Imake configuration files contain two types of variables: imake variables and make variables. The imake variables are interpreted by cpp when imake is run β by convention they are mixed case. The make variables are written into the Makefile for later interpretation by make β by convention make variables are upper case. iykyk π
The rules file (usually named Imake.rules in the configuration directory) contains a variety of cpp macro functions that are configured according to the current platform. Imake replaces any occurrences of the string @@ with a newline to allow macros that generate more than one line of make rules. For example, the macro:
#define program_target(program, objlist) @@\
program: objlist @@\
$(CC) -o $@ objlist $(LDFLAGS)
when called with program_target(foo, foo1.o foo2.o) will expand to:
foo: foo1.o foo2.o
$(CC) -o $@ foo1.o foo2.o $(LDFLAGS)
see how that works? it's giving transformation β¨
Imake also replaces any occurrences of the word XCOMM with the character # to permit placing comments in the Makefile without causing "invalid directive" errors from the preprocessor. so you can have your comments and not break stuff too π
Some complex imake macros require generated make variables local to each invocation of the macro, often because their value depends on parameters passed to the macro. Such variables can be created by using an imake variable of the form XVARdefn, where n is a single digit. A unique make variable will be substituted. Later occurrences of the variable XVARusen will be replaced by the variable created by the corresponding XVARdefn. it's giving variable inception, bestie π€―
β οΈ On systems whose cpp reduces multiple tabs and spaces to a single space, imake attempts to put back any necessary tabs (make is very picky about the difference between tabs and spaces). For this reason, colons (:) in command lines must be preceded by a backslash (\). no cap, this is important β make will literally throw a fit if you don't do this π
π USE WITH THE X WINDOW SYSTEM π
The X Window System used imake extensively up through the X11R6.9 release, for both full builds within the source tree and external software. X has since moved to GNU autoconf and automake for its build system in X11R7.0 and later releases, but still maintains imake for building existing external software programs that have not yet converted. it's giving "still iconic even after the glow-up" π
As mentioned above, two special variables, TOPDIR and CURDIR, are set to make referencing files using relative path names easier. For example, the following command is generated automatically to build the Makefile in the directory lib/X/ (relative to the top of the sources):
% ../.././config/imake -I../.././config \
-DTOPDIR=../../. -DCURDIR=./lib/X
When building X programs outside the source tree, a special symbol UseInstalled is defined and TOPDIR and CURDIR are omitted. If the configuration files have been properly installed, the script xmkmf(1) may be used. slay π¦
π INPUT FILES π
Here is a summary of the files read by imake as used by X. The indentation shows what files include what other files:
Imake.tmpl generic variables
site.def site-specific, BeforeVendorCF defined
*.cf machine-specific
*Lib.rules shared library rules
site.def site-specific, AfterVendorCF defined
Imake.rules rules
Project.tmpl X-specific variables
*Lib.tmpl shared library variables
Imakefile
Library.tmpl library rules
Server.tmpl server rules
Threads.tmpl multi-threaded rules
Note that site.def gets included twice β once before the *.cf file and once after. Although most site customizations should be specified after the *.cf file, some, such as the choice of compiler, need to be specified before, because other variable settings may depend on them. it's giving "order matters" energy π
The first time site.def is included, the variable BeforeVendorCF is defined, and the second time, the variable AfterVendorCF is defined. All code in site.def should be inside an #ifdef for one of these symbols. no cap, this is critical bestie π
πΈ ENVIRONMENT VARIABLES πΈ
The following environment variables may be set, however their use is not recommended as they introduce dependencies that are not readily apparent when imake is run:
IMAKEINCLUDEβ If defined, this specifies a-Iinclude argument to pass to the C preprocessor. E.g.,-I/usr/X11/config. lowkey useful but also lowkey chaotic πIMAKECPPβ If defined, this should be a valid path to a preprocessor program. E.g.,/usr/local/cpp. By default,imakewill usecc -Eor/usr/bin/cpp, depending on the OS specific configuration. it's giving "pick your fighter" energy βIMAKEMAKEβ If defined, this should be a valid path to a make program, such as/usr/local/make. By default,imakewill use whatever make program is found usingexecvp(3). This variable is only used if the-eoption is specified. so like, only relevant when you're actually running the thing π
π FILES π
Imakefile.cβ temporary input file for cpp/tmp/Imf.XXXXXXβ temporary Makefile for-s/tmp/IIf.XXXXXXβ temporary Imakefile if specified Imakefile uses#comments/usr/bin/cppβ default C preprocessor
π₯ SEE ALSO π₯
cpp(1),make(1),xmkmf(1)- Paul DuBois β imake-Related Software and Documentation, http://www.snake.net/software/imake-stuff/
- Paul DuBois β Software Portability with imake, Second Edition, O'Reilly & Associates, 1996.
- S. I. Feldman β Make β A Program for Maintaining Computer Programs
π«Ά AUTHORS π«Ά
Todd Brunhoff, Tektronix and MIT Project Athena; Jim Fulton, MIT X Consortium
okay bestie, that's literally the whole thing π this page is from imake 1.0.11 dated 2009-06-22 β it's giving vintage but still relevant energy, and honestly? we love to see it. go forth and generate those Makefiles, you absolute icon πβ¨
π¦ where this page comes from
- alpine 3.24: imake-doc 1.0.11-r0 Β· custom
- arch rolling: imake 1.0.11-1 Β· MIT-open-group AND HPND
- Copyright (c) 1993, 1994, 1998 The Open Group
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms