2419 lines
44 KiB
Plaintext
2419 lines
44 KiB
Plaintext
#LyX 2.5 created this file. For more info see https://www.lyx.org/
|
|
\lyxformat 643
|
|
\begin_document
|
|
\begin_header
|
|
\save_transient_properties true
|
|
\origin unavailable
|
|
\textclass article
|
|
\use_default_options true
|
|
\begin_modules
|
|
figs-within-sections
|
|
tabs-within-sections
|
|
algorithm2e
|
|
\end_modules
|
|
\maintain_unincluded_children no
|
|
\language american
|
|
\language_package default
|
|
\inputencoding utf8
|
|
\fontencoding auto
|
|
\font_roman "default" "default"
|
|
\font_sans "default" "default"
|
|
\font_typewriter "default" "default"
|
|
\font_math "auto" "auto"
|
|
\font_default_family default
|
|
\use_non_tex_fonts false
|
|
\font_sc false
|
|
\font_roman_osf false
|
|
\font_sans_osf false
|
|
\font_typewriter_osf false
|
|
\font_sf_scale 100 100
|
|
\font_tt_scale 100 100
|
|
\use_microtype false
|
|
\use_dash_ligatures true
|
|
\graphics default
|
|
\default_output_format default
|
|
\output_sync 0
|
|
\bibtex_command default
|
|
\index_command default
|
|
\float_placement class
|
|
\float_alignment class
|
|
\paperfontsize default
|
|
\spacing single
|
|
\use_hyperref false
|
|
\papersize a4
|
|
\use_geometry false
|
|
\use_package amsmath 1
|
|
\use_package amssymb 1
|
|
\use_package cancel 1
|
|
\use_package esint 1
|
|
\use_package mathdots 1
|
|
\use_package mathtools 1
|
|
\use_package mhchem 1
|
|
\use_package stackrel 1
|
|
\use_package stmaryrd 1
|
|
\use_package undertilde 1
|
|
\cite_engine basic
|
|
\cite_engine_type default
|
|
\biblio_style plain
|
|
\use_bibtopic false
|
|
\use_indices false
|
|
\paperorientation portrait
|
|
\suppress_date false
|
|
\justification default
|
|
\crossref_package refstyle
|
|
\use_formatted_ref 0
|
|
\use_minted 0
|
|
\use_lineno 0
|
|
\backgroundcolor white
|
|
\fontcolor black
|
|
\notefontcolor none
|
|
\boxbgcolor none
|
|
\table_border_color default
|
|
\table_odd_row_color default
|
|
\table_even_row_color default
|
|
\table_alt_row_colors_start 1
|
|
\index Index
|
|
\shortcut idx
|
|
\color #008080
|
|
\end_index
|
|
\secnumdepth 3
|
|
\tocdepth 3
|
|
\paragraph_separation indent
|
|
\paragraph_indentation default
|
|
\is_math_indent 0
|
|
\math_numbering_side default
|
|
\quotes_style english
|
|
\dynamic_quotes 0
|
|
\papercolumns 1
|
|
\papersides 1
|
|
\paperpagestyle default
|
|
\tablestyle default
|
|
\tracking_changes false
|
|
\output_changes false
|
|
\change_bars false
|
|
\postpone_fragile_content true
|
|
\html_math_output 0
|
|
\html_css_as_file 1
|
|
\html_be_strict false
|
|
\docbook_table_output 0
|
|
\docbook_mathml_prefix 1
|
|
\docbook_mathml_version 0
|
|
\end_header
|
|
|
|
\begin_body
|
|
|
|
\begin_layout Title
|
|
Automake
|
|
\end_layout
|
|
|
|
\begin_layout Author
|
|
Let Automake do the work :)
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset CommandInset toc
|
|
LatexCommand tableofcontents
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Section
|
|
Introduction
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
As we have discussed about the Automake in the Autotools,
|
|
it is seems very tempting to start generate Makefiles for your projects and generate a Makefile for each module with a master Makefile at the top of project directory structure.
|
|
However,
|
|
there is a very good and informative paper by Peter Miller regarding
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset href
|
|
LatexCommand href
|
|
name "Recursive Makefiles are Considered Harmful"
|
|
target "https://wikileaks.org/ciav7p1/cms/files/auug97.pdf"
|
|
literal "false"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
.
|
|
As per this paper,
|
|
projects with Recursive Makefiles build system are not very optimal for building projects,
|
|
especially which are very large in size.
|
|
But,
|
|
writing a single Makefile for a very large project or even generating it using Automake is not very manageable,
|
|
which is good argument.
|
|
So,
|
|
a
|
|
\begin_inset CommandInset href
|
|
LatexCommand href
|
|
name "blog"
|
|
target "http://karelzak.blogspot.com/2013/02/non-recursive-automake.html"
|
|
literal "false"
|
|
|
|
\end_inset
|
|
|
|
by Karel Zak suggest that we can create a single resulting Makefile from bunch of
|
|
\shape italic
|
|
include files
|
|
\shape default
|
|
which are included in main Makefile.am.
|
|
Therefore,
|
|
our first goal is to create a build system which is optimal.
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset Float figure
|
|
placement document
|
|
alignment center
|
|
wide false
|
|
sideways false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
\align center
|
|
\begin_inset Graphics
|
|
filename images/project-tree.png
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
\align center
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
Project structure
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Section
|
|
Enabling Automake in configure.ac
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
|
|
\size normal
|
|
Just for the introduction,
|
|
lets briefly understand what's configure.ac is?
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
configure.ac is the input file which is used by Autoconf to generate configure which is used to setup the environment for project compilation.
|
|
In other word,
|
|
this script allows us to configure our project build system.
|
|
Detailed discussion over this is done in
|
|
\begin_inset CommandInset href
|
|
LatexCommand href
|
|
name "Autoconf"
|
|
target "Autoconf.html"
|
|
type "file:"
|
|
literal "false"
|
|
|
|
\end_inset
|
|
|
|
tutorial.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Much of the configure.ac script can be generated automatically based on the existing project tree or even updated based on the the current status.
|
|
This automatic generation of configure.ac script is done using autoscan script.
|
|
Note,
|
|
that as the project structure grows,
|
|
we don't have to create new configure.ac every time.
|
|
Instead,
|
|
autoscan will read the existing configure.ac and improve upon it.
|
|
The resulting output of the autoscan is configure.scan and autoscan.log.
|
|
configure.scan can be change to configure.ac to use by autoconf for configuration of the project.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
The output of autoscan looks like:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\size default
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "language=bash,basicstyle={\footnotesize\ttfamily},breaklines=true,tabsize=10"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
# Process this file with autoconf to produce a configure script.
|
|
-*- Autoconf -*-
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_PREREQ([2.71])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_INIT([FULL-PACKAGE-NAME],
|
|
[VERSION],
|
|
[BUG-REPORT-ADDRESS])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_CONFIG_SRCDIR([foo/myprog.c])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_CONFIG_HEADERS([config.h])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
# Checks for programs.
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
# This below is added only for C++ files.
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_PROG_CXX AC_PROG_CC
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
\align center
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
# Checks for libraries.
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
# Checks for header files.
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
# Checks for typedefs,
|
|
structures,
|
|
and compiler characteristics.
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_CHECK_HEADER_STDBOOL
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
# Checks for library functions.
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_CONFIG_FILES([Makefile])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_OUTPUT
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\shape italic
|
|
configure.ac generated from autoscan.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
|
|
\size normal
|
|
Note that the generated script is not enabled to use Automake tool the generate the Makefiles from Makefile.am input files.
|
|
Oh wait!
|
|
Didn't we just say that Automake generates Makefiles automatically for the project.
|
|
Well,
|
|
lets address that in the next section.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Now,
|
|
to enable the Automake in this build system,
|
|
we need to add one single line onto the above script.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\size default
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "language=bash,basicstyle={\footnotesize\ttfamily}"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_PREREQ([2.71])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_INIT([FULL-PACKAGE-NAME],
|
|
[VERSION],
|
|
[BUG-REPORT-ADDRESS])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_INIT_AUTOMAKE
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_CONFIG_SRCDIR([creational-pattern/src/MazeGame.cpp])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_CONFIG_HEADERS([config.h])
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\shape italic
|
|
Automake enabled
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\size normal
|
|
Executing the autoreconf -i command will now make the build system of project,
|
|
Automake enabled.
|
|
\end_layout
|
|
|
|
\begin_layout Section
|
|
What is a Makefile.am file?
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
|
|
\size normal
|
|
It is just like a regular Makefile,
|
|
but with comparatively less Makefile code and some syntactically specific to Automake.
|
|
But,
|
|
why Automake needs some input file at the first place to generate a output Makefile.
|
|
Well,
|
|
the main intent of the Automake tool is to generate a Makefile which mostly comprises of boilerplate code.
|
|
Since GCS enforce lot of standard rules,
|
|
this leads to lot of code begin boilerplate which makes it very redundant to write it by hand and also making sure that it is logically correct.
|
|
Here,
|
|
Automake comes in handy as it generates a
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
complete
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
Makefile which is compliant to GCS.
|
|
Another benefit of using Automake is,
|
|
it has automatic dependency tracking capability which allows the tracking of header files changes which are included in the source files.
|
|
It is annoying problem where change in header files are often not reflected in the compiled build due to missing dependency checks and Automake handles it very gracefully to ensure the dependency checks are efficiently managed.
|
|
\end_layout
|
|
|
|
\begin_layout Section
|
|
Preparing the structure
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
Since our goal is to create a non-recursive build system of Makefiles using Automake,
|
|
all the targets rules should appear in the top-makefile which may tell you that we may need to write a big Makefile.am for a project which is at the top of project directory.
|
|
Fortunately,
|
|
Automake can still create a single Makefile from bunch of input *.am files.
|
|
This makes it super manageable.
|
|
Writing bunch of
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
Makemodule.am
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
for each sub-directories of the project and including them in top Makefile.am will help us in completing our goal.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "language=bash,basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
bin_PROGRAMS =
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
man_MANS =
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
include foo/Makemodule.am
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
include bar/Makemodule.am
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\shape italic
|
|
Makefile.am in root directory.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Here,
|
|
we can see that defining the variable at the top of top Makefile.am and then using it in the Makemodule.am in the sub-directories.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
For ex,
|
|
in
|
|
\series bold
|
|
foo/Makemodule.am
|
|
\series default
|
|
:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "language=bash,basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
bin_PROGRAMS += myprog # PLV
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
man_MANS += foo/myprog.8
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
myprog_SOURCES = foo/myprog.c
|
|
\backslash
|
|
# PSV
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
foo/myprog-utils.c
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\shape italic
|
|
Makemodule.am in foo directory of project.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Here in Makefile.am and Makemodule.am,
|
|
we are using two important types of variables.
|
|
These are
|
|
\series bold
|
|
Product List Variable
|
|
\series default
|
|
and
|
|
\series bold
|
|
Product Source Variable
|
|
\series default
|
|
.
|
|
\end_layout
|
|
|
|
\begin_layout Subsection
|
|
Product List Variable:
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
Products of the build systems are specified to the Makefile.am using
|
|
\shape italic
|
|
Product List variable (PLV)
|
|
\shape default
|
|
.
|
|
These are class of variables which have special meaning to Automake.
|
|
They tell what are the resultant output of the Makefiles or build system that will be generated after the successful completion of the build process.
|
|
This variable consist of white-space-separated list of products and the variable (as you can see in above example) consist of two major parts separated by a underscore.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
These two components are:
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
bin:
|
|
Prefix
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
PROGRAMS:
|
|
Primary
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
The
|
|
\shape italic
|
|
bin
|
|
\shape default
|
|
portion of the PLV represent a
|
|
\shape italic
|
|
installation location prefix
|
|
\shape default
|
|
.
|
|
This is used to define the installation location for the list of products which are mentioned in the PLV.
|
|
The GCS defines many installation locations.
|
|
However,
|
|
make variable ending with
|
|
\shape italic
|
|
dir
|
|
\shape default
|
|
,
|
|
whose value is a file-system location,
|
|
is a viable installation location and can be used as prefix in a Automake PLV.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
What we mean here is that any
|
|
\series bold
|
|
make
|
|
\series default
|
|
variable ending with
|
|
\family typewriter
|
|
dir,
|
|
|
|
\family default
|
|
for example
|
|
\family typewriter
|
|
$(bindir)
|
|
\family default
|
|
,
|
|
with a installation location value can be used by Automake to produce
|
|
\family typewriter
|
|
install
|
|
\family default
|
|
rule which will install the list of products to the
|
|
\family typewriter
|
|
$(bindir)
|
|
\family default
|
|
location.
|
|
However,
|
|
only those products will be installed that are mentioned in the PLV which have prefix
|
|
\family typewriter
|
|
bin
|
|
\family default
|
|
as mentioned in the above example (bin_PROGRAMS) and PROGRAMS is termed as Primary which represent the type of product that is expected to be produced,
|
|
which in this case is the list of binary files.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Automake by default recognizes 4 type of variable which they can be treated as installation locations and they have a prefix pkg.
|
|
These variables are:
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
pkgincludedir
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
pkgdatadir
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
pkglibexecdir
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
pkglibdir
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
These pkg version of standard
|
|
\family typewriter
|
|
libdir
|
|
\family default
|
|
,
|
|
|
|
\family typewriter
|
|
includedir
|
|
\family default
|
|
,
|
|
|
|
\family typewriter
|
|
datadir
|
|
\family default
|
|
and
|
|
\family typewriter
|
|
libexecdir
|
|
\family default
|
|
indicates that the installation of the products listed in the PLV equivalent variable should be installed in the sub-directory of these location mentioned in these standard make variable where the sub-directory is named after the package.
|
|
For example,
|
|
our Project which is named as
|
|
\shape slanted
|
|
Project
|
|
\shape default
|
|
in our Figure 1,
|
|
will have binary files (like
|
|
\shape slanted
|
|
myprog
|
|
\shape default
|
|
) installed in the
|
|
\shape slanted
|
|
Project
|
|
\shape default
|
|
sub-directory of the
|
|
\series bold
|
|
bin
|
|
\series default
|
|
system directory.
|
|
And yes,
|
|
we can change the installation directory from
|
|
\series bold
|
|
bin
|
|
\series default
|
|
to any other directory by overriding the value of the
|
|
\family typewriter
|
|
$(bindir)
|
|
\family default
|
|
variable in Makefile.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
We can also provide our own PLV custom prefix which represent a variable,
|
|
having the location for installation of some list of products.
|
|
For example,
|
|
for installation of some XML files to a custom location,
|
|
we can define a xmldir variable having value for the installation path and a PLV xml_DATA having value a list of xml files which will be installed in the installation path.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
xmldir = $(datadir)/xml
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
xml_DATA = file1.xml file2.xml file3.xml ...
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
Custom PLV with variable in Makefile.am
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Installation location can default values which are either defined by Automake or by user itself.
|
|
However,
|
|
these default value can be overridden using the argument passed while running the configure script or make command.
|
|
If we don't want to install certain products to the installation location,
|
|
Automake generated rules ensures to generate rules to handle such situations.
|
|
For example,
|
|
if we don't want to install binary and library files and only want to install the data files,
|
|
we can pass the command
|
|
\family typewriter
|
|
make bindir='' libdir='' install
|
|
\family default
|
|
.
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Subsection
|
|
Prefix Not Associated with Installation
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
Sometimes,
|
|
we don't want certain products to installed anywhere.
|
|
That's why we have certain prefix which are not associated with any installation location.
|
|
There are 3 main such prefix:
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
noinst
|
|
\family default
|
|
:
|
|
This signifies that the product listed in a variable with this prefix is not to be installed anywhere in the system after the build process.
|
|
It could be a
|
|
\shape italic
|
|
convenience
|
|
\shape default
|
|
static library which is only used to build a final product.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
check
|
|
\family default
|
|
:
|
|
The products listed will be build only when
|
|
\family typewriter
|
|
make check
|
|
\family default
|
|
command is used.
|
|
These products are only build for testing purpose.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
EXTRA
|
|
\family default
|
|
:
|
|
This signifies the list of products which may be conditionally build and eventually,
|
|
installed.
|
|
This types of configuration control is possible via
|
|
\family typewriter
|
|
\shape slanted
|
|
configure
|
|
\family default
|
|
\shape default
|
|
script where we pass some argument to it and prompts to build some
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
extra
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
products.
|
|
However,
|
|
enabling such feature of autoconf and automake is not as simple as above two.
|
|
Go through the below illustration:
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
AC_INIT(...)
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
...
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
optional_programs=
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
AC_SUBST([optional_programs])
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
...
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
if test "x$(build_opt_prog)" = xyes;
|
|
then
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
optional_programs=$(optional_programs) optprog ### 1 ###
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
fi
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
...
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
A shell script code in configure.ac for building
|
|
\series bold
|
|
optprog
|
|
\series default
|
|
product conditionally.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
EXTRA_PROGRAMS = optprog ### 2 ###
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
bin_PROGRAMS = myprog $(optional_programs) ### 3 ###
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
Using the EXTRA prefix to conditionally build products in Makefile.am
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
In Listing 6 ### 1 ###,
|
|
|
|
\series bold
|
|
optprog
|
|
\series default
|
|
is appended to an Autoconf substitution variable called
|
|
\family sans
|
|
optional_program
|
|
\family default
|
|
.
|
|
The
|
|
\family sans
|
|
EXTRA_PROGRAMS
|
|
\family default
|
|
variable at ### 2 ### in Listing 7 list
|
|
\family sans
|
|
optprog,
|
|
|
|
\family default
|
|
as a product that may or may not be build.
|
|
This redundant information of
|
|
\family sans
|
|
EXTRA_PROGRAMS
|
|
\family default
|
|
in Makefile.am make it ensure that Automake knows that optprog is a optional product and make the resultant Makefile with appropriate script.
|
|
This make sure that even if
|
|
\series bold
|
|
optprog
|
|
\series default
|
|
is not mentioned in
|
|
\family typewriter
|
|
$(optional_programs)
|
|
\family default
|
|
variable in some build.
|
|
\end_layout
|
|
|
|
\begin_layout Subsection
|
|
Primaries
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
|
|
\shape italic
|
|
Primaries
|
|
\shape default
|
|
represent type of product which is generated by this build system.
|
|
That's it!
|
|
What are these type of files?
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
These files can be executable,
|
|
libraries,
|
|
config files in terms of xml,
|
|
json and event normal txt files.
|
|
Wait,
|
|
normal txt files?
|
|
Well,
|
|
what it means is that some products (not exactly) of build system are not actually generated by the build system.
|
|
These are part of the project and we will need these files while executing the software in our system after the build process of that software.
|
|
For example,
|
|
C or C++ language have the prototype of the function or API written in header files (.h or .hpp) which allows the user of the library to make there software aware of these API before using it and enables in linking the implementation to the function calls while in the linking process of the build system.
|
|
So,
|
|
the main intent of this long boring example is to provide a context on why we have different kind of primaries as this helps in differentiating the type of product to Automake and hence generate rules in resultant Makefile accordingly.
|
|
Interestingly,
|
|
we can define our own primaries,but beware,
|
|
we need to write the rules for those on our own in Makefile.am.
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
Let us see the default primaries supported by Automake.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\series bold
|
|
PROGRAMS
|
|
\series default
|
|
:
|
|
These are binary executable programs.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\series bold
|
|
LIBRARIES/LTLIBRARIES
|
|
\series default
|
|
:
|
|
The LIBRARIES primary enables Automake to generate rules for building static libraries using system compiler and librarian (
|
|
\series bold
|
|
ar
|
|
\series default
|
|
).
|
|
The LTLIBRARIES also do the same thing but to build
|
|
\shape italic
|
|
libtool
|
|
\shape default
|
|
shared libraries which are generated by executing
|
|
\shape italic
|
|
libtool scripts
|
|
\shape default
|
|
.
|
|
The installation of these products are limited to
|
|
\family typewriter
|
|
$(libdir)
|
|
\family default
|
|
or
|
|
\family typewriter
|
|
$(pkglibdir)
|
|
\family default
|
|
.
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\series bold
|
|
SCRIPTS
|
|
\series default
|
|
:
|
|
Scripts are generally handwritten which may be a part of project,
|
|
however,
|
|
Automake don't have the assumption that it will not make any rules to build the scripts or they are static files in the project.
|
|
The scripts can be generated from handwritten rules in Makefile.am files,
|
|
sometimes by processing a input file using the sed or awk utility tools.
|
|
Even if the static script are present in the project and is intended to be distributed with the project tarball,
|
|
then
|
|
\series bold
|
|
dist
|
|
\series default
|
|
modifier should be used with
|
|
\series bold
|
|
SCRIPT
|
|
\series default
|
|
primary.
|
|
The installation location for scripts includes
|
|
\family typewriter
|
|
$(bindir)
|
|
\family default
|
|
,
|
|
|
|
\family typewriter
|
|
$(sbindir)
|
|
\family default
|
|
,
|
|
|
|
\family typewriter
|
|
$(libexecdir)
|
|
\family default
|
|
,
|
|
and
|
|
\family typewriter
|
|
$(pkgdatadir)
|
|
\family default
|
|
.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\series bold
|
|
DATA
|
|
\series default
|
|
:
|
|
Data files are similar to what scripts files are intended for and can be distributed with project tarball and for that we can use
|
|
\series bold
|
|
dist
|
|
\series default
|
|
modifier with
|
|
\series bold
|
|
DATA
|
|
\series default
|
|
primary.
|
|
The installation location for these type of files are
|
|
\family typewriter
|
|
$(datadir)
|
|
\family default
|
|
,
|
|
|
|
\family typewriter
|
|
$(sysconfdir)
|
|
\family default
|
|
,
|
|
|
|
\family typewriter
|
|
$(sharedstatedir)
|
|
\family default
|
|
and
|
|
\family typewriter
|
|
$(localstatedir)
|
|
\family default
|
|
.
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\series bold
|
|
HEADERS
|
|
\series default
|
|
:
|
|
Headers files are just like static files but are used for building of the project.
|
|
These files generally contained the public interface of the installed libraries which can be used by other projects for using the libraries functionality.
|
|
The PLV for these type of files are pkginclude_HEADERS and include_HEADERS and the installation locations are
|
|
\family typewriter
|
|
$(includedir)
|
|
\family default
|
|
and
|
|
\family typewriter
|
|
$(pkgincludedir)
|
|
\family default
|
|
.
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
There are also other types of primaries that Automake supports,
|
|
but we will currently discuss about the ones which are used the most.
|
|
The rest of the commonly used primaries are
|
|
\series bold
|
|
MANS
|
|
\series default
|
|
,
|
|
|
|
\series bold
|
|
TEXTINFOS
|
|
\series default
|
|
,
|
|
|
|
\series bold
|
|
PYTHON
|
|
\series default
|
|
,
|
|
|
|
\series bold
|
|
JAVA
|
|
\series default
|
|
,
|
|
etc.
|
|
\end_layout
|
|
|
|
\begin_layout Subsection
|
|
Product Source Variable
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
If you notice,
|
|
the second line in Listing 7 is an example of Automake
|
|
\shape italic
|
|
product source variable
|
|
\shape default
|
|
(PSV).
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
[modifier-list]product_SOURCES = file1 file2 ...
|
|
fileN
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Just like PLV which represent list of products,
|
|
PSV represent list of files on which the product is dependent on.
|
|
These are the source files which are used to build the products of the projects.
|
|
Only characters that are allowed in make variables (letters,
|
|
numbers,
|
|
and the at sign) are allowed in the product tag of a PSV.
|
|
So,
|
|
Automake converst illegal characters into underscores.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
lib_LIBRARIES = libc++.a
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
libc___a_SOURCES = ...
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
Illegal make variable characters are converted to underscores in product tags.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Subsection
|
|
PLV and PSV Modifiers
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
Modifiers are optional prefix added to PLV or PSV to modify the behavior of these Automake variable which would have behaved differently if not added.
|
|
It is better to understand this with examples:
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
Some files may be intended to be distributed and some files may not,
|
|
while the distribution tarball is begin built.
|
|
This can be achieved for the case of source file by adding the prefix to PSV,
|
|
like the one shown below:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
dist_myprog_SOURCES = file1.c file2.c
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
nodist_myprog_SOURCES = file3.c file4.c
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
Using the
|
|
\shape italic
|
|
dist
|
|
\shape default
|
|
and
|
|
\shape italic
|
|
nodist
|
|
\shape default
|
|
modifiers in a Makefile.am file.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
Automake normally strips relative path information from the list of header files in a
|
|
\family typewriter
|
|
HEADERS
|
|
\family default
|
|
PLV.
|
|
The
|
|
\family typewriter
|
|
nobase
|
|
\family default
|
|
modifier restrict this behavior and let the directory structure of the project tree to be followed in the same area where the list of header files are installed (generally in system header file location).
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
nobase_pkginclude_HEADERS = mylib.h sys/constants.h
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
Using the
|
|
\shape italic
|
|
nobase
|
|
\shape default
|
|
PLV modifier in a Makefile.am file.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
This ensures that the constanst.h file is stored in
|
|
\family typewriter
|
|
$(pkginclude)
|
|
\family default
|
|
directory inside
|
|
\family typewriter
|
|
sys
|
|
\family default
|
|
subdirectory.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
The notrans modifier is generally used for not allowing any transformation to the name of the source file.
|
|
This generally occurs for man pages whose source file name is transformed from .
|
|
\shape italic
|
|
man
|
|
\shape default
|
|
to .
|
|
\shape italic
|
|
N
|
|
\shape default
|
|
(where N is 0,1,2,3...9).
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
There are certain source files which might be used for compilation of the executable product based on the condition defined in configure.ac,
|
|
so,
|
|
for such source file
|
|
\family typewriter
|
|
EXTRA
|
|
\family default
|
|
modifier is added to the PSV to handle such cases.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
EXTRA_myprog_SOURCES = possibly.c
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
Using the
|
|
\shape italic
|
|
EXTRA
|
|
\shape default
|
|
prefix with a product
|
|
\shape italic
|
|
SOURCES
|
|
\shape default
|
|
variable.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Section
|
|
Unit Testing:
|
|
Automake support for make check
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
Check the example below first:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
...
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
check:
|
|
all
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
./myprog | grep
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
Hello from .*myprog!
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
@echo
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
*** ALL TESTS PASSED ***
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
...
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
The
|
|
\shape italic
|
|
check
|
|
\shape default
|
|
target
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
As we can see to test the sanity of the executable produced by the build system,
|
|
in this case is a Makefile is used for testing.
|
|
Here,
|
|
it is executing the executable and using grep to check the output is as expected as shown above.
|
|
Automake can also automate this by using variables specific to this functionality.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
bin_PROGRAMS = myprog
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
myprog_SOURCES = myprog.c
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
check_SCRIPTS = greptest.sh @1
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
TESTS = $(check_SCRIPTS) @2
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
greptest.sh: @3
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
echo './myprog | grep
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
Hello from .*jupiter!
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
' > greptest.sh
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
chmod +x greptest.sh
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
CLEANFILES = greptest.sh @4
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
src/Makefile.am:
|
|
Additional code required to support the check target
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
The
|
|
\family typewriter
|
|
check_SCRIPTS
|
|
\family default
|
|
(@1) is a PLV which refers to a script that is generated at build time.
|
|
This script is only generated when
|
|
\family typewriter
|
|
make check
|
|
\family default
|
|
command is executed.
|
|
Also,
|
|
we need to keep in mind that the generated script should be cleaned (or deleted) as they are not files which should be distributed.
|
|
So,
|
|
|
|
\family typewriter
|
|
CLEANFILES(@4)
|
|
\family default
|
|
variable takes care about the cleaning part.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
The
|
|
\family typewriter
|
|
TESTS
|
|
\family default
|
|
(@2) line is the important one in Listing 13.
|
|
It tells which targets should be executed when make check is executed and since the
|
|
\family typewriter
|
|
check_SCRIPTS
|
|
\family default
|
|
have complete list of these target,
|
|
hence it is referenced.
|
|
However,
|
|
since
|
|
\family typewriter
|
|
TESTS
|
|
\family default
|
|
variable ensures that appropriate rules are generated so that the test scripts are build and executed successfully.
|
|
Therefore,
|
|
|
|
\family typewriter
|
|
check_SCRIPTS
|
|
\family default
|
|
is redundant and can be skipped by replacing it with the contents of it.
|
|
|
|
\family typewriter
|
|
check_*
|
|
\family default
|
|
PLVs becomes important only when helper scripts needs to build which are not executed directly but are executed by script which are listed in
|
|
\family typewriter
|
|
TESTS
|
|
\family default
|
|
variable.
|
|
Note,
|
|
|
|
\family typewriter
|
|
TESTS
|
|
\family default
|
|
is actually for executing the script and Automake always build the script before executing if it is already not build.
|
|
\end_layout
|
|
|
|
\begin_layout Section
|
|
Convenience Libraries:
|
|
Static libraries.
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
noinst_LIBRARIES = libcommon.a
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
libcomman_a_SOURCES = common.h print.c
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
common/Makefile.am:
|
|
To build the temporary library.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
The first line defines what library should be build and as you have noticed,
|
|
one
|
|
\family typewriter
|
|
noinst
|
|
\family default
|
|
modifier is used so that the build library is not installed into the system directory after the project is build and installed.
|
|
The goal of such library is to compile common code in one static library and used in many different section of the projects.
|
|
Here,
|
|
|
|
\family typewriter
|
|
libcommon.a
|
|
\family default
|
|
is like a archive file which is given to compiler for compilation of executable.
|
|
The only difference between
|
|
\family typewriter
|
|
.tar
|
|
\family default
|
|
and
|
|
\family typewriter
|
|
.a
|
|
\family default
|
|
files is that the compiler know which object files to use to compile the executable which is present inside the static library.
|
|
\end_layout
|
|
|
|
\begin_layout Subsection
|
|
Product Option Variables
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
In order for the source files which will be used to build the executable to find the relevant code from the static library and also find the correct corresponding header files,
|
|
we need to add some additional information to the
|
|
\family typewriter
|
|
Makefile.am
|
|
\family default
|
|
(more specifically Makemodule.am)of the
|
|
\family typewriter
|
|
src
|
|
\family default
|
|
directory.
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\begin_layout Standard
|
|
\begin_inset listings
|
|
lstparams "basicstyle={\footnotesize\ttfamily},breaklines=true"
|
|
inline false
|
|
status open
|
|
|
|
\begin_layout Plain Layout
|
|
bin_PROGRAMS = myprog
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
myprog_SOURCES = main.c
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
myprog_CPPFLAGS = -I$(top_srcdir)/common
|
|
\end_layout
|
|
|
|
\begin_layout Plain Layout
|
|
myprog_LDADD = ../common/libcommon.a
|
|
\begin_inset Caption Standard
|
|
|
|
\begin_layout Plain Layout
|
|
src/Makefile.am:
|
|
Adding compiler and linker directives to Makefile.am files.
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\end_layout
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset CommandInset line
|
|
LatexCommand rule
|
|
offset "0.5ex"
|
|
width "100col%"
|
|
height "1pt"
|
|
|
|
\end_inset
|
|
|
|
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
The two new variable added here (
|
|
\family typewriter
|
|
myprog_CPPFLAGS
|
|
\family default
|
|
and
|
|
\family typewriter
|
|
myprog_LDADD
|
|
\family default
|
|
) are
|
|
\shape italic
|
|
product option variables (POVs)
|
|
\shape default
|
|
are used to specify product-specific options to tools that are used to build products from source code.
|
|
The
|
|
\family typewriter
|
|
myprog_CPPFLAGS
|
|
\family default
|
|
variable adds product-specific C-preprocessor flags to the compiler command line for all source files that are compiled for the
|
|
\family typewriter
|
|
myprog
|
|
\family default
|
|
program.
|
|
This add reference to the list of location that the compiler will look for header file when the source files are used for compilation.
|
|
The
|
|
\family typewriter
|
|
myprog_LDADD
|
|
\family default
|
|
variable is used to add libraries to the linker command line.
|
|
The path
|
|
\family typewriter
|
|
../common/libcommon.a
|
|
\family default
|
|
is added to the linker command line while building the
|
|
\family typewriter
|
|
myprog
|
|
\family default
|
|
product so that the relevant object files can be used to link and build the product.
|
|
The variables
|
|
\family typewriter
|
|
program_LDADD
|
|
\family default
|
|
and
|
|
\family typewriter
|
|
program_LIBADD
|
|
\family default
|
|
is only necessary for libraries that are built as part of our own package.
|
|
If our project requires libraries which are already a part of user's system,
|
|
then all we need is a macro call of
|
|
\family typewriter
|
|
AC_CHECK_LIB
|
|
\family default
|
|
or
|
|
\family typewriter
|
|
AC_SEARCH_LIB
|
|
\family default
|
|
in configure.ac file.
|
|
This will generate appropriate script in
|
|
\family typewriter
|
|
configure
|
|
\family default
|
|
that will add the references to these libraries in linker command via
|
|
\family typewriter
|
|
LIBS
|
|
\family default
|
|
variable.
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
The set of POVs supported by Automake are listed below:
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
product_CPPFLAGS
|
|
\family default
|
|
:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Use
|
|
\family typewriter
|
|
product_CPPFLAGS
|
|
\family default
|
|
to pass flags to the C preprocessor on compiler command line.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
product_CFLAGS
|
|
\family default
|
|
:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Same as above but for C-compiler flags.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
product_LDFLAGS
|
|
\family default
|
|
:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Use
|
|
\family typewriter
|
|
product_LDFLAGS
|
|
\family default
|
|
to pass global and order-independent shared library and program linker configuration flags and options to the linker,
|
|
including -static,
|
|
-version-info,
|
|
-release,
|
|
and so on.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
program_LDADD
|
|
\family default
|
|
:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Use
|
|
\family typewriter
|
|
program_LDADD
|
|
\family default
|
|
to add libtool objects (
|
|
\family typewriter
|
|
.lo
|
|
\family default
|
|
) or libraries (
|
|
\family typewriter
|
|
.la
|
|
\family default
|
|
) or non-Libtool objects (
|
|
\family typewriter
|
|
.o
|
|
\family default
|
|
) or archives (.
|
|
\family typewriter
|
|
a
|
|
\family default
|
|
) to the linker command line when linking a program.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
library_LIBADD
|
|
\family default
|
|
:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Use
|
|
\family typewriter
|
|
library_LIBADD
|
|
\family default
|
|
to add non-Libtool linker objects and archives to non-Libtool archives on the
|
|
\family typewriter
|
|
ar
|
|
\family default
|
|
utility command line.
|
|
The
|
|
\family typewriter
|
|
ar
|
|
\family default
|
|
utility will incorporate archives mentioned on the command line into the product archive,
|
|
so you can use this variable to gather multiple archives together into one.
|
|
\end_layout
|
|
|
|
\begin_layout Itemize
|
|
|
|
\family typewriter
|
|
ltlibrary_LIBADD
|
|
\family default
|
|
:
|
|
\begin_inset Newline newline
|
|
\end_inset
|
|
|
|
Use
|
|
\family typewriter
|
|
ltlibrary_LIBADD
|
|
\family default
|
|
to add Libtool linker objects (
|
|
\family typewriter
|
|
.lo
|
|
\family default
|
|
) and Libtool static or shared libraries (
|
|
\family typewriter
|
|
.la
|
|
\family default
|
|
) to a Libtool static or shared library.
|
|
\end_layout
|
|
|
|
\end_body
|
|
\end_document
|