xref: /aosp_15_r20/external/libcups/DEVELOPING.md (revision 5e7646d21f1134fb0638875d812ef646c12ab91e)
1*5e7646d2SAndroid Build Coastguard WorkerDeveloping for CUPS
2*5e7646d2SAndroid Build Coastguard Worker===================
3*5e7646d2SAndroid Build Coastguard Worker
4*5e7646d2SAndroid Build Coastguard WorkerPlease see the [Contributing to CUPS](CONTRIBUTING.md) file for information on
5*5e7646d2SAndroid Build Coastguard Workercontributing to the CUPS project.
6*5e7646d2SAndroid Build Coastguard Worker
7*5e7646d2SAndroid Build Coastguard Worker
8*5e7646d2SAndroid Build Coastguard WorkerHow To Contact The Developers
9*5e7646d2SAndroid Build Coastguard Worker-----------------------------
10*5e7646d2SAndroid Build Coastguard Worker
11*5e7646d2SAndroid Build Coastguard WorkerThe CUPS mailing lists are the primary means of asking questions and informally
12*5e7646d2SAndroid Build Coastguard Workerdiscussing issues and feature requests with the CUPS developers and other
13*5e7646d2SAndroid Build Coastguard Workerexperienced CUPS users and developers.  The "cups" mailing list is intended for
14*5e7646d2SAndroid Build Coastguard WorkerCUPS usage questions and new software announcements while the "cups-devel"
15*5e7646d2SAndroid Build Coastguard Workermailing list provides a forum for CUPS developers and monitoring new bugs.
16*5e7646d2SAndroid Build Coastguard Worker
17*5e7646d2SAndroid Build Coastguard Worker
18*5e7646d2SAndroid Build Coastguard WorkerInterfaces
19*5e7646d2SAndroid Build Coastguard Worker----------
20*5e7646d2SAndroid Build Coastguard Worker
21*5e7646d2SAndroid Build Coastguard WorkerCUPS interfaces, including the C APIs and command-line arguments, environment
22*5e7646d2SAndroid Build Coastguard Workervariables, configuration files, and output format, are stable across patch
23*5e7646d2SAndroid Build Coastguard Workerversions and are generally backwards-compatible with interfaces used in prior
24*5e7646d2SAndroid Build Coastguard Workermajor and minor versions.  However, program interfaces such as those used by
25*5e7646d2SAndroid Build Coastguard Workerthe scheduler to run filter, port monitor, and backend processes for job
26*5e7646d2SAndroid Build Coastguard Workerprocessing should only be considered stable from the point of view of a
27*5e7646d2SAndroid Build Coastguard Workerfilter, port monitor, or backend.  Software that simulates the scheduler in
28*5e7646d2SAndroid Build Coastguard Workerorder to run those programs outside of CUPS must necessarily be updated when
29*5e7646d2SAndroid Build Coastguard Workerthe corresponding interface is changed in a subsequent CUPS release, otherwise
30*5e7646d2SAndroid Build Coastguard Workerundefined behavior can occur.
31*5e7646d2SAndroid Build Coastguard Worker
32*5e7646d2SAndroid Build Coastguard WorkerCUPS C APIs starting with an underscore (`_`) are considered to be private to
33*5e7646d2SAndroid Build Coastguard WorkerCUPS and are not subject to the normal guarantees of stability between CUPS
34*5e7646d2SAndroid Build Coastguard Workerreleases and must never be used in non-CUPS source code.  Similarly,
35*5e7646d2SAndroid Build Coastguard Workerconfiguration and state files written by CUPS are considered private if a
36*5e7646d2SAndroid Build Coastguard Workercorresponding man page is not provided with the CUPS release.  Never rely on
37*5e7646d2SAndroid Build Coastguard Workerundocumented files or formats when developing software for CUPS.  Always use a
38*5e7646d2SAndroid Build Coastguard Workerpublished C API to access data stored in a file to avoid compatibility problems
39*5e7646d2SAndroid Build Coastguard Workerin the future.
40*5e7646d2SAndroid Build Coastguard Worker
41*5e7646d2SAndroid Build Coastguard Worker
42*5e7646d2SAndroid Build Coastguard WorkerBuild System
43*5e7646d2SAndroid Build Coastguard Worker------------
44*5e7646d2SAndroid Build Coastguard Worker
45*5e7646d2SAndroid Build Coastguard WorkerThe CUPS build system uses GNU autoconf to tailor the library to the local
46*5e7646d2SAndroid Build Coastguard Workeroperating system.  Project files for the current release of Microsoft Visual
47*5e7646d2SAndroid Build Coastguard WorkerStudio are also provided for Microsoft Windows®.  To improve portability,
48*5e7646d2SAndroid Build Coastguard Workermakefiles must not make use of features unique to GNU make.  See the MAKEFILE
49*5e7646d2SAndroid Build Coastguard WorkerGUIDELINES section for a description of the allowed make features and makefile
50*5e7646d2SAndroid Build Coastguard Workerguidelines.
51*5e7646d2SAndroid Build Coastguard Worker
52*5e7646d2SAndroid Build Coastguard WorkerAdditional GNU build programs such as GNU automake and GNU libtool must not be
53*5e7646d2SAndroid Build Coastguard Workerused.  GNU automake produces non-portable makefiles which depend on GNU-
54*5e7646d2SAndroid Build Coastguard Workerspecific extensions, and GNU libtool is not portable or reliable enough for
55*5e7646d2SAndroid Build Coastguard WorkerCUPS.
56*5e7646d2SAndroid Build Coastguard Worker
57*5e7646d2SAndroid Build Coastguard Worker
58*5e7646d2SAndroid Build Coastguard WorkerVersion Numbering
59*5e7646d2SAndroid Build Coastguard Worker-----------------
60*5e7646d2SAndroid Build Coastguard Worker
61*5e7646d2SAndroid Build Coastguard WorkerCUPS uses a three-part version number separated by periods to represent the
62*5e7646d2SAndroid Build Coastguard Workermajor, minor, and patch release numbers.  Major release numbers indicate large
63*5e7646d2SAndroid Build Coastguard Workerdesign changes or backwards-incompatible changes to the CUPS API or CUPS
64*5e7646d2SAndroid Build Coastguard WorkerImaging API.  Minor release numbers indicate new features and other smaller
65*5e7646d2SAndroid Build Coastguard Workerchanges which are backwards-compatible with previous CUPS releases.  Patch
66*5e7646d2SAndroid Build Coastguard Workernumbers indicate bug fixes to the previous feature or patch release.  This
67*5e7646d2SAndroid Build Coastguard Workerversion numbering scheme is consistent with the
68*5e7646d2SAndroid Build Coastguard Worker[Semantic Versioning](http://semver.org) specification.
69*5e7646d2SAndroid Build Coastguard Worker
70*5e7646d2SAndroid Build Coastguard Worker> Note:
71*5e7646d2SAndroid Build Coastguard Worker>
72*5e7646d2SAndroid Build Coastguard Worker> When we talk about compatibility, we are talking about binary compatibility
73*5e7646d2SAndroid Build Coastguard Worker> for public APIs and output format compatibility for program interfaces.
74*5e7646d2SAndroid Build Coastguard Worker> Changes to configuration file formats or the default behavior of programs
75*5e7646d2SAndroid Build Coastguard Worker> are not generally considered incompatible as the upgrade process can
76*5e7646d2SAndroid Build Coastguard Worker> normally address such changes gracefully.
77*5e7646d2SAndroid Build Coastguard Worker
78*5e7646d2SAndroid Build Coastguard WorkerProduction releases use the plain version numbers:
79*5e7646d2SAndroid Build Coastguard Worker
80*5e7646d2SAndroid Build Coastguard Worker    MAJOR.MINOR.PATCH
81*5e7646d2SAndroid Build Coastguard Worker    1.0.0
82*5e7646d2SAndroid Build Coastguard Worker    ...
83*5e7646d2SAndroid Build Coastguard Worker    1.1.0
84*5e7646d2SAndroid Build Coastguard Worker    ...
85*5e7646d2SAndroid Build Coastguard Worker    1.1.23
86*5e7646d2SAndroid Build Coastguard Worker    ...
87*5e7646d2SAndroid Build Coastguard Worker    2.0.0
88*5e7646d2SAndroid Build Coastguard Worker    ...
89*5e7646d2SAndroid Build Coastguard Worker    2.1.0
90*5e7646d2SAndroid Build Coastguard Worker    2.1.1
91*5e7646d2SAndroid Build Coastguard Worker    2.1.2
92*5e7646d2SAndroid Build Coastguard Worker    2.1.3
93*5e7646d2SAndroid Build Coastguard Worker
94*5e7646d2SAndroid Build Coastguard WorkerThe first production release in a MAJOR.MINOR series (MAJOR.MINOR.0) is called
95*5e7646d2SAndroid Build Coastguard Workera feature release.  Feature releases are the only releases that may contain new
96*5e7646d2SAndroid Build Coastguard Workerfeatures.  Subsequent production releases in a MAJOR.MINOR series may only
97*5e7646d2SAndroid Build Coastguard Workercontain bug fixes.
98*5e7646d2SAndroid Build Coastguard Worker
99*5e7646d2SAndroid Build Coastguard WorkerBeta-test releases are identified by appending the letter B to the major and
100*5e7646d2SAndroid Build Coastguard Workerminor version numbers followed by the beta release number:
101*5e7646d2SAndroid Build Coastguard Worker
102*5e7646d2SAndroid Build Coastguard Worker    MAJOR.MINORbNUMBER
103*5e7646d2SAndroid Build Coastguard Worker    2.2b1
104*5e7646d2SAndroid Build Coastguard Worker
105*5e7646d2SAndroid Build Coastguard WorkerRelease candidates are identified by appending the letters RC to the major and
106*5e7646d2SAndroid Build Coastguard Workerminor version numbers followed by the release candidate number:
107*5e7646d2SAndroid Build Coastguard Worker
108*5e7646d2SAndroid Build Coastguard Worker    MAJOR.MINORrcNUMBER
109*5e7646d2SAndroid Build Coastguard Worker    2.2rc1
110*5e7646d2SAndroid Build Coastguard Worker
111*5e7646d2SAndroid Build Coastguard Worker
112*5e7646d2SAndroid Build Coastguard WorkerCoding Guidelines
113*5e7646d2SAndroid Build Coastguard Worker-----------------
114*5e7646d2SAndroid Build Coastguard Worker
115*5e7646d2SAndroid Build Coastguard WorkerContributed source code must follow the guidelines below.  While the examples
116*5e7646d2SAndroid Build Coastguard Workerare for C and C++ source files, source code for other languages should conform
117*5e7646d2SAndroid Build Coastguard Workerto the same guidelines as allowed by the language.
118*5e7646d2SAndroid Build Coastguard Worker
119*5e7646d2SAndroid Build Coastguard WorkerSource code comments provide the reference portion of the CUPS Programming
120*5e7646d2SAndroid Build Coastguard WorkerManual, which is generated using the [codedoc](https://www.msweet.org/codedoc)
121*5e7646d2SAndroid Build Coastguard Workersoftware.
122*5e7646d2SAndroid Build Coastguard Worker
123*5e7646d2SAndroid Build Coastguard Worker
124*5e7646d2SAndroid Build Coastguard Worker### Source Files
125*5e7646d2SAndroid Build Coastguard Worker
126*5e7646d2SAndroid Build Coastguard WorkerAll source files names must be 16 characters or less in length to ensure
127*5e7646d2SAndroid Build Coastguard Workercompatibility with older UNIX filesystems.  Source files containing functions
128*5e7646d2SAndroid Build Coastguard Workerhave an extension of ".c" for C and ".cxx" for C++ source files.  All other
129*5e7646d2SAndroid Build Coastguard Worker"include" files have an extension of ".h".  Tabs are set to 8 characters or
130*5e7646d2SAndroid Build Coastguard Workercolumns.
131*5e7646d2SAndroid Build Coastguard Worker
132*5e7646d2SAndroid Build Coastguard Worker> Note:
133*5e7646d2SAndroid Build Coastguard Worker>
134*5e7646d2SAndroid Build Coastguard Worker> The ".cxx" extension is used because it is the only common C++ extension
135*5e7646d2SAndroid Build Coastguard Worker> between Linux, macOS, UNIX, and Windows.
136*5e7646d2SAndroid Build Coastguard Worker
137*5e7646d2SAndroid Build Coastguard WorkerThe top of each source file contains a header giving the purpose or nature of
138*5e7646d2SAndroid Build Coastguard Workerthe source file and the copyright and licensing notice:
139*5e7646d2SAndroid Build Coastguard Worker
140*5e7646d2SAndroid Build Coastguard Worker    /*
141*5e7646d2SAndroid Build Coastguard Worker     * Description of file contents.
142*5e7646d2SAndroid Build Coastguard Worker     *
143*5e7646d2SAndroid Build Coastguard Worker     * Copyright 2017 by Apple Inc.
144*5e7646d2SAndroid Build Coastguard Worker     *
145*5e7646d2SAndroid Build Coastguard Worker     * Licensed under Apache License v2.0.  See the file "LICENSE" for more
146*5e7646d2SAndroid Build Coastguard Worker     * information.
147*5e7646d2SAndroid Build Coastguard Worker     */
148*5e7646d2SAndroid Build Coastguard Worker
149*5e7646d2SAndroid Build Coastguard Worker
150*5e7646d2SAndroid Build Coastguard Worker### Header Files
151*5e7646d2SAndroid Build Coastguard Worker
152*5e7646d2SAndroid Build Coastguard WorkerAll public header files must include the "versioning.h" header file, or a header
153*5e7646d2SAndroid Build Coastguard Workerthat does so.  Function declarations are then "decorated" with the correct
154*5e7646d2SAndroid Build Coastguard Worker`_CUPS_API_major_minor` macro to define its availability based on the build
155*5e7646d2SAndroid Build Coastguard Workerenvironment, for example:
156*5e7646d2SAndroid Build Coastguard Worker
157*5e7646d2SAndroid Build Coastguard Worker    extern int cupsDoThis(int foo, int bar) _CUPS_API_2_2;
158*5e7646d2SAndroid Build Coastguard Worker
159*5e7646d2SAndroid Build Coastguard WorkerPrivate API header files must be named with the suffix "-private", for example
160*5e7646d2SAndroid Build Coastguard Workerthe "cups.h" header file defines all of the public CUPS APIs while the
161*5e7646d2SAndroid Build Coastguard Worker"cups-private.h" header file defines all of the private CUPS APIs as well.
162*5e7646d2SAndroid Build Coastguard WorkerTypically a private API header file will include the corresponding public API
163*5e7646d2SAndroid Build Coastguard Workerheader file.
164*5e7646d2SAndroid Build Coastguard Worker
165*5e7646d2SAndroid Build Coastguard Worker
166*5e7646d2SAndroid Build Coastguard Worker### Comments
167*5e7646d2SAndroid Build Coastguard Worker
168*5e7646d2SAndroid Build Coastguard WorkerAll source code utilizes block comments within functions to describe the
169*5e7646d2SAndroid Build Coastguard Workeroperations being performed by a group of statements; avoid putting a comment
170*5e7646d2SAndroid Build Coastguard Workerper line unless absolutely necessary, and then consider refactoring the code
171*5e7646d2SAndroid Build Coastguard Workerso that it is not necessary.  C source files use the block comment format
172*5e7646d2SAndroid Build Coastguard Worker("/* comment */") since many vendor C compilers still do not support C99/C++
173*5e7646d2SAndroid Build Coastguard Workercomments ("// comment"):
174*5e7646d2SAndroid Build Coastguard Worker
175*5e7646d2SAndroid Build Coastguard Worker    /*
176*5e7646d2SAndroid Build Coastguard Worker     * Clear the state array before we begin...
177*5e7646d2SAndroid Build Coastguard Worker     */
178*5e7646d2SAndroid Build Coastguard Worker
179*5e7646d2SAndroid Build Coastguard Worker     for (i = 0; i < (sizeof(array) / sizeof(sizeof(array[0])); i ++)
180*5e7646d2SAndroid Build Coastguard Worker       array[i] = CUPS_STATE_IDLE;
181*5e7646d2SAndroid Build Coastguard Worker
182*5e7646d2SAndroid Build Coastguard Worker    /*
183*5e7646d2SAndroid Build Coastguard Worker     * Wait for state changes on another thread...
184*5e7646d2SAndroid Build Coastguard Worker     */
185*5e7646d2SAndroid Build Coastguard Worker
186*5e7646d2SAndroid Build Coastguard Worker     do
187*5e7646d2SAndroid Build Coastguard Worker     {
188*5e7646d2SAndroid Build Coastguard Worker       for (i = 0; i < (sizeof(array) / sizeof(sizeof(array[0])); i ++)
189*5e7646d2SAndroid Build Coastguard Worker         if (array[i] != CUPS_STATE_IDLE)
190*5e7646d2SAndroid Build Coastguard Worker           break;
191*5e7646d2SAndroid Build Coastguard Worker
192*5e7646d2SAndroid Build Coastguard Worker       if (i == (sizeof(array) / sizeof(array[0])))
193*5e7646d2SAndroid Build Coastguard Worker         sleep(1);
194*5e7646d2SAndroid Build Coastguard Worker     } while (i == (sizeof(array) / sizeof(array[0])));
195*5e7646d2SAndroid Build Coastguard Worker
196*5e7646d2SAndroid Build Coastguard Worker
197*5e7646d2SAndroid Build Coastguard Worker### Indentation
198*5e7646d2SAndroid Build Coastguard Worker
199*5e7646d2SAndroid Build Coastguard WorkerAll code blocks enclosed by brackets begin with the opening brace on a new
200*5e7646d2SAndroid Build Coastguard Workerline.  The code then follows starting on a new line after the brace and is
201*5e7646d2SAndroid Build Coastguard Workerindented 2 spaces.  The closing brace is then placed on a new line following
202*5e7646d2SAndroid Build Coastguard Workerthe code at the original indentation:
203*5e7646d2SAndroid Build Coastguard Worker
204*5e7646d2SAndroid Build Coastguard Worker    {
205*5e7646d2SAndroid Build Coastguard Worker      int i; /* Looping var */
206*5e7646d2SAndroid Build Coastguard Worker
207*5e7646d2SAndroid Build Coastguard Worker     /*
208*5e7646d2SAndroid Build Coastguard Worker      * Process foobar values from 0 to 999...
209*5e7646d2SAndroid Build Coastguard Worker      */
210*5e7646d2SAndroid Build Coastguard Worker
211*5e7646d2SAndroid Build Coastguard Worker      for (i = 0; i < 1000; i ++)
212*5e7646d2SAndroid Build Coastguard Worker      {
213*5e7646d2SAndroid Build Coastguard Worker        do_this(i);
214*5e7646d2SAndroid Build Coastguard Worker        do_that(i);
215*5e7646d2SAndroid Build Coastguard Worker      }
216*5e7646d2SAndroid Build Coastguard Worker    }
217*5e7646d2SAndroid Build Coastguard Worker
218*5e7646d2SAndroid Build Coastguard WorkerSingle-line statements following "do", "else", "for", "if", and "while" are
219*5e7646d2SAndroid Build Coastguard Workerindented 2 spaces as well.  Blocks of code in a "switch" block are indented 4
220*5e7646d2SAndroid Build Coastguard Workerspaces after each "case" and "default" case:
221*5e7646d2SAndroid Build Coastguard Worker
222*5e7646d2SAndroid Build Coastguard Worker    switch (array[i])
223*5e7646d2SAndroid Build Coastguard Worker    {
224*5e7646d2SAndroid Build Coastguard Worker      case CUPS_STATE_IDLE :
225*5e7646d2SAndroid Build Coastguard Worker          do_this(i);
226*5e7646d2SAndroid Build Coastguard Worker          do_that(i);
227*5e7646d2SAndroid Build Coastguard Worker          break;
228*5e7646d2SAndroid Build Coastguard Worker
229*5e7646d2SAndroid Build Coastguard Worker      default :
230*5e7646d2SAndroid Build Coastguard Worker          do_nothing(i);
231*5e7646d2SAndroid Build Coastguard Worker          break;
232*5e7646d2SAndroid Build Coastguard Worker    }
233*5e7646d2SAndroid Build Coastguard Worker
234*5e7646d2SAndroid Build Coastguard Worker
235*5e7646d2SAndroid Build Coastguard Worker### Spacing
236*5e7646d2SAndroid Build Coastguard Worker
237*5e7646d2SAndroid Build Coastguard WorkerA space follows each reserved word such as `if`, `while`, etc.  Spaces are not
238*5e7646d2SAndroid Build Coastguard Workerinserted between a function name and the arguments in parenthesis.
239*5e7646d2SAndroid Build Coastguard Worker
240*5e7646d2SAndroid Build Coastguard Worker
241*5e7646d2SAndroid Build Coastguard Worker### Return Values
242*5e7646d2SAndroid Build Coastguard Worker
243*5e7646d2SAndroid Build Coastguard WorkerParenthesis surround values returned from a function:
244*5e7646d2SAndroid Build Coastguard Worker
245*5e7646d2SAndroid Build Coastguard Worker    return (CUPS_STATE_IDLE);
246*5e7646d2SAndroid Build Coastguard Worker
247*5e7646d2SAndroid Build Coastguard Worker
248*5e7646d2SAndroid Build Coastguard Worker### Functions
249*5e7646d2SAndroid Build Coastguard Worker
250*5e7646d2SAndroid Build Coastguard WorkerFunctions with a global scope have a lowercase prefix followed by capitalized
251*5e7646d2SAndroid Build Coastguard Workerwords, e.g., `cupsDoThis`, `cupsDoThat`, `cupsDoSomethingElse`, etc.  Private
252*5e7646d2SAndroid Build Coastguard Workerglobal functions begin with a leading underscore, e.g., `_cupsDoThis`,
253*5e7646d2SAndroid Build Coastguard Worker`_cupsDoThat`, etc.
254*5e7646d2SAndroid Build Coastguard Worker
255*5e7646d2SAndroid Build Coastguard WorkerFunctions with a local scope are declared static with lowercase names and
256*5e7646d2SAndroid Build Coastguard Workerunderscores between words, e.g., `do_this`, `do_that`, `do_something_else`, etc.
257*5e7646d2SAndroid Build Coastguard Worker
258*5e7646d2SAndroid Build Coastguard WorkerEach function begins with a comment header describing what the function does,
259*5e7646d2SAndroid Build Coastguard Workerthe possible input limits (if any), the possible output values (if any), and
260*5e7646d2SAndroid Build Coastguard Workerany special information needed:
261*5e7646d2SAndroid Build Coastguard Worker
262*5e7646d2SAndroid Build Coastguard Worker    /*
263*5e7646d2SAndroid Build Coastguard Worker     * 'do_this()' - Compute y = this(x).
264*5e7646d2SAndroid Build Coastguard Worker     *
265*5e7646d2SAndroid Build Coastguard Worker     * Notes: none.
266*5e7646d2SAndroid Build Coastguard Worker     */
267*5e7646d2SAndroid Build Coastguard Worker
268*5e7646d2SAndroid Build Coastguard Worker    static float       /* O - Inverse power value, 0.0 <= y <= 1.1 */
269*5e7646d2SAndroid Build Coastguard Worker    do_this(float x)   /* I - Power value (0.0 <= x <= 1.1) */
270*5e7646d2SAndroid Build Coastguard Worker    {
271*5e7646d2SAndroid Build Coastguard Worker      ...
272*5e7646d2SAndroid Build Coastguard Worker      return (y);
273*5e7646d2SAndroid Build Coastguard Worker    }
274*5e7646d2SAndroid Build Coastguard Worker
275*5e7646d2SAndroid Build Coastguard WorkerReturn/output values are indicated using an "O" prefix, input values are
276*5e7646d2SAndroid Build Coastguard Workerindicated using the "I" prefix, and values that are both input and output use
277*5e7646d2SAndroid Build Coastguard Workerthe "IO" prefix for the corresponding in-line comment.
278*5e7646d2SAndroid Build Coastguard Worker
279*5e7646d2SAndroid Build Coastguard WorkerThe [codedoc](https://www.msweet.org/codedoc) documentation generator also
280*5e7646d2SAndroid Build Coastguard Workerunderstands the following special text in the function description comment:
281*5e7646d2SAndroid Build Coastguard Worker
282*5e7646d2SAndroid Build Coastguard Worker    @deprecated@         - Marks the function as deprecated: not recommended
283*5e7646d2SAndroid Build Coastguard Worker                           for new development and scheduled for removal.
284*5e7646d2SAndroid Build Coastguard Worker    @link name@          - Provides a hyperlink to the corresponding function
285*5e7646d2SAndroid Build Coastguard Worker                           or type definition.
286*5e7646d2SAndroid Build Coastguard Worker    @since CUPS version@ - Marks the function as new in the specified version
287*5e7646d2SAndroid Build Coastguard Worker                           of CUPS.
288*5e7646d2SAndroid Build Coastguard Worker    @private@            - Marks the function as private so it will not be
289*5e7646d2SAndroid Build Coastguard Worker                           included in the documentation.
290*5e7646d2SAndroid Build Coastguard Worker
291*5e7646d2SAndroid Build Coastguard Worker
292*5e7646d2SAndroid Build Coastguard Worker### Variables
293*5e7646d2SAndroid Build Coastguard Worker
294*5e7646d2SAndroid Build Coastguard WorkerVariables with a global scope are capitalized, e.g., `ThisVariable`,
295*5e7646d2SAndroid Build Coastguard Worker`ThatVariable`, `ThisStateVariable`, etc.  Globals in CUPS libraries are either
296*5e7646d2SAndroid Build Coastguard Workerpart of the per-thread global values managed by the `_cupsGlobals` function
297*5e7646d2SAndroid Build Coastguard Workeror are suitably protected for concurrent access.  Global variables should be
298*5e7646d2SAndroid Build Coastguard Workerreplaced by function arguments whenever possible.
299*5e7646d2SAndroid Build Coastguard Worker
300*5e7646d2SAndroid Build Coastguard WorkerVariables with a local scope are lowercase with underscores between words,
301*5e7646d2SAndroid Build Coastguard Workere.g., `this_variable`, `that_variable`, etc.  Any "local global" variables
302*5e7646d2SAndroid Build Coastguard Workershared by functions within a source file are declared static.  As for global
303*5e7646d2SAndroid Build Coastguard Workervariables, local static variables are suitably protected for concurrent access.
304*5e7646d2SAndroid Build Coastguard Worker
305*5e7646d2SAndroid Build Coastguard WorkerEach variable is declared on a separate line and is immediately followed by a
306*5e7646d2SAndroid Build Coastguard Workercomment block describing the variable:
307*5e7646d2SAndroid Build Coastguard Worker
308*5e7646d2SAndroid Build Coastguard Worker    int         ThisVariable;    /* The current state of this */
309*5e7646d2SAndroid Build Coastguard Worker    static int  that_variable;   /* The current state of that */
310*5e7646d2SAndroid Build Coastguard Worker
311*5e7646d2SAndroid Build Coastguard Worker
312*5e7646d2SAndroid Build Coastguard Worker### Types
313*5e7646d2SAndroid Build Coastguard Worker
314*5e7646d2SAndroid Build Coastguard WorkerAll type names are lowercase with underscores between words and `_t` appended
315*5e7646d2SAndroid Build Coastguard Workerto the end of the name, e.g., `cups_this_type_t`, `cups_that_type_t`, etc.
316*5e7646d2SAndroid Build Coastguard WorkerType names start with a prefix, typically `cups` or the name of the program,
317*5e7646d2SAndroid Build Coastguard Workerto avoid conflicts with system types.  Private type names start with an
318*5e7646d2SAndroid Build Coastguard Workerunderscore, e.g., `_cups_this_t`, `_cups_that_t`, etc.
319*5e7646d2SAndroid Build Coastguard Worker
320*5e7646d2SAndroid Build Coastguard WorkerEach type has a comment block immediately after the typedef:
321*5e7646d2SAndroid Build Coastguard Worker
322*5e7646d2SAndroid Build Coastguard Worker    typedef int cups_this_type_t;  /* This type is for CUPS foobar options. */
323*5e7646d2SAndroid Build Coastguard Worker
324*5e7646d2SAndroid Build Coastguard Worker
325*5e7646d2SAndroid Build Coastguard Worker### Structures
326*5e7646d2SAndroid Build Coastguard Worker
327*5e7646d2SAndroid Build Coastguard WorkerAll structure names are lowercase with underscores between words and `_s`
328*5e7646d2SAndroid Build Coastguard Workerappended to the end of the name, e.g., `cups_this_s`, `cups_that_s`, etc.
329*5e7646d2SAndroid Build Coastguard WorkerStructure names start with a prefix, typically `cups` or the name of the
330*5e7646d2SAndroid Build Coastguard Workerprogram, to avoid conflicts with system types.  Private structure names start
331*5e7646d2SAndroid Build Coastguard Workerwith an underscore, e.g., `_cups_this_s`, `_cups_that_s`, etc.
332*5e7646d2SAndroid Build Coastguard Worker
333*5e7646d2SAndroid Build Coastguard WorkerEach structure has a comment block immediately after the struct and each member
334*5e7646d2SAndroid Build Coastguard Workeris documented similar to the variable naming policy above:
335*5e7646d2SAndroid Build Coastguard Worker
336*5e7646d2SAndroid Build Coastguard Worker    struct cups_this_struct_s  /* This structure is for CUPS foobar options. */
337*5e7646d2SAndroid Build Coastguard Worker    {
338*5e7646d2SAndroid Build Coastguard Worker      int this_member;         /* Current state for this */
339*5e7646d2SAndroid Build Coastguard Worker      int that_member;         /* Current state for that */
340*5e7646d2SAndroid Build Coastguard Worker    };
341*5e7646d2SAndroid Build Coastguard Worker
342*5e7646d2SAndroid Build Coastguard Worker
343*5e7646d2SAndroid Build Coastguard Worker### Constants
344*5e7646d2SAndroid Build Coastguard Worker
345*5e7646d2SAndroid Build Coastguard WorkerAll constant names are uppercase with underscores between words, e.g.,
346*5e7646d2SAndroid Build Coastguard Worker`CUPS_THIS_CONSTANT`, `CUPS_THAT_CONSTANT`, etc.  Constants begin with an
347*5e7646d2SAndroid Build Coastguard Workeruppercase prefix, typically `CUPS_` or the program or type name.  Private
348*5e7646d2SAndroid Build Coastguard Workerconstants start with an underscore, e.g., `_CUPS_THIS_CONSTANT`,
349*5e7646d2SAndroid Build Coastguard Worker`_CUPS_THAT_CONSTANT`, etc.
350*5e7646d2SAndroid Build Coastguard Worker
351*5e7646d2SAndroid Build Coastguard WorkerTyped enumerations should be used whenever possible to allow for type checking
352*5e7646d2SAndroid Build Coastguard Workerby the compiler.
353*5e7646d2SAndroid Build Coastguard Worker
354*5e7646d2SAndroid Build Coastguard WorkerComment blocks immediately follow each constant:
355*5e7646d2SAndroid Build Coastguard Worker
356*5e7646d2SAndroid Build Coastguard Worker    typedef enum cups_tray_e  /* Tray enumerations */
357*5e7646d2SAndroid Build Coastguard Worker    {
358*5e7646d2SAndroid Build Coastguard Worker      CUPS_TRAY_THIS,         /* This tray */
359*5e7646d2SAndroid Build Coastguard Worker      CUPS_TRAY_THAT          /* That tray */
360*5e7646d2SAndroid Build Coastguard Worker    } cups_tray_t;
361*5e7646d2SAndroid Build Coastguard Worker
362*5e7646d2SAndroid Build Coastguard Worker
363*5e7646d2SAndroid Build Coastguard Worker## Makefile Guidelines
364*5e7646d2SAndroid Build Coastguard Worker
365*5e7646d2SAndroid Build Coastguard WorkerThe following is a guide to the makefile-based build system used by CUPS.
366*5e7646d2SAndroid Build Coastguard WorkerThese standards have been developed over the years to allow CUPS to be built on
367*5e7646d2SAndroid Build Coastguard Workeras many systems and environments as possible.
368*5e7646d2SAndroid Build Coastguard Worker
369*5e7646d2SAndroid Build Coastguard Worker
370*5e7646d2SAndroid Build Coastguard Worker### General Organization
371*5e7646d2SAndroid Build Coastguard Worker
372*5e7646d2SAndroid Build Coastguard WorkerThe CUPS source code is organized functionally into a top-level makefile,
373*5e7646d2SAndroid Build Coastguard Workerinclude file, and subdirectories each with their own makefile and dependencies
374*5e7646d2SAndroid Build Coastguard Workerfiles.  The ".in" files are template files for the autoconf software and are
375*5e7646d2SAndroid Build Coastguard Workerused to generate a static version of the corresponding file.
376*5e7646d2SAndroid Build Coastguard Worker
377*5e7646d2SAndroid Build Coastguard Worker
378*5e7646d2SAndroid Build Coastguard Worker### Makefile Documentation
379*5e7646d2SAndroid Build Coastguard Worker
380*5e7646d2SAndroid Build Coastguard WorkerEach makefile starts with the standard CUPS header containing the description
381*5e7646d2SAndroid Build Coastguard Workerof the file, and CUPS copyright and license notice:
382*5e7646d2SAndroid Build Coastguard Worker
383*5e7646d2SAndroid Build Coastguard Worker    #
384*5e7646d2SAndroid Build Coastguard Worker    # Makefile for ...
385*5e7646d2SAndroid Build Coastguard Worker    #
386*5e7646d2SAndroid Build Coastguard Worker    # Copyright 2017 by Apple Inc.
387*5e7646d2SAndroid Build Coastguard Worker    #
388*5e7646d2SAndroid Build Coastguard Worker    # Licensed under Apache License v2.0.  See the file "LICENSE" for more
389*5e7646d2SAndroid Build Coastguard Worker    # information.
390*5e7646d2SAndroid Build Coastguard Worker    #
391*5e7646d2SAndroid Build Coastguard Worker
392*5e7646d2SAndroid Build Coastguard Worker
393*5e7646d2SAndroid Build Coastguard Worker### Portable Makefile Construction
394*5e7646d2SAndroid Build Coastguard Worker
395*5e7646d2SAndroid Build Coastguard WorkerCUPS uses a common subset of make program syntax to ensure that the software
396*5e7646d2SAndroid Build Coastguard Workercan be compiled "out of the box" on as many systems as possible.  The following
397*5e7646d2SAndroid Build Coastguard Workeris a list of assumptions we follow when constructing makefiles:
398*5e7646d2SAndroid Build Coastguard Worker
399*5e7646d2SAndroid Build Coastguard Worker- Targets; we assume that the make program supports the notion of simple
400*5e7646d2SAndroid Build Coastguard Worker  targets of the form "name:" that perform tab-indented commands that follow
401*5e7646d2SAndroid Build Coastguard Worker  the target, e.g.:
402*5e7646d2SAndroid Build Coastguard Worker
403*5e7646d2SAndroid Build Coastguard Worker      target:
404*5e7646d2SAndroid Build Coastguard Worker      TAB target commands
405*5e7646d2SAndroid Build Coastguard Worker
406*5e7646d2SAndroid Build Coastguard Worker- Dependencies; we assume that the make program supports recursive dependencies
407*5e7646d2SAndroid Build Coastguard Worker  on targets, e.g.:
408*5e7646d2SAndroid Build Coastguard Worker
409*5e7646d2SAndroid Build Coastguard Worker      target: foo bar
410*5e7646d2SAndroid Build Coastguard Worker      TAB target commands
411*5e7646d2SAndroid Build Coastguard Worker
412*5e7646d2SAndroid Build Coastguard Worker      foo: bla
413*5e7646d2SAndroid Build Coastguard Worker      TAB foo commands
414*5e7646d2SAndroid Build Coastguard Worker
415*5e7646d2SAndroid Build Coastguard Worker      bar:
416*5e7646d2SAndroid Build Coastguard Worker      TAB bar commands
417*5e7646d2SAndroid Build Coastguard Worker
418*5e7646d2SAndroid Build Coastguard Worker      bla:
419*5e7646d2SAndroid Build Coastguard Worker      TAB bla commands
420*5e7646d2SAndroid Build Coastguard Worker
421*5e7646d2SAndroid Build Coastguard Worker- Variable Definition; we assume that the make program supports variable
422*5e7646d2SAndroid Build Coastguard Worker  definition on the command-line or in the makefile using the following form:
423*5e7646d2SAndroid Build Coastguard Worker
424*5e7646d2SAndroid Build Coastguard Worker      name=value
425*5e7646d2SAndroid Build Coastguard Worker
426*5e7646d2SAndroid Build Coastguard Worker- Variable Substitution; we assume that the make program supports variable
427*5e7646d2SAndroid Build Coastguard Worker  substitution using the following forms:
428*5e7646d2SAndroid Build Coastguard Worker
429*5e7646d2SAndroid Build Coastguard Worker      - `$(name)`; substitutes the value of "name",
430*5e7646d2SAndroid Build Coastguard Worker      - `$(name:.old=.new)`; substitutes the value of "name" with the filename
431*5e7646d2SAndroid Build Coastguard Worker        extension ".old" changed to ".new",
432*5e7646d2SAndroid Build Coastguard Worker      - `$(MAKEFLAGS)`; substitutes the command-line options passed to the
433*5e7646d2SAndroid Build Coastguard Worker        program without the leading hyphen (-),
434*5e7646d2SAndroid Build Coastguard Worker      - `$$`; substitutes a single $ character,
435*5e7646d2SAndroid Build Coastguard Worker      - `$<`; substitutes the current source file or dependency, and
436*5e7646d2SAndroid Build Coastguard Worker      - `$@`; substitutes the current target name.
437*5e7646d2SAndroid Build Coastguard Worker
438*5e7646d2SAndroid Build Coastguard Worker- Suffixes; we assume that the make program supports filename suffixes with
439*5e7646d2SAndroid Build Coastguard Worker  assumed dependencies, e.g.:
440*5e7646d2SAndroid Build Coastguard Worker
441*5e7646d2SAndroid Build Coastguard Worker      .SUFFIXES: .c .o
442*5e7646d2SAndroid Build Coastguard Worker      .c.o:
443*5e7646d2SAndroid Build Coastguard Worker      TAB $(CC) $(CFLAGS) -o $@ -c $<
444*5e7646d2SAndroid Build Coastguard Worker
445*5e7646d2SAndroid Build Coastguard Worker- Include Files; we assume that the make program supports the include
446*5e7646d2SAndroid Build Coastguard Worker  directive, e.g.:
447*5e7646d2SAndroid Build Coastguard Worker
448*5e7646d2SAndroid Build Coastguard Worker      include ../Makedefs
449*5e7646d2SAndroid Build Coastguard Worker      include Dependencies
450*5e7646d2SAndroid Build Coastguard Worker
451*5e7646d2SAndroid Build Coastguard Worker- Comments; we assume that comments begin with a # character and proceed to the
452*5e7646d2SAndroid Build Coastguard Worker  end of the current line.
453*5e7646d2SAndroid Build Coastguard Worker
454*5e7646d2SAndroid Build Coastguard Worker- Line Length; we assume that there is no practical limit to the length of
455*5e7646d2SAndroid Build Coastguard Worker  lines.
456*5e7646d2SAndroid Build Coastguard Worker
457*5e7646d2SAndroid Build Coastguard Worker- Continuation of long lines; we assume that the `\` character may be placed at
458*5e7646d2SAndroid Build Coastguard Worker  the end of a line to concatenate two or more lines in a makefile to form a
459*5e7646d2SAndroid Build Coastguard Worker  single long line.
460*5e7646d2SAndroid Build Coastguard Worker
461*5e7646d2SAndroid Build Coastguard Worker- Shell; we assume a POSIX-compatible shell is present on the build system.
462*5e7646d2SAndroid Build Coastguard Worker
463*5e7646d2SAndroid Build Coastguard Worker
464*5e7646d2SAndroid Build Coastguard Worker### Standard Variables
465*5e7646d2SAndroid Build Coastguard Worker
466*5e7646d2SAndroid Build Coastguard WorkerThe following variables are defined in the "Makedefs" file generated by the
467*5e7646d2SAndroid Build Coastguard Workerautoconf software:
468*5e7646d2SAndroid Build Coastguard Worker
469*5e7646d2SAndroid Build Coastguard Worker- `ALL_CFLAGS`; the combined C compiler options,
470*5e7646d2SAndroid Build Coastguard Worker- `ALL_CXXFLAGS`; the combined C++ compiler options,
471*5e7646d2SAndroid Build Coastguard Worker- `AMANDIR`; the administrative man page installation directory (section 8/1m
472*5e7646d2SAndroid Build Coastguard Worker  depending on the platform),
473*5e7646d2SAndroid Build Coastguard Worker- `AR`; the library archiver command,
474*5e7646d2SAndroid Build Coastguard Worker- `ARFLAGS`; options for the library archiver command,
475*5e7646d2SAndroid Build Coastguard Worker- `AWK`; the local awk command,
476*5e7646d2SAndroid Build Coastguard Worker- `BINDIR`; the binary installation directory,
477*5e7646d2SAndroid Build Coastguard Worker- `BUILDROOT`; optional installation prefix (defaults to DSTROOT),
478*5e7646d2SAndroid Build Coastguard Worker- `CC`; the C compiler command,
479*5e7646d2SAndroid Build Coastguard Worker- `CFLAGS`; options for the C compiler command,
480*5e7646d2SAndroid Build Coastguard Worker- `CHMOD`; the chmod command,
481*5e7646d2SAndroid Build Coastguard Worker- `CXX`; the C++ compiler command,
482*5e7646d2SAndroid Build Coastguard Worker- `CXXFLAGS`; options for the C++ compiler command,
483*5e7646d2SAndroid Build Coastguard Worker- `DATADIR`; the data file installation directory,
484*5e7646d2SAndroid Build Coastguard Worker- `DSO`; the C shared library building command,
485*5e7646d2SAndroid Build Coastguard Worker- `DSOXX`; the C++ shared library building command,
486*5e7646d2SAndroid Build Coastguard Worker- `DSOFLAGS`; options for the shared library building command,
487*5e7646d2SAndroid Build Coastguard Worker- `INCLUDEDIR`; the public header file installation directory,
488*5e7646d2SAndroid Build Coastguard Worker- `INSTALL`; the install command,
489*5e7646d2SAndroid Build Coastguard Worker- `INSTALL_BIN`; the program installation command,
490*5e7646d2SAndroid Build Coastguard Worker- `INSTALL_COMPDATA`; the compressed data file installation command,
491*5e7646d2SAndroid Build Coastguard Worker- `INSTALL_CONFIG`; the configuration file installation command,
492*5e7646d2SAndroid Build Coastguard Worker- `INSTALL_DATA`; the data file installation command,
493*5e7646d2SAndroid Build Coastguard Worker- `INSTALL_DIR`; the directory installation command,
494*5e7646d2SAndroid Build Coastguard Worker- `INSTALL_LIB`; the library installation command,
495*5e7646d2SAndroid Build Coastguard Worker- `INSTALL_MAN`; the documentation installation command,
496*5e7646d2SAndroid Build Coastguard Worker- `INSTALL_SCRIPT`; the shell script installation command,
497*5e7646d2SAndroid Build Coastguard Worker- `LD`; the linker command,
498*5e7646d2SAndroid Build Coastguard Worker- `LDFLAGS`; options for the linker,
499*5e7646d2SAndroid Build Coastguard Worker- `LIBDIR`; the library installation directory,
500*5e7646d2SAndroid Build Coastguard Worker- `LIBS`; libraries for all programs,
501*5e7646d2SAndroid Build Coastguard Worker- `LN`; the ln command,
502*5e7646d2SAndroid Build Coastguard Worker- `MAN1EXT`; extension for man pages in section 1,
503*5e7646d2SAndroid Build Coastguard Worker- `MAN3EXT`; extension for man pages in section 3,
504*5e7646d2SAndroid Build Coastguard Worker- `MAN5EXT`; extension for man pages in section 5,
505*5e7646d2SAndroid Build Coastguard Worker- `MAN7EXT`; extension for man pages in section 7,
506*5e7646d2SAndroid Build Coastguard Worker- `MAN8DIR`; subdirectory for man pages in section 8,
507*5e7646d2SAndroid Build Coastguard Worker- `MAN8EXT`; extension for man pages in section 8,
508*5e7646d2SAndroid Build Coastguard Worker- `MANDIR`; the man page installation directory,
509*5e7646d2SAndroid Build Coastguard Worker- `OPTIM`; common compiler optimization options,
510*5e7646d2SAndroid Build Coastguard Worker- `PRIVATEINCLUDE`; the private header file installation directory,
511*5e7646d2SAndroid Build Coastguard Worker- `RM`; the rm command,
512*5e7646d2SAndroid Build Coastguard Worker- `SHELL`; the sh (POSIX shell) command,
513*5e7646d2SAndroid Build Coastguard Worker- `STRIP`; the strip command,
514*5e7646d2SAndroid Build Coastguard Worker- `srcdir`; the source directory.
515*5e7646d2SAndroid Build Coastguard Worker
516*5e7646d2SAndroid Build Coastguard Worker
517*5e7646d2SAndroid Build Coastguard Worker### Standard Targets
518*5e7646d2SAndroid Build Coastguard Worker
519*5e7646d2SAndroid Build Coastguard WorkerThe following standard targets are defined in each makefile:
520*5e7646d2SAndroid Build Coastguard Worker
521*5e7646d2SAndroid Build Coastguard Worker- `all`; creates all target programs, libraries, and documentation files,
522*5e7646d2SAndroid Build Coastguard Worker- `clean`; removes all target programs libraries, documentation files, and object
523*5e7646d2SAndroid Build Coastguard Worker  files,
524*5e7646d2SAndroid Build Coastguard Worker- `depend`; generates automatic dependencies for any C or C++ source files (also
525*5e7646d2SAndroid Build Coastguard Worker  see "DEPENDENCIES"),
526*5e7646d2SAndroid Build Coastguard Worker- `distclean`; removes autoconf-generated files in addition to those removed by
527*5e7646d2SAndroid Build Coastguard Worker  the "clean" target,
528*5e7646d2SAndroid Build Coastguard Worker- `install`; installs all distribution files in their corresponding locations
529*5e7646d2SAndroid Build Coastguard Worker  (also see "INSTALL/UNINSTALL SUPPORT"),
530*5e7646d2SAndroid Build Coastguard Worker- `install-data`; installs all data files in their corresponding locations (also
531*5e7646d2SAndroid Build Coastguard Worker  see "INSTALL/UNINSTALL SUPPORT"),
532*5e7646d2SAndroid Build Coastguard Worker- `install-exec`; installs all executable files in their corresponding locations
533*5e7646d2SAndroid Build Coastguard Worker  (also see "INSTALL/UNINSTALL SUPPORT"),
534*5e7646d2SAndroid Build Coastguard Worker- `install-headers`; installs all include files in their corresponding locations
535*5e7646d2SAndroid Build Coastguard Worker  (also see "INSTALL/UNINSTALL SUPPORT"),
536*5e7646d2SAndroid Build Coastguard Worker- `install-libs`; installs all library files in their corresponding locations
537*5e7646d2SAndroid Build Coastguard Worker  (also see "INSTALL/UNINSTALL SUPPORT"), and
538*5e7646d2SAndroid Build Coastguard Worker- `uninstall`; removes all distribution files from their corresponding locations
539*5e7646d2SAndroid Build Coastguard Worker  (also see "INSTALL/UNINSTALL SUPPORT").
540*5e7646d2SAndroid Build Coastguard Worker
541*5e7646d2SAndroid Build Coastguard Worker
542*5e7646d2SAndroid Build Coastguard Worker### Object Files
543*5e7646d2SAndroid Build Coastguard Worker
544*5e7646d2SAndroid Build Coastguard WorkerObject files (the result of compiling a C or C++ source file) have the
545*5e7646d2SAndroid Build Coastguard Workerextension ".o".
546*5e7646d2SAndroid Build Coastguard Worker
547*5e7646d2SAndroid Build Coastguard Worker
548*5e7646d2SAndroid Build Coastguard Worker### Programs
549*5e7646d2SAndroid Build Coastguard Worker
550*5e7646d2SAndroid Build Coastguard WorkerProgram files are the result of linking object files and libraries together to
551*5e7646d2SAndroid Build Coastguard Workerform an executable file.  A typical program target looks like:
552*5e7646d2SAndroid Build Coastguard Worker
553*5e7646d2SAndroid Build Coastguard Worker    program: $(OBJS)
554*5e7646d2SAndroid Build Coastguard Worker    TAB echo Linking $@...
555*5e7646d2SAndroid Build Coastguard Worker    TAB $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
556*5e7646d2SAndroid Build Coastguard Worker
557*5e7646d2SAndroid Build Coastguard Worker### Static Libraries
558*5e7646d2SAndroid Build Coastguard Worker
559*5e7646d2SAndroid Build Coastguard WorkerStatic libraries have a prefix of "lib" and the extension ".a". A typical
560*5e7646d2SAndroid Build Coastguard Workerstatic library target looks like:
561*5e7646d2SAndroid Build Coastguard Worker
562*5e7646d2SAndroid Build Coastguard Worker    libname.a: $(OBJECTS)
563*5e7646d2SAndroid Build Coastguard Worker    TAB echo Creating $@...
564*5e7646d2SAndroid Build Coastguard Worker    TAB $(RM) $@
565*5e7646d2SAndroid Build Coastguard Worker    TAB $(AR) $(ARFLAGS) $@ $(OBJECTS)
566*5e7646d2SAndroid Build Coastguard Worker    TAB $(RANLIB) $@
567*5e7646d2SAndroid Build Coastguard Worker
568*5e7646d2SAndroid Build Coastguard Worker### Shared Libraries
569*5e7646d2SAndroid Build Coastguard Worker
570*5e7646d2SAndroid Build Coastguard WorkerShared libraries have a prefix of "lib" and the extension ".dylib" or ".so"
571*5e7646d2SAndroid Build Coastguard Workerdepending on the operating system.  A typical shared library is composed of
572*5e7646d2SAndroid Build Coastguard Workerseveral targets that look like:
573*5e7646d2SAndroid Build Coastguard Worker
574*5e7646d2SAndroid Build Coastguard Worker    libname.so: $(OBJECTS)
575*5e7646d2SAndroid Build Coastguard Worker    TAB echo $(DSOCOMMAND) libname.so.$(DSOVERSION) ...
576*5e7646d2SAndroid Build Coastguard Worker    TAB $(DSOCOMMAND) libname.so.$(DSOVERSION) $(OBJECTS)
577*5e7646d2SAndroid Build Coastguard Worker    TAB $(RM) libname.so libname.so.$(DSOMAJOR)
578*5e7646d2SAndroid Build Coastguard Worker    TAB $(LN) libname.so.$(DSOVERSION) libname.so.$(DSOMAJOR)
579*5e7646d2SAndroid Build Coastguard Worker    TAB $(LN) libname.so.$(DSOVERSION) libname.so
580*5e7646d2SAndroid Build Coastguard Worker
581*5e7646d2SAndroid Build Coastguard Worker    libname.dylib: $(OBJECTS)
582*5e7646d2SAndroid Build Coastguard Worker    TAB echo $(DSOCOMMAND) libname.$(DSOVERSION).dylib ...
583*5e7646d2SAndroid Build Coastguard Worker    TAB $(DSOCOMMAND) libname.$(DSOVERSION).dylib \
584*5e7646d2SAndroid Build Coastguard Worker    TAB TAB -install_name $(libdir)/libname.$(DSOMAJOR).dylib \
585*5e7646d2SAndroid Build Coastguard Worker    TAB TAB -current_version libname.$(DSOVERSION).dylib \
586*5e7646d2SAndroid Build Coastguard Worker    TAB TAB -compatibility_version $(DSOMAJOR).0 \
587*5e7646d2SAndroid Build Coastguard Worker    TAB TAB $(OBJECTS) $(LIBS)
588*5e7646d2SAndroid Build Coastguard Worker    TAB $(RM) libname.dylib
589*5e7646d2SAndroid Build Coastguard Worker    TAB $(RM) libname.$(DSOMAJOR).dylib
590*5e7646d2SAndroid Build Coastguard Worker    TAB $(LN) libname.$(DSOVERSION).dylib libname.$(DSOMAJOR).dylib
591*5e7646d2SAndroid Build Coastguard Worker    TAB $(LN) libname.$(DSOVERSION).dylib libname.dylib
592*5e7646d2SAndroid Build Coastguard Worker
593*5e7646d2SAndroid Build Coastguard Worker### Dependencies
594*5e7646d2SAndroid Build Coastguard Worker
595*5e7646d2SAndroid Build Coastguard WorkerStatic dependencies are expressed in each makefile following the target, for
596*5e7646d2SAndroid Build Coastguard Workerexample:
597*5e7646d2SAndroid Build Coastguard Worker
598*5e7646d2SAndroid Build Coastguard Worker    foo: bar
599*5e7646d2SAndroid Build Coastguard Worker
600*5e7646d2SAndroid Build Coastguard WorkerStatic dependencies are only used when it is not possible to automatically
601*5e7646d2SAndroid Build Coastguard Workergenerate them.  Automatic dependencies are stored in a file named
602*5e7646d2SAndroid Build Coastguard Worker"Dependencies" and included at the end of the makefile.  The following "depend"
603*5e7646d2SAndroid Build Coastguard Workertarget rule is used to create the automatic dependencies:
604*5e7646d2SAndroid Build Coastguard Worker
605*5e7646d2SAndroid Build Coastguard Worker    depend:
606*5e7646d2SAndroid Build Coastguard Worker    TAB $(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies
607*5e7646d2SAndroid Build Coastguard Worker
608*5e7646d2SAndroid Build Coastguard WorkerWe regenerate the automatic dependencies on an macOS system and express any
609*5e7646d2SAndroid Build Coastguard Workernon-macOS dependencies statically in the makefile.
610*5e7646d2SAndroid Build Coastguard Worker
611*5e7646d2SAndroid Build Coastguard Worker
612*5e7646d2SAndroid Build Coastguard Worker### Install/Uninstall Support
613*5e7646d2SAndroid Build Coastguard Worker
614*5e7646d2SAndroid Build Coastguard WorkerAll makefiles contains install and uninstall rules which install or remove the
615*5e7646d2SAndroid Build Coastguard Workercorresponding software.  These rules must use the $(BUILDROOT) variable as a
616*5e7646d2SAndroid Build Coastguard Workerprefix to any installation directory so that CUPS can be installed in a
617*5e7646d2SAndroid Build Coastguard Workertemporary location for packaging by programs like rpmbuild.
618*5e7646d2SAndroid Build Coastguard Worker
619*5e7646d2SAndroid Build Coastguard WorkerThe `INSTALL_BIN`, `INSTALL_COMPDATA`, `INSTALL_CONFIG`, `INSTALL_DATA`,
620*5e7646d2SAndroid Build Coastguard Worker`INSTALL_DIR`, `INSTALL_LIB`, `INSTALL_MAN`, and `INSTALL_SCRIPT` variables
621*5e7646d2SAndroid Build Coastguard Workermust be used when installing files so that the proper ownership and permissions
622*5e7646d2SAndroid Build Coastguard Workerare set on the installed files.
623*5e7646d2SAndroid Build Coastguard Worker
624*5e7646d2SAndroid Build Coastguard WorkerThe `$(RANLIB)` command must be run on any static libraries after installation
625*5e7646d2SAndroid Build Coastguard Workersince the symbol table is invalidated when the library is copied on some
626*5e7646d2SAndroid Build Coastguard Workerplatforms.
627