2013-01-21 18:37:33 +01:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2000-06-23 02:37:15 +02:00
|
|
|
<!-- Copyright (c) 1999 Neil Blakey-Milner, All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source (SGML DocBook) and 'compiled' forms
|
|
|
|
(SGML HTML, PDF, PostScript, RTF and so forth) with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
1. Redistributions of source code (SGML DocBook) must retain the above
|
|
|
|
copyright notice, this list of conditions and the following
|
|
|
|
disclaimer as the first lines of this file unmodified.
|
|
|
|
|
|
|
|
2. Redistributions in compiled form (transformed to other DTDs,
|
|
|
|
converted to PDF, PostScript, RTF and other formats) must reproduce
|
|
|
|
the above copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other materials
|
|
|
|
provided with the distribution.
|
|
|
|
|
|
|
|
THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL NIK CLAYTON BE LIABLE FOR ANY DIRECT,
|
|
|
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2001-11-01 00:47:32 +01:00
|
|
|
$FreeBSD$
|
2000-06-23 02:37:15 +02:00
|
|
|
-->
|
2013-11-07 16:39:28 +01:00
|
|
|
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="doc-build">
|
2000-06-23 02:37:15 +02:00
|
|
|
<title>The Documentation Build Process</title>
|
|
|
|
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>This chapter covers organization of the documentation build
|
|
|
|
process and how &man.make.1; is used to control it.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<sect1 xml:id="doc-build-toolset">
|
2013-07-20 03:21:45 +02:00
|
|
|
<title>The &os; Documentation Build Toolset</title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>These are the tools used to build and install the
|
|
|
|
<acronym>FDP</acronym> documentation.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>The primary build tool is &man.make.1;, specifically
|
2000-06-23 02:37:15 +02:00
|
|
|
<application>Berkeley Make</application>.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2013-07-20 03:21:45 +02:00
|
|
|
<para>Package building is handled by &os;'s
|
|
|
|
&man.pkg.create.1;.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>&man.gzip.1; is used to create compressed versions of
|
|
|
|
the document. &man.bzip2.1; archives are also supported.
|
|
|
|
&man.tar.1; is used for package building.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>&man.install.1; is used to install the
|
|
|
|
documentation.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</sect1>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<sect1 xml:id="doc-build-makefiles">
|
2012-05-20 05:43:43 +02:00
|
|
|
|
|
|
|
<title>Understanding <filename>Makefile</filename>s in the
|
|
|
|
Documentation Tree</title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2012-02-15 05:27:21 +01:00
|
|
|
<para>There are three main types of <filename>Makefile</filename>s
|
2013-07-20 03:21:45 +02:00
|
|
|
in the &os; Documentation Project tree.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para><link linkend="sub-make">Subdirectory
|
2012-02-15 05:27:21 +01:00
|
|
|
<filename>Makefile</filename>s</link> simply pass
|
2000-06-23 02:37:15 +02:00
|
|
|
commands to those directories below them.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para><link linkend="doc-make">Documentation
|
2012-02-15 05:27:21 +01:00
|
|
|
<filename>Makefile</filename>s</link> describe the
|
|
|
|
document(s) that should be produced from this
|
|
|
|
directory.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><link linkend="make-includes"><application>Make</application>
|
2012-02-15 05:27:21 +01:00
|
|
|
includes</link> are the glue that perform the document
|
|
|
|
production, and are usually of the form
|
2014-02-26 04:27:51 +01:00
|
|
|
<filename>doc.<replaceable>xxx</replaceable>.mk</filename>.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<sect2 xml:id="sub-make">
|
2012-05-20 05:40:37 +02:00
|
|
|
<title>Subdirectory <filename>Makefile</filename>s</title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2012-02-15 05:27:21 +01:00
|
|
|
<para>These <filename>Makefile</filename>s usually take the form
|
|
|
|
of:</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<programlisting>SUBDIR =articles
|
|
|
|
SUBDIR+=books
|
|
|
|
|
|
|
|
COMPAT_SYMLINK = en
|
|
|
|
|
|
|
|
DOC_PREFIX?= ${.CURDIR}/..
|
|
|
|
.include "${DOC_PREFIX}/share/mk/doc.project.mk"</programlisting>
|
|
|
|
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>The first four non-empty lines define the &man.make.1;
|
2013-11-07 16:39:28 +01:00
|
|
|
variables <varname>SUBDIR</varname>,
|
|
|
|
<varname>COMPAT_SYMLINK</varname>, and
|
|
|
|
<varname>DOC_PREFIX</varname>.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>The <varname>SUBDIR</varname> statement and
|
|
|
|
<varname>COMPAT_SYMLINK</varname> statement show how to
|
2000-06-23 02:37:15 +02:00
|
|
|
assign a value to a variable, overriding any previous
|
|
|
|
value.</para>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>The second <varname>SUBDIR</varname> statement shows how a
|
2000-06-23 02:37:15 +02:00
|
|
|
value is appended to the current value of a variable. The
|
2013-11-07 16:39:28 +01:00
|
|
|
<varname>SUBDIR</varname> variable is now <literal>articles
|
2012-02-15 05:27:21 +01:00
|
|
|
books</literal>.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>The <varname>DOC_PREFIX</varname> assignment shows how a
|
2012-02-15 05:27:21 +01:00
|
|
|
value is assigned to the variable, but only if it is not
|
|
|
|
already defined. This is useful if
|
2013-11-07 16:39:28 +01:00
|
|
|
<varname>DOC_PREFIX</varname> is not where this
|
2012-02-15 05:27:21 +01:00
|
|
|
<filename>Makefile</filename> thinks it is - the user can
|
|
|
|
override this and provide the correct value.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>What does it all mean? <varname>SUBDIR</varname>
|
2000-06-23 02:37:15 +02:00
|
|
|
mentions which subdirectories below this one the build process
|
|
|
|
should pass any work on to.</para>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>COMPAT_SYMLINK</varname> is specific to
|
2012-02-15 05:27:21 +01:00
|
|
|
compatibility symlinks (amazingly enough) for languages to
|
|
|
|
their official encoding (<filename>doc/en</filename> would
|
|
|
|
point to <filename>en_US.ISO-8859-1</filename>).</para>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>DOC_PREFIX</varname> is the path to the root of
|
2013-07-20 03:28:57 +02:00
|
|
|
the &os; Document Project tree. This is not always that easy
|
|
|
|
to find, and is also easily overridden, to allow for
|
2013-11-07 16:39:28 +01:00
|
|
|
flexibility. <varname>.CURDIR</varname> is a &man.make.1;
|
2013-07-20 03:28:57 +02:00
|
|
|
builtin variable with the path to the current
|
|
|
|
directory.</para>
|
|
|
|
|
|
|
|
<para>The final line includes the &os; Documentation Project's
|
|
|
|
project-wide &man.make.1; system file
|
|
|
|
<filename>doc.project.mk</filename> which is the glue which
|
|
|
|
converts these variables into build instructions.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</sect2>
|
2012-02-15 05:27:21 +01:00
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<sect2 xml:id="doc-make">
|
2012-05-20 05:40:37 +02:00
|
|
|
<title>Documentation <filename>Makefile</filename>s</title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>These <filename>Makefile</filename>s set &man.make.1;
|
|
|
|
variables that describe how to build the documentation
|
|
|
|
contained in that directory.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<para>Here is an example:</para>
|
|
|
|
|
|
|
|
<programlisting>MAINTAINER=nik@FreeBSD.org
|
|
|
|
|
|
|
|
DOC?= book
|
|
|
|
|
|
|
|
FORMATS?= html-split html
|
|
|
|
|
|
|
|
INSTALL_COMPRESSED?= gz
|
|
|
|
INSTALL_ONLY_COMPRESSED?=
|
|
|
|
|
|
|
|
# SGML content
|
2012-10-01 11:53:01 +02:00
|
|
|
SRCS= book.xml
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
DOC_PREFIX?= ${.CURDIR}/../../..
|
|
|
|
|
|
|
|
.include "$(DOC_PREFIX)/share/mk/docproj.docbook.mk"</programlisting>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>The <varname>MAINTAINER</varname> variable allows
|
2013-07-20 03:28:57 +02:00
|
|
|
committers to claim ownership of a document in the &os;
|
|
|
|
Documentation Project, and take responsibility for maintaining
|
2000-06-23 02:37:15 +02:00
|
|
|
it.</para>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>DOC</varname> is the name (sans the
|
2012-10-01 11:53:01 +02:00
|
|
|
<filename>.xml</filename> extension) of the main document
|
2013-11-07 16:39:28 +01:00
|
|
|
created by this directory. <varname>SRCS</varname> lists all
|
2000-06-23 02:37:15 +02:00
|
|
|
the individual files that make up the document. This should
|
|
|
|
also include important files in which a change should result
|
|
|
|
in a rebuild.</para>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>FORMATS</varname> indicates the default formats
|
2000-06-23 02:37:15 +02:00
|
|
|
that should be built for this document.
|
2013-11-07 16:39:28 +01:00
|
|
|
<varname>INSTALL_COMPRESSED</varname> is the default list of
|
2000-06-23 02:37:15 +02:00
|
|
|
compression techniques that should be used in the document
|
2013-11-07 16:39:28 +01:00
|
|
|
build. <varname>INSTALL_ONLY_COMPRESS</varname>, empty by
|
2000-06-23 02:37:15 +02:00
|
|
|
default, should be non-empty if only compressed documents are
|
|
|
|
desired in the build.</para>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>The <varname>DOC_PREFIX</varname> and include statements
|
2000-06-23 02:37:15 +02:00
|
|
|
should be familiar already.</para>
|
|
|
|
</sect2>
|
|
|
|
</sect1>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<sect1 xml:id="make-includes">
|
2013-07-20 03:21:45 +02:00
|
|
|
<title>&os; Documentation Project
|
2012-05-20 05:43:43 +02:00
|
|
|
<application>Make</application> Includes</title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>&man.make.1; includes are best explained by inspection of
|
|
|
|
the code. Here are the system include files:</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para><filename>doc.project.mk</filename> is the main project
|
2012-02-15 05:27:21 +01:00
|
|
|
include file, which includes all the following include
|
|
|
|
files, as necessary.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para><filename>doc.subdir.mk</filename> handles traversing of
|
2012-02-15 05:27:21 +01:00
|
|
|
the document tree during the build and install
|
|
|
|
processes.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para><filename>doc.install.mk</filename> provides variables
|
|
|
|
that affect ownership and installation of documents.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para><filename>doc.docbook.mk</filename> is included if
|
2013-11-07 16:39:28 +01:00
|
|
|
<varname>DOCFORMAT</varname> is <literal>docbook</literal>
|
|
|
|
and <varname>DOC</varname> is set.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
|
|
|
|
<sect2>
|
2012-05-20 05:40:37 +02:00
|
|
|
<title><filename>doc.project.mk</filename></title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<para>By inspection:</para>
|
|
|
|
|
|
|
|
<programlisting>DOCFORMAT?= docbook
|
|
|
|
MAINTAINER?= doc@FreeBSD.org
|
|
|
|
|
|
|
|
PREFIX?= /usr/local
|
2001-06-11 03:20:40 +02:00
|
|
|
PRI_LANG?= en_US.ISO8859-1
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
.if defined(DOC)
|
|
|
|
.if ${DOCFORMAT} == "docbook"
|
|
|
|
.include "doc.docbook.mk"
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.include "doc.subdir.mk"
|
|
|
|
.include "doc.install.mk"</programlisting>
|
|
|
|
|
|
|
|
<sect3>
|
|
|
|
|
|
|
|
<title>Variables</title>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>DOCFORMAT</varname> and
|
|
|
|
<varname>MAINTAINER</varname> are assigned default values,
|
2012-02-15 05:27:21 +01:00
|
|
|
if these are not set by the document make file.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>PREFIX</varname> is the prefix under which the
|
2012-02-15 05:27:21 +01:00
|
|
|
<link linkend="tools">documentation building tools</link>
|
|
|
|
are installed. For normal package and port installation,
|
|
|
|
this is <filename>/usr/local</filename>.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>PRI_LANG</varname> should be set to whatever
|
2012-02-15 05:27:21 +01:00
|
|
|
language and encoding is natural amongst users these
|
|
|
|
documents are being built for. US English is the
|
|
|
|
default.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<note>
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>PRI_LANG</varname> does not affect which
|
2012-02-15 05:27:21 +01:00
|
|
|
documents can, or even will, be built. Its main use is
|
|
|
|
creating links to commonly referenced documents into the
|
2013-07-20 03:21:45 +02:00
|
|
|
&os; documentation install root.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</note>
|
|
|
|
</sect3>
|
|
|
|
|
|
|
|
<sect3>
|
|
|
|
<title>Conditionals</title>
|
2012-02-15 05:27:21 +01:00
|
|
|
|
|
|
|
<para>The <literal>.if defined(DOC)</literal> line is an
|
2013-07-20 03:28:57 +02:00
|
|
|
example of a &man.make.1; conditional which, like in other
|
|
|
|
programs, defines behavior if some condition is true or if
|
|
|
|
it is false. <literal>defined</literal> is a function which
|
|
|
|
returns whether the variable given is defined or not.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<para><literal>.if ${DOCFORMAT} == "docbook"</literal>, next,
|
2013-11-07 16:39:28 +01:00
|
|
|
tests whether the <varname>DOCFORMAT</varname> variable is
|
2000-06-23 02:37:15 +02:00
|
|
|
<literal>"docbook"</literal>, and in this case, includes
|
|
|
|
<filename>doc.docbook.mk</filename>.</para>
|
|
|
|
|
|
|
|
<para>The two <literal>.endif</literal>s close the two above
|
|
|
|
conditionals, marking the end of their application.</para>
|
|
|
|
</sect3>
|
|
|
|
</sect2>
|
|
|
|
|
|
|
|
<sect2>
|
2012-05-20 05:40:37 +02:00
|
|
|
<title><filename>doc.subdir.mk</filename></title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2013-07-20 03:28:57 +02:00
|
|
|
<para>This file is too long to explain in detail. These notes
|
|
|
|
describe the most important features.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<sect3>
|
|
|
|
<title>Variables</title>
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>SUBDIR</varname> is a list of
|
2012-02-15 05:27:21 +01:00
|
|
|
subdirectories that the build process should go further
|
|
|
|
down into.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>ROOT_SYMLINKS</varname> is the name of
|
2000-06-23 02:37:15 +02:00
|
|
|
directories that should be linked to the document
|
|
|
|
install root from their actual locations, if the current
|
|
|
|
language is the primary language (specified by
|
2013-11-07 16:39:28 +01:00
|
|
|
<varname>PRI_LANG</varname>).</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><varname>COMPAT_SYMLINK</varname> is described in
|
2012-02-15 05:27:21 +01:00
|
|
|
the
|
2000-06-23 02:37:15 +02:00
|
|
|
<link linkend="sub-make">Subdirectory Makefile</link>
|
|
|
|
section.</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</sect3>
|
|
|
|
|
|
|
|
<sect3>
|
2012-05-20 05:40:37 +02:00
|
|
|
<title>Targets and Macros</title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2012-02-15 05:27:21 +01:00
|
|
|
<para>Dependencies are described by
|
2014-02-26 04:27:51 +01:00
|
|
|
<literal><replaceable>target</replaceable>:
|
|
|
|
<replaceable>dependency1 dependency2
|
|
|
|
...</replaceable></literal> tuples, where to build
|
2013-07-20 03:21:45 +02:00
|
|
|
<literal>target</literal>, the given
|
|
|
|
dependencies must be built first.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2012-02-15 05:27:21 +01:00
|
|
|
<para>After that descriptive tuple, instructions on how to
|
|
|
|
build the target may be given, if the conversion process
|
|
|
|
between the target and its dependencies are not previously
|
|
|
|
defined, or if this particular conversion is not the same as
|
|
|
|
the default conversion method.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<para>A special dependency <literal>.USE</literal> defines
|
|
|
|
the equivalent of a macro.</para>
|
|
|
|
|
2012-05-20 05:43:43 +02:00
|
|
|
<programlisting>_SUBDIRUSE: .USE
|
2000-06-23 02:37:15 +02:00
|
|
|
.for entry in ${SUBDIR}
|
2006-01-05 21:03:39 +01:00
|
|
|
@${ECHO} "===> ${DIRPRFX}${entry}"
|
|
|
|
@(cd ${.CURDIR}/${entry} && \
|
2000-06-23 02:37:15 +02:00
|
|
|
${MAKE} ${.TARGET:S/realpackage/package/:S/realinstall/install/} DIRPRFX=${DIRPRFX}${entry}/ )
|
|
|
|
.endfor</programlisting>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>In the above, <buildtarget>_SUBDIRUSE</buildtarget> is now
|
2012-02-15 05:27:21 +01:00
|
|
|
a macro which will execute the given commands when it is
|
|
|
|
listed as a dependency.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2012-02-15 05:27:21 +01:00
|
|
|
<para>What sets this macro apart from other targets?
|
|
|
|
Basically, it is executed <emphasis>after</emphasis> the
|
|
|
|
instructions given in the build procedure it is listed as a
|
|
|
|
dependency to, and it does not adjust
|
2013-11-07 16:39:28 +01:00
|
|
|
<varname>.TARGET</varname>, which is the variable which
|
2012-02-15 05:27:21 +01:00
|
|
|
contains the name of the target currently being
|
|
|
|
built.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2012-05-20 05:43:43 +02:00
|
|
|
<programlisting>clean: _SUBDIRUSE
|
2000-06-23 02:37:15 +02:00
|
|
|
rm -f ${CLEANFILES}</programlisting>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>In the above, <buildtarget>clean</buildtarget> will use
|
|
|
|
the <buildtarget>_SUBDIRUSE</buildtarget> macro after it has
|
2012-02-15 05:27:21 +01:00
|
|
|
executed the instruction
|
|
|
|
<command>rm -f ${CLEANFILES}</command>. In effect, this
|
2013-11-07 16:39:28 +01:00
|
|
|
causes <buildtarget>clean</buildtarget> to go further and
|
2012-02-15 05:27:21 +01:00
|
|
|
further down the directory tree, deleting built files as it
|
|
|
|
goes <emphasis>down</emphasis>, not on the way back
|
|
|
|
up.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<sect4>
|
2012-05-20 05:40:37 +02:00
|
|
|
<title>Provided Targets</title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><buildtarget>install</buildtarget> and
|
|
|
|
<buildtarget>package</buildtarget> both go down the
|
2000-06-23 02:37:15 +02:00
|
|
|
directory tree calling the real versions of themselves
|
2005-09-12 18:47:36 +02:00
|
|
|
in the subdirectories
|
2013-11-07 16:39:28 +01:00
|
|
|
(<buildtarget>realinstall</buildtarget> and
|
|
|
|
<buildtarget>realpackage</buildtarget>
|
2012-02-15 05:27:21 +01:00
|
|
|
respectively).</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2013-11-07 16:39:28 +01:00
|
|
|
<para><buildtarget>clean</buildtarget> removes files
|
2012-02-15 05:27:21 +01:00
|
|
|
created by the build process (and goes down the
|
|
|
|
directory tree too).
|
2013-11-07 16:39:28 +01:00
|
|
|
<buildtarget>cleandir</buildtarget> does the same, and
|
2012-02-15 05:27:21 +01:00
|
|
|
also removes the object directory, if any.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</sect4>
|
|
|
|
</sect3>
|
|
|
|
|
|
|
|
<sect3>
|
2012-05-20 05:40:37 +02:00
|
|
|
<title>More on Conditionals</title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para><literal>exists</literal> is another condition
|
2012-02-15 05:27:21 +01:00
|
|
|
function which returns true if the given file
|
|
|
|
exists.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para><literal>empty</literal> returns true if the given
|
|
|
|
variable is empty.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para><literal>target</literal> returns true if the given
|
|
|
|
target does not already exist.</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</sect3>
|
|
|
|
|
|
|
|
<sect3>
|
2012-05-20 05:43:43 +02:00
|
|
|
<title>Looping Constructs in <command>make
|
|
|
|
(.for)</command></title>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2012-02-15 05:27:21 +01:00
|
|
|
<para><literal>.for</literal> provides a way to repeat a set
|
|
|
|
of instructions for each space-separated element in a
|
|
|
|
variable. It does this by assigning a variable to contain
|
|
|
|
the current element in the list being examined.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
|
2012-05-20 05:43:43 +02:00
|
|
|
<programlisting>_SUBDIRUSE: .USE
|
2000-06-23 02:37:15 +02:00
|
|
|
.for entry in ${SUBDIR}
|
2006-01-05 21:03:39 +01:00
|
|
|
@${ECHO} "===> ${DIRPRFX}${entry}"
|
|
|
|
@(cd ${.CURDIR}/${entry} && \
|
2000-06-23 02:37:15 +02:00
|
|
|
${MAKE} ${.TARGET:S/realpackage/package/:S/realinstall/install/} DIRPRFX=${DIRPRFX}${entry}/ )
|
|
|
|
.endfor</programlisting>
|
|
|
|
|
2013-11-07 16:39:28 +01:00
|
|
|
<para>In the above, if <varname>SUBDIR</varname> is empty, no
|
2000-06-23 02:37:15 +02:00
|
|
|
action is taken; if it has one or more elements, the
|
|
|
|
instructions between <literal>.for</literal> and
|
|
|
|
<literal>.endfor</literal> would repeat for every element,
|
2013-11-07 16:39:28 +01:00
|
|
|
with <varname>entry</varname> being replaced with the value
|
2012-02-15 05:27:21 +01:00
|
|
|
of the current element.</para>
|
2000-06-23 02:37:15 +02:00
|
|
|
</sect3>
|
|
|
|
</sect2>
|
|
|
|
</sect1>
|
|
|
|
</chapter>
|