-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutotools.txt
87 lines (70 loc) · 1.82 KB
/
Autotools.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
$ apt install build-essential git perl flex bison gperf \
automake autoconf libtool pkg-config gettext
$ autoscan
$ mv configure.scan configure.ac
$ cat configure.ac
AC_PREREQ([2.71])
AC_INIT([MyProject], [1.2], [support@email])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_MACRO_DIRS([m4])
AM_PROG_AR
LT_INIT
AC_PROG_CC # CXX
AC_CONFIG_HEADERS([config.h])
# put dependency first
AC_CONFIG_FILES([
Makefile
foo/Makefile
])
AC_OUTPUT
$
$ cat Makefile.am
ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = main
#lib_LTLIBRARIES =
main_SOURCES = main.c
CFLAGS = -std=c99 -g -fPIC # CXXFLAGS
main_CPPFLAGS = # -I./foo
main_LDFLAGS = # -L./foo -lfoo -shared
# rpath for dev
main_LDFLAGS += # -Wl,-rpath,'$$ORIGIN/../foo/.libs'
# rpath for install: make DESTDIR=~/tmp install
main_LDFLAGS += # -Wl,-rpath,'$$ORIGIN/../lib'
# library versioning with soname
main_LDFLAGS += # -release $(PACKAGE_VERSION) -version-info 0:8:0
# put dependency first
SUBDIRS = ./foo
$
$ cat autogen.sh
# usage
# ./autogen
# ./autogen clean
# autogen
if (( $# == 0 )); then
[[ ! -d m4 ]] && mkdir m4
autoreconf -i
fi
# clean
if [[ $1 == "clean" ]]; then
# temporaries by autoreconf -i
rm -fr aclocal.m4 compile config.* configure \
configure~ depcomp install-sh m4 missing ar-lib \
autom4te.cache ltmain.sh
find . -name "Makefile.in" -exec rm -fr {} \;
# temporaries by ./configure
rm -fr libtool stamp-h1
find . -name ".deps" -type d -exec rm -fr {} \;
find . -name "Makefile" -exec rm -fr {} \;
# temporaries by make
find . \( -name "*.la" -o -name "*.lai" -o -name "*.lo" \
-o -name "*.d" -o -name "*.o" \) -exec rm -fr {} \;
fi
$
$ autoreconf -i
$ ./configure
$ make
$ ./configure --help
Ref:
Autotools Tutorial, Handout version in PDF
(4 slides per pages without animations, for printing)
https://www.lrde.epita.fr/~adl/dl/autotools-handout-4.pdf