# CUPS Developer Guide

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.

## Overview

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 developers on Apple's operating systems to develop CUPS-based software under alternate license terms. Significant contributions to CUPS must be licensed to Apple using the Apple Contributor Agreement.

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.

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.

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 never 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. Never rely on undocumented files or formats when developing software for CUPS. Always use a published C API to access data stored in a file to avoid compatibility problems in the future.

## Communication

### How to Contact the Developers

The CUPS.org mailing lists 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. The cups@cups.org mailing list is intended for CUPS usage questions and new software announcements while the cups-devel@cups.org mailing list provides a forum for CUPS developers and monitoring new bugs.

### How to Submit a Bug Report or Feature Request

The CUPS.org Bugs page provides access to the CUPS Software Trouble Report (STR) database and is the formal way to submit a bug report or feature request to the CUPS developers. Please note, however, that we do not provide answers to usage questions or resolve problems in third-party software on this page - use the CUPS.org mailing lists for that instead.

Unlike discussions that occur on the CUPS.org 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.

> Note:

> Please use the search feature of the Bugs 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.

### How to Prepare a Patch

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 GIT "master" branch, which can be generated easily using the following Git command:

    git format-patch remotes/trunk >filename.patch

If you produce a patch using a released source archive, use one of the following commands instead:

    diff -u oldfilename filename >filename.patch

    diff -urN olddirectory directory >filename.patch

New files and files with significant changes can be submitted in their entirety, however that may delay the adoption of your changes.

> Note:

> Patches and files must conform to the standards outlined in the "Coding Guidelines" and "Makefile Guidelines" sections in this document. In addition, since Apple Inc. provides CUPS under multiple licenses, we require that you license significant changes and files to us for inclusion in CUPS. The CUPS developers will inform you if licensing is required.

## Software Development Practices

### Version Numbering

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.

> Note:

> 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.

Production releases use the plain version numbers:

    MAJOR.MINOR.PATCH
    1.0.0
    1.0.1
    1.0.2
    ...
    1.1.0
    ...
    1.1.23
    1.2.0
    1.2.1
    ...
    1.3.0
    ...
    2.0.0

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.

> Note:

> 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.

Beta-test releases are identified by appending the letter B to the major and minor version numbers followed by the beta release number:

    MAJOR.MINORbNUMBER
    1.2b1

Release candidates are identified by appending the letters RC to the major and minor version numbers followed by the release candidate number:

    MAJOR.MINORrcNUMBER
    1.2rc1

Developer snapshots are identified by appending the letters SVN-R to the major and minor version numbers followed by the revision number:

    MAJOR.MINORsvn-rREV
    1.2svn-r1234

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.

### Version Control (Subversion)

The CUPS source files are managed by the Subversion ("SVN") software, available at:

    subversion.apache.org

