]> git.ipfire.org Git - thirdparty/cups.git/blame - doc/help/spec-cmp.html
Drop "contents" requirement from source file header. Most IDEs now provide a list of
[thirdparty/cups.git] / doc / help / spec-cmp.html
CommitLineData
745129be 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4744bd90 2<HTML>
3<!-- SECTION: Specifications -->
4<HEAD>
e1d6a774 5 <TITLE>CUPS Developer Guide</TITLE>
178cb736 6 <LINK REL="STYLESHEET" TYPE="text/css" HREF="../cups-printable.css">
4744bd90 7</HEAD>
8<BODY>
9
178cb736
MS
10<H1 CLASS="title">CUPS Developer Guide</H1>
11
12<P>This developer guide documents the guidelines and processes we use when developing and maintaining CUPS and related software. Our goal is to provide reliable and efficient software and documentation that addresses the needs of our users.</P>
4744bd90 13
a29fd7dd
MS
14<H2 CLASS="title"><A NAME="OVERVIEW">Overview</A></H2>
15
16<P>CUPS is developed by Apple Inc. and distributed as open source software under a combination of GNU GPL2 and GNU LGPL2 licenses with exceptions to allow linking to OpenSSL (which has a GPL-incompatible license) and for developers on Apple's operating systems to develop CUPS-based software until alternate license terms. Significant contributions to CUPS must be licensed to Apple using the <A HREF="http://www.cups.org/AppleContributorAgreement_2011-03-10.pdf">Apple Contributor Agreement</A>.</P>
17
18<P>Apple releases updates to the CUPS software approximately every three months. Each release has a version number consisting of the major version (currently 1), minor version (currently 6), and patch version (starting at 0) separated by the period, for example "1.6.0". Releases where only the patch version number changes will contain only bug fixes to the previous release, for example "1.6.1" includes bug fixes for the "1.6.0" release. New features require the major or minor version numbers to change, for example "1.6.0" release contains new features compared to the "1.5.3" release. Multiple beta and "candidate" releases generally precede each new feature release, for example "1.5b1", "1.5b2", and "1.5rc1" preceded the "1.5.0" release. Finally, we also post regular Subversion snapshot releases, for example "1.6svn-r10486", which represent a snapshot of the development for the next feature release.</P>
19
20<P>CUPS interfaces, including the C APIs and command-line arguments, environment variables, configuration files, and output format, are stable across patch versions and are generally backwards-compatible with interfaces used in prior major and minor versions. However, program interfaces such as those used by the scheduler to run filter, port monitor, and backend processes for job processing should only be considered stable from the point of view of a filter, port monitor, or backend. Software that simulates the scheduler in order to run those programs outside of CUPS must necessarily be updated when the corresponding interface is changed in a subsequent CUPS release, otherwise undefined behavior can occur.</P>
21
22<P>CUPS C APIs starting with an underscore (_) are considered to be private to CUPS and are not subject to the normal guarantees of stability between CUPS releases and must <em>never</em> be used in non-CUPS source code. Similarly, configuration and state files written by CUPS are considered private if a corresponding man page is not provided with the CUPS release. <em>Never</em> rely on undocumented files or formats when developing software for CUPS. <em>Always</em> use a published C API to access data stored in a file to avoid compatibility problems in the future.</P>
23
24
4744bd90 25<H2 CLASS="title"><A NAME="COMMUNICATION">Communication</A></H2>
26
27<H3><A NAME="CONTACT">How to Contact the Developers</A></H3>
28
a29fd7dd 29<P>The <A HREF="http://lists.cups.org/">CUPS Mailing Lists</A> are the primary means of asking questions and informally discussing issues and feature requests with the CUPS developers and other experienced CUPS users and developers. Table 1 shows the available mailing lists and their focus:</P>
4744bd90 30
31<DIV CLASS="table"><TABLE SUMMARY="CUPS Forums">
a29fd7dd 32<CAPTION>Table 1: CUPS Mailing Lists</CAPTION>
4744bd90 33<TR>
a29fd7dd 34 <TH>List</TH>
4744bd90 35 <TH>Focus/Purpose</TH>
36</TR>
37<TR>
a29fd7dd
MS
38 <TD>cups</TD>
39 <TD>General discussion and usage questions for the CUPS software</TD>
4744bd90 40</TR>
41<TR>
a29fd7dd
MS
42 <TD>cups-bugs</TD>
43 <TD>Discussion of bugs and issues in the CUPS software</TD>
4744bd90 44</TR>
45<TR>
a29fd7dd
MS
46 <TD>cups-commit</TD>
47 <TD>Report of all commits to the Subversion repository (read-only)</TD>
4744bd90 48</TR>
49<TR>
a29fd7dd
MS
50 <TD>cups-dev</TD>
51 <TD>Development questions and discussion of new features in the CUPS software</TD>
4744bd90 52</TR>
53</TABLE></DIV>
54
a29fd7dd 55
4744bd90 56<H3><A NAME="SUBMIT">How to Submit a Bug Report or Feature Request</A></H3>
57
a29fd7dd
MS
58<P>The CUPS "<A HREF="http://www.cups.org/str.php">Bugs &amp; Features</A>" page provides access to the CUPS <em>Software Trouble Report</em> (STR) database and is the formal way to submit a bug report or feature request to the CUPS developers. Please note, however, that we <em>do not</em> provide answers to usage questions or resolve problems in third-party software on this page - use the <A HREF="#CONTACT">CUPS Mailing Lists</A> for that instead.</P>
59
60<P>Unlike discussions that occur on the CUPS Mailing Lists, formal bug reports and feature requests must be acted on by the CUPS developers. This does not mean that every bug report is resolved or every feature request is implemented, but we do respond and keep track of them all for posterity.</P>
61
62<BLOCKQUOTE>Please use the search feature of the Bugs &amp; Features page before submitting a new bug report or feature request. If you see an existing report that matches your issue, please post a message to that report ("I have this issue as well", "I would also like to see", etc.) rather than submitting a new report. This helps speed the resolution of your issue by reducing the CUPS developers' work load and identifying popular issues.</BLOCKQUOTE>
63
4744bd90 64
65<H3><A NAME="PATCH">How to Prepare a Patch</A></H3>
66
a29fd7dd 67<P>When submitting a bug report or feature request, you can include patch files that resolve the bug or implement the feature to speed the inclusion of that bug fix or feature in a new CUPS release. For changes to existing files, we prefer a unified diff against the current Subversion <VAR>trunk</VAR> branch, which can be generated easily using the following Subversion command:</P>
4744bd90 68
69<PRE CLASS="command">
70svn diff >filename.patch
71</PRE>
72
a29fd7dd 73<P>If you produce a patch using a released source archive, use one of the following commands instead:</P>
4744bd90 74
75<PRE CLASS="command">
76diff -u oldfilename filename >filename.patch
77
78diff -urN olddirectory directory >filename.patch
79</PRE>
80
a29fd7dd
MS
81<P>New files and files with significant changes can be submitted in their entirety, however that may delay the adoption of your changes.</P>
82
83<BLOCKQUOTE><B>Note:</B>
4744bd90 84
a29fd7dd 85<P>Patches and files must conform to the standards outlined in the "<A HREF="#CODING">Coding Guidelines</A>" and "<A HREF="#MAKEFILES">Makefile Guidelines</A>" sections in this document. In addition, since Apple Inc. provides CUPS under multiple licenses, we require that you <A HREF="http://www.cups.org/AppleContributorAgreement_2011-03-10.pdf">license</A> significant changes and files to us for inclusion in CUPS. The CUPS developers will inform you if licensing is required.</P></BLOCKQUOTE>
4744bd90 86
87
88<H2 CLASS="title"><A NAME="PRACTICES">Software Development Practices</A></H2>
89
90<H3><A NAME="VERSIONS">Version Numbering</A></H3>
91
a29fd7dd
MS
92<P>CUPS uses a three-part version number separated by periods to represent the major, minor, and patch release numbers. Major release numbers indicate large design changes or backwards-incompatible changes to the CUPS API or CUPS Imaging API. Minor release numbers indicate new features and other smaller changes which are backwards-compatible with previous CUPS releases. Patch numbers indicate bug fixes to the previous feature release.</P>
93
94<BLOCKQUOTE><B>Note:</B>
95
96<P>When we talk about compatibility, we are talking about binary compatibility for public APIs and output format compatibility for program interfaces. Changes to configuration file formats or the default behavior of programs are not generally considered incompatible as the upgrade process can normally address such changes gracefully.</P></BLOCKQUOTE>
4744bd90 97
98<P>Production releases use the plain version numbers:</P>
99
100<PRE CLASS="command">
101MAJOR.MINOR.PATCH
1021.0.0
1031.0.1
1041.0.2
105...
1061.1.0
107...
1081.1.23
1091.2.0
1101.2.1
111...
1121.3.0
113...
1142.0.0
115</PRE>
116
a29fd7dd
MS
117<P>The first production release in a MAJOR.MINOR series (MAJOR.MINOR.0) is called a feature release. Feature releases are the only releases that may contain new features. Subsequent production releases in a MAJOR.MINOR series may only contain bug fixes.</P>
118
119<BLOCKQUOTE><B>Note:</B>
4744bd90 120
a29fd7dd 121<P>We did not hold to this limitation in the CUPS 1.1 series for a variety of reasons. Starting with CUPS 1.2, the "no new features in a patch release" policy has been strictly enforced. The policy has also resulted in fewer new features (and interactions!) to validate/test in the subsequence feature releases.</P></BLOCKQUOTE>
4744bd90 122
a29fd7dd 123<P>Beta-test releases are identified by appending the letter B to the major and minor version numbers followed by the beta release number:</P>
4744bd90 124
125<PRE CLASS="command">
126MAJOR.MINORbNUMBER
1271.2b1
128</PRE>
129
a29fd7dd 130<P>Release candidates are identified by appending the letters RC to the major and minor version numbers followed by the release candidate number:</P>
4744bd90 131
132<PRE CLASS="command">
133MAJOR.MINORrcNUMBER
1341.2rc1
135</PRE>
136
a29fd7dd 137<P>Developer snapshots are identified by appending the letters SVN-R to the major and minor version numbers followed by the revision number:</P>
4744bd90 138
139<PRE CLASS="command">
140MAJOR.MINORsvn-rREV
1411.2svn-r1234
142</PRE>
143
a29fd7dd 144<P>Beta-test releases, release candidates, and developer snapshots are only created for new minor releases. Once a production release has been made (MAJOR.MINOR.0), subsequent patch releases are issued without preliminary beta or release testing.</P>
4744bd90 145
146<H3>Version Control (Subversion)</H3>
147
a29fd7dd 148<P>The CUPS source files are managed by the Subversion ("SVN") software, available at:</P>
4744bd90 149
150<PRE CLASS="command">
a29fd7dd 151<A HREF="http://subversion.apache.org/" TARGET="_blank">subversion.apache.org</A>
4744bd90 152</PRE>
153
a29fd7dd 154<P>Source files are "checked in" with each change so that modifications can be tracked, and each checkin must reference any applicable STRs. The following format <em>must</em> be used for commit log messages:</P>
4744bd90 155
156<PRE CLASS="command">
f8b3a85b 157Summary of the change on one line followed by bug number (STR #NNNN)
4744bd90 158
f8b3a85b 159Detailed list of changes.
4744bd90 160</PRE>
161
a29fd7dd 162<P>Primary development occurs on the <var>trunk</var> branch, with changes merged back to release branches as needed. Table 2 shows the URLs developers use for the various CUPS sub-projects and branches:</P>
4744bd90 163
164<DIV CLASS="table"><TABLE SUMMARY="CUPS Subversion URLs">
165<CAPTION>Table 2: CUPS Subversion URLs</CAPTION>
166<TR>
167 <TH>URL</TH>
168 <TH>Purpose</TH>
169</TR>
170<TR>
a29fd7dd 171 <TD><A HREF="http://svn.cups.org/public/cups/trunk/">https://svn.cups.org/public/cups/trunk/</A></TD>
4744bd90 172 <TD>Primary CUPS development branch</TD>
173</TR>
174<TR>
a29fd7dd 175 <TD><A HREF="http://svn.cups.org/public/cups/branches/">https://svn.cups.org/public/cups/branches/</A></TD>
4744bd90 176 <TD>CUPS maintenance branches (merge-only)</TD>
177</TR>
178<TR>
a29fd7dd 179 <TD><A HREF="http://svn.cups.org/public/cups/tags/">https://svn.cups.org/public/cups/tags/</A></TD>
4744bd90 180 <TD>CUPS release tags (read-only)</TD>
181</TR>
4744bd90 182</TABLE></DIV>
183
a29fd7dd 184<P>The branch for a MAJOR.MINOR release are created when the first production release (MAJOR.MINOR.0) is made using the name "branch-MAJOR.MINOR". Release tags are created for every beta, candidate, and production release using the name "release-MAJOR.MINORbNUMBER", "release-MAJOR.MINORrcNUMBER", or "release-MAJOR.MINOR.PATCH", respectively. No release tags are created for developer snapshots.</P>
4744bd90 185
186
187<H3>Files and Directories</H3>
188
a29fd7dd 189<P>File and directory names may not exceed 16 characters in length to ensure compatibility with older UNIX filesystems. In addition, to avoid problems with case-insensitive filesystems, you may not use names which differ only by case, for example "ReadMe" and "README" are not allowed in the same directory.</P>
4744bd90 190
a29fd7dd 191<P>Source files must be documented and formatted as described in "<A HREF="#CODING">Coding Requirements</A>". Makefiles must follow the guidelines in "<A HREF="#MAKEFILE">Makefile Guidelines</A>".</P>
4744bd90 192
193
194<H3>Build System</H3>
195
a29fd7dd
MS
196<P>The CUPS build system uses <A HREF="http://www.gnu.org/software/autoconf/">GNU autoconf</A> to tailor the library to the local operating system. Project files for the current release of Visual C++ are also provided for Microsoft Windows<SUP>&reg;</SUP>. To improve portability, makefiles must not make use of features unique to <A HREF="http://www.gnu.org/software/make/">GNU make</A>. See the <A HREF="#MAKEFILES">Makefile Guidelines</A> section for a description of the allowed make features and makefile guidelines.</P>
197
198<P>Additional GNU build programs such as <A HREF="http://www.gnu.org/software/automake">GNU automake</A> and <A HREF="http://www.gnu.org/software/libtool">GNU libtool</A> must not be used. GNU automake produces non-portable makefiles which depend on GNU-specific extensions, and GNU libtool is not portable or reliable enough for CUPS.</P>
4744bd90 199
200
201<H3><A NAME="PACKAGING">Packaging</A></H3>
202
a29fd7dd 203<P>Source packages are created using the <VAR>tools/makesrcdist</VAR> script in the Subversion repository. The script optionally uses a version number argument:</P>
4744bd90 204
205<PRE CLASS="command">
206tools/makesrcdist
207tools/makesrcdist <I>version</I>
208</PRE>
209
a29fd7dd
MS
210<P>When run with no arguments, the script creates a snapshot of the current working copy and names it using the highest revision number in the WC, for example "/tmp/cups-1.3svn-r1234-source.tar.bz2" and "/tmp/cups-1.3svn-r1234-source.tar.gz". When run with two arguments, the script creates a release tag in the repository and exports that tag, creating the files
211"/tmp/cups-<I>version</I>-source.tar.bz2" and "/tmp/cups-<I>version</I>-source.tar.gz".</P>
212
213<P>Binary packages are not generally distributed by the CUPS team, however the <VAR>packaging/cups.spec</VAR> and <VAR>packaging/cups.list</VAR> files may be used to create binary packages on Linux, OS X, and UNIX. The <VAR>packaging/cups.spec</VAR> file produces a binary package using the <CODE>rpmbuild(8)</CODE> software:</P>
4744bd90 214
215<PRE CLASS="command">
216rpmbuild -ta cups-<I>version</I>-source.tar.gz
217</PRE>
218
a29fd7dd 219<P>The <VAR>cups.list</VAR> file is generated by the <VAR>configure</VAR> script and produces binary packages for many platforms using the <A HREF="http://www.epmhome.org/" TARGET="_blank">EPM</A> software. Table 3 shows the targets that are available for each type of binary package:</P>
4744bd90 220
221<DIV CLASS="table"><TABLE SUMMARY="Binary Package Targets">
222<CAPTION>Table 3: Binary Package Targets</CAPTION>
223<TR>
224 <TH>Target</TH>
225 <TH>Type of Package</TH>
226</TR>
227<TR>
228 <TD>aix</TD>
229 <TD>AIX installp</TD>
230</TR>
231<TR>
232 <TD>bsd</TD>
233 <TD>*BSD pkg_install</TD>
234</TR>
235<TR>
236 <TD>deb</TD>
237 <TD>Debian dpkg</TD>
238</TR>
239<TR>
240 <TD>depot</TD>
241 <TD>HP-UX swinstall</TD>
242</TR>
243<TR>
244 <TD>epm</TD>
245 <TD>Portable tarball with install script</TD>
246</TR>
4744bd90 247<TR>
248 <TD>pkg</TD>
249 <TD>Solaris pkgadd</TD>
250</TR>
251<TR>
252 <TD>rpm</TD>
253 <TD>RPM binary</TD>
254</TR>
255<TR>
256 <TD>setld</TD>
257 <TD>Tru64 UNIX setld</TD>
258</TR>
259<TR>
260 <TD>slackware</TD>
261 <TD>Slackware install</TD>
262</TR>
263<TR>
264 <TD>swinstall</TD>
265 <TD>HP-UX swinstall</TD>
266</TR>
4744bd90 267</TABLE></DIV>
268
a29fd7dd 269<P>Finally, the <VAR>tools/testrpm</VAR> and <VAR>tools/testosx</VAR> scripts can be used to create binary packages from the current working copy for testing on Linux and OS X, respectively:</P>
4744bd90 270
271<PRE CLASS="command">
272tools/testrpm
273sudo rpm -U /usr/src/redhat/RPMS/i386/cups*.rpm
274
275sudo tools/testosx
276open cups.pkg
277</PRE>
278
279
280<H3><A NAME="TESTING">Testing</A></H3>
281
a29fd7dd 282<P>Software testing is conducted according to the <A HREF="spec-stp.html">CUPS Software Test Plan</A>. This testing is automated via the top-level makefile <VAR>test</VAR> target:</P>
4744bd90 283
284<PRE CLASS="command">
285make test
286</PRE>
287
a29fd7dd 288<P>The test environment allows for both short-term automated testing and long-term testing and development without the automated test script.</P>
4744bd90 289
290
291<H2 CLASS="title"><A NAME="STR">Trouble Report Processing</A></H2>
292
a29fd7dd 293<P>A Software Trouble Report ("STR") must be submitted every time a user or vendor experiences a problem with the CUPS software. Trouble reports are maintained on the <A HREF="http://www.cups.org/str.php" TARGET="_blank">Bugs &amp; Features</A> page with one of the following states:</P>
4744bd90 294
295<OL>
296
297 <LI>STR is closed with complete resolution</LI>
298
299 <LI>STR is closed without resolution</LI>
300
301 <LI>STR is active, waiting on information from submitter</LI>
302
303 <LI>STR is pending with additional information from submitter</LI>
304
305 <LI>STR is newly submitted</LI>
306
307</OL>
308
309<P>Trouble reports are processed using the following steps.</P>
310
a29fd7dd 311<H3>1. Classification</H3>
4744bd90 312
a29fd7dd 313<P>When a trouble report is received it must be classified at one of the following priority levels:</P>
4744bd90 314
315<OL>
316
a29fd7dd 317 <LI>Request for enhancement, e.g. asking for a feature
4744bd90 318
a29fd7dd 319 <LI>Low, e.g. a documentation error or undocumented side-effect
4744bd90 320
a29fd7dd 321 <LI>Moderate, e.g. unable to print a file or unable to compile the software
4744bd90 322
a29fd7dd 323 <LI>High, e.g. unable to print to a printer or key functionality not working
4744bd90 324
325 <LI>Critical, e.g. unable to print at all
326
327</OL>
328
a29fd7dd 329<P>Level 4 and 5 trouble reports must be resolved in the next software release. Level 2 and 3 trouble reports are scheduled for resolution in a specific release at the discretion of the release coordinator. Level 1 trouble reports are scheduled for resolution in a future feature release.</P>
4744bd90 330
331<P>The scope of the problem is also determined as:</P>
332
333<OL>
334
335 <LI>Specific to a machine or printer
336
337 <LI>Specific to an operating system
338
339 <LI>Applies to all machines, printers, and operating systems
340
341</OL>
342
a29fd7dd 343<H3>2. Identification</H3>
4744bd90 344
a29fd7dd 345<P>Once the level and scope of the trouble report is determined the software sub-system(s) involved with the problem are determined. This may involve additional communication with the user or vendor to isolate the problem to a specific cause.</P>
4744bd90 346
a29fd7dd 347<P>When the sub-system(s) involved have been identified, an engineer will then determine the change(s) needed and estimate the time required for the change(s).</P>
4744bd90 348
a29fd7dd 349<H3>3. Correction</H3>
4744bd90 350
a29fd7dd 351<P>Corrections are scheduled based upon the severity and complexity of the problem. Once all changes have been made, documented, and tested successfully a new software release snapshot is generated. Additional tests are added as necessary for proper testing of the changes.</P>
4744bd90 352
a29fd7dd 353<H3>4. Notification</H3>
4744bd90 354
a29fd7dd 355<P>The user or vendor is notified when the fix is available or if the problem was caused by user error.</P>
4744bd90 356
357
358<H2 CLASS="title"><A NAME="RELEASES">Release Management</A></H2>
359
a29fd7dd 360<P>When testing has been completed successfully, a new source package is created using the <VAR>tools/makesrcdist</VAR> script. Three types of releases - beta, candidate, and production - are created and released to the public using the basic schedule in Table 4. At least one beta and one release candidate must be created prior to a production release, and there must be at least two weeks between the last beta and first candidate and last candidate and first production release.</P>
4744bd90 361
362<DIV CLASS="table"><TABLE SUMMARY="CUPS Basic Release Schedule">
363<CAPTION>Table: CUPS Basic Release Schedule</CAPTION>
364<TR>
365 <TH>Week</TH>
366 <TH>Version</TH>
367 <TH>Description</TH>
368</TR>
369<TR>
370 <TD>T-6 weeks</TD>
371 <TD>1.2b1</TD>
372 <TD>First beta release</TD>
373</TR>
374<TR>
375 <TD>T-5 weeks</TD>
376 <TD>1.2b2</TD>
377 <TD>Second beta release</TD>
378</TR>
379<TR>
380 <TD>T-3 weeks</TD>
381 <TD>1.2rc1</TD>
382 <TD>First release candidate</TD>
383</TR>
384<TR>
385 <TD>T-2 weeks</TD>
386 <TD>1.2rc2</TD>
387 <TD>Second release candidate</TD>
388</TR>
389<TR>
390 <TD>T-0 weeks</TD>
391 <TD>1.2.0</TD>
392 <TD>Production (feature) release</TD>
393</TR>
394</TABLE></DIV>
395
396
397<H2 CLASS="title"><A NAME="CODING">Coding Guidelines</A></H2>
398
a29fd7dd
MS
399<P>These coding guidelines provide detailed information on source file formatting and documentation content and must be applied to all C and C++ source files provided with CUPS. Source code for other languages should conform to these guidelines as allowed by the language.</P>
400
4744bd90 401
402<H3>Source Files</H3>
403
a29fd7dd 404<P>All source files names must be 16 characters or less in length to ensure compatibility with older UNIX filesystems. Source files containing functions have an extension of ".c" for ANSI C and ".cxx" for C++ source files. All other "include" files have an extension of ".h". Tabs are set to 8 characters.</P>
4744bd90 405
a29fd7dd
MS
406<BLOCKQUOTE><B>Note:</B>
407
408<P>The ".cxx" extension is used because it is the only common C++ extension between Linux, OS X, UNIX, and Windows.</P></BLOCKQUOTE>
409
9d661958 410<P>The top of each source file contains a header giving the name of the file, the purpose or nature of the source file, and the copyright and licensing notice. The file name and revision information is provided by the Subversion "&#36;Id$" tag:</P>
4744bd90 411
412<PRE CLASS="command">
413/*
414 * "&#36;Id$"
415 *
9d661958 416 * Description of file contents.
4744bd90 417 *
9d661958 418 * Copyright 2013 by Apple Inc.
4744bd90 419 *
9d661958
MS
420 * These coded instructions, statements, and computer programs are the
421 * property of Apple Inc. and are protected by Federal copyright
422 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
423 * which should have been included with this file. If this file is
424 * file is missing or damaged, see the license at "http://www.cups.org/".
4744bd90 425 */
426</PRE>
427
a29fd7dd 428<P>For source files that are subject to the Apple OS-Developed Software exception, the following additional comment appears after the contact information:</P>
4744bd90 429
430<PRE CLASS="command">
9d661958 431 * This file is subject to the Apple OS-Developed Software exception.
4744bd90 432</PRE>
433
a29fd7dd 434<P>The bottom of each source file contains a trailer giving the name of the file using the Subversion "&#36;Id$" tag. The primary purpose of this is to mark the end of a source file; if the trailer is missing it is possible that code has been lost near the end of the file:</P>
4744bd90 435
436<PRE CLASS="command">
437/*
438 * End of "&#36;Id$".
439 */
440</PRE>
441
a29fd7dd
MS
442
443<H3>Comments</H3>
444
445<P>All source code utilizes block comments within functions to describe the operations being performed by a group of statements; avoid putting a comment per line unless absolutely necessary, and then consider refactoring the code so that it is not necessary. C source files use the block comment format ("/* comment */") since many vendor C compilers still do not support C99/C++ comments ("// comment"):</P>
446
447<PRE CLASS="command">
448 /*
449 * Clear the state array before we begin...
450 */
451
452 for (i = 0; i &lt; (sizeof(array) / sizeof(sizeof(array[0])); i ++)
453 array[i] = CUPS_STATE_IDLE;
454
455 /*
456 * Wait for state changes on another thread...
457 */
458
459 do
460 {
461 for (i = 0; i &lt; (sizeof(array) / sizeof(sizeof(array[0])); i ++)
462 if (array[i] != CUPS_STATE_IDLE)
463 break;
464
465 if (i == (sizeof(array) / sizeof(array[0])))
466 sleep(1);
467 } while (i == (sizeof(array) / sizeof(array[0])));
468</PRE>
469
470<H3>Indentation</H3>
471
472<P>All code blocks enclosed by brackets begin with the opening brace on a new line. The code then follows starting on a new line after the brace and is indented 2 spaces. The closing brace is then placed on a new line following the code at the original indentation:</P>
473
474<PRE CLASS="command">
475{
476 int i; /* Looping var */
477
478
479 /*
480 * Process foobar values from 0 to 999...
481 */
482
483 for (i = 0; i &lt; 1000; i ++)
484 {
485 do_this(i);
486 do_that(i);
487 }
488}
489</PRE>
490
491<P>Single-line statements following "do", "else", "for", "if", and "while" are indented 2 spaces as well. Blocks of code in a "switch" block are indented 4 spaces after each "case" and "default" case:</P>
492
493<PRE CLASS="command">
494switch (array[i])
495{
496 case CUPS_STATE_IDLE :
497 do_this(i);
498 do_that(i);
499 break;
500 default :
501 do_nothing(i);
502 break;
503}
504</PRE>
505
506
507<H3>Spacing</H3>
508
509<P>A space follows each reserved word such as "if", "while", etc. Spaces are not inserted between a function name and the arguments in parenthesis.</P>
510
511
512<H3>Return Values</H3>
513
514<P>Parenthesis surround values returned from a function:</P>
515
516<PRE CLASS="command">
517return (CUPS_STATE_IDLE);
518</PRE>
519
520
4744bd90 521<H3>Functions</H3>
522
a29fd7dd 523<P>Functions with a global scope have a lowercase prefix followed by capitalized words, e.g., "cupsDoThis", "cupsDoThat", "cupsDoSomethingElse", etc. Private global functions begin with a leading underscore, e.g., "_cupsDoThis", "_cupsDoThat", etc.</P>
4744bd90 524
a29fd7dd 525<P>Functions with a local scope are declared "static" with lowercase names and underscores between words, e.g., "do_this", "do_that", "do_something_else", etc.</P>
4744bd90 526
a29fd7dd 527<P>Each function begins with a comment header describing what the function does, the possible input limits (if any), and the possible output values (if any), and any special information needed:</P>
4744bd90 528
529<PRE CLASS="command">
530/*
531 * 'do_this()' - Compute y = this(x).
532 *
533 * Notes: none.
534 */
535
536static float /* O - Inverse power value, 0.0 &lt;= y &lt;= 1.1 */
537do_this(float x) /* I - Power value (0.0 &lt;= x &lt;= 1.1) */
538{
539 ...
540 return (y);
541}
542</PRE>
543
a29fd7dd 544<P>Return/output values are indicated using an "O" prefix, input values are indicated using the "I" prefix, and values that are both input and output use the "IO" prefix for the corresponding in-line comment.</P>
4744bd90 545
a29fd7dd 546<P>The Mini-XML documentation generator also understands the following special text in the function description comment:</P>
4744bd90 547
548<UL>
549
a29fd7dd 550 <LI><CODE>@deprecated@</CODE> - Marks the function as deprecated (not recommended for new development and scheduled for removal)</LI>
4744bd90 551
a29fd7dd 552 <LI><CODE>@since CUPS <I>version</I>@</CODE> - Marks the function as new in the specified version of CUPS.</LI>
f8b3a85b 553
a29fd7dd 554 <LI><CODE>@private@</CODE> - Marks the function as private (same as starting the function name with an underscore)</LI>
f8b3a85b 555
4744bd90 556</UL>
557
a29fd7dd 558
4744bd90 559<H3>Variables</H3>
560
a29fd7dd 561<P>Variables with a global scope are capitalized, e.g., "ThisVariable", "ThatVariable", "ThisStateVariable", etc. Globals in CUPS libraries are either part of the per-thread global values managed by the "_cupsGlobals()" function or are suitably protected for concurrent access. Global variables should be replaced by function arguments whenever possible.</P>
4744bd90 562
a29fd7dd 563<P>Variables with a local scope are lowercase with underscores between words, e.g., "this_variable", "that_variable", etc. Any "local global" variables shared by functions within a source file are declared "static". As for global variables, local static variables are suitably protected for concurrent access.</P>
4744bd90 564
a29fd7dd 565<P>Each variable is declared on a separate line and is immediately followed by a comment block describing the variable:</P>
4744bd90 566
567<PRE CLASS="command">
a29fd7dd
MS
568int ThisVariable; /* The current state of this */
569static int that_variable; /* The current state of that */
4744bd90 570</PRE>
571
a29fd7dd 572
4744bd90 573<H3>Types</H3>
574
a29fd7dd 575<P>All type names are lowercase with underscores between words and "_t" appended to the end of the name, e.g., "cups_this_type_t", "cups_that_type_t", etc. Type names start with a prefix, typically "cups" or the name of the program, to avoid conflicts with system types. Private type names start with an underscore, e.g., "_cups_this_t", "_cups_that_t", etc.</P>
4744bd90 576
a29fd7dd 577<P>Each type has a comment block immediately after the typedef:</P>
4744bd90 578
579<PRE CLASS="command">
a29fd7dd 580typedef int cups_this_type_t; /* This type is for CUPS foobar options. */
4744bd90 581</PRE>
582
a29fd7dd 583
4744bd90 584<H3>Structures</H3>
585
a29fd7dd 586<P>All structure names are lowercase with underscores between words and "_s" appended to the end of the name, e.g., "cups_this_s", "cups_that_s", etc. Structure names start with a prefix, typically "cups" or the name of the program, to avoid conflicts with system types. Private structure names start with an underscore, e.g., "_cups_this_s", "_cups_that_s", etc.</P>
4744bd90 587
a29fd7dd 588<P>Each structure has a comment block immediately after the struct and each member is documented similar to the variable naming policy above:</P>
4744bd90 589
590<PRE CLASS="command">
a29fd7dd 591struct cups_this_struct_s /* This structure is for CUPS foobar options. */
4744bd90 592{
a29fd7dd
MS
593 int this_member; /* Current state for this */
594 int that_member; /* Current state for that */
4744bd90 595};
596</PRE>
597
a29fd7dd 598
4744bd90 599<H3>Constants</H3>
600
a29fd7dd 601<P>All constant names are uppercase with underscores between words, e.g., "CUPS_THIS_CONSTANT", "CUPS_THAT_CONSTANT", etc. Constants begin with an uppercase prefix, typically "CUPS" or the program name. Private constants start with an underscore, e.g., "_CUPS_THIS_CONSTANT", "_CUPS_THAT_CONSTANT", etc.</P>
4744bd90 602
a29fd7dd 603<P>Typed enumerations should be used whenever possible to allow for type checking by the compiler.</P>
4744bd90 604
a29fd7dd 605<P>Comment blocks immediately follow each constant:</P>
4744bd90 606
607<PRE CLASS="command">
608enum
609{
610 CUPS_THIS_TRAY, /* This tray */
611 CUPS_THAT_TRAY /* That tray */
612};
613</PRE>
614
4744bd90 615
616<H2 CLASS="title"><A NAME="MAKEFILES">Makefile Guidelines</A></H2>
617
a29fd7dd
MS
618<P>The following is a guide to the makefile-based build system used by CUPS. These standards have been developed over the years to allow CUPS to be built on as many systems and environments as possible.</P>
619
4744bd90 620
621<H3>General Organization</H3>
622
a29fd7dd
MS
623<P>The CUPS source code is organized functionally into a top-level makefile, include file, and subdirectories each with their own makefile and dependencies files. The ".in" files are template files for the <CODE>autoconf</CODE> software and are used to generate a static version of the corresponding file.</P>
624
4744bd90 625
626<H3>Makefile Documentation</H3>
627
a29fd7dd 628<P>Each makefile starts with the standard CUPS header containing the Subversion "&#36;Id$" keyword, description of the file, and CUPS copyright and license notice:</P>
4744bd90 629
630<PRE CLASS="command">
631#
632# "&#36;Id$"
633#
9d661958 634# Makefile for ...
4744bd90 635#
9d661958 636# Copyright 2013 by Apple Inc.
4744bd90 637#
9d661958
MS
638# These coded instructions, statements, and computer programs are the
639# property of Apple Inc. and are protected by Federal copyright
640# law. Distribution and use rights are outlined in the file "LICENSE.txt"
641# which should have been included with this file. If this file is
642# file is missing or damaged, see the license at "http://www.cups.org/".
4744bd90 643#
644</PRE>
645
a29fd7dd 646<P>The end of each makefile has a comment saying:</P>
4744bd90 647
648<PRE CLASS="command">
649#
650# End of "&#36;Id$".
651#
652</PRE>
653
a29fd7dd
MS
654<P>The purpose of the trailer is to indicate the end of the makefile so that truncations are immediately obvious.</P>
655
4744bd90 656
657<H3>Portable Makefile Construction</H3>
658
a29fd7dd 659<P>CUPS uses a common subset of make program syntax to ensure that the software can be compiled "out of the box" on as many systems as possible. The following is a list of assumptions we follow when constructing makefiles:</P>
4744bd90 660
661<UL>
662
a29fd7dd 663 <LI><b>Targets</b>; we assume that the make program supports the notion of simple targets of the form "name:" that perform tab-indented commands that follow the target, e.g.:
4744bd90 664 <PRE CLASS="command">
665target:
666&rarr; target commands</PRE></LI>
667
a29fd7dd 668 <LI><b>Dependencies</b>; we assume that the make program supports recursive dependencies on targets, e.g.:
4744bd90 669 <PRE CLASS="command">
670target: foo bar
671&rarr; target commands
672
673foo: bla
674&rarr; foo commands
675
676bar:
677&rarr; bar commands
678
679bla:
680&rarr; bla commands</PRE></LI>
681
a29fd7dd 682 <LI><b>Variable Definition</b>; we assume that the make program supports variable definition on the command-line or in the makefile using the following form:
4744bd90 683 <PRE CLASS="command">
684name=value</PRE>
685
a29fd7dd 686 <LI><b>Variable Substitution</b>; we assume that the make program supports variable substitution using the following forms:
4744bd90 687 <UL>
688 <LI><CODE>$(name)</CODE>; substitutes the value of "name",</LI>
a29fd7dd
MS
689 <LI><CODE>($name:.old=.new)</CODE>; substitutes the value of "name" with the filename extension ".old" changed to ".new",</LI>
690 <LI><CODE>$(MAKEFLAGS)</CODE>; substitutes the command-line options passed to the program without the leading hyphen (-),</LI>
4744bd90 691 <LI><CODE>$$</CODE>; substitutes a single <CODE>$</CODE> character,</LI>
692 <LI><CODE>$&lt;</CODE>; substitutes the current source file or dependency, and</LI>
693 <LI><CODE>$@</CODE>; substitutes the current target name.</LI>
694 </UL></LI>
695
a29fd7dd 696 <LI><b>Suffixes</b>; we assume that the make program supports filename suffixes with assumed dependencies, e.g.:
4744bd90 697 <PRE CLASS="command">
698.SUFFIXES: .c .o
699.c.o:
700&rarr; $(CC) $(CFLAGS) -o $@ -c $&lt;</PRE></LI>
701
702 <LI><b>Include Files</b>; we assume that the make program
703 supports the <CODE>include</CODE> directive, e.g.:
704 <PRE CLASS="command">
705include ../Makedefs
706include Dependencies</PRE></LI>
707
a29fd7dd 708 <LI><b>Comments</b>; we assume that comments begin with a <CODE>#</CODE> character and proceed to the end of the current line.</LI>
4744bd90 709
a29fd7dd 710 <LI><b>Line Length</b>; we assume that there is no practical limit to the length of lines.</LI>
4744bd90 711
a29fd7dd 712 <LI><b>Continuation of long lines</b>; we assume that the <CODE>\</CODE> character may be placed at the end of a line to concatenate two or more lines in a makefile to form a single long line.</LI>
4744bd90 713
a29fd7dd 714 <LI><b>Shell</b>; we assume a POSIX-compatible shell is present on the build system.</LI>
4744bd90 715
716</UL>
717
a29fd7dd 718
4744bd90 719<H3>Standard Variables</H3>
720
a29fd7dd 721<P>The following variables are defined in the "Makedefs" file generated by the <CODE>autoconf</CODE> software:</P>
4744bd90 722
723<UL>
724
a29fd7dd 725 <LI><CODE>ALL_CFLAGS</CODE>; the combined C compiler options,</LI>
4744bd90 726
a29fd7dd 727 <LI><CODE>ALL_CXXFLAGS</CODE>; the combined C++ compiler options,</LI>
4744bd90 728
a29fd7dd 729 <LI><CODE>AMANDIR</CODE>; the administrative man page installation directory (section 8/1m depending on the platform),</LI>
4744bd90 730
a29fd7dd 731 <LI><CODE>AR</CODE>; the library archiver command,</LI>
4744bd90 732
a29fd7dd 733 <LI><CODE>ARFLAGS</CODE>; options for the library archiver command,</LI>
4744bd90 734
a29fd7dd 735 <LI><CODE>AWK</CODE>; the local awk command,</LI>
4744bd90 736
a29fd7dd 737 <LI><CODE>BINDIR</CODE>; the binary installation directory,</LI>
4744bd90 738
a29fd7dd 739 <LI><CODE>BUILDROOT</CODE>; optional installation prefix (defaults to DSTROOT),</LI>
4744bd90 740
741 <LI><CODE>CC</CODE>; the C compiler command,</LI>
742
743 <LI><CODE>CFLAGS</CODE>; options for the C compiler command,</LI>
744
a29fd7dd
MS
745 <LI><CODE>CHMOD</CODE>; the chmod command,</LI>
746
4744bd90 747 <LI><CODE>CXX</CODE>; the C++ compiler command,</LI>
748
749 <LI><CODE>CXXFLAGS</CODE>; options for the C++ compiler command,</LI>
750
a29fd7dd
MS
751 <LI><CODE>DATADIR</CODE>; the data file installation directory,</LI>
752
753 <LI><CODE>DSO</CODE>; the C shared library building command,</LI>
754
755 <LI><CODE>DSOXX</CODE>; the C++ shared library building command,</LI>
4744bd90 756
757 <LI><CODE>DSOFLAGS</CODE>; options for the shared library building command,</LI>
758
a29fd7dd
MS
759 <LI><CODE>INCLUDEDIR</CODE>; the public header file installation directory,</LI>
760
4744bd90 761 <LI><CODE>INSTALL</CODE>; the <CODE>install</CODE> command,</LI>
762
763 <LI><CODE>INSTALL_BIN</CODE>; the program installation command,</LI>
764
a29fd7dd
MS
765 <LI><CODE>INSTALL_COMPDATA</CODE>; the compressed data file installation command,</LI>
766
767 <LI><CODE>INSTALL_CONFIG</CODE>; the configuration file installation command,</LI>
768
4744bd90 769 <LI><CODE>INSTALL_DATA</CODE>; the data file installation command,</LI>
770
771 <LI><CODE>INSTALL_DIR</CODE>; the directory installation command,</LI>
772
773 <LI><CODE>INSTALL_LIB</CODE>; the library installation command,</LI>
774
775 <LI><CODE>INSTALL_MAN</CODE>; the documentation installation command,</LI>
776
777 <LI><CODE>INSTALL_SCRIPT</CODE>; the shell script installation command,</LI>
778
a29fd7dd
MS
779 <LI><CODE>LD</CODE>; the linker command,</LI>
780
4744bd90 781 <LI><CODE>LDFLAGS</CODE>; options for the linker,</LI>
782
a29fd7dd
MS
783 <LI><CODE>LIBDIR</CODE>; the library installation directory,</LI>
784
4744bd90 785 <LI><CODE>LIBS</CODE>; libraries for all programs,</LI>
786
787 <LI><CODE>LN</CODE>; the <CODE>ln</CODE> command,</LI>
788
a29fd7dd 789 <LI><CODE>MAN1EXT</CODE>; extension for man pages in section 1,</LI>
4744bd90 790
a29fd7dd 791 <LI><CODE>MAN3EXT</CODE>; extension for man pages in section 3,</LI>
4744bd90 792
a29fd7dd 793 <LI><CODE>MAN5EXT</CODE>; extension for man pages in section 5,</LI>
4744bd90 794
a29fd7dd 795 <LI><CODE>MAN7EXT</CODE>; extension for man pages in section 7,</LI>
4744bd90 796
a29fd7dd
MS
797 <LI><CODE>MAN8DIR</CODE>; subdirectory for man pages in section 8,</LI>
798
799 <LI><CODE>MAN8EXT</CODE>; extension for man pages in section 8,</LI>
4744bd90 800
a29fd7dd 801 <LI><CODE>MANDIR</CODE>; the man page installation directory,</LI>
4744bd90 802
a29fd7dd
MS
803 <LI><CODE>OPTIM</CODE>; common compiler optimization options,</LI>
804
805 <LI><CODE>PRIVATEINCLUDE</CODE>; the private header file installation directory,</LI>
4744bd90 806
a29fd7dd 807 <LI><CODE>RM</CODE>; the <CODE>rm</CODE> command,</LI>
4744bd90 808
a29fd7dd 809 <LI><CODE>SHELL</CODE>; the <CODE>sh</CODE> (POSIX shell) command,</LI>
4744bd90 810
a29fd7dd 811 <LI><CODE>STRIP</CODE>; the <CODE>strip</CODE> command,</LI>
4744bd90 812
813 <LI><CODE>srcdir</CODE>; the source directory.</LI>
814
815</UL>
816
a29fd7dd 817
4744bd90 818<H3>Standard Targets</H3>
819
a29fd7dd 820<P>The following standard targets are defined in each makefile:</P>
4744bd90 821
822<UL>
823
a29fd7dd
MS
824 <LI><CODE>all</CODE>; creates all target programs, libraries, and documentation files,</LI>
825
826 <LI><CODE>clean</CODE>; removes all target programs libraries, documentation files, and object files,</LI>
827
828 <LI><CODE>depend</CODE>; generates automatic dependencies for any C or C++ source files (also see <A HREF="#DEPEND_TARGET">"Dependencies"</A>),</LI>
829
830 <LI><CODE>distclean</CODE>; removes autoconf-generated files in addition to those removed by the "clean" target,</LI>
831
832 <LI><CODE>install</CODE>; installs all distribution files in their corresponding locations (also see <A HREF="#INSTALL_TARGET">"Install/Uninstall Support"</A>),</LI>
4744bd90 833
a29fd7dd 834 <LI><CODE>install-data</CODE>; installs all data files in their corresponding locations (also see <A HREF="#INSTALL_TARGET">"Install/Uninstall Support"</A>),</LI>
4744bd90 835
a29fd7dd 836 <LI><CODE>install-exec</CODE>; installs all executable files in their corresponding locations (also see <A HREF="#INSTALL_TARGET">"Install/Uninstall Support"</A>),</LI>
4744bd90 837
a29fd7dd 838 <LI><CODE>install-headers</CODE>; installs all include files in their corresponding locations (also see <A HREF="#INSTALL_TARGET">"Install/Uninstall Support"</A>),</LI>
4744bd90 839
a29fd7dd 840 <LI><CODE>install-libs</CODE>; installs all library files in their corresponding locations (also see <A HREF="#INSTALL_TARGET">"Install/Uninstall Support"</A>),</LI>
4744bd90 841
a29fd7dd 842 <LI><CODE>uninstall</CODE>; removes all distribution files from their corresponding locations (also see <A HREF="#INSTALL_TARGET">"Install/Uninstall Support"</A>), and</LI>
4744bd90 843
844</UL>
845
846
847<H3>Object Files</H3>
848
a29fd7dd
MS
849<P>Object files (the result of compiling a C or C++ source file) have the extension ".o".</P>
850
4744bd90 851
852<H3>Programs</H3>
853
a29fd7dd 854<P>Program files are the result of linking object files and libraries together to form an executable file. A typical program target looks like:</P>
4744bd90 855
856<PRE CLASS="command">
857program: $(OBJS)
858&rarr; echo Linking $@...
859&rarr; $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
860</PRE>
861
a29fd7dd 862
4744bd90 863<H3>Static Libraries</H3>
864
a29fd7dd 865<P>Static libraries have a prefix of "lib" and the extension ".a". A typical static library target looks like:</P>
4744bd90 866
867<PRE CLASS="command">
868libname.a: $(OBJECTS)
869&rarr; echo Creating $@...
870&rarr; $(RM) $@
871&rarr; $(AR) $(ARFLAGS) $@ $(OBJECTS)
872&rarr; $(RANLIB) $@
873</PRE>
874
a29fd7dd 875
4744bd90 876<H3>Shared Libraries</H3>
877
a29fd7dd 878<P>Shared libraries have a prefix of "lib" and the extension ".dylib", ".sl", ".so", or "_s.a" depending on the operating system. A typical shared library is composed of several targets that look like:</P>
4744bd90 879
880<PRE CLASS="command">
881libname.so: $(OBJECTS)
882&rarr; echo $(DSOCOMMAND) libname.so.$(DSOVERSION) ...
883&rarr; $(DSOCOMMAND) libname.so.$(DSOVERSION) $(OBJECTS)
884&rarr; $(RM) libname.so libname.so.$(DSOMAJOR)
885&rarr; $(LN) libname.so.$(DSOVERSION) libname.so.$(DSOMAJOR)
886&rarr; $(LN) libname.so.$(DSOVERSION) libname.so
887
888libname.sl: $(OBJECTS)
889&rarr; echo $(DSOCOMMAND) libname.sl.$(DSOVERSION) ...
890&rarr; $(DSOCOMMAND) libname.sl.$(DSOVERSION) $(OBJECTS)
891&rarr; $(RM) libname.sl libname.sl.$(DSOMAJOR)
892&rarr; $(LN) libname.sl.$(DSOVERSION) libname.sl.$(DSOMAJOR)
893&rarr; $(LN) libname.sl.$(DSOVERSION) libname.sl
894
895libname.dylib: $(OBJECTS)
896&rarr; echo $(DSOCOMMAND) libname.$(DSOVERSION).dylib ...
897&rarr; $(DSOCOMMAND) libname.$(DSOVERSION).dylib \
898&rarr; &rarr; -install_name $(libdir)/libname.$(DSOMAJOR).dylib \
899&rarr; &rarr; -current_version libname.$(DSOVERSION).dylib \
900&rarr; &rarr; -compatibility_version $(DSOMAJOR).0 \
901&rarr; &rarr; $(OBJECTS) $(LIBS)
902&rarr; $(RM) libname.dylib
903&rarr; $(RM) libname.$(DSOMAJOR).dylib
904&rarr; $(LN) libname.$(DSOVERSION).dylib libname.$(DSOMAJOR).dylib
905&rarr; $(LN) libname.$(DSOVERSION).dylib libname.dylib
906
907libname_s.a: $(OBJECTS)
908&rarr; echo $(DSOCOMMAND) libname_s.o ...
909&rarr; $(DSOCOMMAND) libname_s.o $(OBJECTS) $(LIBS)
910&rarr; echo $(LIBCOMMAND) libname_s.a libname_s.o
911&rarr; $(RM) $@
912&rarr; $(LIBCOMMAND) libname_s.a libname_s.o
913&rarr; $(CHMOD) +x libname_s.a
914</PRE>
915
916
917<H3>Dependencies</H3>
918
a29fd7dd 919<P>Static dependencies are expressed in each makefile following the target, for example:</P>
4744bd90 920
921<PRE CLASS="command">
922foo: bar
923</PRE>
924
a29fd7dd 925<P>Static dependencies are only used when it is not possible to automatically generate them. Automatic dependencies are stored in a file named "Dependencies" and included at the end of the makefile. The following "depend" target rule is used to create the automatic dependencies:
4744bd90 926
927<PRE CLASS="command">
928depend:
a29fd7dd 929&rarr; $(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies
4744bd90 930</PRE>
931
a29fd7dd
MS
932<P>We regenerate the automatic dependencies on an OS X system and express any non-OS X dependencies statically in the makefile.</P>
933
4744bd90 934
935<H3><A NAME="TARGET_INSTALL">Install/Uninstall Support</A></H3>
936
a29fd7dd
MS
937<P>All makefiles contains install and uninstall rules which install or remove the corresponding software. These rules must use the <CODE>$(BUILDROOT)</CODE> variable as a prefix to any installation directory so that CUPS can be installed in a temporary location for packaging by programs like <CODE>rpmbuild</CODE>.</P>
938
939<P>The <CODE>$(INSTALL_BIN)</CODE>, <CODE>$(INSTALL_COMPDATA)</CODE>, <CODE>$(INSTALL_CONFIG)</CODE>, <CODE>$(INSTALL_DATA)</CODE>, <CODE>$(INSTALL_DIR)</CODE>, <CODE>$(INSTALL_LIB)</CODE>, <CODE>$(INSTALL_MAN)</CODE>, and <CODE>$(INSTALL_SCRIPT)</CODE> variables must be used when installing files so that the proper ownership and permissions are set on the installed files.</P>
940
941<P>The <CODE>$(RANLIB)</CODE> command must be run on any static libraries after installation since the symbol table is invalidated when the library is copied on some platforms.</P>
4744bd90 942
943</BODY>
944</HTML>