Skip to content
Snippets Groups Projects
asdf.texinfo 250 KiB
Newer Older
\input texinfo          @c -*- texinfo -*-
@c %**start of header
@settitle ASDF Manual
@c %**end of header

@c We use @&key, etc to escape & from TeX in lambda lists --
@c so we need to define them for info as well.
@c for install-info
@dircategory Software development
@direntry
* asdf: (asdf).           Another System Definition Facility (for Common Lisp)
This manual describes ASDF, a system definition facility
for Common Lisp programs and libraries.
You can find the latest version of this manual at
@url{https://common-lisp.net/project/asdf/asdf.html}.
ASDF Copyright @copyright{} 2001-2015 Daniel Barlow and contributors.
This manual Copyright @copyright{} 2001-2015 Daniel Barlow and contributors.
This manual revised @copyright{} 2009-2015 Robert P. Goldman and Francois-Rene Rideau.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@end copying

@include version.texinfo
@title ASDF: Another System Definition Facility
@subtitle Manual for Version @value{VERSION}
@c The following two commands start the copyright page.
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@c Output the table of contents at the beginning.
@contents

@c -------------------

@ifnottex

@node Top, Introduction, (dir), (dir)
@top ASDF: Another System Definition Facility
@ifnottex
Manual for Version @value{VERSION}
@end ifnottex

* Introduction::
* Quick start summary::
* Loading ASDF::
* Configuring ASDF::
* Using ASDF::
* Defining systems with defsystem::
* The object model of ASDF::
* Controlling where ASDF searches for systems::
* Controlling where ASDF saves compiled files::
* Error handling::
* Miscellaneous additional functionality::
* Getting the latest version::
* FAQ::
* Concept Index::
* Function and Class Index::
* Variable Index::              @c @detailmenu

@detailmenu
 --- The Detailed Node Listing ---

Loading ASDF

* Loading a pre-installed ASDF::
* Checking whether ASDF is loaded::
* Upgrading ASDF::
* Replacing your implementation's ASDF::
* Loading ASDF from source::
Configuring ASDF

* Configuring ASDF to find your systems::
* Configuring ASDF to find your systems --- old style::
* Configuring where ASDF stores object files::
* Resetting the ASDF configuration::
Defining systems with defsystem

* The defsystem form::
* A more involved example::
* The defsystem grammar::
* Other code in .asd files::
* The package-inferred-system extension::
* Operations::
* Components::
* Predefined operations of ASDF::
* Creating new operations::
* Common attributes of components::
* Pre-defined subclasses of component::
* Creating new component types::
* Pre-defined subclasses of component::
* Creating new component types::
Controlling where ASDF searches for systems

* Configurations::
* Truenames and other dangers::
* XDG base directory::
* Backward Compatibility::
* Configuration DSL::
* Configuration Directories::
* Shell-friendly syntax for configuration::
* Search Algorithm::
* Caching Results::
* Configuration API::
* Introspection::
* Status::
* Rejected ideas::
* TODO::
* Credits for the source-registry::

Configuration Directories

* The here directive::

Introspection

* *source-registry-parameter* variable::
* Information about system dependencies::

Controlling where ASDF saves compiled files

* Output Configurations::
* Output Backward Compatibility::
* Output Configuration DSL::
* Output Configuration Directories::
* Output Shell-friendly syntax for configuration::
* Semantics of Output Translations::
* Output Caching Results::
* Output location API::
* Credits for output translations::

Miscellaneous additional functionality

* Controlling file compilation::
* Controlling source file character encoding::
* Miscellaneous Functions::
* Where do I report a bug?::
* Mailing list::
* What has changed between ASDF 1 ASDF 2 and ASDF 3?::
* Issues with installing the proper version of ASDF::
* Issues with configuring ASDF::
* Issues with using and extending ASDF to define systems::
* ASDF development FAQs::
``What has changed between ASDF 1, ASDF 2, and ASDF 3?''
* What are ASDF 1 2 3?::
* How do I detect the ASDF version?::
* ASDF can portably name files in subdirectories::
* Output translations::
* Source Registry Configuration::
* Usual operations are made easier to the user::
* Many bugs have been fixed::
* ASDF itself is versioned::
* ASDF can be upgraded::
* Decoupled release cycle::
* Pitfalls of the transition to ASDF 2::
* Pitfalls of the upgrade to ASDF 3::
* What happened to the bundle operations::

Issues with installing the proper version of ASDF

* My Common Lisp implementation comes with an outdated version of ASDF. What to do?::
* I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?::

Issues with configuring ASDF

* How can I customize where fasl files are stored?::
* How can I wholly disable the compiler output cache?::

Issues with using and extending ASDF to define systems

* How can I cater for unit-testing in my system?::
* How can I cater for documentation generation in my system?::
* How can I maintain non-Lisp (e.g. C) source files?::
* I want to put my module's files at the top level.  How do I do this?::
* How do I create a system definition where all the source files have a .cl extension?::
* How do I mark a source file to be loaded only and not compiled?::
* How do I work with readtables?::
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
* How do I run the tests interactively in a REPL?::
@end menu

@end ifnottex

@c -------------------

@node Introduction, Quick start summary, Top, Top
@comment  node-name,  next,  previous,  up
@chapter Introduction
@cindex ASDF-related features
@vindex *features*
@cindex Testing for ASDF
@cindex ASDF versions
@cindex :asdf
@cindex :asdf2
ASDF is Another System Definition Facility:
a tool for specifying how systems of Common Lisp software
are made up of components (sub-systems and files),
and how to operate on these components in the right order
so that they can be compiled, loaded, tested, etc.
If you are new to ASDF, @pxref{Quick start summary,,the quick start

ASDF presents three faces:
one for users of Common Lisp software who want to reuse other people's code,
one for writers of Common Lisp software who want to specify how to build their systems,
and one for implementers of Common Lisp extensions who want to extend
the build system.
@pxref{Using ASDF},
to learn how to use ASDF to load a system.
Robert P. Goldman's avatar
Robert P. Goldman committed
@xref{Defining systems with defsystem},
to learn how to define a system of your own.
@xref{The object model of ASDF}, for a description of
Robert P. Goldman's avatar
Robert P. Goldman committed
the ASDF internals and how to extend ASDF.
ASDF is @emph{not} a tool for library and system @emph{installation};
it plays a role like @code{make} or @code{ant}, not like a package manager.
In particular, ASDF should not to be confused with Quicklisp or ASDF-Install,
that attempt to find and download ASDF systems for you.
Despite what the name might suggest, ASDF-Install is not part of ASDF, but a separate piece of software.
ASDF-Install is also unmaintained and obsolete.
(@uref{http://www.quicklisp.org/}) instead,
a Common Lisp package manager which works well and is being actively maintained.
If you want to download software from version control instead of tarballs,
so you may more easily modify it, we recommend clbuild (@uref{http://common-lisp.net/project/clbuild/}).
We recommend @file{~/common-lisp/}
as a place into which to install Common Lisp software;
starting with ASDF 3.1.2, it is included in the default source-registry configuration.
Finally, note that this manual is incomplete.
All the bases are covered,
but many advanced topics are only barely alluded to,
and there is not much in terms of examples.
The source code remains the ultimate source of information,
free software systems in Quicklisp remain the best source of examples,
and the mailing-list the best place to ask for help.


@node  Quick start summary, Loading ASDF, Introduction, Top
@chapter Quick start summary
Load ASDF itself into your Lisp image, using
@code{(require "asdf")}.
Check that you have a recent version using @code{(asdf:asdf-version)}.
For more details, or if any of the above fails, @pxref{Loading ASDF}.
Make sure software is installed where ASDF can find it.
The simplest way is to put all your Lisp code in subdirectories of
@file{~/common-lisp/} (starting with ASDF 3.1.2),
or @file{~/.local/share/common-lisp/source/}
(for ASDF 2 and later, or if you want to keep source in a hidden directory).
For more details, @pxref{Configuring ASDF to find your systems}.
Load your system with @code{(asdf:load-system "@var{my-system}")}.
@xref{Using ASDF}.

@end itemize

@item To make your own ASDF system:

@itemize
@item
As above, load and configure ASDF.

@item
Make a new directory for your system, @code{@var{my-system}/},
again in a location where ASDF can find it.
All else being equal, the easiest location is probably
@file{~/common-lisp/my-system/}.
@xref{Configuring ASDF to find your systems}.
Create an ASDF system definition listing the dependencies of
your system, its components, and their interdependencies,
and put it in @file{@var{my-system}.asd}.
This file must have the same name as your system, all lowercase.
@xref{Defining systems with defsystem}.
Use @code{(asdf:load-system "@var{my-system}")}
to make sure it's all working properly. @xref{Using ASDF}.
@c FIXME: (1) add a sample project that the user can cut and paste to
@c get started.  (2) discuss the option of starting with Quicklisp.





@node Loading ASDF, Configuring ASDF, Quick start summary, Top
@comment  node-name,  next,  previous,  up
@menu
* Loading a pre-installed ASDF::
* Checking whether ASDF is loaded::
* Upgrading ASDF::
* Replacing your implementation's ASDF::
@node  Loading a pre-installed ASDF, Checking whether ASDF is loaded, Loading ASDF, Loading ASDF
@section Loading a pre-installed ASDF

The recommended way to load ASDF is via:
@lisp
(require "asdf")
@end lisp

All actively maintained Lisp implementations now include a copy of ASDF 3
that you can load this way using Common Lisp's @code{require} function.@footnote{
NB: all implementations except GNU CLISP also accept
@code{(require "ASDF")}, @code{(require 'asdf)} and @code{(require :asdf)}.
For portability's sake, you should use @code{(require "asdf")}.
If the implementation you are using doesn't provide a recent ASDF 3,
we recommend you upgrade it.
If for some reason you would rather not upgrade it,
we recommend you replace your implementation's ASDF.
@xref{Replacing your implementation's ASDF}.
If all else fails, see @pxref{Loading ASDF from source} below.

If you use an actively maintained implementation that fails to provide
an up-to-date enough stable release of ASDF,
you may also send a bug report to your Lisp vendor and complain about it
--- or you may fix the issue yourself if it's free software.

As of the writing of this manual,
the following implementations provide ASDF 3 this way:
ABCL, Allegro CL, CLASP, Clozure CL, CMUCL, ECL, GNU CLISP, LispWorks, MKCL, SBCL.
The following implementations only provide ASDF 2:
MOCL, XCL.
The following implementations don't provide ASDF:
Corman CL, GCL, Genera, MCL, SCL.
The latter implementations are not actively maintained (except maybe GCL);
if some of them are ever released again, they probably will include ASDF 3.

For maximum convenience you might want to have ASDF loaded
whenever you start your Lisp implementation,
for example by loading it from the startup script or dumping a custom core
--- check your Lisp implementation's manual for details.
SLIME notably sports a @code{slime-asdf} contrib that makes life easier with ASDF.

@node Checking whether ASDF is loaded, Upgrading ASDF, Loading a pre-installed ASDF, Loading ASDF
@section Checking whether ASDF is loaded

To check that ASDF is properly loaded, you can run this form:

@lisp
(asdf:asdf-version)
@end lisp

If it returns a string,
that is the version of ASDF that is currently installed.
If that version is suitably recent (say, 3.1.2 or later),
then you can skip directly to next chapter: @xref{Configuring ASDF}.

If it raises an error,
then either ASDF is not loaded, or
you are using a very old version of ASDF,
and need to install ASDF 3.
For more precision in detecting versions old and new,
@pxref{How do I detect the ASDF version?}.
If you are experiencing problems with ASDF,
please try upgrading to the latest released version,
using the method below,
before you contact us and raise an issue.
@node  Upgrading ASDF, Replacing your implementation's ASDF, Checking whether ASDF is loaded, Loading ASDF
@section Upgrading ASDF
@c FIXME: tighten this up a bit -- there's a lot of stuff here that
@c doesn't matter to almost anyone.  Move discussion of updating antique
@c versions of ASDF down, or encapsulate it.
If your implementation already provides ASDF 3 or later (and it should),
but you want a more recent ASDF version than your implementation provides,
then you just need to ensure the more recent ASDF is installed in a configured path, like any other system.
We recommend you download an official tarball or checkout a release from git into
@file{~/common-lisp/asdf/}.
(@pxref{Configuring ASDF to find your systems}).

Once the source code for ASDF is installed,
you don't need any extra step to load it beyond the usual @code{(require "asdf")}:
ASDF 3 will automatically look whether an updated version of itself is available
amongst the regularly configured systems, before it compiles anything else.

If your implementation fails to provide ASDF 3 or later,
@pxref{Replacing your implementation's ASDF}.
@node Replacing your implementation's ASDF, Loading ASDF from source, Upgrading ASDF, Loading ASDF
@section Replacing your implementation's ASDF

All maintained implementations now provide ASDF 3 in their latest release.
If your doesn't, we recommend you upgrade it.
Now, if you insist on using an old implementation that didn't provide ASDF or provided an old version,
we recommend installing a recent ASDF, as explained below,
into your implementation's installation directory.
Thus your modified implementation will now provide ASDF 3.
This requires proper write permissions and may necessitate execution as a system administrator.

The ASDF source repository contains a tool to help you upgrade your implementation's ASDF.
You can invoke it from the shell command-line as
@code{tools/asdf-tools install-asdf lispworks}
(where you can replace @code{lispworks} by the name of the relevant implementation),
or you can @code{(load "tools/install-asdf.lisp")} from your Lisp REPL.

This script works on
Allegro CL, Clozure CL, CMU CL, ECL, GCL, GNU CLISP, LispWorks, MKCL, SBCL, SCL, XCL.
It doesn't work on ABCL, Corman CL, Genera, MCL, MOCL.
Happily, ABCL is usually pretty up to date and shouldn't need that script.
GCL requires a very recent version, and hasn't been tested much.
Corman CL, Genera, MCL are obsolete anyway.
MOCL is incomplete.
@node Loading ASDF from source,  , Replacing your implementation's ASDF, Loading ASDF
@section Loading ASDF from source
If you write build scripts that must remain portable to old machines with old implementations
that you cannot ensure have been upgraded or modified to provide a recent ASDF,
you may have to install the file @file{asdf.lisp}
somewhere and load it with:

@lisp
(load "/path/to/your/installed/asdf.lisp")
@end lisp
The single file @file{asdf.lisp} is all you normally need to use ASDF.
You can extract this file from latest release tarball on the
@url{https://common-lisp.net/project/asdf/,ASDF website}.
If you are daring and willing to report bugs, you can get
the latest and greatest version of ASDF from its git repository.
@xref{Getting the latest version}.

For scripts that try to use ASDF simply via @code{require} at first, and
make heroic attempts to load it the hard way if at first they don't succeed,
see @file{tools/load-asdf.lisp} distributed with the ASDF source repository,
or the code of @url{https://cliki.net/cl-launch,@code{cl-launch}}.
@node Configuring ASDF, Using ASDF, Loading ASDF, Top
@comment  node-name,  next,  previous,  up
For standard use cases, ASDF should work pretty much out of the box.
We recommend you skim the sections on configuring ASDF to find your systems
and choose the method of installing Lisp software that works best for you.
Then skip directly to @xref{Using ASDF}. That will probably be enough.
You are unlikely to have to worry about the way ASDF stores object files,
and resetting the ASDF configuration is usually only needed in corner cases.
* Configuring ASDF to find your systems::
* Configuring ASDF to find your systems --- old style::
* Configuring where ASDF stores object files::
* Resetting the ASDF configuration::
Robert P. Goldman's avatar
Robert P. Goldman committed
@end menu

@node Configuring ASDF to find your systems, Configuring ASDF to find your systems --- old style, Configuring ASDF, Configuring ASDF
@section Configuring ASDF to find your systems

Robert P. Goldman's avatar
Robert P. Goldman committed
In order to compile and load your systems, ASDF must be configured to find
the @file{.asd} files that contain system definitions.

Robert P. Goldman's avatar
Robert P. Goldman committed
There are a number of different techniques for setting yourself up with
ASDF, starting from easiest to the most complex:

@itemize @bullet
Put all of your systems in one of the standard locations,
subdirectories of
@file{~/common-lisp/} or
@file{~/.local/share/common-lisp/source/}.
If you install software there, you don't need further
configuration.@footnote{
  @file{~/common-lisp/} is only included in
  the default configuration
  starting with ASDF 3.1.2 or later.
  If your implementation provides an earlier variant of ASDF,
  you may need to explicitly configure it to use this path,
  as further explained.
}
You can then skip to the next section. @xref{Loading a system}.
Robert P. Goldman's avatar
Robert P. Goldman committed

If you're using some tool to install software (e.g. Quicklisp),
the authors of that tool should already have configured ASDF.

Robert P. Goldman's avatar
Robert P. Goldman committed
If you have more specific desires about how to lay out your software on
disk, the preferred way to configure where ASDF finds your systems is
the @code{source-registry} facility,
fully described in its own chapter of this manual.
@xref{Controlling where ASDF searches for systems}.
Here is a quick recipe for getting started.

First create the directory
@file{~/.config/common-lisp/source-registry.conf.d/}@footnote{
  For Windows users, and starting with ASDF 3.1.5, start from your
  @file{%LOCALAPPDATA%}, which is usually @file{~/AppData/Local/}
  (but you can ask in a @code{CMD.EXE} terminal
  @code{echo %LOCALAPPDATA%} to make sure)
  and underneath create a subpath
  @file{config/common-lisp/source-registry.conf.d/}.
};
there create a file with any name of your choice
but with the type @file{conf}@footnote{
  By requiring the @file{.conf}
  extension, and ignoring other files, ASDF allows you to have disabled files,
  editor backups, etc. in the same directory with your active
  configuration files.

  ASDF will also ignore files whose names start with a @file{.} character.

  It is customary to start the filename with two digits, to control the
  sorting of the @code{conf} files in the source registry directory, and
  thus the order in which the directories will be scanned.
},
for instance @file{50-luser-lisp.conf};
in this file, add the following line
to tell ASDF to recursively scan all the subdirectories under @file{/home/luser/lisp/}
for @file{.asd} files:
@kbd{(:tree "/home/luser/lisp/")}
That's enough. You may replace @file{/home/luser/lisp/} by wherever you want to install your source code.
You don't actually need to specify anything if you use the default @file{~/common-lisp/} as above
and your implementation provides ASDF 3.1.2 or later.
If your implementation provides an earlier variant of ASDF 3,
you might want to specify @kbd{(:tree (:home "common-lisp/"))} for bootstrap purposes,
then install a recent source tree of ASDF under @file{~/common-lisp/asdf/}.
If you prefer to use a ``link farm'', which is faster to use but costlier to manage than a recursive traversal,
say at @file{/home/luser/.asd-link-farm/}, then
you may instead (or additionally) create a file @file{42-asd-link-farm.conf}, containing the line:
@kbd{(:directory "/home/luser/.asd-link-farm/")}

ASDF will automatically read your configuration
the first time you try to find a system.
Robert P. Goldman's avatar
Robert P. Goldman committed
If necessary, you can reset the source-registry configuration with:
@lisp
(asdf:clear-source-registry)
@end lisp

Robert P. Goldman's avatar
Robert P. Goldman committed
@item
In earlier versions of ASDF, the system source registry was configured
using a global variable, @code{asdf:*central-registry*}.
For more details about this, see the following section,
@ref{Configuring ASDF to find your systems --- old style}.
Unless you need to understand this,
Robert P. Goldman's avatar
Robert P. Goldman committed
skip directly to @ref{Configuring where ASDF stores object files}.
Robert P. Goldman's avatar
Robert P. Goldman committed
@end itemize

Note that your Operating System distribution or your system administrator
may already have configured system-managed libraries for you.



@node Configuring ASDF to find your systems --- old style, Configuring where ASDF stores object files, Configuring ASDF to find your systems, Configuring ASDF
@section Configuring ASDF to find your systems --- old style


@c FIXME: this section should be moved elsewhere.  The novice user
@c should not be burdened with it. [2014/02/27:rpg]

The old way to configure ASDF to find your systems is by
@code{push}ing directory pathnames onto the variable
@code{asdf:*central-registry*}.

You must configure this variable between the time you load ASDF
and the time you first try to use it.
Loading and configuring ASDF presumably happen
as part of some initialization script that builds or starts
your Common Lisp software system.
(For instance, some SBCL users used to put it in their @file{~/.sbclrc}.)

The @code{asdf:*central-registry*} is empty by default in ASDF 2 or ASDF 3,
but is still supported for compatibility with ASDF 1.
When used, it takes precedence over the above source-registry.@footnote{
It is possible to further customize
the system definition file search.
That's considered advanced use, and covered later:
search forward for
@code{*system-definition-search-functions*}.
@xref{Defining systems with defsystem}.}
For example, let's say you want ASDF to find the @file{.asd} file
@file{/home/me/src/foo/foo.asd}.
In your lisp initialization file, you could have the following:
(push "/home/me/src/foo/" asdf:*central-registry*)
@end lisp

Note the trailing slash: when searching for a system,
ASDF will evaluate each entry of the central registry
and coerce the result to a pathname.@footnote{
ASDF will indeed call @code{eval} on each entry.
It will skip entries that evaluate to @code{nil}.

Strings and pathname objects are self-evaluating,
in which case the @code{eval} step does nothing;
but you may push arbitrary s-expressions onto the central registry.
These s-expressions may be evaluated to compute context-dependent
entries, e.g. things that depend
on the value of shell variables or the identity of the user.

The variable @code{asdf:*central-registry*} is thus a list of
``system directory designators''.
A @dfn{system directory designator} is a form
which will be evaluated whenever a system is to be found,
and must evaluate to a directory to look in (or @code{NIL}).
By ``directory'', we mean
``designator for a pathname with a non-empty DIRECTORY component''.
The trailing directory name separator
is necessary to tell Lisp that you're discussing a directory
rather than a file.  If you leave it out, ASDF is likely to look in
@code{/home/me/src/} instead of @code{/home/me/src/foo/} as you
intended, and fail to find your system definition.
Typically there are a lot of @file{.asd} files, and
a common idiom was to put
@emph{symbolic links} to all of one's @file{.asd} files
in a common directory
and push @emph{that} directory (the ``link farm'')
onto
@code{asdf:*central-registry*},
instead of pushing each individual system directory.

ASDF knows to follow @emph{symlinks}
to the actual location of the systems.@footnote{
  On Windows, you can use Windows shortcuts instead of POSIX symlinks.
  if you try aliases under MacOS, we are curious to hear about your experience.
}
For example, if @code{#p"/home/me/cl/systems/"}
is an element of @code{*central-registry*}, you could set up the
system @var{foo} as follows:

@example
$ cd /home/me/cl/systems/
$ ln -s ~/src/foo/foo.asd .
@end example

This old style for configuring ASDF is not recommended for new users,
but it is supported for old users, and for users who want a simple way to
programmatically control what directories are added to the ASDF search path.
@node Configuring where ASDF stores object files, Resetting the ASDF configuration, Configuring ASDF to find your systems --- old style, Configuring ASDF
@section Configuring where ASDF stores object files
@findex clear-output-translations

ASDF lets you configure where object files will be stored.
Sensible defaults are provided and
you shouldn't normally have to worry about it.

This allows the same source code repository to be shared
between several versions of several Common Lisp implementations,
between several users using different compilation options,
with users who lack write privileges on shared source directories, etc.
This also keeps source directories from being cluttered
with object/fasl files.
Starting with ASDF 2, the @code{asdf-output-translations} facility
was added to ASDF itself.  This facility controls where object files will be stored.
This facility is fully described in a chapter of this manual,
@ref{Controlling where ASDF saves compiled files}.
@c FIXME: possibly this should be moved elsewhere.  It's redundant here,
@c and makes this section of the manual too long and daunting for the
@c new user. [2014/02/27:rpg]
@c The simplest way to add a translation to your search path,
@c say from @file{/foo/bar/baz/quux/}
@c to @file{/where/i/want/my/fasls/}
@c is to create the directory
@c @file{~/.config/common-lisp/asdf-output-translations.conf.d/}
@c and there create a file with any name of your choice and the type @file{conf},
@c for instance @file{42-bazquux.conf}
@c containing the line:

@c @kbd{("/foo/bar/baz/quux/" "/where/i/want/my/fasls/")}

@c To disable output translations for source under a given directory,
@c say @file{/toto/tata/}
@c you can create a file @file{40-disable-toto.conf}
@c with the line:

@c @kbd{("/toto/tata/")}

@c To wholly disable output translations for all directories,
@c you can create a file @file{00-disable.conf}
@c with the line:

@c @kbd{(t t)}

@c Note that your Operating System distribution or your system administrator
@c may already have configured translations for you.
@c In absence of any configuration, the default is to redirect everything
@c under an implementation-dependent subdirectory of @file{~/.cache/common-lisp/}.
@c @xref{Controlling where ASDF searches for systems}, for full details.

@c The required @file{.conf} extension allows you to have disabled files
@c or editor backups (ending in @file{~}), and works portably
@c (for instance, it is a pain to allow both empty and non-empty extension on CLISP).
@c Excluded are files the name of which start with a @file{.} character.
@c It is customary to start the filename with two digits
@c that specify the order in which the directories will be scanned.

@c ASDF will automatically read your configuration
@c the first time you try to find a system.
@c You can reset the source-registry configuration with:

@c @lisp
@c (asdf:clear-output-translations)
@c @end lisp
@c And you probably should do so before you dump your Lisp image,
@c if the configuration may change
@c between the machine where you save it at the time you save it
@c and the machine you resume it at the time you resume it.
@c (Once again, you should use @code{(asdf:clear-configuration)}
@c before you dump your Lisp image, which includes the above.)
other ASDF add-ons offered the same functionality,
each in subtly different and incompatible ways:
ASDF-Binary-Locations, cl-launch, common-lisp-controller.
ASDF-Binary-Locations is now not needed anymore and should not be used.
cl-launch 3.000 and common-lisp-controller 7.2 have been updated
to delegate object file placement to ASDF.
@node Resetting the ASDF configuration,  , Configuring where ASDF stores object files, Configuring ASDF
@section Resetting the ASDF configuration

@c FIXME: this should probably be moved out of the "quickstart" part of
@c the manual. [2014/02/27:rpg]

When you dump and restore an image, or when you tweak your configuration,
you may want to reset the ASDF configuration.
For that you may use the following function:

@defun clear-configuration
   Undoes any ASDF configuration
   regarding source-registry or output-translations.
@end defun

@vindex *image-dump-hook*
This function is pushed onto the @code{uiop:*image-dump-hook*} by default,
which means that if you save an image using @code{uiop:dump-image},
or via @code{asdf:image-op} and @code{asdf:program-op},
it will be automatically called to clear your configuration.
If for some reason you prefer to call your implementation's underlying functionality,
be sure to call @code{clear-configuration} manually,
or push it into your implementation's equivalent of @code{uiop:*image-dump-hook*},
e.g. @code{sb-ext:*save-hooks*} on SBCL, or @code{ext:*before-save-initializations*}
on CMUCL and SCL, etc.
@node  Using ASDF, Defining systems with defsystem, Configuring ASDF, Top
Robert P. Goldman's avatar
Robert P. Goldman committed
@menu
* Loading a system::
Robert P. Goldman's avatar
Robert P. Goldman committed
* Moving on::
@end menu

@node Loading a system, Convenience Functions, Using ASDF, Using ASDF
@section Loading a system

The system @var{foo} is loaded (and compiled, if necessary)
by evaluating the following Lisp form:
(asdf:load-system :@var{foo})
On some implementations (@pxref{Convenience Functions}),
ASDF hooks into the @code{cl:require} facility and you can just use:
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed

@example
(require :@var{foo})
@end example

Note that the canonical name of a system is a string, conventionally lowercase.
A system name can also be specified as a symbol (including a keyword),
in which case its @code{symbol-name} is taken and lowercased.
The name must be a suitable value for the @code{:name} initarg
to @code{make-pathname} in whatever filesystem the system is to be found.
The lower-casing-symbols behaviour is unconventional,
but was selected after some consideration.
The type of systems we want to support
either have lowercase as customary case (Unix, Mac, Windows)
or silently convert lowercase to uppercase (lpns).
@c so this makes more sense than attempting to use @code{:case :common},
@c which is reported not to work on some implementations
@node Convenience Functions, Moving on, Loading a system, Using ASDF
@section Convenience Functions
Robert Goldman's avatar
Robert Goldman committed

@findex load-system
@findex compile-system
@findex test-system
Robert Goldman's avatar
Robert Goldman committed
@findex require-system
@findex make
ASDF provides three commands for the most common system operations:
@code{load-system}, @code{compile-system}, and @code{test-system}.
It also provides @code{require-system}, a version of @code{load-system}
that skips trying to update systems that are already loaded.
And it provides @code{make}, a function that uses whichever operation
was specified by the author of the target system,
which by default behaves like @code{load-system}.
@c FIXME: We seem to export @findex bundle-system also, that some ECL users seem to rely on.
@c But it's probably better that bundle operations have their own manual chapter at some point.
Because ASDF is an extensible system
for defining @emph{operations} on @emph{components},
it also provides a generic function @code{operate},
so you may arbitrarily operate on your systems beyond the default operations.
(At the interactive REPL, users often use its shorter alias @code{oos},
which stands for operate-on-system, a name inherited from @code{mk-defsystem}.)
You'll use @code{operate} whenever you want to do something beyond
compiling, loading and testing.
Note that output from ASDF and ASDF extensions are sent
to the CL stream @code{*standard-output*},
so rebinding that stream around calls to @code{asdf:operate}
should redirect all output from ASDF operations.
@c Reminder: before ASDF can operate on a system, however,
@c it must be able to find and load that system's definition.
@c @xref{Configuring ASDF to find your systems}.
@c FIXME: the following is too complicated for here, especially since
@c :force hasn't been defined yet.  Move it. [2014/02/27:rpg]
@findex load-system
@vindex *load-system-operation*
@findex already-loaded-systems
@findex require-system
@code{load-system} applies @code{operate} with the operation from
the system, and any provided keyword arguments.
@code{*load-system-operation*} by default is @code{load-op};
it would be @code{load-bundle-op} by default on ECL, if only an implementation bug were fixed.
@code{require-system} skips any update to systems that have already been loaded,
in the spirit of @code{cl:require}.
It does it by calling @code{load-system} with a keyword option excluding already loaded systems.@footnote{
  For the curious, the option is @code{:force-not (already-loaded-systems)}.
}.
On actively maintained free software implementations
(namely recent versions of ABCL, Clozure CL, CMUCL, ECL, GNU CLISP, MKCL and SBCL),
once ASDF itself is loaded, @code{cl:require} too can load ASDF systems,
by falling back on @code{require-system}
for module names not recognized by the implementation.

Note that @code{cl:require} and @code{require-system} are appropriate to load code
that is not being modified during the current programming session.
This notably includes the implementation-provided extension modules that @code{cl:require} can load.
This also includes any number of ASDF systems that the user isn't either developing or debugging,
for which a previously installed version is deemed to be satisfactory.
@code{require-system} and through it @code{cl:require} can load these systems without any problem.
But for code that you are actively developing, debugging, or otherwise modifying,
you should use @code{load-system}, so ASDF will pick on your modifications
and transitively re-build the modified files and everything that depends on them.

Finally, starting with ASDF 3.1, a function @code{make} is also available,
that does ``The Right Thing'' with your system.
The default behaviour is to load the system as if by @code{load-system};
but instead of this default, system authors can specify
the intended use of their system by specifying their desired operation
with a @code{:build-operation} argument in the system definition.