A public read-only Git mirror is maintained for external developers. Details can be found on the CUPS.org Software page.

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 must be used for commit log messages:

    Summary of the change on one line followed by bug number (STR #NNNN)

    Detailed list of changes.

Primary development occurs on the trunk branch, with changes merged back to release branches as needed.

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.

### Files and Directories

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.

Source files must be documented and formatted as described in "Coding Requirements". Makefiles must follow the guidelines in "Makefile Guidelines".

### Build System

The CUPS build system uses GNU autoconf to tailor the library to the local operating system. Project files for the current release of Microsoft Visual Studio are also provided for Microsoft Windows®. To improve portability, makefiles must not make use of features unique to GNU make. See the Makefile Guidelines section for a description of the allowed make features and makefile guidelines.

Additional GNU build programs such as GNU automake and GNU libtool 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.

### Packaging

Source packages are created using the tools/makesrcdist script in the Subversion repository. The script optionally uses a version number argument:

    tools/makesrcdist
    tools/makesrcdist version

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 "/tmp/cups-version-source.tar.bz2" and "/tmp/cups-version-source.tar.gz".

Binary packages are not generally distributed by the CUPS team, however the packaging/cups.spec and packaging/cups.list files may be used to create binary packages on Linux, OS X, and UNIX. The packaging/cups.spec file produces a binary package using the `rpmbuild(8)` software:

    rpmbuild -ta cups-version-source.tar.gz

The cups.list file is generated by the configure script and produces binary packages for many platforms using the EPM software. Table 3 shows the targets that are available for each type of binary package:

Table 3: Binary Package Targets
Target | Type of Package
--- | ---
bsd | *BSD pkg_install
deb | Debian dpkg
epm | Portable tarball with install script
pkg | Solaris pkgadd
rpm | RPM binary
slackware | Slackware install

Finally, the tools/testrpm and tools/testosx scripts can be used to create binary packages from the current working copy for testing on Linux and OS X, respectively:

    tools/testrpm
    sudo rpm -U /usr/src/redhat/RPMS/{arm,i386,x64_64}/cups*.rpm

    sudo tools/testosx
    open cups.pkg

### Testing

Software testing is conducted according to the CUPS Software Test Plan. This testing is automated via the top-level makefile test target:

    make test

The test environment allows for both short-term automated testing and long-term testing and development without the automated test script.

## Trouble Report Processing

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 Bugs page with one of the following states:

1. STR is closed with complete resolution
2. STR is closed without resolution
3. STR is active, waiting on information from submitter
4. STR is pending with additional information from submitter
5. STR is newly submitted

Trouble reports are processed using the following steps.

### 1. Classification

When a trouble report is received it must be classified at one of the following priority levels:

1. Request for enhancement, e.g. asking for a feature
2. Low, e.g. a documentation error or undocumented side-effect
3. Moderate, e.g. unable to print a file or unable to compile the software
4. High, e.g. unable to print to a printer or key functionality not working
5. Critical, e.g. unable to print at all

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.

The scope of the problem is also determined as:

1. Specific to a machine or printer
2. Specific to an operating system
3. Applies to all machines, printers, and operating systems

### 2. Identification

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.

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).

### 3. Correction

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.

### 4. Notification

The user or vendor is notified when the fix is available or if the problem was caused by user error.

## Release Management

When testing has been completed successfully, a new source package is created using the tools/makesrcdist 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.

Table: CUPS Basic Release Schedule
Week | Version | Description
--- | --- | ---
T-6 weeks | 1.2b1 | First beta release
T-5 weeks | 1.2b2 | Second beta release
T-3 weeks | 1.2rc1 | First release candidate
T-2 weeks | 1.2rc2 | Second release candidate
T-0 weeks | 1.2.0 | Production (feature) release

## Coding Guidelines

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.

### Source Files

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.

> Note:

> The ".cxx" extension is used because it is the only common C++ extension between Linux, OS X, UNIX, and Windows.

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 "$Id$" tag:

    /*
     * "$Id$"
     *
     * Description of file contents.
     *
     * Copyright 2013 by Apple Inc.
     *
     * These coded instructions, statements, and computer programs are the
     * property of Apple Inc. and are protected by Federal copyright
     * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
     * which should have been included with this file.  If this file is
     * file is missing or damaged, see the license at "http://www.cups.org/".
     */

For source files that are subject to the Apple OS-Developed Software exception, the following additional comment appears after the contact information:

     * This file is subject to the Apple OS-Developed Software exception.

The bottom of each source file contains a trailer giving the name of the file using the Subversion "$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:

    /*
     * End of "$Id$".
     */

### Header Files

All public header files must include the versioning.h header file, or a header that does so. Function declarations are then "decorated" with the correct `_CUPS_API_major_minor` macro to define its availability based on the build environment, for example:

    extern int cupsDoThis(int foo, int bar) _CUPS_API_2_0;

