home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / papers / misc / config-WRPRC-X11R4 / config-X11R4.ms < prev    next >
Encoding:
Text File  |  1992-10-18  |  61.8 KB  |  2,238 lines

  1. .\" format with
  2. .\" tbl % | xroff -ms | lpr
  3. .\"
  4. .\" revision date - change whenever this file is edited
  5. .ds Rd 3 August 1990
  6. .\" document revision number - change each time document is released
  7. .ds Rn 1.03
  8. .\"
  9. .nr PO 1.2i    \" page offset 1.2 inches
  10. .nr PD .7v    \" inter-paragraph distance
  11. .\"
  12. .EH 'Imake in X11R4'- % -''
  13. .OH ''- % -'Imake in X11R4'
  14. .OF 'Revision date:\0\0\*(Rd'\s+1\*-DRAFT SCRIBBLINGS\*-\s-1'Printed:\0\0\n(dy \*(MO 19\n(yr'
  15. .EF 'Revision date:\0\0\*(Rd'\s+1\*-DRAFT SCRIBBLINGS\*-\s-1'Printed:\0\0\n(dy \*(MO 19\n(yr'
  16. .\"
  17. .\"
  18. .\" I - italic font (taken from -ms and changed)
  19. .de I
  20. .nr PQ \\n(.f
  21. .if t \&\\$3\\f2\\$1\\fP\&\\$2
  22. .if n .if \\n(.$=1 \&\\$1
  23. .if n .if \\n(.$>1 \&\\$1\c
  24. .if n .if \\n(.$>1 \&\\$2
  25. ..
  26. .\" start block.  LP gives a bit extra space. Can say .Ds .IP C, etc.
  27. .de Ds
  28. .if \\n(.$<1 .LP
  29. .if \\n(.$>=1 \\$1
  30. .if \\n(.$<2 .DS
  31. .if \\n(.$>=2 .DS \\$2 \\$3 \\$4 \\$5
  32. ..
  33. .\" end block.  If arg is given, it replaces the .LP (e.g., .De .IP).
  34. .de De
  35. .DE
  36. .if \\n(.$<1 .LP
  37. .if \\n(.$>=1 \\$1 \\$2 \\$3 \\$4 \\$5
  38. ..
  39. .TL
  40. Using Imake to Configure
  41. .br
  42. the X Window System
  43. .br
  44. Version 11, Release 4
  45. .AU
  46. Paul DuBois
  47. dubois@primate.wisc.edu
  48. .AI
  49. Wisconsin Regional Primate Research Center
  50. Document revision:\0\0\*(Rn
  51. Revision date:\0\0\*(Rd
  52. .AB
  53. The X Window System\(dg
  54. .FS \(dg
  55. X Window System is a trademark of the Massachusetts Institute of Technology.
  56. .FE
  57. is a large software project that, despite its size,
  58. is remarkable in its portability.
  59. Much of this is due to the method employed to configure the X
  60. distribution for building and installation: use of a small number of
  61. tools and isolation of machine dependencies into a small number of
  62. files that can be easily maintained and modified.
  63. This document discusses one of those tools,
  64. .I imake ,
  65. and the design of the configuration files used in conjunction with it.
  66. .AE
  67. .NH
  68. Introduction
  69. .LP
  70. This document describes how
  71. .I imake
  72. configuration files are set up in the X Window System.
  73. It is assumed that you know something about what
  74. .I imake
  75. is supposed to be used for (in general),
  76. and that you're reading this to find out something
  77. about how that is accomplished in X (in particular).
  78. The description applies to X Version 11, release 4 configuration files, which
  79. are organized quite differently than those from previous releases.
  80. .LP
  81. Other documentation (from the X11R4 distribution) that you may find useful
  82. includes:
  83. .IP \(bu
  84. Section 2 of ``X Window System, Version 11 Release 4 Release Notes,''
  85. by Jim Fulton.
  86. .IP \(bu
  87. .I mit/doc/config/usenixws/paper.ms :
  88. ``Configuration Management in the X Window System,'' also by Jim Fulton.
  89. .IP \(bu
  90. .I mit/config/README :
  91. ``X Window System Imake Configuration Guide, Release 4.''
  92. .IP \(bu
  93. .I mit/config/imake.man :
  94. manual page for
  95. .I imake .
  96. .IP \(bu
  97. .I mit/util/makedepend/mkdepend.man :
  98. manual page for
  99. .I makedepend .
  100. .IP \(bu
  101. .I contrib/doc/imake/imake.tex :
  102. ``An
  103. .I Imake
  104. Tutorial,'' by Mark Moraes.
  105. This was written between R3 and R4, but is worthwhile reading, nevertheless.
  106. .LP
  107. You should also have access to the X configuration files (in
  108. .I mit/config ).
  109. These are not really documentation as such,
  110. but it is expected that you have them at hand, for comparison
  111. against the descriptions below.
  112. .LP
  113. .I imake
  114. is generally conceded to have a pretty steep learning curve.
  115. The
  116. .I README
  117. referred to above notes that
  118. .I imake
  119. ``can be somewhat tricky to master,'' an observation attested to by
  120. many who use it.
  121. There seem to be three camps regarding
  122. .I imake ;
  123. those who think it's wonderful, those who think it's wretched, and those
  124. who suspect it might be useful (else why would it be used to configure
  125. a major publicly-available effort like X?) but are puzzled by it.
  126. The present document was written to fill in some of the gaps in the
  127. existing documentation, in order to try to swell the ranks of the first
  128. group by depleting the membership of the third.
  129. (Those who despise
  130. .I imake \*-members
  131. of the second group\*-have good reasons for doing so and the present
  132. effort is not likely to sway them.
  133. It is worth noting that the author of
  134. .I imake
  135. is in this group.)
  136. .LP
  137. Where appropriate, the current X configuration files are compared to those
  138. from previous releases to show how limitations of earlier configuration
  139. architectures have been eased.
  140. There are also occasional comments to indicate how
  141. .I imake
  142. and the X configuration files might be adapted for use in contexts
  143. other than building X.
  144. .LP
  145. This document is independent of the efforts of the MIT X Consortium.
  146. There are no doubt errors lurking within, both of understanding and of fact;
  147. they are my own.
  148. Please send corrections, criticisms and comments to the address above.
  149. .NH
  150. The tools: imake, makedepend, xmkmf
  151. .LP
  152. .I imake
  153. is a configuration tool\*-the main tool used to configure X.
  154. It is not a replacement for the
  155. .I make
  156. program, but it works
  157. in an environment that assumes the availability of
  158. .I make
  159. as the tool used to direct project building and installation.
  160. .I imake
  161. eliminates the need to write
  162. .I Makefiles
  163. directly.
  164. The name means ``include-make''\*-\fIimake\fR
  165. uses the C preprocessor
  166. .I cpp ,
  167. taking advantage of its include-file and macro-processing
  168. facilities for the purpose of generating
  169. .I Makefiles
  170. suitable for
  171. .I make .
  172. .LP
  173. For each directory in the X distribution,
  174. .I imake
  175. reads a bunch of
  176. configuration files that go to a lot of trouble to compensate for and
  177. adjust to the individual characteristics of your system.
  178. These are combined with an
  179. .I Imakefile
  180. from the current directory and the whole mess is sent through
  181. .I cpp
  182. to build a
  183. .I Makefile
  184. there.
  185. The same configuration files are used to build every
  186. .I Makefile ;
  187. they are kept together in
  188. .I mit/config ,
  189. isolating machine dependencies in one location to ease development
  190. and maintenance.
  191. In contrast, the
  192. .I Imakefile
  193. is directory-specific (it specifies the targets to be built in that directory)
  194. and is machine-independent.
  195. .LP
  196. This means that when the distribution is built on a different machine,
  197. only the configuration files need be changed.
  198. The
  199. .I Imakefiles
  200. do not need to be.
  201. If X configuration were specified directly using
  202. .I Makefiles ,
  203. this would not be true.
  204. Because
  205. the configuration information in
  206. .I Makefiles
  207. is not portable, each one would have to be edited individually\*-bad
  208. enough for a single
  209. .I Makefile ,
  210. but an overwhelming prospect for a project the size of X.
  211. .LP
  212. The value of being able to localize machine-dependent configuration
  213. information into one place should not be underestimated, particularly
  214. as X becomes more sophisticated and the number of systems on which it
  215. runs increases.
  216. The number of
  217. .I make
  218. variables used to build X has increased from approximately 60
  219. in R1 to 100 in R3 to 150 in R4.
  220. .LP
  221. Another tool,
  222. .I makedepend ,
  223. is used to generate header file dependencies for C source files in
  224. each directory after the
  225. .I Makefile
  226. has been built.
  227. Dependencies of targets upon object files can be statically listed in the
  228. .I Imakefile ,
  229. but not those for header files.
  230. Different systems organize these differently so dependencies on them
  231. must be generated dynamically.
  232. .LP
  233. While X is being built,
  234. .I imake
  235. itself is located with the configuration files in
  236. .I mit/config .
  237. .I makedepend
  238. lives in
  239. .I util/makedepend
  240. if you use the compiled version (preferred),
  241. or in
  242. .I util/scripts
  243. if you use the shell script version (slower).
  244. .LP
  245. When X is installed, copies of
  246. .I imake ,
  247. .I makedepend ,
  248. and a related tool,
  249. .I xmkmf ,
  250. are placed in a public directory, and the configuration files are
  251. copied to
  252. .I /usr/lib/X11/config .
  253. .I xmkmf
  254. is used to bootstrap a
  255. .I Makefile
  256. from an
  257. .I Imakefile
  258. using the installed configuration files,\**
  259. .FS
  260. Normally a new
  261. .I Makefile
  262. is produced with ``make Makefile'', an operation that presumes you
  263. already have a properly configured
  264. .I Makefile
  265. containing the rules necessary to run
  266. .I imake .
  267. Hence the bootstrap problem.
  268. Obviously, if you know the proper incantation to utter, you can issue
  269. the appropriate
  270. .I imake
  271. command manually, but
  272. .I xmkmf
  273. eliminates the need.
  274. Besides, the only way you'd know which wand to wave is by having a
  275. reasonable understanding of
  276. .I imake
  277. in the first place\*-in which case you wouldn't be reading this!
  278. .FE
  279. and can be used to build
  280. programs from outside of the X source tree, such as you might write
  281. yourself or get from comp.sources.x on Usenet.
  282. .LP
  283. The X configuration files make very
  284. few assumptions about the capabilities of
  285. .I make
  286. itself.
  287. Although several enhanced versions of
  288. .I make
  289. provide special features or extensions, any
  290. .I Makefile
  291. that relies on universal availability of those features
  292. will fail on systems with less-capable versions of
  293. .I make .
  294. .I Makefiles
  295. produced by
  296. .I imake
  297. in X do not use any of these constructs, so they should work with
  298. even the lowest-common-denominator
  299. .I make
  300. program.
  301. .LP
  302. Since
  303. .I imake
  304. passes its input through
  305. .I cpp ,
  306. the configuration file writer can take advantage of several features
  307. not present in plain-vanilla
  308. .I make ,
  309. such as parametrized macros (using #define), file inclusion (using
  310. #include) and conditional testing (using #if, #ifdef, #ifndef).
  311. This ameliorates many of the consequences of having to assume that such a
  312. .I make
  313. is the only one available.
  314. .LP
  315. Use of
  316. .I cpp
  317. can produce problems, too, of course.
  318. .IP (1)
  319. How to specify comments that should end up in the
  320. .I Makefile .
  321. .I make
  322. comments are introduced by a ``#'' character\*-unfortunately,
  323. .I cpp
  324. treats lines beginning with ``#'' as preprocessor directives.
  325. A comment of the form
  326. .Ds
  327. # if your system doesn't have ranlib, use /bin/true
  328. .De .IP
  329. is considered a symbol test by
  330. .I cpp
  331. and is gobbled up, while a comment like
  332. .Ds
  333. # The next rule is a workaround for a broken compiler
  334. .De .IP
  335. generates a
  336. .I cpp
  337. syntax error.
  338. To get around this, comments
  339. should be preceded by ``/**/#'' instead of just ``#''.
  340. .I cpp
  341. will strip off the ``/**/'' (the empty C comment)
  342. and won't treat the line as a directive (though it's
  343. still liable to symbol substitution).
  344. .IP
  345. The exception to this ``comment-commenting'' convention is in the
  346. .I Imakefile
  347. itself, where
  348. .I imake
  349. automatically adds ``/**/'' onto lines beginning with ``#'' that are not
  350. preprocessor directives.
  351. The reason for this is to insulate the end user of
  352. .I imake
  353. (who simply writes the
  354. .I Imakefile
  355. and not the underlying configuration files) from the need to be aware
  356. of, or abide by, the commenting convention.
  357. I would hazard a guess that many people are not aware of this
  358. exception, given the high incidence of
  359. .I Imakefiles
  360. containing ``/**/#''.
  361. .IP
  362. Comments that are to be passed through to the
  363. .I Makefile
  364. can be written as normal C comments (text surrounded by ``/*'' and ``*/'')
  365. and will deleted by
  366. .I cpp .
  367. .IP (2)
  368. The configuration files define several multiple-line macros that are
  369. intended to produce multiple lines of output.
  370. .I cpp
  371. joins multi-line macros into a single line, so some post-processing is
  372. necessary.
  373. .IP (3)
  374. Sometimes the values of
  375. .I cpp
  376. symbols are to be concatenated.
  377. The symbol names cannot be concatenated in the configuration files,
  378. because that results in a different symbol name, so they must be kept
  379. apart somehow.
  380. The empty C comment is useful here, too.
  381. For instance, if Prefix, LibName and Suffix are defined as
  382. .I lib ,
  383. .I mylib
  384. and
  385. .I .a ,
  386. respectively, to obtain the concatentation value
  387. .I libmylib.a
  388. one must write Prefix/**/LibName/**/Suffix, not PrefixLibNameSuffix.
  389. .NH
  390. Configuration file architecture
  391. .LP
  392. To produce a
  393. .I Makefile
  394. from an
  395. .I Imakefile ,
  396. the following configuration files are used:
  397. .Ds
  398. .ta 1.5i
  399. Imake.tmpl    master template
  400. \fIplatform\fR.cf    platform-specific definitions (the filename varies)
  401. site.def    site-specific definitions
  402. Project.tmpl    X-specific default definitions
  403. Imake.rules    \fIcpp\fR macros to generate \fImake\fR rules
  404. .De
  405. In general,
  406. if a port exists for your system, the only file that you should need to modify
  407. to build and install X is
  408. .I site.def .
  409. In some cases it may be necessary to modify the platform file.
  410. .I Imake.tmpl ,
  411. .I Project.tmpl
  412. and
  413. .I Imake.rules
  414. should be left alone.\**
  415. .FS
  416. It should be emphasized that ``should be left alone'' applies
  417. .I "only to building X itself" .
  418. If you are adapting the configuration files for use with another
  419. project, you will probably modify all of them somewhat.
  420. You may even find yourself in the position of having modified them to such
  421. an extent that they end up hacked to bits, incapable of configuring
  422. anything, with you left possessing only the faint hope that something useful
  423. will rise, Phoenix-like, from out of the remains.
  424. Be assured\*-it won't.
  425. But cheer up; start again and learn from your mistakes.
  426. .FE
  427. .LP
  428. If you are porting X to a new platform, you will need to write your
  429. own platform file, and modify the top part of
  430. .I Imake.tmpl
  431. slightly.
  432. If you are doing a new port of X,
  433. .I or
  434. porting the X configuration files for use with a different project, you
  435. are well-advised to study all of the configuration files thoroughly.
  436. Ignorance is not bliss in such instances.
  437. .LP
  438. .I Imake.tmpl
  439. contains an #include line for each of the other four configuration files and
  440. for the
  441. .I Imakefile
  442. in the current directory.
  443. It also contains in-line sections for global constant definitions,
  444. header block selection, description of system characteristics, build
  445. definitions, and extra
  446. .I make
  447. rules.
  448. The template is
  449. structured as follows to make everything fit together:
  450. .LP
  451. .TS
  452. box tab (%) ;
  453. l   l   s   l   l
  454. l   _   _   _   l
  455. l | l   l   s | l
  456. l | l   l   s | l
  457. l | l   _   l | l
  458. l | l | l | l | l
  459. l | l   _   l | l
  460. l | l   _   l | l
  461. l | l | l | l | l
  462. l | l   _   l | l
  463. l | l   l   l | l
  464. l | l   l   l | l
  465. l | l   _   l | l
  466. l | l | l | l | l
  467. l | l   _   l | l
  468. l | l   _   l | l
  469. l | l | l | l | l
  470. l | l   _   l | l
  471. l | l   _   l | l
  472. l | l | l | l | l
  473. l | l   _   l | l
  474. l | l   l   s | l
  475. l   _   _   _   l .
  476. \h'.01i'%Imake.tmpl:%\h'.01i'%\h'.01i'
  477. %
  478. %\h'.01i'%global constants
  479. %%header blocks
  480. %%
  481. %%#include <\fIplatform\fR.cf>
  482. %%
  483. %%
  484. %%#include <site.def>
  485. %%
  486. %%system description and
  487. %%build definitions
  488. %%
  489. %%#include <Project.tmpl>
  490. %%
  491. %%
  492. %%#include <Imake.rules>
  493. %%
  494. %%
  495. %%#include "./Imakefile"
  496. %%
  497. %%extra \fImake\fR rules
  498. %
  499. .TE
  500. .LP
  501. Before these sections of the template are described, there are some general
  502. principles that should be kept in mind.
  503. .LP
  504. Much of the flexibility of the X configuration files is achieved
  505. through the use of the following construct, which defines
  506. .I symbol
  507. only if it has not already been defined:
  508. .Ds
  509. #ifndef \fIsymbol\fR
  510. #define \fIsymbol value\fR
  511. #endif
  512. .De
  513. This construct allows any system-, build- or project-related symbol to
  514. be given a default definition if none has been supplied earlier;
  515. coupled with support for inclusion of platform- and site-specific
  516. files prior to the section in which the default is defined,
  517. the default may be overridden
  518. by a definition occurring within those files.
  519. For example, the default for the C compiler symbol occurs in the build
  520. definitions section of
  521. .I Imake.tmpl
  522. and is defined thus:
  523. .Ds
  524. #ifndef CcCmd
  525. #define CcCmd cc
  526. #endif
  527. .De
  528. If the GNU C compiler is to be used instead, the default definition
  529. can be overridden
  530. simply by putting the following in
  531. .I site.def :
  532. .Ds
  533. #ifndef CcCmd
  534. #define CcCmd gcc
  535. #endif
  536. .De
  537. Use of the #ifndef/#endif construct is pervasive throughout the X11R4
  538. configuration files, to a much greater extent than in the X11R3 files.
  539. This is especially true in the platform-specific files.
  540. .LP
  541. A fairly consistent pattern followed within the system/build section of
  542. .I Imake.tmpl
  543. and within
  544. .I Project.tmpl
  545. is that definitions for
  546. .I cpp
  547. symbols are listed first, followed by definitions for
  548. .I make
  549. variables.
  550. I presume this is done because there is greater flexibility
  551. available in defining
  552. .I cpp
  553. symbols, e.g., through #ifndef conditional testing.
  554. Since
  555. .I cpp
  556. can't tell whether a
  557. .I make
  558. variable has previously been defined, the strategy adopted is to associate a
  559. .I cpp
  560. symbol with a given
  561. .I make
  562. variable, define the symbol conditionally to allow the possibility of
  563. overriding, then equate the
  564. variable to whatever value the symbol ends up with.
  565. For instance,
  566. .I Imake.tmpl
  567. contains:
  568. .Ds
  569. #ifndef CcCmd
  570. #define CcCmd cc
  571. #endif
  572. .sp .3v
  573. \&. . .
  574. .sp .3v
  575. CC = CcCmd
  576. .De
  577. If no earlier definition of CcCmd overrides the default (e.g., in
  578. .I site.def ),
  579. CC ends up as
  580. ``cc''.
  581. On the other hand, if the default is overridden, e.g., to use ``gcc''
  582. instead, CC ends up as ``gcc''.
  583. .LP
  584. Sometimes ``mixed'' symbol definitions occur, in which
  585. .I cpp
  586. symbols are defined in terms of
  587. .I make
  588. variables.
  589. There are at least two reasons to do this.
  590. .IP (1)
  591. To avoid order-of-definition problems.
  592. Consider the two sets of definitions below.
  593. .Ds
  594. .ta 3i
  595. #ifndef a    #ifndef a
  596. #define a b    #define a ${B}
  597. #endif    #endif
  598. A = a    A = a
  599. .sp .3v
  600. \&. . .    . . .
  601. .sp .3v
  602. #ifndef b    #ifndef b
  603. #define b z    #define b z
  604. #endif    #endif
  605. B = b    B = b
  606. .De .IP
  607. What ends up in the
  608. .I Makefile
  609. is:
  610. .Ds
  611. .ta 3i
  612. A = b    A = ${B}
  613. B = z    B = z
  614. .De .IP
  615. The example on the left defines a (and hence A) in terms of
  616. a symbol that hasn't been defined yet; both get the value of a
  617. literal ``b''.
  618. The example on the right works; b is defined as ``z'', B gets
  619. the same value.
  620. A becomes ``${B}'', which is not evaluated further until
  621. .I make
  622. is run.
  623. At that time A evaluates properly to ``z'', independently of the order in
  624. which a and b are defined in the configuration file.
  625. .IP (2)
  626. To allow for greater flexibility at installation time.
  627. For example, UsrLibDir and USRLIBDIR are defined as:
  628. .Ds
  629. #ifndef UsrLibDir
  630. #define UsrLibDir $(DESTDIR)/usr/lib
  631. #endif
  632. .sp .3v
  633. \&. . .
  634. .sp .3v
  635. USRLIBDIR = UsrLibDir
  636. .De .IP
  637. Symbols such as IncRoot, BinDir, AdmDir are defined similarly, even
  638. though DestDir (to which DESTDIR is eventually equated) is defined
  639. earlier (i.e., there is no order-of-definition problem here).
  640. If a user wants the install to take place under a different root than
  641. DestDir, the command ``make DESTDIR=/alternate/root install''
  642. suffices, by overriding the definition of DESTDIR in the
  643. .I Makefile .
  644. If UsrLibDir, etc., were defined directly in terms of DestDir rather
  645. than DESTDIR, this would not be possible.\**
  646. .FS
  647. Actually, it would be possible, but cumbersome: ``make install
  648. BINDIR=/alt/bin/dir ADMDIR=/alt/adm/dir LIBDIR=/alt/lib/dir ...''
  649. .FE
  650. .LP
  651. Each of the sections of
  652. .I Imake.tmpl
  653. is described below.
  654. The descriptions only contain representative examples of the symbols
  655. used in each configuration file.
  656. For exhaustive lists, consult the appendix.
  657. .NH 2
  658. Global constant definitions
  659. .LP
  660. This section of
  661. .I Imake.tmpl
  662. defines two symbols (YES as 1 and NO as 0).
  663. References to these symbols are legion
  664. throughout the rest of the configuration
  665. specification and their values should not be changed.
  666. .LP
  667. Note: symbols #define'd in the configuration files or the
  668. .I Imakefile
  669. have nothing to do with symbols #define'd in your programs; they
  670. are entirely independent.\**
  671. .FS
  672. I once wondered about this, which seems pretty ridiculous now.
  673. .FE
  674. .NH 2
  675. Header block selection
  676. .LP
  677. The header block section of
  678. .I Imake.tmpl
  679. determines the type of machine on which
  680. .I imake
  681. is being run.
  682. This is done by looking for a
  683. .I trigger \*-a
  684. .I cpp
  685. preprocessor symbol that uniquely and unambiguously indicates a given platform.
  686. For instance,
  687. ``sun'' is defined only on Sun systems, ``apollo'' only on Apollo systems,
  688. and
  689. ``ultrix'' is only on Ultrix systems.
  690. Their header blocks look like this:
  691. .Ds
  692. .ta 3i
  693. \fBSun:\fR    \fBUltrix:\fR
  694. #ifdef sun    #ifdef ultrix
  695. #define MacroIncludeFile <sun.cf>    #define MacroIncludeFile <ultrix.cf>
  696. #define MacroFile sun.cf    #define MacroFile ultrix.cf
  697. #undef sun    #ifdef vax
  698. #define SunArchitecture    #undef vax
  699. #endif /* sun */    #define VaxArchitecture
  700.     #endif
  701. \fBApollo:\fR    #ifdef mips
  702. #ifdef apollo    #undef mips
  703. #define MacroIncludeFile <apollo.cf>    #define MipsArchitecture
  704. #define MacroFile apollo.cf    #endif
  705. #undef apollo    #undef ultrix
  706. #define ApolloArchitecture    #define UltrixArchitecture
  707. #endif /* apollo */    #endif
  708. .De
  709. The trigger symbol might be predefined by
  710. .I cpp
  711. itself; if no such predefined symbol is available,\**
  712. .FS
  713. A goal ANSI C will help us reach?
  714. .FE
  715. .I imake
  716. is built to explicitly pass a definition for one to
  717. .I cpp
  718. to cause the correct header block to be selected.
  719. .LP
  720. If no trigger is defined, a generic configuration
  721. header block is selected instead.
  722. Since that means the platform wasn't
  723. properly determined, a warning is written into the
  724. .I Makefile :
  725. .Ds
  726. # WARNING:  Imake.tmpl not configured; guessing at definitions!!!
  727. # This might mean that BOOTSTRAPCFLAGS wasn't set when building imake.
  728. .De
  729. The resulting generically-configured
  730. .I Makefile
  731. will probably fail in one of a number of strange and wondrous ways when
  732. used to try to build anything,
  733. With any luck, the hapless user will examine the
  734. .I Makefile
  735. to figure out
  736. what went wrong, see the warning, and realize that the platform wasn't
  737. determined properly.
  738. .LP
  739. Failure to find a defined trigger symbol might occur because no
  740. port exists for the machine in question, and thus no header block for
  741. it exists.
  742. (Each time X is ported to a new platform, a new header block is added
  743. to this section of
  744. .I Imake.tmpl .)
  745. Failure will also occur if
  746. .I imake
  747. was not built properly (i.e., it doesn't pass the
  748. proper trigger symbol definition to
  749. .I cpp ).
  750. .LP
  751. Assuming the proper header block is selected, several
  752. things happen inside of it.
  753. The name of the associated platform-specific
  754. .I .cf
  755. file is defined for later inclusion by the template; one or more architecture
  756. indicator symbols are defined that can be used
  757. by later configuration sections
  758. to test for particular software or hardware platforms;
  759. the trigger symbol is undefined so it won't trigger any other header
  760. block.
  761. .LP
  762. A header block may define a single architecture indicator symbol that refers
  763. both to the software and hardware,
  764. or separate indicators may be defined for an operating system that
  765. runs on multiple hardware types,
  766. For example, ``ultrix'' indicates an Ultrix system, but it is no longer
  767. true (as it once was) that a VAX can be assumed as the hardware
  768. platform\*-RISC Ultrix systems run on MIPS chips now.
  769. Thus UltrixArchitecture is defined as the software indicator symbol, and
  770. VaxArchitecture or MipsArchitecture as the hardware indicator.
  771. .LP
  772. Software indicator symbols should be unique.
  773. Hardware indicator symbols are not necessarily unique in themselves
  774. and may be shared across different software
  775. platforms, e.g., MipsArchitecture can be defined for Ultrix or SGI systems,
  776. VaxArchitecture for Ultrix or BSD systems.
  777. .LP
  778. .I Imakefiles
  779. should always test for indicator symbols rather than trigger symbols,
  780. since the former are more reliable (the latter are undefined by the
  781. header block, anyway).
  782. .LP
  783. The use of predefined or
  784. .I imake -supplied
  785. .I cpp
  786. trigger symbols is fraught with peril, and one must construct the
  787. header blocks carefully, for two reasons:
  788. .IP (1)
  789. Symbols may be ambiguous.
  790. For instance, ``vax'' can be defined both under Ultrix and under BSD.
  791. Thus, the Ultrix header block must come first.
  792. It tests for ``ultrix'' and if that succeeds, defines UltrixArchitecture
  793. and undefines ``vax'' so the BSD block will fail.
  794. .IP (2)
  795. Symbols may become ambiguous in unanticipated ways in the
  796. future.
  797. The ``mips'' symbol is an example.
  798. In R3 it was used to unambiguously detect a true MIPS machine.
  799. This can no longer be done given the presence of that symbol on other
  800. systems that also run on MIPS chips now.
  801. .LP
  802. When porting X to other platforms, it is sometimes
  803. difficult to know either what the trigger symbol should be, or what
  804. indicator symbol(s) to use.
  805. Consider MIPS machines running RISC/os.
  806. ``mips'' is insufficient as a trigger, because it is does not
  807. unambiguously define MIPS systems.
  808. The hardware indicator symbol is clear enough, MipsArchitecture, but
  809. the software indicator is less so.
  810. The name of the MIPS operating system suggests that
  811. RiscosArchitecture might be a good choice.
  812. Guess again.
  813. Acorn Computers Ltd. has an OS with a similar name, ``RISC OS''.\**
  814. .FS
  815. My own preference is to use ``mipsriscos'' as the trigger symbol,
  816. MipsArchitecture as the hardware indicator,
  817. and MipsRiscosArchitecture
  818. (which seems suitably unique, but has the disadvantage of being quite
  819. long, and uneuphonious to boot) as the software indicator.
  820. .FE
  821. .NH 2
  822. platform.cf
  823. .LP
  824. After the header block section has determined which platform-specific
  825. file to use, that file is then included by
  826. .I Imake.tmpl :
  827. .Ds
  828. /**/################################################################
  829. /**/# platform-specific configuration parameters - edit MacroFile to change
  830. #include MacroIncludeFile
  831. .De
  832. where MacroIncludeFile has been defined properly by the header block.
  833. .LP
  834. The platform file contains definitions needed to make X build and
  835. install correctly on a particular system.
  836. Some common things found here are definitions for the operating
  837. system name version numbers (major and minor), C compiler version
  838. numbers, and workarounds for missing commands.
  839. Overall, these files are really quite a hodgepodge of different things,
  840. and it is difficult to describe them in any general way.
  841. You really should read through the
  842. .I .cf
  843. file for your system before you try to compile anything, to get an
  844. idea what can be done with it.
  845. (It doesn't hurt to read
  846. .I all
  847. the
  848. .I .cf
  849. files, as a matter of fact, especially if you are doing a new port.)
  850. .LP
  851. It is important that version numbers in the platform file
  852. accurately reflect your system.
  853. Some symbol definitions are contingent upon the OS or C
  854. compiler version, to accommodate system changes, deficiencies, or
  855. bugs, so you want to make sure you get the right definitions.
  856. For example,
  857. .I sun.cf
  858. contains the following:
  859. .Ds
  860. #if OSMajorVersion <= 3
  861. #define HasVoidSignalReturn NO
  862. #else
  863. #define HasVoidSignalReturn YES
  864. #endif
  865. .De
  866. This reflects a change in the return type of the
  867. .I signal()
  868. system call (from int to void) on Sun systems beginning with SunOS 4.0.
  869. .LP
  870. A common missing command workaround occurs for those systems
  871. that have no BSD-compatible
  872. .I install
  873. command, such as in
  874. .I cray.cf :
  875. .Ds
  876. #define InstallCmd sh $(SCRIPTSRC)/install.sh
  877. .De
  878. It is important to set the value of the SystemV symbol to either YES or NO
  879. in the platform file because
  880. (1) the value of parameters defined in
  881. .I site.def
  882. may depend on it, and the default value is not set until
  883. the system/build definition section (i.e., after
  884. .I site.def );
  885. (2)
  886. the default values of many parameters in later parts of the template
  887. depend on the value of SystemV.
  888. For instance, there is usually no
  889. .I ranlib
  890. under System V, so the default is defined as a no-op:
  891. .Ds
  892. #ifndef RanlibCmd
  893. #if SystemV
  894. #define RanlibCmd /bin/true
  895. #else
  896. #define RanlibCmd ranlib
  897. #endif
  898. #endif
  899. .De
  900. It is perhaps safer to rely on predefined
  901. .I cpp
  902. symbols (should they exist)
  903. in the platform-specific files than in the header block section of
  904. .I Imake.tmpl
  905. since once you know the system type
  906. the universe of such
  907. symbols is more constrained and their meanings cannot clash with those
  908. of symbols defined on other vendors' systems.
  909. .LP
  910. The platform files were significantly reorganized between R3 and R4.
  911. In R3, each platform file was expected to contain a definition for
  912. each of the build parameters (C compiler, loader, link command,
  913. etc.).
  914. Whenever a change was made that affected one platform file, it usually
  915. affected them all.
  916. Since the definitions were usually broadly similar across platforms,
  917. this was more work than necessary.
  918. The approach adopted in R4 is to supply best-guess values as the
  919. default definitions for these parameters in the template, which
  920. individual platform files may override as necessary.
  921. This set of defaults defines a baseline configuration.
  922. There are two advantages to this method.
  923. The platform files need only specify where they
  924. .I differ
  925. from the baseline, by overriding the default definitions; and changes or
  926. additions to the baseline do not necessarily require all platform files to
  927. be changed.
  928. .NH 2
  929. site.def
  930. .LP
  931. This file contains site-specific definitions.
  932. It is used to reflect local site-wide conventions, at least in
  933. theory.
  934. Should you wish to override the defaults,
  935. this is the place to indicate installation directories, whether to
  936. build the server and example programs, any special versions of
  937. programs to use during the build, etc.
  938. .LP
  939. The name
  940. .I site.def
  941. seems, to me at least, something of a misnomer.
  942. For instance, one of the things that is likely to be set there
  943. is HasLargeTmp, to indicate whether you have a large temp file
  944. directory.
  945. .I site.def
  946. is the place for this definition (it depends on your particular
  947. file system layout, so it doesn't go in the platform-specific file,
  948. and it's not
  949. .I cpp -guessable,
  950. so it doesn't go in the system description section).
  951. But a ``site'' can be a location at which multiple hosts
  952. are administered, and which may be configured dissimilarly.
  953. Some may have a large temp directory, others may not.
  954. Similarly,
  955. .I site.def
  956. is the logical place to specify that you want to use the GNU C
  957. compiler,
  958. but you might not necessarily want to use it on all hosts at a site.
  959. In some ways
  960. .I host.def
  961. might be a better name for this file.
  962. .NH 2
  963. System description and build parameter definitions
  964. .LP
  965. The platform- and site-specific files are followed by a section containing
  966. a number of default definitions.
  967. Generally, these describe system characteristics
  968. (e.g., does it have
  969. .I vfork() ?
  970. does it have sockets?) or are related to management of the
  971. build and installation\**
  972. .FS
  973. Viz.,
  974. .I how
  975. things should be installed, not
  976. .I where ;
  977. defaults for the latter are in
  978. .I Project.tmpl .
  979. .FE
  980. processes (e.g., what is the name of the C compiler?
  981. does the loader need any special flags?).
  982. These are not X issues and so are segregated into their own section.
  983. .LP
  984. This section of
  985. .I Imake.tmpl
  986. should not be modified; definitions should be overridden
  987. in platform- or site-specific files.
  988. .NH 2
  989. Project.tmpl
  990. .LP
  991. This
  992. file contains definitions for parameters that are specific to X.
  993. Examples: whether to build debuggable versions of libraries, the
  994. screen resolution, what sorts of connections to accept (UNIX, TCP
  995. or DECnet sockets), where programs or libraries should be installed.
  996. .LP
  997. A number of the
  998. .I make
  999. variables in
  1000. .I Project.tmpl
  1001. are directory locations.
  1002. Most of them are named in one of two ways, \fIXXX\fRDIR or \fIXXX\fRSRC.
  1003. Variables of the first form are defined by equating them to the
  1004. values
  1005. .I cpp
  1006. symbols having similar names (e.g., LIBDIR=LibDir).
  1007. The
  1008. .I cpp
  1009. symbols are defined in the usual default-provided-but-override-allowed
  1010. manner.
  1011. This is because these variables refer to where things are to be placed
  1012. at installation time, something which the installer might wish to
  1013. change.
  1014. .LP
  1015. Variables of the second form, \fIXXX\fRSRC, indicate the layout of various
  1016. source directories within the X distribution.
  1017. They are not supposed to be changed, so there is no provision for
  1018. overriding them; they are simply defined
  1019. directly (e.g., SERVERSRC=$(TOP)/server), rather than being equated to
  1020. .I cpp
  1021. symbols.
  1022. .LP
  1023. .I Project.tmpl
  1024. should not be modified; definitions should be overridden
  1025. in platform- or site-specific files.
  1026. .NH 2
  1027. Imake.rules
  1028. .LP
  1029. This file contains
  1030. .I cpp
  1031. macros used to generate (sometimes quite complicated)
  1032. .I make
  1033. rules from concise descriptions of targets and dependencies.
  1034. Since all the
  1035. .I cpp
  1036. symbol substitution functionality is available, these macros can be
  1037. very powerful.
  1038. On the other hand, the syntax used to express them is somewhat
  1039. strange, in order to keep
  1040. .I cpp
  1041. from totally destroying the usefulness of the output for
  1042. .I make
  1043. purposes.
  1044. In fact, one of the functions of
  1045. .I imake
  1046. is to undo some of the damage done by
  1047. .I cpp ;
  1048. an uneasy alliance indeed.
  1049. .LP
  1050. Rules may be defined over multiple lines by appending ``\e'' to the
  1051. end of all lines but the last.
  1052. Since
  1053. .I cpp
  1054. collapses all multi-line macros into a single line, a special trick is
  1055. used to allow
  1056. .I imake
  1057. to post-process
  1058. .I cpp
  1059. output to figure out where to put the newlines back so that proper
  1060. .I make
  1061. syntax is preserved:
  1062. ``@@'' in a rule is replaced by a newline in the resulting
  1063. .I Makefile .\**
  1064. .FS
  1065. This all seems quite natural and obvious, now that I have worked
  1066. with these things for a while.
  1067. I remember, though, that the first few times I looked at the X
  1068. .I imake
  1069. rules, especially the more complicated ones,
  1070. the formatting and syntax seemed so bizarre to me that
  1071. a switch flipped in my brain, which then refused to comprehend
  1072. anything at all.
  1073. Repeated exposure gradually inured me to the infelicities of the
  1074. syntax.
  1075. .FE
  1076. .LP
  1077. .B Example:
  1078. A simple rule to compile a program might be (this isn't an actual X
  1079. rule):
  1080. .Ds
  1081. .ta .5i +4i
  1082. # define CompileProgram(program,objects,libraries)    @@\e
  1083. program: objects    @@\e
  1084.     c \-o program objects libraries
  1085. .De
  1086. If invoked in an
  1087. .I Imakefile
  1088. as:
  1089. .Ds
  1090. CompileProgram (xproga, main.o, \-lm)
  1091. .De
  1092. this would expand in the
  1093. .I Makefile
  1094. to:
  1095. .Ds
  1096. .ta .5i
  1097. xproga: main.o
  1098.     cc \-o xproga main.o \-lm
  1099. .De
  1100. If invoked as:
  1101. .Ds
  1102. CompileProgram (xprogb, main.o parse.o scan.o, \-lm \-ll \-ly)
  1103. .De
  1104. this would expand to:
  1105. .Ds
  1106. .ta .5i
  1107. xproga: main.o parse.o scan.o
  1108.     cc \-o xproga main.o parse.o scan.o \-lm \-ll \-ly
  1109. .De
  1110. .LP
  1111. All the rules in
  1112. .I Imake.rules
  1113. are defined using the standard override
  1114. construct:
  1115. .Ds
  1116. #ifndef \fIrulename\fR
  1117. #define \fIrulename\fR ...
  1118. #endif
  1119. .De
  1120. Thus, even rules are subject to being overridden (something that was
  1121. not true in R3).
  1122. If a rule needs to be overridden for a particular platform,
  1123. the default definition will be placed in the
  1124. platform-specific
  1125. file (\fIsgi.cf\fR does this).
  1126. If a rule only needs redefining in a single directory, it may be
  1127. better to undefine it and redefine right it in that directory's
  1128. .I Imakefile
  1129. (see
  1130. .I mit/config/Imakefile
  1131. for an example).
  1132. .LP
  1133. .I Imake.rules
  1134. should not be modified; definitions should be overridden
  1135. in platform- or site-specific files.
  1136. .NH 2
  1137. \&./Imakefile
  1138. .LP
  1139. The last file included by the template is the
  1140. .I Imakefile
  1141. from the current directory.
  1142. As already mentioned,
  1143. .I make
  1144. comments in this file are made
  1145. .I cpp -safe
  1146. by preceding them with ``/**/'' if necessary.
  1147. The
  1148. .I Imakefile
  1149. indicates targets to be built and installed, and their
  1150. dependencies, in terms of the
  1151. .I cpp
  1152. macros defined in
  1153. .I Imake.rules .
  1154. There may also be targets for generating dependencies, creating
  1155. installation directories, creating lint libraries or tag files, etc.
  1156. .LP
  1157. .I Imakefile -writing
  1158. is described in more detail in a later section.
  1159. .NH 2
  1160. Extra make rules
  1161. .LP
  1162. The last section of
  1163. .I Imake.tmpl
  1164. adds some common targets to the
  1165. .I Makefile ,
  1166. such as a ``Makefile'' target to regenerate the
  1167. .I Makefile
  1168. itself, and default ``tags'' and ``clean'' targets.
  1169. If the directory has subdirectories, rules to
  1170. recurse through them for the ``install'', ``install.man'', ``clean'',
  1171. ``tags'', ``Makefiles'' and ``includes'' targets are generated.
  1172. These rules are added if
  1173. IHaveSubdirs is defined and SUBDIRS is equated to the list of
  1174. subdirectories in the
  1175. .I Imakefile .
  1176. .NH
  1177. Building imake
  1178. .LP
  1179. Before you can build any part of X,
  1180. .I imake
  1181. itself must be built.
  1182. ``make World'' in the top-level X directory builds
  1183. .I imake
  1184. automatically (in
  1185. .I mit/config ).
  1186. The following discussion explains what happens during that process and
  1187. some of the things you may need to do in preparation for the ``World''
  1188. build..
  1189. You want to read this section if ``make World'' dies when you try it, or you
  1190. want to port X to another platform,
  1191. or you want to build
  1192. .I imake
  1193. or adapt the X configuration files for use with other projects.
  1194. It is best if you are willing to look at the following files:
  1195. .I Makefile.ini ;
  1196. .I imakemdep.h ;
  1197. .I ccimake.c ;
  1198. .I imake.c .
  1199. .NH 2
  1200. What you are trying to accomplish
  1201. .LP
  1202. When you build
  1203. .I imake
  1204. you want to
  1205. (1) get it to compile successfully, so you can use it;
  1206. (2) guarantee that it makes sure
  1207. .I cpp
  1208. knows the trigger symbol\*-whether
  1209. .I cpp
  1210. predefines it or not\*-so you don't end up with generically-configured
  1211. .I Makefiles .
  1212. Conspiring to keep you from your goal are three dilemmas.
  1213. .LP
  1214. Dilemma #1:
  1215. .I imake
  1216. generates
  1217. .I Makefiles
  1218. for use in compiling programs;
  1219. .I imake
  1220. is compiled using a
  1221. .I Makefile .
  1222. .LP
  1223. Dilemma #2:
  1224. .I imake
  1225. needs to know your system's trigger symbol in order to pass it along to
  1226. .I cpp
  1227. for proper
  1228. .I Makefile
  1229. generation.
  1230. But
  1231. .I imake
  1232. doesn't know the trigger itself if neither
  1233. .I cc
  1234. nor
  1235. .I cpp
  1236. predefine it.
  1237. .LP
  1238. Dilemma #3:
  1239. Some systems require special C compiler flags to ensure proper
  1240. compilation of all but the most trivial programs.
  1241. One of the facilities provided by
  1242. .I imake -generated
  1243. .I Makefiles
  1244. is that these flags can be automatically specified.
  1245. Of course, that is small consolation when the program to be compiled is
  1246. .I imake \*-which
  1247. happens to be just such a non-trivial program itself.
  1248. .LP
  1249. The solution to the first dilemma is to use a handwritten minimal file
  1250. .I Makefile.ini
  1251. instead.\**
  1252. .FS
  1253. There might be a
  1254. .I Makefile
  1255. in
  1256. .I mit/config
  1257. already,
  1258. but it might not have been generated on your system, so it's not safe to
  1259. use.
  1260. It has a bug in it, anyway.
  1261. .FE
  1262. You might need to hack
  1263. .I Makefile.ini
  1264. file slightly for your system\*-but only slightly.
  1265. If you find yourself making large changes, that is a symptom you don't
  1266. understand what you're supposed to be doing.\**
  1267. .FS
  1268. Or a symptom that I've not explained very clearly what is supposed to
  1269. happen...of course, I prefer the first possibility!
  1270. .FE
  1271. Stop and think some more first.
  1272. .LP
  1273. The second and third dilemmas are solved by manually passing the trigger symbol
  1274. to the
  1275. .I imake
  1276. compilation and using a small bootstrap program that knows what
  1277. special flags are necessary to get
  1278. .I imake
  1279. to compile without error.
  1280. The commands in
  1281. .I Makefile.ini
  1282. that build
  1283. .I imake
  1284. look something like this:\**
  1285. .FS
  1286. The commands actually use CFLAGS, which is defined
  1287. as ``CFLAGS = $(BOOTSTRAPCFLAGS) $(CDEBUGFLAGS)''; you get the idea.
  1288. .FE
  1289. .Ds
  1290. $(CC) \-o ccimake $(BOOTSTRAPCFLAGS) $(CDEBUGFLAGS) ccimake.c
  1291. $(CC) \-o imake $(BOOTSTRAPCFLAGS) $(CDEBUGFLAGS) imake.c `./ccimake`
  1292. .De
  1293. BOOTSTRAPCFLAGS is the
  1294. .I make
  1295. variable used to pass the trigger value for your system to
  1296. .I ccimake
  1297. and
  1298. .I imake
  1299. so they know the platform type.
  1300. It is typically ``BOOTSTRAPCFLAGS=\-D\fItrigger\fR''
  1301. if your
  1302. .I cpp
  1303. doesn't predefine the trigger, empty otherwise.\**
  1304. .FS
  1305. The BOOTSTRAPCFLAGS mechanism was not present in some earlier versions
  1306. of X11 (e.g., R1).
  1307. The number of systems to which X had been ported then was smaller and
  1308. apparently all of them had
  1309. .I cpp 's
  1310. that predefined a unique symbol.
  1311. .FE
  1312. .I ccimake
  1313. is the bootstrap program used to figure out any extra flags needed on
  1314. your platform to get
  1315. .I imake
  1316. to compile.
  1317. It is itself\*-by design\*-so simple that it should compile
  1318. without any special treatment.
  1319. .LP
  1320. BOOTSTRAPCFLAGS is supplied to the
  1321. .I ccimake
  1322. build so it can select the necessary extra flags by platform type.
  1323. Compiled with those flags, and the trigger value in BOOTSTRAPCFLAGS,
  1324. .I imake
  1325. builds correctly, and learns and memorizes the trigger for
  1326. itself, to pass along to
  1327. .I cpp .
  1328. That in turn allows
  1329. .I cpp
  1330. to properly determine the correct header block in
  1331. .I Imake.tmpl
  1332. when
  1333. .I Makefiles
  1334. are generated.
  1335. .NH 2
  1336. Lay the groundwork
  1337. .LP
  1338. First, you need to determine what the trigger symbol is for your system,
  1339. as well as the value of BOOTSTRAPCFLAGS.
  1340. For existing ports, you can find out the trigger symbol by
  1341. examining the header block section of
  1342. .I Imake.tmpl .
  1343. The value of BOOTSTRAPCFLAGS can be found in the platform
  1344. .I .cf
  1345. file for your system.
  1346. Look for a line that defines BootstrapCFlags; if
  1347. .I cpp
  1348. predefines the trigger, there will likely be no such line.
  1349. This means BOOTSTRAPCFLAGS is empty.\**
  1350. .FS
  1351. A complication likely to arise in the future with regard to
  1352. predefined preprocessor symbols is that ANSI C takes a dim view of
  1353. all (or almost all) such.
  1354. BOOTSTRAPCFLAGS is likely
  1355. to be non-empty on more systems as implementations of ANSI C become
  1356. distributed more widely.
  1357. .FE
  1358. Otherwise the value will be something like ``\-D\fItrigger\fR'', e.g.,
  1359. ``\-DmacII'', ``\-Datt'', ``\-Daix''.
  1360. .LP
  1361. (\fBNote:\fR
  1362. .I Imake.tmpl
  1363. contains some comments near its beginning pertaining to new ports.
  1364. These indicate that
  1365. .I imake.c ,
  1366. and
  1367. .I main.c
  1368. in the
  1369. .I makedepend
  1370. source, should be modified.
  1371. These comments are correct for R3 but evidently were not updated for R4;
  1372. in both cases the modifications should be made to
  1373. .I imakemdep.h .
  1374. Similarly, the
  1375. .I README
  1376. file refers to
  1377. .I ccflags.c ,
  1378. the R3 equivalent of
  1379. .I ccimake.c .)
  1380. .LP
  1381. For new ports, you need to invent a trigger symbol
  1382. that uniquely identifies your system and define
  1383. BOOTSTRAPCFLAGS accordingly.
  1384. Suppose you have a Brand X system.
  1385. You can use ``brandx'' as the trigger and ``BOOTSTRAPCFLAGS=\-Dbrandx''.
  1386. You also must modify
  1387. .I imakemdep.h .
  1388. This is a header file #include'd by three programs,
  1389. .I ccimake ,
  1390. .I imake
  1391. and
  1392. .I makedepend ,
  1393. and has one section for each.
  1394. .LP
  1395. The first section of
  1396. .I imakemdep.h
  1397. pertains to
  1398. .I ccimake ;
  1399. it consists of a bunch of #ifdef/#endif blocks that define
  1400. .I imake_ccflags
  1401. according to the trigger symbol.
  1402. .I imake_ccflags
  1403. is defined as the flags needed to compile
  1404. .I imake
  1405. on your platform.
  1406. For instance, if your Brand X system is System V-based, you need to
  1407. specify that:
  1408. .Ds
  1409. #ifdef brandx
  1410. #define imake_ccflags "\-DSYSV"
  1411. #endif
  1412. .De
  1413. .I ccimake
  1414. simply writes the value of
  1415. .I imake_ccflags
  1416. to its standard output.
  1417. Common flags in this definition are \-DSYSV or \-DUSG to indicate System
  1418. V or USG systems.
  1419. Other flags might also be necessary\*-see the ``hpux'' and ``umips''
  1420. blocks for some particularly unpleasant examples.
  1421. If no special flags are necessary to compile
  1422. .I imake
  1423. (e.g., under Ultrix or BSD),
  1424. there does not need to be any block for your trigger symbol, and
  1425. .I ccimake
  1426. simply writes out a default definition of
  1427. .I imake_ccflags
  1428. (currently \-O).
  1429. .LP
  1430. You might have to fool around trying to compile
  1431. .I imake
  1432. by hand to determine the correct flags before you know how to define
  1433. .I imake_ccflags .
  1434. .LP
  1435. The second section of
  1436. .I imakemdep.h
  1437. is for
  1438. .I imake .
  1439. It too has a set of #ifdef/#endif blocks, this time to select a
  1440. trigger symbol definition based on the trigger symbol.
  1441. That sounds circular and it is.
  1442. These blocks add entries to
  1443. .I cpp_argv [\|],
  1444. which is an array of strings to be passed to
  1445. .I cpp
  1446. by
  1447. .I imake .
  1448. If your
  1449. .I cpp
  1450. predefines the correct trigger symbol automatically, you don't need to
  1451. do anything to this.
  1452. Otherwise, this is where you want your trigger symbol to be listed,
  1453. and there should be a block something like this:
  1454. .Ds
  1455. #ifdef brandx
  1456.         "\-Dbrandx",        /* for Brand X systems */
  1457. #endif
  1458. .De
  1459. This causes
  1460. .I imake
  1461. to pass ``\-Dbrandx'' to
  1462. .I cpp
  1463. to make it simulate predefinition of the trigger.
  1464. When
  1465. .I cpp
  1466. reads the configuration files the trigger will have been defined and
  1467. the correct header block in
  1468. .I Imake.tmpl
  1469. will be selected.
  1470. .LP
  1471. Following the sections for
  1472. .I ccimake
  1473. and
  1474. .I imake ,
  1475. .I imakemdep.h
  1476. contains a third section for
  1477. .I makedepend
  1478. (the compiled version; if you use the shell script version of
  1479. .I makedepend
  1480. in
  1481. .I mit/util/scripts ,
  1482. this section of
  1483. .I imakemdep.h
  1484. is irrelevant).
  1485. It looks for various system- and compiler-related definitions that may
  1486. be predefined by
  1487. .I cc
  1488. and/or
  1489. .I cpp .
  1490. .I makedepend
  1491. uses this information to be smart.
  1492. Consider the following C program fragment:
  1493. .Ds
  1494. #ifdef ultrix
  1495. #include "inca.h"
  1496. #else
  1497. #include "incb.h"
  1498. #endif /* ultrix */
  1499. .De
  1500. If ``ultrix'' is defined,
  1501. .I makedepend
  1502. knows to generate a dependency for ``inca.h'' and not
  1503. ``incb.h'';
  1504. a dumb
  1505. .I makedepend
  1506. has to to assume dependencies on both.
  1507. .LP
  1508. It's easiest simply to leave this section of
  1509. .I imakemdep.h
  1510. alone.
  1511. .NH 2
  1512. Build the program
  1513. .LP
  1514. You're ready to begin (this should actually be simple if you've done
  1515. the above correctly).
  1516. The first thing to do is ensure the absence of any detritus that might
  1517. be laying around from previous builds:
  1518. .Ds
  1519. make \-f Makefile.ini clean
  1520. .De
  1521. Then build
  1522. .I ccimake
  1523. and
  1524. .I imake .
  1525. If your
  1526. .I cpp
  1527. predefines the trigger, you can build with:
  1528. .Ds
  1529. make \-f Makefile.ini
  1530. or
  1531. make \-f Makefile.ini BOOTSTRAPCFLAGS=
  1532. .De
  1533. Otherwise, specify the trigger explicitly.
  1534. E.g., for Brand X, use:
  1535. .Ds
  1536. make \-f Makefile.ini BOOTSTRAPCFLAGS=\-Dbrandx
  1537. .De .NH 2
  1538. Test your handiwork
  1539. .LP
  1540. If
  1541. .I imake
  1542. is supposed to pass a trigger symbol definition to
  1543. .I cpp ,
  1544. you should test whether it actually does or not by executing the
  1545. following command (\fB\-T\fI/dev/null\fR provides an empty input template, and
  1546. \fB\-s\fI/dev/null\fR throws away the output so it doesn't clobber the
  1547. .I Makefile
  1548. in your current directory):
  1549. .Ds
  1550. imake \-v \-T/dev/null \-s/dev/null
  1551. .De
  1552. .B \-v
  1553. causes
  1554. .I imake
  1555. to print out the
  1556. .I cpp
  1557. command that it executes.
  1558. If you don't see a \-D\fItrigger\fR
  1559. in that command,
  1560. .I imake
  1561. wasn't built properly.
  1562. .NH 2
  1563. Modifying other configuration files for a new platform
  1564. .LP
  1565. If you are developing a new port to another system,
  1566. you have to do more than be able to compile
  1567. .I imake ,
  1568. you also need to be able to use it
  1569. in conjunction with the configuration files.
  1570. First, you must modify the header block section of
  1571. .I Imake.tmpl
  1572. to add a block for your system.
  1573. It will look something like this:
  1574. .Ds
  1575. #ifdef brandx
  1576. #define MacroIncludeFile <brandx.cf>
  1577. #define MacroFile brandx.cf
  1578. #undef brandx
  1579. #define BrandxArchitecture
  1580. #endif /* brandx */
  1581. .De
  1582. Second, you must create a platform-specific file
  1583. .I brandx.cf .
  1584. If your bootstrap flags are non-empty, this should contain, at
  1585. minimum, ``#define BootstrapCFlags \-Dbrandx''.
  1586. Most certainly it will have other things in it, too.
  1587. You will discover just what as you go through the process
  1588. of porting the server and/or clients.
  1589. .NH
  1590. Building X, or, When is BOOTSTRAPCFLAGS necessary?
  1591. .LP
  1592. If you have gotten this far, you know you can get
  1593. .I imake
  1594. to build and can proceed to build X itself.
  1595. .I "Before you do anything else,"
  1596. copy the top-level
  1597. .I Makefile
  1598. somewhere safe (outside of the source tree).
  1599. If something goes wrong and this file gets trashed,
  1600. you want to be able to recover it.
  1601. .LP
  1602. Since this document is really about configuring X, not building it, the
  1603. question addressed in this section is:
  1604. how can you get all the
  1605. .I Makefiles
  1606. built?
  1607. .LP
  1608. The ``do everything'' operation in building X is ``make World''.
  1609. It builds
  1610. .I imake ,
  1611. generates all the
  1612. .I Makefiles ,
  1613. removes extraneous object files, builds the header file tree,
  1614. generates dependencies, and compiles everything.
  1615. The only interesting part of from a configuration perspective is the first two
  1616. steps.
  1617. .LP
  1618. The important questions are: (1) what is the value of BOOTSTRAPCFLAGS;
  1619. and (2) when
  1620. must BOOTSTRAPCFLAGS be specified?
  1621. You have already answered the first question in determining how to
  1622. build
  1623. .I imake ,
  1624. so only the second is considered below.
  1625. .LP
  1626. When you build
  1627. .I imake
  1628. ``manually'' in
  1629. .I mit/config
  1630. using
  1631. .I Makefile.ini ,
  1632. you must specify BOOTSTRAPCFLAGS explicitly if it is non-empty.
  1633. What about when building from the top-level directory, e.g., ``make
  1634. World''?
  1635. It is a useful exercise to build
  1636. .I imake
  1637. by hand to test your understanding of the issues involved, but that
  1638. won't help you to do the ``World'' build\*-the first thing
  1639. ``make World'' does, unfortunately, is throw
  1640. .I imake
  1641. away and rebuild it from scratch.
  1642. .LP
  1643. The X Release Notes (section 2) indicate that for
  1644. ``make World'' you should
  1645. specify BOOTSTRAPCFLAGS if you find a definition for BootstrapCFlags in the platform
  1646. .I .cf
  1647. file (which means there is no unique predefined
  1648. .I cpp
  1649. symbol).
  1650. By implication, you do not need to specify BOOTSTRAPCFLAGS
  1651. if there is no value of BootstrapCFlags in your platform
  1652. .I .cf
  1653. file.
  1654. This means essentially that the empty value ``BOOTSTRAPCFLAGS='' is sufficient to
  1655. compile
  1656. .I imake
  1657. properly, which brings up a subtle point.
  1658. Each
  1659. .I Makefile
  1660. created in the X distribution contains a line that says
  1661. .Ds
  1662. BOOTSTRAPCFLAGS=\fIsomething\fR
  1663. .De
  1664. where
  1665. .I something
  1666. may or may not be empty.
  1667. Thus, when you execute a command such as
  1668. .Ds
  1669. make World BOOTSTRAPCFLAGS=\-Dbrandx
  1670. .De
  1671. you are not just
  1672. .I providing
  1673. a value of BOOTSTRAPCFLAGS, you are also
  1674. .I overriding
  1675. the default value in the
  1676. .I Makefile .
  1677. .LP
  1678. The implication that BOOTSTRAPCFLAGS need not be specified when BootstrapCFlags is
  1679. not defined involves a hidden assumption, i.e., that BOOTSTRAPCFLAGS
  1680. .I already
  1681. has the empty value in the top-level
  1682. .I Makefile .
  1683. If you obtain your X distribution from a system on which X has been built
  1684. and on which BOOTSTRAPCFLAGS is non-empty, that assumption is incorrect, so
  1685. if you don't explicitly provide an empty value by saying
  1686. .Ds
  1687. make World BOOTSTRAPCFLAGS=
  1688. .De
  1689. to override the default in the
  1690. .I Makefile ,
  1691. a value which is incorrect for your system is used instead.
  1692. You can get some very strange results this way.
  1693. .LP
  1694. I submit that, in general, the deciding factor determining whether to
  1695. specify BOOTSTRAPCFLAGS is not so much whether BootstrapCFlags is defined or not,
  1696. but whether you've built your
  1697. .I Makefiles
  1698. yet.
  1699. If not, you need to specify BOOTSTRAPCFLAGS,
  1700. .I "even if it's empty."
  1701. Otherwise, you don't have to.
  1702. In practice, this means that when you are building X on a new system,
  1703. you should assume BOOTSTRAPCFLAGS in the
  1704. .I Makefile
  1705. is incorrect and explicitly override it on the command line.
  1706. Normally this will be on the first ``World'' or ``mastermakefiles'' build.
  1707. .LP
  1708. The Release Notes do not cover the general case.
  1709. Rather, they assume you are working from a virgin distribution (where
  1710. the default BOOTSTRAPCFLAGS is in fact empty).
  1711. .LP
  1712. Once the
  1713. .I Makefiles
  1714. have BOOTSTRAPCFLAGS set properly, they will take care of propagating the correct value
  1715. for you automatically\*-forever, even into another operation that
  1716. rebuilds
  1717. .I imake
  1718. and the
  1719. .I Makefiles .
  1720. You can test this for yourself on a machine that has a non-empty BOOTSTRAPCFLAGS.
  1721. Do ``make mastermakefiles BOOTSTRAPCFLAGS=\-D\fItrigger\fR'', then ``make
  1722. mastermakefiles''.
  1723. You'll see that in the second case, BOOTSTRAPCFLAGS is supplied for you.
  1724. .LP
  1725. .B "Note 1:"
  1726. The above discussion assumes that if BOOTSTRAPCFLAGS is not empty, BootstrapCFlags is
  1727. defined
  1728. correctly in the platform
  1729. .I .cf
  1730. file, because BOOTSTRAPCFLAGS normally gets its value from that symbol when
  1731. .I Makefiles
  1732. are generated.
  1733. .LP
  1734. .B "Note 2:"
  1735. It is not necessary to do a ``World'' build to build
  1736. .I imake
  1737. and the
  1738. .I Makefiles ;
  1739. there is a ``mastermakefiles'' target that will do so.
  1740. This is a far more modest undertaking than doing the ``World'' build
  1741. and you can check a few of the
  1742. .I Makefiles
  1743. afterward to see if the ``World'' build is likely to succeed or not:
  1744. If BOOTSTRAPCFLAGS is correct and the correct header block was selected,
  1745. you can
  1746. then go ahead and do ``make World'' without having to specify BOOTSTRAPCFLAGS.
  1747. .NH 2
  1748. Alternatives to BOOTSTRAPCFLAGS
  1749. .LP
  1750. There are two alternatives to specifying BOOTSTRAPCFLAGS explicitly
  1751. on the
  1752. command line when you build
  1753. the
  1754. .I Makefiles ,
  1755. both sneaky and both deprecated.
  1756. They are mentioned here in order to point out why you shouldn't use
  1757. them.
  1758. .LP
  1759. First, you can edit
  1760. .I Makefile.ini
  1761. manually to set the value of BOOTSTRAPCFLAGS directly.
  1762. The reason this is not a good idea is that if you give your X
  1763. distribution to somebody else that doesn't have the same kind of
  1764. machine, you've given away an explicitly misconfigured
  1765. .I Makefile.ini .
  1766. The recipient might fail to appreciate the subtle irony of this
  1767. gesture.
  1768. .LP
  1769. Second, you can forget about BOOTSTRAPCFLAGS entirely.
  1770. That's correct\*-you can build
  1771. .I imake
  1772. with wild abandon and total lack of regard for whether it knows about
  1773. the correct trigger symbol or not.
  1774. ``But on some systems,
  1775. .I imake
  1776. must pass the trigger definition to
  1777. .I cpp
  1778. explicitly,'' you say, ``and
  1779. .I imake
  1780. compiled in such a reckless and irresponsible manner may not do the job.''
  1781. Quite right.
  1782. However...
  1783. .I imake
  1784. also examines your environment, and the value of IMAKEINCLUDE, if
  1785. defined there, is passed to
  1786. .I cpp .
  1787. The value of IMAKEINCLUDE must begin with ``\-I'' (or
  1788. .I imake
  1789. will reject it), but you can set it to ``\-I. \-Dbrandx'' and the
  1790. trigger symbol will be passed through to
  1791. .I cpp
  1792. and your
  1793. .I Makefiles
  1794. will build happily.
  1795. .LP
  1796. This is sneaky because it uses the environment to affect the
  1797. build process in a way that is not evident.
  1798. Worse yet, if you actually install an
  1799. .I imake
  1800. built this way, it won't work for anyone else who isn't privy to the
  1801. IMAKEINCLUDE convention.
  1802. .LP
  1803. (A third alternative is to edit
  1804. BOOTSTRAPCFLAGS to the proper value in the top-level
  1805. .I Makefile
  1806. before ``make World''.
  1807. This is functionally equivalent to specifying it on the command line and
  1808. doesn't really gain you anything.)
  1809. .LP
  1810. (Might want to discuss here how BOOTSTRAPCFLAGS propagates during
  1811. those
  1812. .I make
  1813. operations through use of the ImakeDependency() rule.
  1814. Discuss what that rule checks.)
  1815. .LP
  1816. Discuss
  1817. .I xmkmf ,
  1818. IMAKE_CMD and operation of UseInstalled here.
  1819. .NH
  1820. Imakeconoclasm\*-X configuration bugs
  1821. .LP
  1822. Ugh.
  1823. Highly redundant.
  1824. .LP
  1825. ``make World'' does a ``make clean'' after making all the
  1826. .I Makefiles .
  1827. This means that if you need to remake a
  1828. .I Makefile ,
  1829. .I imake
  1830. will have been removed.
  1831. The rules for ``make Makefile'' include a check to see whether
  1832. .I imake
  1833. needs rebuilding, which is clever enough.
  1834. Unfortunately, when they cause
  1835. .I imake
  1836. to be rebuilt they may not pass BOOTSTRAPCFLAGS.
  1837. This means that every time you build a ``Makefile'' target, BOOTSTRAPCFLAGS
  1838. needs to be specified if it's not empty.
  1839. .B "Give the fix."
  1840. .LP
  1841. .B "[Bug section]"
  1842. If what you are doing won't build
  1843. .I imake ,
  1844. you don't need BOOTSTRAPCFLAGS.
  1845. But it is not always apparent whether a given target will build it or
  1846. not.
  1847. If you don't have UseInstalled defined, the rules for the``Makefile''
  1848. target (present in virtually every
  1849. .I Makefile )
  1850. contain a check to see whether
  1851. .I mit/config/imake
  1852. is actually built; if not, they build it.
  1853. Thus even an apparently innocuous ``make Makefile''
  1854. in some obscure directory somewhere might trigger an
  1855. .I imake
  1856. build.
  1857. .LP
  1858. One bit of confusion that may strike you:
  1859. Do ``make World''.
  1860. This builds
  1861. .I imake ,
  1862. generates all the
  1863. .I Makefiles ,
  1864. cleans all the directories and finally builds the X stuff.
  1865. .LP
  1866. If you later rebuild the
  1867. .I Makefile
  1868. in any directory with ``make Makefile'', you might be surprised to
  1869. find that
  1870. .I imake
  1871. is rebuilt first.
  1872. This reason is that the rules for the ``Makefile'' target check
  1873. whether
  1874. .I imake
  1875. exists, and if not they build it first.
  1876. Since the ``World'' build does a clean after generating the
  1877. .I Makefiles ,
  1878. .I imake
  1879. was thrown away.
  1880. .LP
  1881. In fact,
  1882. .I imake
  1883. will be built the first time ``make Makefile'' is done even if the
  1884. cleaning had not been done.
  1885. The rules that check
  1886. .I imake 's
  1887. existence look for
  1888. .I Makefile
  1889. in
  1890. .I mit/config
  1891. and build
  1892. .I imake
  1893. with that if it's there.
  1894. (It will be because the ``World'' build generates it.)
  1895. But the dependency for
  1896. .I imake
  1897. in
  1898. .I Makefile
  1899. is
  1900. .I imake.o
  1901. while the dependency in
  1902. .I Makefile.ini
  1903. (which
  1904. .I imake
  1905. is initially built with) is
  1906. .I imake.c .
  1907. This means that even if
  1908. .I imake
  1909. is present in
  1910. .I mit/config ,
  1911. it will be built again because
  1912. .I imake.o
  1913. isn't.
  1914. .LP
  1915. That isn't a bug, but it can be confusing.
  1916. What
  1917. .I is
  1918. a bug is that...
  1919. .LP
  1920. The IncRoot symbol is defined twice, once in
  1921. .I Imake.tmpl
  1922. and once in
  1923. .I Project.tmpl .
  1924. This is a minor nit, since neither file is supposed to be modified.
  1925. However, if you use a copy of the configuration files as a base for your own
  1926. projects, you probably
  1927. .I will
  1928. modify them; be aware that changing the definition in
  1929. .I Project.tmpl
  1930. has no effect if you leave both definitions in.
  1931. .LP
  1932. .I makedepend
  1933. has some hardwired pathnames.
  1934. This may bite you if you use
  1935. .I gcc
  1936. or compile on a MIPS system under BSD environment.
  1937. .NH
  1938. Courting disaster:  How to do the wrong thing
  1939. .LP
  1940. .I imake
  1941. is wonderful for portability when everything is configured
  1942. properly.
  1943. However, subtle syntax errors in the configuration files are often difficult
  1944. to track down when you begin to make any significant changes to them.
  1945. This section describes some of the misfortunes that may beset you
  1946. should you make so bold as to engage in such an endeavor.
  1947. .LP
  1948. For X, the source of problems might be in any of
  1949. .I Imakefile ,
  1950. .I Imake.rules ,
  1951. .I Imake.tmpl ,
  1952. the platform
  1953. .I .cf
  1954. file, or
  1955. .I site.def .
  1956. The most likely candidates are
  1957. .I site.def
  1958. and the platform file, though, since those are the only ones you're supposed
  1959. to edit.
  1960. (If you're writing an
  1961. .I Imakefile ,
  1962. add that to the list, too.)
  1963. Just remember that effects of mistakes in the early files may
  1964. not be manifest until much later on.
  1965. Problems may appear to originate at locations far from the actual
  1966. cause.
  1967. .IP (1)
  1968. .I Makefile
  1969. trashing
  1970. .IP
  1971. A number of problems during ``make Makefile'' can result in a trashed
  1972. .I Makefile .
  1973. If you have
  1974. .I xmkmf
  1975. working, you can use that to regenerate the
  1976. .I Makefile
  1977. after fixing whatever the problem was.
  1978. Otherwise you must recover it somehow.
  1979. If you have a copy of
  1980. .I Makefile
  1981. stashed somewhere, you can use that.
  1982. If not:
  1983. the first thing that ``make Makefile'' does is to move the original
  1984. .I Makefile
  1985. to
  1986. .I Makefile.bak ;
  1987. if the new
  1988. .I  Makefile
  1989. isn't created properly, you can
  1990. usually recover it with ``cp Makefile.bak Makefile''.
  1991. Then you can fix
  1992. the problem and try again.
  1993. If
  1994. .I Makefile.bak
  1995. is trashed as well, you can
  1996. grab the
  1997. .I Makefile
  1998. from another directory at the same level and use that (this works because
  1999. they both contain the same ``make Makefile''
  2000. rule).
  2001. You can also use a
  2002. .I Makefile
  2003. from a directory at another level,
  2004. but you need to edit the line that sets TOP to reflect where the top
  2005. project directory is in relation to the current directory.
  2006. .IP (2)
  2007. Boolean vs. existent/nonexistent symbols
  2008. .IP
  2009. Some symbols are used in boolean fashion and are defined as
  2010. YES or NO.
  2011. They are tested by ``#if \fIsymbol\fR'' or ``#if !\fIsymbol\fR''.
  2012. Others are turned on simply by being defined.
  2013. They are tested by ``#ifdef \fIsymbol\fR'' or ``#ifndef \fIsymbol\fR''.
  2014. Failure to distinquish the sense in which a symbol is used can lead to
  2015. problems.
  2016. It is necessary to define symbols properly
  2017. .I and
  2018. to test them properly.
  2019. .IP
  2020. .B Example:
  2021. YES/NO symbols must be defined properly.
  2022. SystemV is such a symbol, and the test is ``#if SystemV''.
  2023. If you use ``#define SystemV'' thinking that will turn it on, you'll
  2024. have problems; ``#if SystemV'' turns into just ``#if'' and generates:
  2025. .Ds
  2026. cpp: /usr/tmp/tmp-imake.nnnn:line mmmm: syntax error
  2027. .De .IP
  2028. .B Example:
  2029. YES/NO symbols must be tested properly.
  2030. If you test such a symbol with #ifdef, the test will always succeed,
  2031. whether the value is YES or NO; the symbol is defined in
  2032. .I both
  2033. cases.
  2034. .IP
  2035. .B Example:
  2036. Existent/nonexistent symbols must be defined properly.
  2037. A symbol such as UseInstalled is simply defined (as nothing) or left undefined.
  2038. If you say ``#define UseInstalled NO'', thinking that will turn it
  2039. off, you will be surprised.
  2040. (The test ``#ifdef UseInstalled'' will succeed.)
  2041. .IP
  2042. .B Example:
  2043. Existent/nonexistent symbols must be properly.
  2044. Such a symbol may be defined as nothing.
  2045. If you test it, incorrectly, with ``#if symbol'', the test will fail.
  2046. Use #ifdef.
  2047. .IP (3)
  2048. Rule definition problems.
  2049. .IP
  2050. These can occur after ``make Makefile'', if a rule in
  2051. .I Imake.rules
  2052. is
  2053. #define'd with a space between the rule name and the argument list:
  2054. .Ds
  2055. #define rule(arglist)               right
  2056. #define rule (arglist)              wrong!
  2057. .De .IP
  2058. Some (all?)
  2059. .I cpp 's
  2060. will define rulename as ``(arglist)''.
  2061. When this happens, you'll see
  2062. .Ds
  2063. make:  line nnn: syntax error
  2064. .De .IP
  2065. and you'll find `` (arglist)'' on line nnn of the
  2066. .I Makefile
  2067. because ``rule'' wasn't expanded properly (or at least not the way you
  2068. expect).
  2069. Fix it and try again.
  2070. .IP
  2071. Other similar errors can occur if rules are defined or used with spaces
  2072. anywhere between the end of the macro name to the closing parenthesis of
  2073. the argument list.
  2074. This is particularly true if a macro argument is used
  2075. to generate a rule target name.
  2076. .B "Give example."
  2077. .IP (4)
  2078. Failure to supply
  2079. .I cpp
  2080. symbol default values
  2081. .IP
  2082. When a
  2083. .I make
  2084. variable is equated to a
  2085. .I cpp
  2086. symbol, that symbol must be defined somewhere, even if it's just
  2087. defined as nothing.
  2088. Otherwise the make variable will be set to the literal
  2089. .I cpp
  2090. symbol name.
  2091. That is, if you have ``MAKEVAR=CppSymbol'', it must be preceded
  2092. somewhere by:
  2093. .Ds
  2094. #ifndef CppSymbol
  2095. #define CppSymbol \fIwhatever\fR
  2096. #endif
  2097. .De .IP
  2098. or MAKEVAR will end up with the value ``CppSymbol''\*-literally.
  2099. .IP (5)
  2100. Macros expansion failure
  2101. .IP
  2102. Suppose you include the following line in your
  2103. .I Imakefile
  2104. so that a special version of your library will be compiled:
  2105. .Ds
  2106. DebuggedAndProfiledLibraryObjectrule()
  2107. .De .IP
  2108. After you regenerate
  2109. .I Makefile ,
  2110. you try to use it and get the message:
  2111. .Ds
  2112. Make: Must be a separator on rules line nnn.  Stop.
  2113. .De .IP
  2114. This is symptomatic of a spelling error.
  2115. The rule is actually
  2116. ``DebuggedAndProfiledLibraryObjectRule()'';
  2117. compare closely with the above.
  2118. If you spell a rule name incorrectly, it won't be expanded.
  2119. Fortunately, these errors are easy to find, because at least the message
  2120. tells you where to look.
  2121. Unfortunately, you can't say ``make Makefile'' after you fix
  2122. .I Imakefile ,
  2123. because the effect of the error is to make your
  2124. .I Makefile
  2125. unusable.
  2126. .NH
  2127. Writing Imakefiles.
  2128. .LP
  2129. This section assumes that
  2130. .I imake ,
  2131. .I makedepend
  2132. and
  2133. .I xmkmf
  2134. are installed in a public directory somewhere.
  2135. (implies configuration files are installed where
  2136. .I xmkmf
  2137. can get at them.)
  2138. This means, in particular, that you should be able to do ``xmkmf''
  2139. to build a
  2140. .I Makefile
  2141. from an
  2142. .I Imakefile
  2143. in the current directory.
  2144. Detailed
  2145. knowledge of the guts of the configuration process is
  2146. .I not
  2147. assumed.
  2148. .LP
  2149. Give example null
  2150. .I Imakefile
  2151. here.
  2152. .LP
  2153. To test the syntactic correctness of your
  2154. .I Imakefile :
  2155. .Ds
  2156. xmkmf ; make Makefile
  2157. .De
  2158. .I xmkmf
  2159. builds the
  2160. .I Makefile
  2161. from scratch and fails if the configuration is bad.
  2162. .I make
  2163. builds a new
  2164. .I Makefile
  2165. using the one built by
  2166. .I xmkmf ,
  2167. and fails if that one is not legal.
  2168. (say how that can happen, e.g., spelling errors cause it.)
  2169. .LP
  2170. Note that the following command lines are not always equivalent:
  2171. .Ds
  2172. make Makefile Makefiles
  2173. make Makefile ; make Makefiles
  2174. .De
  2175. You normally want to build the ``Makefiles'' target when there are
  2176. subdirectories.
  2177. Suppose you add a new directory.
  2178. This is done by changing
  2179. SUBDIRS in the current directory's
  2180. .I Imakefile .
  2181. You then need to rebuild the
  2182. .I Makefile
  2183. so that the definition of SUBDIRS is reset, and then rebuild
  2184. .I Makefile
  2185. in each of those subdirectories.
  2186. The first command line above builds the ``Makefiles'' target using the
  2187. (old) value of SUBDIRS from the (current)
  2188. .I Makefile ,
  2189. which is incorrect.
  2190. The second command line rebuilds the
  2191. .I Makefile ,
  2192. then runs a second
  2193. .I make
  2194. process to build ``Makefiles''.
  2195. The second process sees the (new) value of SUBDIRS in the (new)
  2196. .I Makefile ,
  2197. which includes the new subdirectory, and has the intended result.
  2198. .LP
  2199. This is an instance of the ``doesn't work first time, works second time
  2200. phenomenon''...
  2201. .LP
  2202. Some rules may not work as you expect after changing
  2203. .I IMakefile .
  2204. This means problems can occur the first time you try ``make \fIop\fR'' that
  2205. mysteriously disappear the second time.
  2206. .B "[Illustrate this.]"
  2207. .LP
  2208. Don't forget ``make depend'' after ``make Makefile''.
  2209. .NH
  2210. Other topics to be dealt with
  2211. .LP
  2212. Listed below are some other topics that should eventually find their
  2213. way into this document.
  2214. What do
  2215. .I you
  2216. want to see?
  2217. .LP
  2218. Shortcomings.
  2219. No provision for building non-shell scripts, especially if
  2220. ExecableScripts is NO.
  2221. List disadvantages of
  2222. .I cpp
  2223. scripts.
  2224. .LP
  2225. Some
  2226. .I cpp
  2227. symbols have no
  2228. .I make
  2229. variable equivalent are exist only to control construction of the
  2230. .I Makefile .
  2231. .LP
  2232. IHaveSubdirs,
  2233. IHaveSpecialMakefileTarget
  2234. .LP
  2235. PassCDebugFlags\*-but related to CDEBUGFLAGS
  2236. .LP
  2237. UseInstalled
  2238.