AutoTools: autoconf, automake, libtools

autoconf package

  • autoconf
  • autoreconf
  • autoheader
  • autoscan
  • autoupdate
  • ifnames
  • autom4te
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.

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

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 文件
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末届搁,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌汪榔,老刑警劉巖选浑,帶你破解...
    沈念sama閱讀 216,372評論 6 498
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡砂心,警方通過查閱死者的電腦和手機彻秆,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,368評論 3 392
  • 文/潘曉璐 我一進店門楔绞,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人唇兑,你說我怎么就攤上這事酒朵。” “怎么了扎附?”我有些...
    開封第一講書人閱讀 162,415評論 0 353
  • 文/不壞的土叔 我叫張陵蔫耽,是天一觀的道長。 經(jīng)常有香客問我留夜,道長匙铡,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,157評論 1 292
  • 正文 為了忘掉前任碍粥,我火速辦了婚禮鳖眼,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘嚼摩。我一直安慰自己钦讳,他們只是感情好,可當我...
    茶點故事閱讀 67,171評論 6 388
  • 文/花漫 我一把揭開白布枕面。 她就那樣靜靜地躺著愿卒,像睡著了一般。 火紅的嫁衣襯著肌膚如雪潮秘。 梳的紋絲不亂的頭發(fā)上琼开,一...
    開封第一講書人閱讀 51,125評論 1 297
  • 那天,我揣著相機與錄音枕荞,去河邊找鬼柜候。 笑死,一個胖子當著我的面吹牛买猖,可吹牛的內(nèi)容都是我干的改橘。 我是一名探鬼主播,決...
    沈念sama閱讀 40,028評論 3 417
  • 文/蒼蘭香墨 我猛地睜開眼玉控,長吁一口氣:“原來是場噩夢啊……” “哼飞主!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,887評論 0 274
  • 序言:老撾萬榮一對情侶失蹤碌识,失蹤者是張志新(化名)和其女友劉穎碾篡,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體筏餐,經(jīng)...
    沈念sama閱讀 45,310評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡开泽,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,533評論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了魁瞪。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片穆律。...
    茶點故事閱讀 39,690評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖导俘,靈堂內(nèi)的尸體忽然破棺而出峦耘,到底是詐尸還是另有隱情,我是刑警寧澤旅薄,帶...
    沈念sama閱讀 35,411評論 5 343
  • 正文 年R本政府宣布辅髓,位于F島的核電站,受9級特大地震影響少梁,放射性物質(zhì)發(fā)生泄漏洛口。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,004評論 3 325
  • 文/蒙蒙 一凯沪、第九天 我趴在偏房一處隱蔽的房頂上張望第焰。 院中可真熱鬧,春花似錦著洼、人聲如沸樟遣。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,659評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至葵陵,卻和暖如春液荸,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背脱篙。 一陣腳步聲響...
    開封第一講書人閱讀 32,812評論 1 268
  • 我被黑心中介騙來泰國打工娇钱, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人绊困。 一個月前我還...
    沈念sama閱讀 47,693評論 2 368
  • 正文 我出身青樓文搂,卻偏偏與公主長得像,于是被迫代替她去往敵國和親秤朗。 傳聞我的和親對象是個殘疾皇子煤蹭,可洞房花燭夜當晚...
    茶點故事閱讀 44,577評論 2 353