1 <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
4 <meta content="text/html; charset=iso-8859-1" http-equiv="content-type">
5 <meta content="Fred T. Hamster" name="Author">
6 <meta name="generator" content="Mozilla/5.0 (X11; U; Linux i686; en-US) [Mozilla]">
7 <title>CLAM Reference Manual</title>
9 <body link="#33ff33" text="#ffff99" vlink="#009900" bgcolor="#400080" alink="#ff9900">
12 <h1><big>CLAM: Coordinated Librarian &</big></h1>
13 <h1><big>Automatic Maker</big></h1>
14 <small></small></center>
15 <center><big><img src="../../infobase/pictures/clams_tran.gif" height="347" width="392"></big></center>
18 <h2><big>Tutorial and Reference Manual</big></h2>
19 <small></small></center>
22 <address><big><a name="lib_manager"></a>By Chris Koeritz (<a href="mailto:koeritz@gruntose.com">koeritz@gruntose.com</a>)</big></address>
23 <small></small></center>
27 <hr noshade="noshade" size="8" width="100%"></h2>
28 <small></small></center>
31 <h2><big>Table of Contents</big></h2>
32 <small></small></center>
34 <small> </small><big> </big><small> </small>
35 <li><big> <a href="#EXECUTIVE_SUMMARY">Executive Summary</a></big></li>
36 <small> </small><big> </big><small> </small>
37 <li><big> <a href="#PREPARATION">Preparing Your Computer to Use
39 <small> </small><big> </big><small> </small>
41 <small> </small><big> </big><small> </small>
42 <li><big> <a href="#STEPS_NEEDED">Necessary Steps</a></big></li>
43 <small> </small><big> </big><small> </small>
45 <small> </small><big> </big><small> </small>
46 <li><big> <a href="#TUTORIAL">CLAM Tutorial</a></big></li>
47 <small> </small><big> </big><small> </small>
49 <small> </small><big> </big><small> </small>
50 <li><big> <a href="#CAVEATS">Caveats</a></big></li>
51 <small> </small><big> </big><small> </small>
52 <li><big> <a href="#TUT_BASICS">Basics</a></big></li>
53 <small> </small><big> </big><small> </small>
54 <li><big> <a href="#TUT_COMMON">Common Files</a></big></li>
55 <small> </small><big> </big><small> </small>
56 <li><big> <a href="#TUT_IMPORTANT_VARS">Important Variables</a></big></li>
57 <small> </small><big> </big><small> </small>
58 <li><big> <a href="#TUT_VAR_ASSIGN">Variable Assignment</a></big></li>
59 <small> </small><big> </big><small> </small>
60 <li><big> <a href="#TUT_OPTIONAL_VARS">Optional Variables</a></big></li>
61 <small> </small><big> </big><small> </small>
62 <li><big> <a href="#WRITING_RULES">Writing Your Own Rules</a></big></li>
63 <small> </small><big> </big><small> </small>
64 <li><big> <a href="#TUT_CONCLUSION">Conclusion</a></big></li>
65 <small> </small><big> </big><small> </small>
67 <small> </small><big> </big><small> </small>
68 <li><big> <a href="#REFERENCE">CLAM Reference</a></big></li>
69 <small> </small><big> </big><small> </small>
71 <small> </small><big> </big><small> </small>
72 <li><big> <a href="#LANG_INDEP_VARS">Language Independent
73 Variables</a></big></li>
74 <small> </small><big> </big><small> </small>
75 <li><big> <a href="#LANG_INDEP_RULES">Language Independent
77 <small> </small><big> </big><small> </small>
78 <li><big> <a href="#LANG_INDEP_TARGETS">Language Independent
79 Targets</a></big></li>
80 <small> </small><big> </big><small> </small>
81 <li><big> <a href="#LANG_INDEP_SCRIPTS">Language Independent
83 <small> </small><big> </big><small> </small>
84 <li><big> <a href="#CPP_VARS">C++ Specific Variables</a></big></li>
85 <small> </small><big> </big><small> </small>
87 <small> </small><big> </big><small> </small>
88 <li><big> <a href="#DIRECTORY_VARS">Directory Structure
89 Variables</a></big></li>
90 <small> </small><big> </big><small> </small>
91 <li><big> <a href="#CPP_FLAGS">Compiler Dependent Flags</a></big></li>
92 <small> </small><big> </big><small> </small>
93 <li><big><a href="#vcpp_only">Microsoft Visual C++ Only</a><br>
95 <small> </small><big> </big><small> </small>
96 <li><big> <a href="#SUPPORT_EXTENSIONS">Support for
98 Extensions</a></big></li>
99 <small> </small><big> </big><small> </small>
101 <small> </small><big> </big><small> </small>
102 <li><big> <a href="#CPP_RULES">C++ Specific Rules</a></big></li>
103 <small> </small><big> </big><small> </small>
104 <li><big> <a href="#CPP_TARGETS">C++ Specific Targets</a></big></li>
105 <small> </small><big> </big><small> </small>
106 <li><big> <a href="#CPP_SCRIPTS">C++ Specific Files</a></big></li>
107 <small> </small><big> </big><small> </small>
109 <small> </small><big> </big><small> </small>
110 <li><big> <a href="#EXAMPLES">Example CLAM Makefiles</a></big></li>
111 <small> </small><big> </big><small> </small>
112 <li><big> <a href="#CLAM_HINTS">CLAM Hints and Troubleshooting</a></big></li>
113 <small> </small><big> </big><small> </small>
114 <li><big> <a href="#ACKS">Acknowledgements</a></big></li>
115 <small> </small><small></small>
118 </big><small></small>
120 <hr noshade="noshade" size="8" width="100%"></h2>
121 <small></small></center>
123 </big><small></small>
124 <h2><big><a name="EXECUTIVE_SUMMARY"></a>Executive Summary</big></h2>
125 <small></small></center>
126 <big> The CLAM system is a set of macros and rules
127 for the GNU make program
129 simplifies the creation of executable programs and code
131 Most makefiles that use the CLAM system are ten lines long or
133 Makefiles are stated in terms of a set of special variable names that
135 interprets in order to issue the correct sequence of compilation
137 This document presents a tutorial on the variable names and simple
139 that need to be used with CLAM. Several example makefiles and the
141 reference manual for CLAM are also included.<br>
142 CLAM is part of the HOOPLE libraries (<a href="http://hoople.org/">http://hoople.org/</a>)
144 downloaded from there or through a sourceforge mirror site.<br>
145 In the remainder of the document, we will often
146 refer to CLAM as just "clam".<br>
149 <center><small></small>
151 <hr noshade="noshade" size="8" width="100%"></h2>
152 <small></small></center>
154 </big><small></small>
155 <h2><big><a name="PREPARATION"></a>Preparing Your Computer to Use
157 <small></small></center>
158 <h3><big><a name="STEPS_NEEDED"></a>Necessary Steps:</big></h3>
160 <small> </small><big> </big><small> </small>
161 <li><big>Setting environment variables for clam:</big></li>
162 <small> </small><big> </big><small> </small>
164 <li><big>FEISTY_MEOW_APEX:</big></li>
165 <small> </small><big> </big><small> </small>
167 <small> </small><big> </big><small> </small>
168 <li><big> **REVISE** out of date... This variable has been needed
170 part of the YETIcode project (at <a href="http://yeticode.org/">http://yeticode.org</a>).</big></li>
172 <li><big>The default location for clam is under the FEISTY_MEOW_APEX
174 folder named clam, although the version of clam shipped with the
176 code (http://hoople.org) actually lives under the root of the
180 <small> </small><big> </big><small> </small>
181 <li><big>If the yeti root directory is in $HOME/yeti
183 default for FEISTY_MEOW_APEX will work and it doesn't need to be
185 <li><big>Setting the variable:<br>
187 <small> </small><big> </big><small> </small>
189 <small> </small><big> </big><small> </small>
190 <li><big>On Unix (with the bash shell): <span style="font-weight: bold;">export
191 MAKEFLAGS="-I $HOME/yeti/clam"</span></big></li>
192 <small> </small><big> </big><small> </small>
193 <li><big>On win32: <span style="font-weight: bold;">set
194 MAKEFLAGS="-I c:/yeti/clam"</span> (or set this in the
196 control panel, under the advanced tab, in environment variables)<span
197 style="font-weight: bold;"><br>
199 <small> </small><big> </big><small> </small>
200 <li><big>Note that the use of
201 forward slashes is mandatory in the clam directory in MAKEFLAGS.<br>
203 <small> </small><big> </big><small> </small>
205 <small> </small><big> </big><small> </small>
207 <small> </small><big> </big><small> </small>
208 <li><big>MAKEFLAGS:</big></li>
209 <small> </small><big> </big><small> </small>
211 <small> </small><big> </big><small> </small>
212 <li><big> This variable is required to be set in the
213 environment before using clam with gnu-make. It tells make
215 to find the clam definitions and scripts.</big></li>
217 <li><big>Setting the variable:<br>
219 <small> </small><big> </big><small> </small>
221 <small> </small><big> </big><small> </small>
222 <li><big>On Unix (assuming bash as shell): <span style="font-weight: bold;">export
223 MAKEFLAGS="-I $FEISTY_MEOW_APEX/clam"</span></big></li>
224 <small> </small><big> </big><small> </small>
225 <li><big>On win32: <span style="font-weight: bold;">set
226 MAKEFLAGS="-I %FEISTY_MEOW_APEX%/clam"</span></big></li>
227 <small> </small><big> </big><small> </small>
228 <li><big>This variable also requires forward slashes
230 backslashes.</big></li>
231 <small> </small><big> </big><small> </small>
233 <small> </small><big> </big><small> </small>
238 <li><big>Required Tools:</big></li>
239 <small> </small><big> </big><small> </small>
241 <small> </small><big> </big><small> </small>
242 <li><big>The compiler itself:<br>
244 <small> </small><big> </big><small> </small>
246 <small> </small><big> </big><small> </small>
247 <li><big>If you are running GNU/Linux (or almost any other
248 Posix-compliant operating system), then the GNU C/C++ compiler
249 suite is pretty much all that's needed.</big></li>
250 <small> </small><big> </big><small> </small>
252 GNU C/C++ compiler (included in the <a href="http://www.mingw.org/">MinGW</a>
253 toolkit) should be all that's needed for
255 but the Microsoft Visual Studio 6.0-8.0 compilers can be used if
256 available. Compatibility is only guaranteed for vc8
259 <small> </small><big> </big><small> </small>
261 <small> </small><big> </big><small> </small>
262 <li><big>Win32 Unix Tools:</big></li>
263 <small> </small><big> </big><small> </small>
265 <small> </small><big> </big><small> </small>
266 <li><big> If you are running a win32-based product
270 windows xp, etc) then a few additional tools are required...<br>
272 <small> </small><big> </big><small> </small><small></small>
273 <li><big>The recommended GNU utilities are available for
276 package (http://www.mingw.org/).</big></li>
277 <li><big>Note that you will need to add the binaries directory from
279 your path. The PATH variable can be accessed under MS-NT
280 type OSes through the
281 "control panel | system | advanced | environment variables" menu
283 plan to use msys outside of clam, then ensure that
284 the MSYS bin directory is prior to the
285 windows system directory in your path; this causes the Unix "find"
286 command to be used instead of the Windows version.</big></li>
287 <li><big>Alternatively, a similar set of GNU utilities is
289 in the <a href="http://cygwin.com/">Cygwin package</a>, although
290 these tools are no longer recommended and are, in
291 fact, actively deprecated.</big></li>
292 <small> </small><big> </big><small> </small>
294 <small> </small><big> </big><small> </small>
296 <small> </small><big> </big><small> </small>
298 <small> </small><big> </big><small> </small>
299 <li><big>makedep and version_stamper tools:</big></li>
300 <small> </small><big> </big><small> </small>
302 <small> </small><big> </big><small> </small>
303 <li><big>The hoople/bin directory in the archive has
305 versions of tools used by clam during a build.<br>
307 <small> </small><big> </big><small> </small>
308 <li><big>If you would rather rebuild them from source, then
310 the script "scripts/generator/produce_feisty_meow.sh" will
311 recreate all of these internal tools.<br>
313 <small> </small><big> </big><small> </small>
315 <small> </small><big> </big><small> </small>
317 <small> </small><big> </big><small> </small>
318 <li><big>Third Party Tools Used By or Supported Within clam:</big></li>
319 <small> </small><big> </big><small> </small>
321 <small> </small><big> </big><small> </small>
322 <li><big>wx widgets:</big></li>
323 <small> </small><big> </big><small> </small>
325 <small> </small><big> </big><small> </small>
326 <li><big>home page: http://www.wxwidgets.org/</big></li>
327 <small> </small><big> </big><small> </small>
328 <li><big>As far as the clam team is concerned, this is the
330 portable (and open source) library for graphical user interfaces.<br>
332 <small> </small><big> </big><small> </small>
334 <small> </small><big> </big><small> </small>
335 <li><big>OpenSSL:</big></li>
336 <small> </small><big> </big><small> </small>
338 <small> </small><big> </big><small> </small>
339 <li><big>home page: http://www.openssl.org/</big></li>
340 <small> </small><big> </big><small> </small>
341 <li><big>This is the team's most favorite library for SSL
343 Sockets Layer) and general encryption needs.<br>
345 <small> </small><big> </big><small> </small>
347 <small> </small><big> </big><small> </small>
348 <li><big>cURL:</big></li>
349 <small> </small><big> </big><small> </small>
351 <small> </small><big> </big><small> </small>
352 <li><big>home page: http://curl.haxx.se/</big></li>
353 <small> </small><big> </big><small> </small>
354 <li><big>The curl library rocks(!) and provides a very
356 tools for programmatically interacting with live web pages.<br>
358 <small> </small><big> </big><small> </small>
360 <small> </small><big> </big><small> </small>
362 <small> </small><big> </big><small> </small>
363 <li><big>Other clam Preconditions:</big></li>
364 <small> </small><big> </big><small> </small>
366 <small> </small><big> </big><small> </small>
367 <li><big>Linux platforms:</big></li>
368 <small> </small><big> </big><small> </small>
370 <small> </small><big> </big><small> </small>
371 <li><big>The standard source code repository is a directory
374 in the user's home directory. If you decompress the hoople
375 library archive in your home directory, you should be all set to
376 perform a build.</big></li>
377 <small> </small><big> </big><small> </small>
378 <li><big>See the HOOPLE website for more details about
379 downloading that codebase (<a href="http://hoople.org">http://hoople.org</a>).<br>
381 <small> </small><big> </big><small> </small>
383 <small></small><small></small>
385 <small> </small><big> </big><small> </small>
387 <small> </small><big> </big><small> </small>
388 <li><big>Win32 platforms:</big></li>
389 <small> </small><big> </big><small> </small>
391 <small> </small><big> </big><small> </small>
392 <li><big>The standard repository for source code is a substituted
393 drive l:, which is where all the other hierarchies start.
395 drive can be mapped to any folder desired using the "subst"
397 (for example, "subst l: c:\build_dir").
399 objects and final products will be generated to the l: drive.</big></li>
400 <small> </small><big> </big><small> </small>
401 <li value="2"><big>Using MS Visual Studio as the Compiler:</big></li>
402 <small> </small><big> </big><small> </small>
404 <small> </small><big> </big><small> </small>
405 <li><big>VS80COMNTOOLS/VS90COMNTOOLS/VS100COMNTOOLS variable:</big></li>
406 <small> </small><big> </big><small> </small>
408 <small> </small><big> </big><small> </small>
409 <li><big>This variable should be automatically created by
410 Visual Studio upon installation. If it isn't, then
412 a bug or you need to restart your current prompt or your
415 <li><big>The paths that clam uses to find compiler binaries
416 is calculated based on this variable.</big></li>
417 <li><big>Older versions of visual studio are currently
418 unsupported because Microsoft constantly rearranges their
420 tools in a non-maintainable way.<br>
423 <li><big>Several other environment variables are required
425 Studio. They can be set up for your current command prompt
427 running "vcvars32.bat" or "vsvars32.bat" (found under
429 compiler's common directory, which varies depending on the
433 <small> </small><big> </big><small> </small>
435 <small> </small><big> </big><small> </small>
437 <small> </small><big> </big><small> </small>
439 <small> </small><small></small>
442 </big><small></small>
444 <hr noshade="noshade" size="8" width="100%"></h2>
445 <small></small></center>
447 </big><small></small>
448 <h2><big><a name="TUTORIAL"></a>CLAM Tutorial</big></h2>
449 <small></small></center>
450 <big> This section provides an overview of
452 works and how you can make it work for you. It is quite brief,
454 should suffice for most common cases of makefiles. For more
456 usage, consult the CLAM Reference section of this document.
458 <h3><big><a name="CAVEATS"></a>Caveats</big></h3>
460 <small> </small><big> </big><small> </small>
461 <li><big>Most of the Unix tools employed in the make process are
462 case-sensitive.
463 This means that they will probably not find any of the clam support if
464 the files have been changed to upper-case names. It also means
466 all code files must match their descriptions in makefiles, letter for
468 And any batch files or executables invoked also need to be in
470 as clam expects them to be.</big></li>
471 <small> </small><big> </big><small> </small>
472 <li><big>A corollary case requirement is that the makefile must
475 "makefile" or "Makefile". These are the Unix standard names and
477 looks for these by default. If you are willing to type "make -f
478 <i>makefile_name</i>",
479 then you can run any makefile. However, the build-ready
481 should be named according to the standard, since the build process
483 look for these automatically.</big></li>
484 <small> </small><small></small>
487 <a name="TUT_BASICS"></a>Basics</big></h3>
488 <big> The C++ Library
489 Automatic Maker system (or CLAM) is defined as a set of
491 (or macro) definitions. These variable definitions are
493 order to compile and link programs. By setting the variables'
495 appropriately, specific products can be generated from the target rules
497 in clam. Both variables and rules are extensible. The
499 procedure for building a clam-based Makefile has four user-defined
503 <small> </small><big> </big><small> </small>
504 <li><big>loading the default variables for clam,</big></li>
505 <small> </small><big> </big><small> </small>
506 <li><big>redefining the default variables where necessary,</big></li>
507 <small> </small><big> </big><small> </small>
508 <li><big>loading the default rule set for clam,</big></li>
509 <small> </small><big> </big><small> </small>
510 <li><big>defining rules that are local to the user's Makefile.</big></li>
511 <small> </small><small></small>
513 <big>Step 4 can usually be omitted unless the project creates
515 whose types are not supported by clam.<br>
516 clam is structured as a directory hierarchy
517 where the root of clam
519 the most general makefile activities. Activities such as
521 into subdirectories and providing support for cleaning up after a make
523 provided at this level. In the remainder of the document, we
525 designate this location with a "$" character to clarify what part of
526 the clam hierarchy we are describing.<br>
527 The root clam
528 support files are mostly language independent, since they are used by
530 varieties of language dependent derived versions of clam. These
532 are generally not of concern unless one is designing a new derived
534 of clam for a language not yet supported.<br>
535 The subdirectories off of the clam root
537 "derived" makefile services, such as C++ or Ada compilation. Each
538 derived clam service implements at least two files to link into the
540 clam system: a variables file and a rules file. The variables
542 the options for the derived make process; by changing the values of
544 different types of targets can be created. The rules file
546 creation of the targets relevant to the programming language being
548 It may be worth noting that clam can be used to
550 any kind of programmatic process--not just compilation. Currently
552 program compilation is the primary goal.
554 <h3><big><a name="TUT_COMMON"></a>Common Files</big></h3>
555 <big> The top-level file called
558 definitions and descriptions of the variables used throughout the clam
559 system. For a non-derived type of make (using only base clam
561 this file should be included near the start of the user's
563 The rules file (stored in "$/rules.def") should be included after the
565 has modified the appropriate variables that will dictate how the make
569 This scheme of including variables at the
570 top and then rules at the bottom of the user's makefile is employed in
571 all clam makefiles. For example, makefiles for C++ compilation
573 same way. The user's C++ makefile includes the C++ variables
575 in a subdirectory called "$/cpp" under the clam root) at the top of the
576 makefile and then includes the C++ rules at the bottom.<br>
577 An example
578 of a C++ makefile is shown below:
581 <small> </small><big> <tt>include cpp/variables.def <br>
585 SOURCE = chaos.cpp checkup.cpp earth_time.cpp guards.cpp istring.cpp \<br>
586 log_base.cpp mutex.cpp occurrence.cpp outcome.cpp
587 outcome_table.cpp \<br>
588 packable.cpp portable.cpp runtime_history.cpp
589 system_outcomes.cpp \<br>
590 utility.cpp version_checker.cpp version_record.cpp<br>
591 TARGETS = basis.lib<br>
593 include cpp/rules.def</tt><br>
594 </big><small></small>
596 <big>The interior of the makefile overrides the TYPE, SOURCE
597 and TARGETS variables for C++ compilation to specify what is to be
599 (basis.lib) and what it consists of (the CPP files mentioned in
601 The PROJECT variable being overridden is actually defined in the
603 a project name is a required feature of all clam makefiles.
605 <h3><big><a name="TUT_IMPORTANT_VARS"></a>Important Variables</big></h3>
606 <big>
607 The clam root directory is pointed to by an internal variable called
609 defined in $/variables.def. This variable is used by the clam
611 to find extra files that might be needed by derived makefile
613 It is important to change this to the appropriate value when you are
614 using the system in a different location. The CLAM_DIR variable
616 be directly edited in $/variables.def, or it can be overridden in the
618 of the shell running the make, or it can be passed on the command line
621 For C++ compilation, the above example
623 (for basis.lib) contains examples for most of the required
624 elements. Additional elements
625 will be discussed in the examples section or can be found in the
627 The absolutely required variables for C++ are PROJECT, TYPE, SOURCE and
630 <p><big> PROJECT is a variable that
633 of the project being compiled. This should be a word that can
635 be used as a directory name and partial component of filenames.
637 spaces and other unusual punctuation characters are discouraged.
638 All of the project's temporary directories will be created based on
640 variable. This project name should be unique across a full build;
641 otherwise files generated by compiling identical project names will be
644 <p><big> TYPE is a variable that describes
646 of project that is being compiled. This is necessary because it
648 some aspects of the compilation, such as where the compilation products
650 generated. All files generated by compilation are stored in the
652 directory (by default, either "~/hoople" in Linux or "l:\" in
653 win32). There are three TYPEs supported so far: </big></p>
655 <small> </small><big> </big><small> </small>
656 <li><big>library: indicates that the project will primarily be
660 dynamic libraries.</big></li>
661 <small> </small><big> </big><small> </small>
662 <li><big>application: indicates that the project will create
663 executables.</big></li>
664 <small> </small><big> </big><small> </small>
665 <li><big>test: indicates that the project constructs test
667 <small> </small><small></small>
669 <big> Projects of the "library" type will
671 an include directory named after the project, such as
672 "~/hoople/include/basis".
673 The include directory is created as a copy of the headers in the
675 directory . Library projects will also have their final products
677 to the lib or dll subdirectories of the build directory being created.<br>
678 Projects that are of type "application" will
679 have their executables
680 copied to the executable directory in the repository (such as
682 The "test" type of project
683 will be promoted to a subdirectory named after the PROJECT that resides
684 under the test hierarchy in the repository (such as
685 "~/hoople/tests/turbodog").
687 <p><big> SOURCE is a list of files that
690 in order to create the final products of the project. These can
692 C++ source files (*.cpp), MS-Win32 resource files (*.rc) and other
694 of source files. The list of objects to create will be determined
695 by transforming the list of SOURCE files (such as by turning a file
697 "fud.cpp" into an object called "fud.obj").
699 <p><big> TARGETS is a list of the products
701 to be created by compilation and linking. The suffix of a target
702 is a well established extension, such as ".lib", ".exe"
703 or ".dll" for MS-Win32 compilation products.
705 <h3><big><a name="TUT_VAR_ASSIGN"></a>Variable Assignment Policies</big></h3>
706 <big>
707 The assignment of variable values is mostly straightforward, but it
709 be valuable to provide a refresher. In GNU make, a variable
711 macro) can be assigned using the following syntax:
714 <small> </small><big>FRED = a b c </big><small> </small>
716 <big>This sets the variable named FRED to the value of "a
717 b c". The variable is referred to as $(FRED) when it is being
719 although its name is just FRED.<br>
720 This syntax is fine when the variable is to be
721 defined only once.
722 In many cases though, a variable is already defined and needs to be
724 to instead of redefined. Using the standard equals (=) operator
726 wipe out the previous definition, so a special assignment
730 <small> </small><big>FRED += d e f </big><small> </small>
732 <big>This is quite similar to the C syntax on integers. It
734 FRED will be given a value equal to its old value plus the new
736 In our example, FRED would be equal to "a b c d e f". Note that
739 FRED = $(FRED) d e f
740 (BAD!)<br>
742 This is not allowed in GNU make because it includes a macro's own value
743 in its definition. This causes a badly formed recursive
745 of the variable; a variable dereferencing operation (such
746 as $(FRED)) causes the variable's current value to
747 be resolved, which in turn dereferences any other variables in the
749 Thus, the reference to $(FRED) causes infinite recursion when
751 in the definition of FRED.<br>
753 In the case of variables that <u>must</u>
754 be defined by the user's makefile, the standard assignment operator
755 (via the = character) can
756 be used. This includes the PROJECT, TYPE, SOURCE, and TARGETS
758 Also, any other variables that are set only by the user's makefile can
759 use simple assignment. This category includes LOCAL_LIBS_USED,
760 LIBS_USED and others of similar nature.<br>
761 But several variables are defined partially
762 by clam, then added to within the user's makefile, and then possibly
764 after the user's makefile is processed (by the clam rules file).
765 These variables cannot use
766 standard assignment and must instead use the incremental assignment
768 operator. Variables included in this category are DEFINITIONS,
770 CLEANUPS, and many others.
772 If you are unsure about the type of variable
773 you are defining, then the incremental assignment (+=) operator is
775 to avoid trashing the variable's previous values.<br>
776
777 Note that when variables are "exported", then any make in a subshell
779 inherit the parent shell's value. This can induce some weird
781 for variables that are incrementally constructed with the +=
783 If this seems to be happening, try using the simple assignment operator
785 that variable in the sub-makefile, if this is allowed. In general
787 variables are not exported unless they MUST be seen by shell scripts
789 this does not occur overly frequently.
791 <h3><big><a name="TUT_OPTIONAL_VARS"></a>Optional Variables</big></h3>
792 <big> There are several miscellaneous
794 are useful, either within one's makefiles or when passed to GNU make on
796 line. These are described below.
798 <p><big> LOCAL_LIBS_USED is a list of
800 that are to be linked in with the library or executable being
802 These are specially formatted names; they are just the prefix part of
804 full library name. For example, if you're building a release
806 and want to link in a data structures library "i_adt.lib" (win32) or
807 "libi_adt.a" (Linux), you can specify:
809 LOCAL_LIBS_USED = i_adt
811 The appropriate prefix and suffix will be attached.
813 <p><big> EXTRA_COPIES is a list of files
814 that should be copied to a project's output folder when it is done
815 being compiled. These should be files that are not already
816 copied as the main products, such as extra data or configuration files
817 that belong with an application.
819 <p><big> EXTRA_VERSIONS is a list of
822 also need to be updated to the main build version during a
824 These are usually needed if a project compiles several executable
826 and each one performs version checking. (By default, any project
827 containing a file called "version.ini" will get a version stamp from
831 <h3><big><a name="WRITING_RULES"></a>Writing Your Own Rules</big></h3>
832 <big> One might need to write new rules
835 file types that are not directly supported by clam. There are a
837 of features provided for writing rules, but there are also some
841 All rules in makefiles need to be prefaced
842 with one of the provided "launcher" macros. These are used to
844 that the rules can be properly executed on different platforms;
846 was especially hard to implement for until these macros were developed
847 (due to what appear to be basic defects in the command line
849 All preaching aside, here are the macros:
852 <small> </small><big> </big><small> </small>
853 <li><big>HIDER: Executes a command but hides the
854 invocation. Any
856 still sent to standard out. If a verbose
857 build is being done, then all of the invocations become visible again.</big></li>
858 <small> </small><big> </big><small> </small>
859 <li><big>HIDESH: Executes a shell script but hides the
861 Similar to HIDER but supports scripts specifically.<br>
863 <small> </small><small></small>
865 <big>Here are some examples of using the macros properly.
868 command itself must be contained in single quotes:<br>
870 $(HIDER) $(MIDL) crumpet_server.idl<br>
872 <blockquote><big>MIDL is also a provided macro; it executes the
874 IDL compiler. </big></blockquote>
875 <big>$(HIDESH) $(CLAM_DIR)/postconditions.sh<br>
877 <blockquote><big>This runs a shell script that handles the end
879 make.</big></blockquote>
881 <a name="TUT_CONCLUSION"></a>Conclusion</big></h3>
882 <big> This tutorial is intended to raise
885 basic usage. Hopefully the reader will now be able to
887 simple makefiles that use . For more aggressive compilation
889 the reference section may be needed; it describes every variable and
891 used in the system. However, it is most likely the case
893 your unsupported compilation needs will also be required by others in
895 future, and it is hoped that you will contribute them to the
896 main-line support. Currently, the appropriate way to do
899 send the makefile code to the <a href="#lib_manager">library
900 administrator</a>, who will include them
901 in the next version of .
903 <center><small></small>
905 <hr noshade="noshade" size="8" width="100%"></h2>
906 <small></small></center>
908 </big><small></small>
909 <h2><big><a name="REFERENCE"></a>CLAM Reference</big></h2>
910 <small></small></center>
912 <a name="LANG_INDEP_VARS"></a><u>Language Independent Variables</u></big></h2>
913 <big> The language independent variables
915 in the file "$/variables.def". They define the overall structure
916 of a make and can usually be overridden to customize how the make is
919 <h4><big>BUILD_BEFORE</big></h4>
920 <big> This is a list of projects that need
923 before this project can be created. The items in the list are
925 as directories that contain a makefile to be run. For example, if
926 an item in BUILD_BEFORE is listed as ?fred?, then the target
928 will be executed. That target changes to the directory 'fred'
930 running the makefile there. The project in the specified
932 is created using make if needed (as determined by that directory's
934 The projects in BUILD_BEFORE are made immediately after the
938 <h4><big>ACTUAL_TARGETS, ACTUAL_FIRST_TARGETS, ACTUAL_LAST_TARGETS</big></h4>
939 <big> See below for TARGETS, FIRST_TARGETS and
942 <h4><big>BUILD_AFTER</big></h4>
943 <big> A list of directory names that
946 into after this project finishes. Each listed directory will have
948 started on any makefile found.<br>
950 <h4><big>BUILD_BEFORE<br>
952 <big> A list of directory names that
954 recursed into before this project
955 starts. Each directory listed will have make started on any
958 <h4><big>MAKEFILE_NAME</big></h4>
959 <big> A variable that specifies the name
962 for all sub-makes. It works with BUILD_BEFORE and
963 BUILD_AFTER and allows the name of the makefile in a
964 subdirectory to be changed to something other than 'makefile'.
966 supports different types of builds which are controlled by different
970 <h4><big>PARAMETER_FILE</big></h4>
971 <big> A file name that is
972 usually found at the root of the repository. The name is
973 often "build.ini", but any name can be used as the parameter file.
974 This file is an extension of the variable set included in
976 and can be used to provide compilation paramters without resorting to
978 command line. This file is associated with a particular build
980 than the support, so different releases will have different build
982 files. On systems supporting version information, the build's
984 number is stored here also.<br>
986 <h4><big>CATCHER</big></h4>
987 <big> A sub-program launcher like HIDESH
988 but this will trap errors it sees and play the build error
989 CLAM_ERROR_SOUND.<br>
991 <h4><big>CLAM_BINARY_DIR</big></h4>
992 <big> This is a folder where the helper
993 binaries for the CLAM makefile system are located. <br>
995 <h4><big>CLAM_DIR</big></h4>
996 <big> This variable points at the location
997 where the definitions and helper scripts are located. The
1000 but this can be overridden for local installations of .<br>
1002 <h4><big>CLAM_ERROR_SOUND</big></h4>
1003 <big> This is a list of sound files
1004 that should be played when a make stops with an error. It serves
1006 an audible warning that something bad happened.<br>
1008 <h4><big>CLAM_FINISH_SOUND</big></h4>
1009 <big> This is a list of sound files
1010 that should be played when the make has concluded
1011 successfully. It should play when the outer-most make
1012 has seen all targets created as intended.<br>
1014 <h4><big>CLAM_TMP</big></h4>
1015 <big> Specifies the location for temporary
1016 files generated during a make. The default value usually works
1018 This directory will be created if it does not already exist.<br>
1020 <h4><big>CLEANUPS</big></h4>
1021 <big> This is a list of files to be
1024 clean command. They are possibly acquired from the TARGETS
1026 in the user's Makefile, or by language dependent rules for
1028 Additional files can be added to this list by the user's makefile also.
1030 <h4><big>DIRTY_FILE</big></h4>
1031 <big> This variable points at a file that
1033 that some targets have been remade. It is not used at the base
1035 of clam, but language-specific versions might do something special if
1037 were remade (such as put them in a build repository).
1039 <h4><big>FAILURE_FILE</big></h4>
1040 <big> This file is used as a flag that
1043 a make has failed. The particular file used depends on the
1045 name for this makefile. It is cleared at both the beginning and
1049 <h4><big>FIRST_TARGETS</big></h4>
1050 <big> The FIRST_TARGETS are made before
1053 are created and before any executables are compiled. There must
1055 a rule for making every entry in this list, either through implicit
1057 or explicit ones provided by the user's makefile.
1059 <h4><big>FLAG_FILES</big></h4>
1060 <big> This is a list of all the files
1061 that are used for compilation flags. They are whacked at the
1063 and end of a make.<br>
1065 <h4><big>HIDER</big></h4>
1066 <big> This macro is used throughout
1068 commands that are being sent to the operating system. It can be
1069 disabled to allow a verbose make (see the NOISY macro).
1071 <h4><big>HIDESH</big></h4>
1072 <big> Just like HIDER, but this macro is
1074 for launching shell scripts. Some versions of GNU make (like
1076 have problems running scripts which don't arise when running executable
1078 Those problems led to the creation of the HIDESH macro for those
1080 cases. This is not an issue for Unix systems.
1082 <h4><big> LAST_TARGETS</big></h4>
1083 <big> The LAST_TARGETS are made after all
1086 standard targets are made. Their must be a rule for making every
1087 entry in this list, either through implicit rules or explicit ones
1089 by the user's makefile.
1091 <h4><big>NOISY</big></h4>
1092 <big> This variable can be used to cause a
1095 If the variable is non-empty, then all commands will be echoed to
1097 output. Otherwise, the default is to hide the commands that are
1099 and just show the output of running those commands.
1101 <h4><big>OP_SYSTEM</big></h4>
1102 <big> This is a flag that defines the
1105 name. This flag is sometimes used to choose the appropriate tools
1106 per platform or to conditionally compile code for system
1107 dependent interfaces. The available possibilities so far are
1109 OS2, SYSV (System V Unix), DOS, and WIN32. Only UNIX and WIN32
1111 currently very functional.
1113 <h4><big> OTHER_CLEANS</big></h4>
1114 <big> These are targets to execute before
1116 the main clean up during "make clean". These might be targets
1118 contain shell commands to execute as part of clean up or they could
1120 the "clean_subdirs" command (defined below).
1122 <h4><big>PROJECT</big></h4>
1123 <big> This is a variable that provides the
1126 project being compiled. This should be a word that can also be
1128 as a directory name and as a partial component of filenames.
1130 and other unusual punctuation characters are discouraged. All of
1131 the project's temporary directories will be created based on this
1134 <h4><big>FEISTY_MEOW_APEX</big></h4>
1135 <big> Specifies the root directory
1136 for compilation or other building activities. The
1138 is also where source code and final products of compilation reside,
1140 the default is over-ridden (see TARGETS_DIR).<br>
1142 <h4><big>SH & SHELL</big></h4>
1143 <big> These variables both point at a
1146 used for starting commands. SHELL is defined by GNU make, whereas
1149 <h4><big>SUB_FLAG_FILES</big></h4>
1150 <big> This is a list of the compilation
1153 should be destroyed only at the end of a make. They are used for
1155 with submakefiles--makefiles that were invoked by "this" makefile.<br>
1157 <h4><big>SUBMAKE_FLAG</big></h4>
1158 <big> This points to a file whose presence
1161 a "submake" performed some actions. The flag can be interpreted
1163 some language-specific versions of as a reason to set a flag
1168 <h4><big>TARGETS</big></h4>
1169 <big> These are the products to be created
1171 Each item listed in TARGETS should have a rule that knows how to create
1172 that type of file. The language independent system provides very
1173 few suffix based rules. TARGETS is filled in by the user in
1174 their file, but it is not used directly by the
1177 a generated variable called ACTUAL_TARGETS is used.<br>
1179 <h4><big>TARGETS_DIR</big></h4>
1180 <big> This folder is where all generated
1183 be stored. It is usually identical to FEISTY_MEOW_APEX but can be
1185 when the targets should be stored elsewhere.<br>
1187 <h4><big>Version components: major, minor, revision, build<br>
1189 <big> These four variables specify the
1192 particular build. They are usually stored in the
1194 The major and minor versions are the traditional 2.3, 4.0, etc
1196 of release numbers. The revision number is often used to sequence
1198 builds of that particular release, such that build 3.5.127 is the 127th
1200 of the 3.5 release.<br>
1201 A version-tagged file (such as an executable or
1203 library) with any one of the major, minor or revision numbers differing
1205 an installed build is incompatible with the installed build. An
1207 file or dynamic library will not be allowed to load other dynamic
1209 where these numbers differ.<br>
1210 The last version component is misleadingly called
1212 this number specifies the service pack level for a file. Files
1214 versions only differ in the last "build" component are intended to be
1216 with each other. The understanding is that if only that number
1218 then the external interface to the file has not changed, although the
1220 implementation may have.<br>
1222 <h2><big><a name="LANG_INDEP_RULES"></a><u>Language Independent
1223 Rules</u></big></h2>
1224 <big> The file "$/rules.def" uses the
1227 defined in "$/variables.def" together with a set of make rules to
1229 actions during compilation. The rules file should be included in
1230 the user's Makefile after the compilation variables have been
1232 for the project being compiled. The user's own targets should be
1233 placed after the directive that includes "$/rules.def".
1235 <h4><big>%.halt</big></h4>
1236 <big> These targets cause to exit,
1239 something that it considers catastrophic. An example of this
1241 be when finds an inappropriate entry in the list of objects to
1243 allowing a "make clean" on this makefile will delete files that are
1245 not intended. Hence, when finds this kind of usage, it will
1246 stop the make and issue a complaint.
1248 <h4><big>%.make</big></h4>
1249 <big> Used to compile a makefile in a
1252 "%". This rule is employed by the BUILD_BEFORE macro, but can be
1253 used in the user's makefile targets also.
1255 <h2><big><a name="LANG_INDEP_TARGETS"></a><u>Language Independent
1256 Targets</u></big></h2>
1257 <big> The following targets are defined by
1260 <h4><big>all</big></h4>
1261 <big> This is a standard target that is
1264 no particular target is specified at the make command line. It is
1265 an umbrella target that invokes all of the other targets required to
1267 a make. The order in which the major targets are created is:
1270 <small> </small><big> </big><small> </small>
1271 <li><big>FIRST_TARGETS</big></li>
1272 <small> </small><big> </big><small> </small>
1273 <li><big>TARGETS</big></li>
1274 <small> </small><big> </big><small> </small>
1275 <li><big>LAST_TARGETS</big></li>
1276 <small> </small><small></small>
1280 <big> This causes all of the files in
1282 removed and also executes all of the targets in OTHER_CLEANS. The
1283 language dependent system can override some of this behavior or it can
1284 just add more files to the list of CLEANUPS.
1286 <h4><big>clean_subdirs</big></h4>
1287 <big> This is similar to "make_subdirs" in
1290 into the subdirectories in no particular order, but it runs "make
1292 in each of them. This allows a directory hierarchy of projects to
1293 be cleaned with one command.
1295 <h4><big>finish</big></h4>
1296 <big> The "finish" target represents the
1298 of a make, whether successful or not. It reports the time and
1302 <h4><big>rm_links</big></h4>
1303 <big> This target causes all link files in
1306 directory to be deleted. This is only applicable on a Unix
1310 <h4><big>make_subdirs</big></h4>
1311 <big> This target allows a makefile to
1313 all of the subdirectories under the current directory should be scanned
1314 for makefiles and that those makefiles should be executed. If a
1316 does not exist, it is skipped. Note that the subdirectories are
1318 into in no particular order; the order depends on how the operating
1320 decides to list the directories. If the order of make is
1322 use BUILD_BEFORE instead.
1324 <h4><big>start</big></h4>
1325 <big> The "start" target represents the
1327 the make. It reports the time and date (and logs them).
1329 <h2><big><a name="LANG_INDEP_SCRIPTS"></a><u>Language Independent
1330 Files</u></big></h2>
1331 <h4><big>$(PARAMETER_FILE)</big></h4>
1332 <big> This is a special
1333 file that has at least two purposes in . It is the source of
1335 version number that will be stamped on all the appropriate DLLs and
1337 created during a build. It is also a place where build-wide
1339 directives can be included so that they do not have to be passed on the
1341 line. For C++ compilation, this is usually an INI file
1343 FEISTY_MEOW_APEX under the build folder.
1344 Here is a sample parameter file:
1346 <blockquote><big><tt><font size="-1"><big>#\</big></font></tt> <br>
1347 <tt><font size="-1"><big>[version]</big></font></tt> <br>
1348 <tt><font size="-1"><big>major=14</big></font></tt> <br>
1349 <tt><font size="-1"><big>minor=3</big></font></tt> <br>
1350 <tt><font size="-1"><big>revision=140</big></font></tt> <br>
1351 <tt><font size="-1"><big>build=0</big></font></tt> </big><small> </small>
1352 <p><big><tt><font size="-1"><big>DEBUG=t</big></font></tt> <br>
1353 <tt><font size="-1"><big>OPTIMIZE=t</big></font></tt> <br>
1355 <small> </small></blockquote>
1356 <big>Note the bizarre comment at the top of the makefile; this is
1359 the "[version]" section marker. The comment is required because
1361 build parameter file is pulled directly into the makefile code to set
1363 variables after the version stamp. Without a comment in front of
1364 the section, a syntax error would result. The "[version]" section
1365 marker is required because this file is also sometimes treated as a
1367 in order to read the version stamp.<br>
1368 The build version is stored in the first four
1369 entries. Our interpretation of the stamp is standard for "major"
1370 and "minor". We treat the "revision" as a build revision number;
1371 within a release, there will be numerous revisions--one for each new
1373 that is performed. We then treat the "build" entry as a patch
1375 within that particular build. When we perform our version
1377 only the first three entries are compared; the patch level in "build"
1379 considered irrelevant.
1381 This example also specifies that the build
1382 should be a debug style (rather than release) build and that it should
1383 be optimizer. We can also see that
1384 the flags for bounds checker instrumentation and true time
1385 analysis support are commented out.<br>
1387 <h4><big>badness_catcher.sh</big></h4>
1388 <big> Runs the command line passed
1389 in as a sub-shell and looks for error conditions. If an error
1391 the build is stopped and the CLAM_ERROR_SOUND is played.<br>
1393 <h4><big>datestamp.sh</big></h4>
1394 <big> Echoes the time and date. This
1397 file to make the cross-platform difference less annoying.<br>
1399 <h4><big>exit_make.sh</big></h4>
1400 <big> Causes the make to stop dead in its
1403 <h4><big>postconditions.sh</big></h4>
1404 <big> Invoked at the end of the
1406 portion of a make.<br>
1408 <h4><big>preconditions.sh</big></h4>
1409 <big> Invoked at the beginning of the
1410 language-invariant portion of a make.<br>
1412 <h4><big>starter.sh</big></h4>
1413 <big> This shell script executes a command
1416 to it as its parameters and logs error conditions to standard
1418 It's used by the CATCHER macro.
1421 <hr noshade="noshade" size="8" width="100%"></h2>
1423 <a name="CPP_VARS"></a><u>C++ Specific Variables</u></big></h2>
1424 <big> These variables are used throughout
1427 support. They are defined in "$/cpp/variables.def".
1429 <h4><big>BASE_CPU</big></h4>
1430 <big> Allows specification of the
1432 build is targeted for. This is needed when special actions must
1434 taken for different processor types. Valid values currently
1436 m68k (for Motorola 68000 series), m68340 (specifically the 68340),
1437 x86 (intel 386 and upwards), and ppc860 (the PowerPC 860).
1439 <h4><big>BUILD_LIST_FILE</big></h4>
1440 <big> The list of files that must
1441 be rebuilt. This is only used with compilers that support
1443 of multiple source files with one invocation of the compiler (currently
1447 <h4><big>BUILD_WHACK_FILE</big></h4>
1448 <big> A list of object files that must be
1451 the make fails. This is only relevant in the same situations as
1452 BUILD_LIST_FILE.<br>
1454 <h4><big>COMPILER</big></h4>
1455 <big> This variable chooses the specific
1458 for the compiler. Not all operating system choices above are
1460 with the COMPILER choices, but generally it is fairly obvious which are
1461 supported. The current possibilities include BORLAND_DOS,
1463 UNIX (default cc), GNU_OS2, GNU_LINUX, OBJECT_CENTER (Saber compiler),
1465 VISUAL_CPP, and DIAB3.
1467 <h4><big>COMPILER_FLAGS</big></h4>
1468 <big> This is the list of flags passed to
1471 and compiler. It is composed of the SYSTEM, the DEFINITIONS, the
1473 and any user-included options. If flags that don't fit one of the
1475 are needed, they can be added here.
1477 <h4><big>CONSOLE_MODE</big></h4>
1478 <big> This causes the program
1479 to be generated as a console application. This is relevant in
1481 (such as win32) where programs have a split personality depending on
1483 they are to have graphical user interfaces or just console interfaces.
1485 <h4><big>DEBUG_FLAGS</big></h4>
1486 <big> These are flags used for generating
1488 versions of object files, such as ones that include debugging code
1490 for gdb) or ones that add code for profiling (e.g., gprof). Possible
1492 in the Sun CenterLine Compiler environment are -g for debugging code
1496 <h4><big>DEFINITIONS</big></h4>
1497 <big> This is a list of compiler flags
1500 value of C or C++ macros. These usually have the format of
1502 but in this particular variable only the <flag> itself should be
1504 (because the compiler option characters ?-D? are added automatically).
1506 <h4><big>DEPENDENCY_ADDITIONS</big></h4>
1507 <big> This is a list of extra flags that
1509 to the auto-dependency tool. The list can vary for each compiler.
1511 <h4><big>DEPS_FILE</big></h4>
1512 <big> This file is where the
1515 is stored. The "makedep" program is used to generate
1517 information for the files listed in SOURCE. During a build, the
1519 is pulled into the actual code of the makefile; this causes the
1521 to be automatically included so that they can dictate the files that
1525 <h4><big>EXTRA_VERSIONS</big></h4>
1526 <big> This is a list of version files that
1528 to be updated to the main build version during a compilation.
1530 are usually needed if a project compiles several executable files, and
1531 each one performs version checking. By default, any project
1533 a file called "version.ini" will get a version stamp from the main
1537 <h4><big>LIBRARIAN_FLAGS</big></h4>
1538 <big> This is a list of flags that are
1540 library creation tool. Sometimes this must be overridden for a
1544 <h4><big>LIBS_USED</big></h4>
1545 <big> These are code libraries that the
1547 depend upon. They are searched for in any of the directories
1549 in the LIBRARY_SEARCH_PATH.
1551 <h4><big>LOAD_FLAG_PREFIX & LOAD_FLAG_SUFFIX</big></h4>
1552 <big> These tell the linker and loader how
1555 the files and where to locate library components. The prefix is listed
1556 on the compilation command line before the object files are listed, and
1557 the suffix after. The prefix should contain information such as the
1559 to be searched for code libraries (although they should be added to
1560 LIBRARY_SEARCH_PATH).
1561 In the suffix definition, actual library loading statements (like
1563 can be included (although they should be listed in a different form in
1564 LIBS_USED or LOCAL_LIBS_USED).
1566 <h4><big>LOCAL_LIBS_USED</big></h4>
1567 <big> The names in this list actually
1570 to be recompiled when the libraries listed have changed. To
1572 this, these libraries MUST be located in the STATIC_LIBRARY_DIR rather
1574 at some arbitrary place on the LIBRARY_SEARCH_PATH. These
1576 also must follow the special naming convention followed by ; if
1578 is an entry in this list, then a library called "basis.lib" will be
1582 <h4><big>NO_COMPILE</big></h4>
1583 <big> Specifies that no compilation
1584 should be performed. Nothing in the SOURCE or TARGETS macros will
1588 <h4><big>NO_DEPS</big></h4>
1589 <big> This is an exclusion flag. If
1592 then no auto-dependency files will be generated. This is useful
1594 you're missing the makedep tool and trying to compile it.<br>
1596 <h4><big>OBJECTS</big></h4>
1597 <big> The OBJECTS are all those files that
1600 created during compilation. Usually this list is filled based on
1601 the files in SOURCE.
1603 <h4><big>OPTIMIZE</big></h4>
1604 <big> Causes the make to create optimized
1606 The default optimization is for speed.
1608 <h4><big>REBUILD</big></h4>
1609 <big> If the REBUILD variable is
1611 files listed in the SOURCE variable are touched. This should
1613 all of those files to be rebuilt during the compilation.
1615 GNU make will complain that a file is newer than the current time, but
1616 this does not usually cause any problems.
1618 <h4><big>SOURCE</big></h4>
1619 <big> The SOURCE variable is a list of
1622 to be compiled in order to create the final products of the
1624 These can be C++ source files (*.cpp), Win32 resource files (*.rc)
1626 other types of source files. The list of objects to create will
1628 determined by transforming the list of SOURCE files (such as by turning
1629 a file called "fud.cpp" into an object called "fud.obj"). More
1631 types will be added as they are needed.
1633 <h4><big>STATIC</big></h4>
1634 <big> Causes the make to create statically
1637 Executables or dynamic libraries will not link in any compiler supplied
1638 dynamic libraries, nor will they require them during run-time.
1640 <h4><big>TYPE</big></h4>
1641 <big> This is a variable that describes
1643 project that is being compiled. Knowing the type of project is
1645 because it controls some elements of the compilation and also of the
1647 promotion of the compiled products. There are three TYPEs
1652 <small> </small><big> </big><small> </small>
1653 <li><big>library: indicates that the project will be primarily
1657 dynamic libraries.</big></li>
1658 <small> </small><big> </big><small> </small>
1659 <li><big>application: indicates that the project will create
1660 executables.</big></li>
1661 <small> </small><big> </big><small> </small>
1662 <li><big>test: indicates that the project constructs test
1663 programs.</big></li>
1664 <small> </small><small></small>
1666 <big>Projects of the "library" type will follow the special
1668 their include directory (which is created as a copy of headers in the
1670 directory). Library projects will also have their final products
1671 copied to the lib or dll subdirectories of the build directory being
1673 Projects that are "application"s will have their executables copied to
1674 the executable directory in the build. And "test" projects will
1676 promoted to a subdirectory named after the PROJECT that resides under
1678 test hierarchy in the build.
1680 <h2><big><a name="DIRECTORY_VARS"></a><u>C++ Directory Structure
1681 Variables</u></big></h2>
1682 <h4><big>BASE_OUTPUT_PATH</big></h4>
1683 <big> This is the parent directory
1684 for object files generated for the specified type of CPU and the style
1686 build (e.g. debug or release builds).<br>
1688 <h4><big>CPU_BUILD_DIR</big></h4>
1689 <big> This variable can be used to
1692 names used for output. It includes the cpu name and the type of
1695 <h4><big>DYNAMIC_LIBRARY_DIR</big></h4>
1696 <big> The directory where dynamic
1698 stored after creation.<br>
1700 <h4><big>EXECUTABLE_DIR</big></h4>
1701 <big> The directory where executable files
1703 stored after creation.<br>
1705 <h4><big>FINAL_DIR</big></h4>
1706 <big> This is the name of the directory
1709 compilation products are stored, currently only import libraries for
1710 dynamic libraries.
1711 It is usually a directory under the OUTPUT_PATH named "final".
1713 <h4><big>HEADER_SEARCH_PATH</big></h4>
1714 <big> This is a list of directories that
1717 for C++ header files (files ending in ?.h?).
1719 <h4><big>HOOPLE_HEADERS</big></h4>
1720 <big> The two standard places to look for
1722 (the repository and the third party directory) are listed in this
1725 <h4><big>HOOPLE_LIBRARIES</big></h4>
1726 <big> This is where our libraries are
1727 located. It is usually a subdirectory called "lib" under the
1731 <h4><big>LIBRARY_SEARCH_PATH</big></h4>
1732 <big> This is a list of directories that
1735 for C++ library archives (files ending in ".a" or ".lib").
1737 <h4><big>LOCAL_HEADERS</big></h4>
1738 <big> This variable provides a way to
1741 prior to the default locations in the search path. For example,
1743 you are compiling locally and have some headers that are not present in
1744 the build you are using, then you can specify where they are in this
1747 <h4><big>LOCAL_LIBRARIES</big></h4>
1748 <big> This variable allows other library
1750 to be added prior to the default search locations. This enables
1752 static or import libraries to be used instead of the standard ones
1756 <h4><big>STATIC_LIBRARY_DIR</big></h4>
1757 <big> This is the location where code
1759 to be copied during promotion and where they are to be searched for
1761 listed in LOCAL_LIBS_USED. Under Unix, these libraries have a
1763 suffix and are created with the "ar" program. Under Win32,
1765 libraries have a ?.lib? suffix and are created with "link".
1767 <h4><big>OBJECT_DIR</big></h4>
1768 <big> This is where object files will be
1771 compilation for the target type being produced.
1773 <h4><big>OUTPUT_DIRECTORY_LIST</big></h4>
1774 <big> This is a list of directories that
1776 created under the OUTPUT_PATH. It contains the "final" directory
1777 where all finished products are stored, as well as all the intermediate
1778 directories for objects.
1780 <h4><big>OUTPUT_PATH</big></h4>
1781 <big> This is the temporary file storage
1783 Any files that are created during the compilation process will be
1785 under here in a subdirectory named after the PROJECT.
1787 <h4><big>OUTPUT_ROOT</big></h4>
1788 <big> This specifies the root portion of
1791 It lets a PC build use drive letters for the root, while a Unix build
1793 specify a directory hierarchy.
1795 <h4><big>SEARCH_DIRS</big></h4>
1796 <big> This is a list of directories that
1799 for both C++ header files and for C++ code libraries. The items
1801 on SEARCH_DIRS will be added to both the LIBRARY_SEARCH_PATH and the
1802 HEADER_SEARCH_PATH.
1803 The reasoning behind this variable is lost in antiquity.
1805 <h4><big>TESTS_DIR <br>
1807 <big> The directory where test programs
1809 stored after creation.<br>
1811 <h4><big>THIRD_PARTY_DIR</big></h4>
1812 <big> Third party components are sometimes
1815 creation of products. The directory is expected to have a
1817 containing "include" and "lib" subdirectories where headers and
1821 <h2><big><a name="CPP_FLAGS"></a><u>Compiler Dependent Flags</u></big></h2>
1824 <big> This is the name of the C++ compiler
1827 <h4><big>COMPILER_HEADER_DIR</big></h4>
1828 <big> This is where the compiler's header
1831 root directory is located. It is usually based on the root
1834 <h4><big>COMPILER_LIBRARY_DIR</big></h4>
1835 <big> This is where the code libraries for
1838 are located. It is usually based on the root directory.
1840 <h4><big>COMPILER_ROOT_DIR</big></h4>
1841 <big> This should automatically be set to
1844 local directory where the C++ compiler is located.
1846 <h4><big>CREATE_LIBRARY_FLAG</big></h4>
1847 <big> This flag, if required, specifies
1850 must precede the name of a library to create. It is passed to the
1851 library creation tool.
1853 <h4><big>DEF_FILE</big></h4>
1854 <big> This flag only applies to Win32
1856 It specifies the name of a DEF file for all of the products created in
1859 <h4><big>LIB_PREFIX & LIB_SUFFIX</big></h4>
1860 <big> The portions of a library's name
1861 dictated by the operating system. For example, on Unix the prefix
1863 and the suffix is ".a", leading to library names like "libbasis.a" for
1865 basis library. On win32, the prefix is "" and the suffix is
1867 to library names like "basis.lib".<br>
1869 <h4><big>LIBRARY_NAME_FLAG</big></h4>
1870 <big> This flag contains the text that
1873 that will be included in a link. It is often "-l".
1875 <h4><big>LIBRARY_PATH_FLAG</big></h4>
1876 <big> This flag provides the text needed
1879 library search path. Multiple occurrences of this flag followed
1881 a directory name are allowed by most compilers.
1883 <h4><big>LIBRARY_TOOL</big></h4>
1884 <big> This is the name of the program
1889 <h4><big>LINK_TOOL</big></h4>
1890 <big> This is the name of the program that
1892 This is sometimes the same as the compiler (CC) and sometimes the same
1893 as the librarian (LIBRARY_TOOL).
1895 <h4><big>LINKER_OPTION_SEPARATOR</big></h4>
1896 <big> In some compilers, linker options
1899 from compiler options that occur on the same command line. This
1901 serves that purpose.
1903 <h4><big>LINKER_OUTPUT_FLAG</big></h4>
1904 <big> This flag is sometimes required by a
1907 specifying the name of the library or executable that it is creating.
1909 <h4><big>OBJECT_NAME_FLAG</big></h4>
1910 <big> This flag is used to specify the
1913 file being created. It is passed to the compiler to override
1915 default name would be used.
1917 <h2><big><u><a name="vcpp_only"></a>Microsoft-Visual C++ Only</u><br>
1919 <h4><big>USE_MFC</big></h4>
1920 <big> This flag only applies to Visual C++
1923 that MFC is to be used in creating this project. This is usually
1924 the case for GUI applications.
1926 <h4><big>VC_ROOT</big></h4>
1927 <big> This is an override that allows the
1930 directory to be customized without changing the code. If
1932 is set (either in a makefile or as an external variable), then it will
1933 be used in place of the COMPILER_ROOT_DIR. The best way to use
1935 override is as an external environment variable; this allows makefiles
1936 to remain the same despite your local configuration of the compiler.
1938 Note that this variable should use
1940 where DOS/Win32 would use backslashes. Also, if you have
1942 Visual C++ in a directory path containing space characters, then please
1943 use the 8.3 notation for the directories containing the spaces; this
1945 the name to be passed around successfully. For example...
1947 <center><small></small><big> </big><big> </big><big> </big><big> </big><big></big><big></big><big>
1948 </big><big> </big><big> </big><big> </big><big>
1949 </big><big> </big><big> </big><big> </big><small> </small><small></small><small>
1950 </small><small> </small><small> </small><small> </small><small>
1951 </small><small> </small><small> </small><small> </small><small> </small><small></small><small>
1952 </small><small> </small><small> </small><small> </small>
1953 <table cellpadding="8" cellspacing="4">
1956 <td><big> </big><small> </small>
1957 <center><big><u>If Visual C++ Is Installed In</u></big></center>
1958 <small> </small><big> </big></td>
1959 <td><big> </big><small> </small>
1960 <center><big><u>Then VC_ROOT Should Be</u></big></center>
1961 <small> </small><big> </big></td>
1964 <td><big> </big><small> </small>
1965 <center><big>c:\devstudio\vc</big></center>
1966 <small> </small><big> </big></td>
1967 <td><big> </big><small> </small>
1968 <center><big>c:/devstudio/vc</big></center>
1969 <small> </small><big> </big></td>
1972 <td><big> </big><small> </small>
1973 <center><big>c:\program files\devstudio\vc</big></center>
1974 <small> </small><big> </big></td>
1975 <td><big> </big><small> </small>
1976 <center><big>c:/progra~1/devstudio/vc</big></center>
1977 <small> </small><big> </big></td>
1981 <small></small></center>
1982 <h4><big>VCS_ROOT</big></h4>
1983 <big> Similarly to the VC_ROOT, this
1985 at the root of the C# support for Visual Studio.Net.<br>
1987 <h4><big>FRAMEWORK_DIR</big></h4>
1988 <big> This variable specifies the location
1990 .Net framework directory. On MS-Windows XP, the default should be
1991 fine. For MS-Windows 2000 or other Win32 OSes, the windows
1993 should be "winnt" instead. If the operating system is configured
1994 in a non-default way, the framework directory can be specified in an
1995 environment variable.<br>
1997 <h4><big>VCPP_USE_BASE</big></h4>
1998 <big> Specifies that standard Win32
2002 <h4><big>VCPP_USE_GUI</big></h4>
2003 <big> Specifies that the MFC libraries
2007 <h4><big>VCPP_USE_OLE</big></h4>
2008 <big> Specifies that the COM / OLE
2012 <h4><big>VCPP_USE_RPC</big></h4>
2013 <big> Specifies that the MS-RPC libraries
2017 <h4><big>VCPP_USE_SOCK</big></h4>
2018 <big> Specifies that the MS-WinSock
2022 <h2><big><a name="CPP_RULES"></a><u>C++ Specific Rules</u></big></h2>
2023 <big> These types of targets have one
2026 if any of the items that a target depends on in SOURCE or
2028 or included files or whatever have changed since the last time the
2030 was created, then it is recompiled.
2032 <h4><big>%.bad</big></h4>
2033 <big> Causes the make to die. This
2034 is added when an incorrect file type is spotted in a list of targets.<br>
2036 <h4><big>%.dll</big></h4>
2037 <big> These create dynamically linked
2041 <h4><big>%.elf</big></h4>
2042 <big> Creates elf-formatted binaries for
2044 firmware build (a specialized RTOS is the only one currently supported).<br>
2046 <h4><big>%.exe</big></h4>
2047 <big> This creates an executable program
2050 the objects and libraries specified. It is therefore important in
2051 a makefile to only have executables that depend on the same group
2052 of object files. The hidden agenda in the "exe" type of target is
2053 that a file ending in ".cpp" must exist; this is taken as the root of
2055 executable. It should usually contain the main() function (or its
2058 <h4><big>%.lib</big></h4>
2059 <big> This creates static libraries from
2064 <h4><big>%.nil</big></h4>
2065 <big> A blank target for test compiles.<br>
2067 <h4><big>%.obj</big></h4>
2068 <big> These create object files from C++
2071 (files ending in .c or .cpp).
2073 <h4><big>%.res</big></h4>
2074 <big> These create compiled resource files
2079 <h2><big><a name="CPP_TARGETS"></a><u>C++ Specific Targets</u></big></h2>
2081 check_requirements</big></h4>
2082 <big> This target ensures that certain
2084 of the makefile are present. It complains and aborts the make if
2087 <h4><big>post_compilation</big></h4>
2088 <big> This target finalizes the
2091 the postconditions script. If PROMOTE is true, then the final
2093 are copied into the repository.
2095 <h4><big>pre_compilation</big></h4>
2096 <big> This target executes the
2097 preconditions script
2098 to set up the compilation's output directories.
2100 <h4><big>rebuild</big></h4>
2101 <big> This target performs the actions of
2103 This mainly involves touching all of the files in SOURCE before the
2107 <h2><big><a name="CPP_SCRIPTS"></a><u>C++ Specific Files</u></big></h2>
2108 <h4><big>postconditions.sh</big></h4>
2109 <big> After a compilation has succeeded,
2112 script performs the final actions required. The nature of these
2114 depends on the type of project being made. For a library project,
2115 the script copies the headers to the project's include directory and
2117 libraries to the appropriate locations. For application and test
2118 program targets, the script copies the final products to the
2120 repository directory.
2122 <h4><big>preconditions.sh</big></h4>
2123 <big> Before any targets are compiled, the
2125 script ensures that the appropriate output directories exist for the
2127 The script also calls the version utilities to update the project's
2129 file and to create any required resource files.<br>
2131 <h4><big>rebuild_oldies.sh</big></h4>
2132 <big> Used for compilers that support
2135 in one invocation. This is launched to compile a batch of sources
2137 catch any errors.<br>
2139 <hr noshade="noshade" size="8" width="100%">
2140 <center><small></small>
2141 <h2><big><a name="EXAMPLES"></a>CLAM Example Makefiles</big></h2>
2142 <small></small></center>
2143 <big> These examples show some common
2145 how is used. The makefiles below are actually used in real
2149 <h3><big>Library-Only Makefile</big></h3>
2150 <big>This example creates a dynamic library.
2153 <small> </small><big> <tt>include cpp/variables.def</tt> </big><small>
2155 <p><big><tt>PROJECT = mechanisms</tt><br>
2156 <tt>TYPE = library</tt> <br>
2157 <tt>SOURCE = delayer.cpp eventmgr.cpp event_po.cpp heartbea.cpp
2160 <tt> libmain.cpp monitor.cpp semaphor.cpp state_ma.cpp
2162 time_sta.cpp</tt> <br>
2163 <tt>TARGETS = mechanisms.dll</tt> <br>
2164 <tt>LOCAL_LIBS_USED = basis</tt> <br>
2165 <tt>DEFINITIONS += BUILD_MECHANISMS USE_HOOPLE_DLLS</tt> </big></p>
2166 <small> </small><big> </big><small> </small>
2167 <p><big><tt>include cpp/rules.def</tt></big></p>
2168 <small> </small><small></small>
2170 <big>The dynamic library created here is mechanisms.dll. The
2173 in also. The file "roller.cpp" will also be copied to the build
2175 include path, presumably since it is a template code file.
2177 <h3><big>Library Plus Executable Makefile</big></h3>
2178 <big>This example shows the basis makefile with a couple of test
2184 <small> </small><big> <tt>include cpp/variables.def</tt> </big><small>
2186 <p><big><tt>PROJECT = basis</tt> <br>
2187 <tt>TYPE = library</tt> <br>
2188 <tt>SOURCE = chaos.cpp checkup.cpp guards.cpp \</tt> <br>
2189 <tt> istring.cpp itime.cpp logger.cpp matrix.cpp
2190 portable.cpp \</tt> <br>
2191 <tt> realtime.cpp textdump.cpp timezone.cpp utility.cpp \</tt> <br>
2192 <tt> version_checker.cpp version_record.cpp</tt> <br>
2193 <tt>TARGETS = basis.lib t_string.exe t_alloc.exe</tt> </big></p>
2194 <small> </small><big> </big><small> </small>
2195 <p><big><tt>include cpp/rules.def</tt></big></p>
2196 <small> </small><small></small>
2198 <big>Note that the executables
2199 "t_string.exe" and "t_alloc.exe" require files called "t_string.cpp"
2201 "t_alloc.cpp" to exist. These files are expected to contain the
2203 or "WinMain()" functions (or the MFC application object). All of
2205 files in the SOURCE variable will be included in each final executable.
2207 <h3><big>Executable-Only Makefile</big></h3>
2208 <big>This example is produces several test programs that exercise
2214 <small> </small><big> <tt>include cpp/variables.def</tt> </big><small>
2216 <p><big><tt>PROJECT = t_basis</tt> <br>
2217 <tt>TYPE = test</tt> <br>
2218 <tt>SOURCE = instance.cpp t_basis.rc</tt> <br>
2219 <tt>TARGETS = t_alloc.exe t_chaos.exe t_checku.exe t_dattim.exe \</tt>
2221 <tt> t_matrix.exe t_sequen.exe t_sorts.exe t_string.exe \</tt> <br>
2222 <tt> t_texdmp.exe</tt> <br>
2223 <tt>LOCAL_LIBS_USED = basis</tt> </big></p>
2224 <small> </small><big> </big><small> </small>
2225 <p><big><tt>include cpp/rules.def</tt></big></p>
2226 <small> </small><small></small>
2228 <big>The programs "t_alloc.exe" and so on will require C++ files
2231 prefix (t_alloc.cpp) to contain the main program (as in the previous
2233 The items in the SOURCE list will be included in each executable, and
2235 basis library will be linked in.
2237 <h2><big><a name="CLAM_HINTS"></a>CLAM Hints</big></h2>
2238 <big> This section
2239 is devoted to untangling snags that have been encountered in the
2241 Hopefully problems you encounter will be discussed here. Please
2243 any new problems found to the <a href="#lib_manager">library
2246 <h3><big>Problem:</big></h3>
2247 <big> A message like:
2250 <small> </small><big> </big><small> </small>
2252 <small> </small><big>make: *** No rule to make target
2253 `o:/x86_w32_rel/project/final/myproj.dll',
2254 needed by `all'. Stop. </big><small> </small>
2256 <small> </small><small></small>
2258 <big>is displayed during a make.
2260 <h3><big>Solution:</big></h3>
2261 <big> The most frequent reason for
2264 similar to the above is that there is a file listed in SOURCE that
2266 does not exist or that is capitalized differently from how it is
2268 Check that all the files in SOURCE are in the makefile's directory and
2269 that the exact spelling of those files (including their case) is
2272 Another potential cause of this problem is
2273 if a file is included in the SOURCE that does not
2275 The standard compilable files are supported (*.cpp, *.c, *.rc), but it
2276 is possible that a makefile must handle a non-standard extension (such
2277 as *.idl). Either the user's makefile must supply a rule for
2279 this type of file or the user must negotiate with the
2281 to get that type of target added to the support.
2283 <h3><big>Problem:</big></h3>
2284 <big> Clam is complaining about programs
2289 <h3><big>Solution:</big></h3>
2290 <big> The most frequent cause of this
2293 not being on your path. The compilation tools bin (~/hoople/bin)
2294 directory must be in
2297 Problems are occasionally seen when the PATH
2298 contains directory names that have spaces in them. Try using the
2299 shorter 8.3 form of the directory name.
2301 An even more obscure situation sometimes
2302 occurs: paths with networked drives seem to somehow hide paths with
2304 are listed later in the PATH variable. The cause of this is
2306 although it was thought to be caused by NetWare at one point. To
2308 the situation, move the local paths before the networked ones.<br>
2311 <hr noshade="noshade" size="8" width="100%">
2312 <center><small></small>
2313 <h2><big><a name="ACKS"></a>Acknowledgements</big></h2>
2314 <small></small></center>
2315 <center><big>Thanks to April Bly Monnen for the wonderful cover
2317 </big><small></small>
2318 <p><big>Thanks to Kevin Wika for some early help with makefiles.
2320 <small></small><big><big>
2321 </big></big><small></small>
2322 <hr noshade="noshade" size="8" width="100%"></center>