Private API header files must be named with the suffix "-private", for example the cups.h header file defines all of the public CUPS APIs while the cups-private.h header file defines all of the private CUPS APIs as well. Typically a private API header file will include the corresponding public API header file.

### Comments

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"):

     /*
      * Clear the state array before we begin...
      */

      for (i = 0; i < (sizeof(array) / sizeof(sizeof(array[0])); i ++)
        array[i] = CUPS_STATE_IDLE;

     /*
      * Wait for state changes on another thread...
      */

      do
      {
        for (i = 0; i < (sizeof(array) / sizeof(sizeof(array[0])); i ++)
          if (array[i] != CUPS_STATE_IDLE)
            break;

        if (i == (sizeof(array) / sizeof(array[0])))
          sleep(1);
      } while (i == (sizeof(array) / sizeof(array[0])));

### Indentation

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:

    {
      int i; /* Looping var */

     /*
      * Process foobar values from 0 to 999...
      */

      for (i = 0; i < 1000; i ++)
      {
        do_this(i);
        do_that(i);
      }
    }

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:

    switch (array[i])
    {
      case CUPS_STATE_IDLE :
          do_this(i);
          do_that(i);
          break;
      default :
          do_nothing(i);
          break;
    }

### Spacing

A space follows each reserved word such as "if", "while", etc. Spaces are not inserted between a function name and the arguments in parenthesis.

### Return Values

Parenthesis surround values returned from a function:

    return (CUPS_STATE_IDLE);

### Functions

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.

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.

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:

    /*
     * 'do_this()' - Compute y = this(x).
     *
     * Notes: none.
     */

    static float                            /* O - Inverse power value, 0.0 <= y <= 1.1 */
    do_this(float x)                        /* I - Power value (0.0 <= x <= 1.1) */
    {
      ...
      return (y);
    }

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.

The Mini-XML documentation generator also understands the following special text in the function description comment:

- `@deprecated@` - Marks the function as deprecated (not recommended for new development and scheduled for removal)
- `@since CUPS version@` - Marks the function as new in the specified version of CUPS.
- `@private@` - Marks the function as private (same as starting the function name with an underscore)

### Variables

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.

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.

Each variable is declared on a separate line and is immediately followed by a comment block describing the variable:

    int         ThisVariable;    /* The current state of this */
    static int  that_variable;   /* The current state of that */

### Types

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.

Each type has a comment block immediately after the typedef:

    typedef int cups_this_type_t;       /* This type is for CUPS foobar options. */

### Structures

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.

Each structure has a comment block immediately after the struct and each member is documented similar to the variable naming policy above:

    struct cups_this_struct_s     /* This structure is for CUPS foobar options. */
    {
      int this_member;            /* Current state for this */
      int that_member;            /* Current state for that */
    };

### Constants

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.

Typed enumerations should be used whenever possible to allow for type checking by the compiler.

Comment blocks immediately follow each constant:

    enum
    {
      CUPS_THIS_TRAY,                       /* This tray */
      CUPS_THAT_TRAY                        /* That tray */
    };

## Makefile Guidelines

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.

### General Organization

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 `autoconf` software and are used to generate a static version of the corresponding file.

### Makefile Documentation

Each makefile starts with the standard CUPS header containing the Subversion "$Id$" keyword, description of the file, and CUPS copyright and license notice:

    #
    # "$Id$"
    #
    # Makefile for ...
    #
    # Copyright 2013 by Apple Inc.
    #
    # These coded instructions, statements, and computer programs are the
    # property of Apple Inc. and are protected by Federal copyright
    # law.  Distribution and use rights are outlined in the file "LICENSE.txt"
    # which should have been included with this file.  If this file is
    # file is missing or damaged, see the license at "http://www.cups.org/".
    #

The end of each makefile has a comment saying:

    #
    # End of "$Id$".
    #

The purpose of the trailer is to indicate the end of the makefile so that truncations are immediately obvious.

### Portable Makefile Construction

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:

- Targets; 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.:

      target:
      → target commands

- Dependencies; we assume that the make program supports recursive dependencies on targets, e.g.:

      target: foo bar
      → target commands

      foo: bla
      → foo commands

      bar:
      → bar commands

      bla:
      → bla commands

- Variable Definition; we assume that the make program supports variable definition on the command-line or in the makefile using the following form:

      name=value

- Variable Substitution; we assume that the make program supports variable substitution using the following forms:
  - `$(name)`; substitutes the value of "name",
  - `($name:.old=.new)`; substitutes the value of "name" with the filename extension ".old" changed to ".new",
  - `$(MAKEFLAGS)`; substitutes the command-line options passed to the program without the leading hyphen (-),
  - `$$`; substitutes a single `$` character,
  - `$<`; substitutes the current source file or dependency, and
  - `$@`; substitutes the current target name.
- Suffixes; we assume that the make program supports filename suffixes with assumed dependencies, e.g.:

      .SUFFIXES: .c .o
      .c.o:
      → $(CC) $(CFLAGS) -o $@ -c $<

- Include Files; we assume that the make program supports the `include` directive, e.g.:

      include ../Makedefs
      include Dependencies

- Comments; we assume that comments begin with a `#` character and proceed to the end of the current line.
- Line Length; we assume that there is no practical limit to the length of lines.
- Continuation of long lines; we assume that the `\` 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.
- Shell; we assume a POSIX-compatible shell is present on the build system.

### Standard Variables

The following variables are defined in the "Makedefs" file generated by the `autoconf` software:

- `ALL_CFLAGS`; the combined C compiler options,
- `ALL_CXXFLAGS`; the combined C++ compiler options,
- `AMANDIR`; the administrative man page installation directory (section 8/1m depending on the platform),
- `AR`; the library archiver command,
- `ARFLAGS`; options for the library archiver command,
- `AWK`; the local awk command,
- `BINDIR`; the binary installation directory,
- `BUILDROOT`; optional installation prefix (defaults to DSTROOT),
- `CC`; the C compiler command,
- `CFLAGS`; options for the C compiler command,
- `CHMOD`; the chmod command,
- `CXX`; the C++ compiler command,
- `CXXFLAGS`; options for the C++ compiler command,
- `DATADIR`; the data file installation directory,
- `DSO`; the C shared library building command,
- `DSOXX`; the C++ shared library building command,
- `DSOFLAGS`; options for the shared library building command,
- `INCLUDEDIR`; the public header file installation directory,
- `INSTALL`; the `install` command,
- `INSTALL_BIN`; the program installation command,
- `INSTALL_COMPDATA`; the compressed data file installation command,
- `INSTALL_CONFIG`; the configuration file installation command,
- `INSTALL_DATA`; the data file installation command,
- `INSTALL_DIR`; the directory installation command,
- `INSTALL_LIB`; the library installation command,
- `INSTALL_MAN`; the documentation installation command,
- `INSTALL_SCRIPT`; the shell script installation command,
- `LD`; the linker command,
- `LDFLAGS`; options for the linker,
- `LIBDIR`; the library installation directory,
- `LIBS`; libraries for all programs,
- `LN`; the `ln` command,
- `MAN1EXT`; extension for man pages in section 1,
- `MAN3EXT`; extension for man pages in section 3,
- `MAN5EXT`; extension for man pages in section 5,
- `MAN7EXT`; extension for man pages in section 7,
- `MAN8DIR`; subdirectory for man pages in section 8,
- `MAN8EXT`; extension for man pages in section 8,
- `MANDIR`; the man page installation directory,
- `OPTIM`; common compiler optimization options,
- `PRIVATEINCLUDE`; the private header file installation directory,
- `RM`; the `rm` command,
- `SHELL`; the `sh` (POSIX shell) command,
- `STRIP`; the `strip` command,
- `srcdir`; the source directory.

### Standard Targets

The following standard targets are defined in each makefile:

- `all`; creates all target programs, libraries, and documentation files,
- `clean`; removes all target programs libraries, documentation files, and object files,
- `depend`; generates automatic dependencies for any C or C++ source files (also see "Dependencies"),
- `distclean`; removes autoconf-generated files in addition to those removed by the "clean" target,
- `install`; installs all distribution files in their corresponding locations (also see "Install/Uninstall Support"),
- `install-data`; installs all data files in their corresponding locations (also see "Install/Uninstall Support"),
- `install-exec`; installs all executable files in their corresponding locations (also see "Install/Uninstall Support"),
- `install-headers`; installs all include files in their corresponding locations (also see "Install/Uninstall Support"),
- `install-libs`; installs all library files in their corresponding locations (also see "Install/Uninstall Support"),
- `uninstall`; removes all distribution files from their corresponding locations (also see "Install/Uninstall Support"), and

### Object Files

Object files (the result of compiling a C or C++ source file) have the extension ".o".

### Programs

Program files are the result of linking object files and libraries together to form an executable file. A typical program target looks like:

    program: $(OBJS)
    → echo Linking $@...
    → $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

### Static Libraries

Static libraries have a prefix of "lib" and the extension ".a". A typical static library target looks like:

    libname.a: $(OBJECTS)
    → echo Creating $@...
    → $(RM) $@
    → $(AR) $(ARFLAGS) $@ $(OBJECTS)
    → $(RANLIB) $@

### Shared Libraries

Shared libraries have a prefix of "lib" and the extension ".dylib" or ".so" depending on the operating system. A typical shared library is composed of several targets that look like:

    libname.so: $(OBJECTS)
    → echo $(DSOCOMMAND) libname.so.$(DSOVERSION) ...
    → $(DSOCOMMAND) libname.so.$(DSOVERSION) $(OBJECTS)
    → $(RM) libname.so libname.so.$(DSOMAJOR)
    → $(LN) libname.so.$(DSOVERSION) libname.so.$(DSOMAJOR)
    → $(LN) libname.so.$(DSOVERSION) libname.so

    libname.dylib: $(OBJECTS)
    → echo $(DSOCOMMAND) libname.$(DSOVERSION).dylib ...
    → $(DSOCOMMAND) libname.$(DSOVERSION).dylib \
    → → -install_name $(libdir)/libname.$(DSOMAJOR).dylib \
    → → -current_version libname.$(DSOVERSION).dylib \
    → → -compatibility_version $(DSOMAJOR).0 \
    → → $(OBJECTS) $(LIBS)
    → $(RM) libname.dylib
    → $(RM) libname.$(DSOMAJOR).dylib
    → $(LN) libname.$(DSOVERSION).dylib libname.$(DSOMAJOR).dylib
    → $(LN) libname.$(DSOVERSION).dylib libname.dylib

### Dependencies

Static dependencies are expressed in each makefile following the target, for example:

    foo: bar

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:

    depend:
    → $(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies

We regenerate the automatic dependencies on an OS X system and express any non-OS X dependencies statically in the makefile.

### Install/Uninstall Support

All makefiles contains install and uninstall rules which install or remove the corresponding software. These rules must use the `$(BUILDROOT)` variable as a prefix to any installation directory so that CUPS can be installed in a temporary location for packaging by programs like `rpmbuild`.

The `$(INSTALL_BIN)`, `$(INSTALL_COMPDATA)`, `$(INSTALL_CONFIG)`, `$(INSTALL_DATA)`, `$(INSTALL_DIR)`, `$(INSTALL_LIB)`, `$(INSTALL_MAN)`, and `$(INSTALL_SCRIPT)` variables must be used when installing files so that the proper ownership and permissions are set on the installed files.

The `$(RANLIB)` command must be run on any static libraries after installation since the symbol table is invalidated when the library is copied on some platforms.