-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
204 lines (174 loc) · 6.87 KB
/
configure.ac
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# configure.ac -- autoconf file
#
# ╔════════════════════════════════╗
# ║ This file uses UTF-8 encoding. ║
# ╚════════════════════════════════╝
#
# Copyright © 2011, Gregory ROMÉ
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form 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.
# * Neither the name of the Gregory ROMÉ nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY GREGORY ROMÉ ''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 GREGORY ROMÉ 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
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ==============================================================================
# Autoconf Layout
#
# 1. Autoconf requirements
# 2. AC_INIT(package, version, bug-report-address)
# 3. information on the package
# 4. checks for programs
# 5. checks for libraries
# 6. checks for header files
# 7. checks for types
# 8. checks for structures
# 9. checks for compiler characteristics
# 10. checks for library functions
# 11. checks for system services
# 12. AC_CONFIG_FILES([file...])
# 13. AC_OUTPUT
# ==============================================================================
# 1. Autoconf requirements
AC_PREREQ(2.59)
# ==============================================================================
# 2. AC_INIT(package, version, bug-report-address)
define([VERSION_NUMBER], [1.0]) # For sharing the version number
AC_INIT([template], [VERSION_NUMBER], [gregory.rome@gmail.com])
# ==============================================================================
# 3. information on the package
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([foreign]) # 'foreign' => not a pure GNU project
LT_INIT
# ------------------------------------------------------------------------------
# Options
# Enable debug
# Debug options are defined in Makefile.am
AC_ARG_WITH([debug], [AS_HELP_STRING([--with-debug],
[Enable debug (default is no)])], [enable_debug=$withval],
[enable_debug=no])
AM_CONDITIONAL(ENABLE_DEBUG, test "X$enable_debug" = "Xyes")
# Enable coverage
AC_ARG_WITH([coverage], [AS_HELP_STRING([--with-coverage],
[Enable coverage (default is no)])], [enable_coverage=$withval],
[enable_coverage=no])
AM_CONDITIONAL(ENABLE_COVERAGE, test "X$enable_coverage" = "Xyes")
if test "X$enable_coverage" = "Xyes"
then
CFLAGS="$CFLAGS --coverage"
LDFLAGS="$LDFLAGS -lgcov"
fi
AM_CONDITIONAL(ENABLE_INDIVIDUAL_TEST, test "X$enable_individual_test" = "Xtrue")
# ==============================================================================
# 4. checks for programs
AC_PATH_PROG(lcov_cmd, lcov)
AC_PATH_PROG(genhtml_cmd, genhtml)
if test X"$lcov_cmd" = "X"
then
AC_MSG_WARN([*** WARNING: you should install lcov \
(sudo apt-get install lcov)])
fi
AM_CONDITIONAL(ENABLE_COVERAGE_REPORT, test X"$lcov_cmd" != "X" \
&& test X"$genhtml_cmd" != "X" && test "X$enable_coverage" = "Xyes")
AC_PATH_PROG(git_cmd, git)
AC_PATH_PROG(svnversion_cmd, svnversion)
have_git_revision=false
have_svn_revision=false
# --------------------------
# Have svn or git revision ?
if test "X$git_cmd" != "X"
then
GIT_REVISION=`cd $srcdir && git describe --all --dirty 2>/dev/null| tr -d '\n'`
fi
if test "X$GIT_REVISION" != "X" || test -f $srcdir/GIT_REVISION
then
have_git_revision=true
else
if test "X$svnversion_cmd" != "X"
then
SVN_REVISION=`svnversion $srcdir`
fi
fi
if test "X$SVN_REVISION" != "Xexported" || test -f $srcdir/SVN_REVISION
then
have_svn_revision=true
fi
AM_CONDITIONAL(HAVE_VCS, test "X$have_svn_revision" = "Xtrue" || test "X$have_git_revision" = "Xtrue")
# ---------------------------
# Define command vcs_revision
if test "X$have_git_revision" = "Xtrue"
then
if test "X$GIT_REVISION" = "X"
then
vcs_revision="cat GIT_REVISION"
else
vcs_revision="git describe --all --dirty 2>/dev/null| tr -d '\n'"
fi
VCS_FILE=GIT_REVISION
elif test "X$have_svn_revision" = "Xtrue"
then
if test "X$SVN_REVISION" = "X"
then
vcs_revision="cat SVN_REVISION"
else
vcs_revision="svnversion"
fi
VCS_FILE=SVN_REVISION
fi
AC_SUBST(vcs_revision)
AC_SUBST(VCS_FILE)
if test "X$have_git_revision" = "Xtrue" || "X$have_svn_revision" = "Xtrue"
then
AC_DEFINE_UNQUOTED(HAVE_VCS_REVISION_H, 1, [Have vcs_revision.h])
fi
# ==============================================================================
# 5. checks for libraries
AC_CHECK_LIB([cunit], [CU_initialize_registry], AS_VAR_SET(have_cunit,true),
AC_MSG_WARN([*** WARNING: cunit is required for testing \
(sudo apt-get install libcunit1-dev) ***]))
if test "X$have_cunit" = "Xtrue"; then
MAYBE_TEST=test
AC_MSG_NOTICE([*** INFO: Test will be generated])
else
MAYBE_TEST=
fi
AC_SUBST([MAYBE_TEST])
# ==============================================================================
# 6. checks for header files
# ==============================================================================
# 7. checks for types
# ==============================================================================
# 8. checks for structures
# ==============================================================================
# 9. checks for compiler characteristics
AC_PROG_CC
AC_PROG_LIBTOOL
# ==============================================================================
# 10. checks for library functions
# ==============================================================================
# 11. checks for system services
# ==============================================================================
# 12. AC_CONFIG_FILES([file...])
AC_CONFIG_FILES(Makefile src/Makefile src/hello/Makefile src/version/Makefile
test/Makefile test/hello/Makefile test/version/Makefile)
# ==============================================================================
AC_OUTPUT