AutoTools: autoconf, automake, libtools

autoconf package

  • autoconf
  • autoreconf
  • autoheader
  • autoscan
  • autoupdate
  • ifnames
  • autom4te
AutoTools: autoconf, automake, libtools_第1张图片
image.png

A dataflow diagram for the autoreconf utility

What does ./bootstrap or ./autogen.sh do?

usually: call autotools commands to copy and generate a number of files. Often just autoreconf -vi.

gnulib provides a very elaborate bootstrap script, see VCS Issues, see Modified imports.

The name bootstrap is preferred over ‘autogen.sh’ as there also exists an independent software package named AutoGen.

AutoTools: autoconf, automake, libtools_第2张图片
image.png

A data flow diagram for autoconf and autoheader

automake

  • $@ refers to the full target name of the current target or the archive filename part of a library archive target. This variable is valid in both explicit and implicit rules.
  • $% refers to a member of an archive and is valid only when the current target is an archive member—that is, an object file that is a member of a static library. This variable is valid in both explicit and implicit rules.
  • $? refers to the list of dependencies that are newer than the current target. This variable is valid in both explicit and implicit rules.
  • $< refers to the member of the dependency list whose existence allowed the rule to be chosen for the target. This variable is only valid in implicit rules.
  • $* refers to the current target name with its suffix deleted. This variable is guaranteed by POSIX to be valid only in implicit rules.
AutoTools: autoconf, automake, libtools_第3张图片
image.png

A data flow diagram for the compile and link processes

Standard Targets

  • all
  • install
  • install-html
  • install-dvi
  • install-pdf
  • install-ps
  • install-strip
  • uninstall
  • clean
  • distclean
  • mostlyclean
  • maintainer-clean
  • TAGS
  • info
  • dvi
  • html
  • pdf
  • ps
  • dist
  • check
  • installcheck
  • installdirs

Prefix Variables and Their Default Values

Variable Default Value
prefix /usr/local
exec_prefix $(prefix)
bindir $(exec_prefix)/bin
sbindir $(exec_prefix)/sbin
libexecdir $(exec_prefix)/libexec
datarootdir $(prefix)/share
datadir $(datarootdir)
sysconfdir $(prefix)/etc
sharedstatedir $(prefix)/com
localstatedir $(prefix)/var
includedir $(prefix)/include
oldincludedir /usr/include
docdir $(datarootdir)/doc/$(package)
infodir $(datarootdir)/info
htmldir $(docdir)
dvidir $(docdir)
pdfdir $(docdir)
psdir $(docdir)
libdir $(exec_prefix)/lib
lispdir $(datarootdir)/emacs/site-lisp
localedir $(datarootdir)/locale
mandir $(datarootdir)/man
manNdir $(mandir)/manN (N = 1..9)
manext .1
manNext .N (N = 1..9)
srcdir The source-tree directory corresponding to the current directory in the build tree

Some User Variables and Their Purposes

Variables Purpose
CC A reference to the system C compiler
CFLAGS Desired C compiler flags
CXX A reference to the system C++ compiler
CXXFLAGS Desired C++ compiler flags
LDFLAGS Desired linker flags
CPPFLAGS Desired C/C++ preprocessor flags

Makefile

CFLAGS = -g -O0

main: main.c
        $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $<

bash

make CC=ccache CFLAGS='-g -O2' CPPFLAGS=-Dtest

Makefile

CFLAGS ?= -g -O0

m4

most like C-preprocessor (CPP)

bootstrap.sh

#!/bin/sh
autoreconf --install
automake --add-missing --copy >/dev/null 2>&1

AC_INIT

AC_INIT(package, version, [bug-report], [tarname], [url])

@PACKAGE_NAME@
@PACKAGE_VERSION@
@PACKAGE_TARNAME@
@PACKAGE_STRING@
@PACKAGE_BUGREPORT@
@PACKAGE_URL@

AC_CONFIG_SRCDIR

AC_CONFIG_SRCDIR(unique-file-in-source-dir)

AC_CONFIG_HEADERS

  • Initialization
  • Check request processing
  • File instantiation request processing
  • Generation of the configure script
AC_CONFIG_XXXS(tag..., [commands], [init-cmds])

Unit Test

AutoTools: autoconf, automake, libtools_第4张图片
image.png

Data flow from maintainer-written input files to the testsuite program

参考:

  1. GitHub Code
  2. GNU AUTOCONF, AUTOMAKE, AND LIBTOOL
  3. 例解 autoconf 和 automake 生成 Makefile 文件

你可能感兴趣的:(AutoTools: autoconf, automake, libtools)