-
Notifications
You must be signed in to change notification settings - Fork 18
/
configure.ac
247 lines (213 loc) · 7.21 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# Copyright (c) 2013-2020 Martin Donath <[email protected]>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
# -----------------------------------------------------------------------------
# Prologue
# -----------------------------------------------------------------------------
AC_PREREQ(2.69)
AC_INIT([protobluff], [1.1.1], [[email protected]])
AM_INIT_AUTOMAKE([subdir-objects foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
: ${CFLAGS=""}
: ${CXXFLAGS=""}
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
LT_INIT
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
# Library versioning as <current:revision:age> - also remember to synchronize
# this value with the version info in the core/common.h header file.
AC_SUBST([VERSION_INFO], [5:1:1])
# Checks for programs
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_LN_S
AC_PROG_MAKE_SET
# Check for Protocol Buffers support to build generator
AC_CHECK_LIB([protobuf], [main], [LIBPROTOBUF="-lprotobuf"], [
AC_MSG_WARN([libprotobuf not found; cannot build protoc-gen-protobluff])])
AC_CHECK_LIB([protoc], [main], [LIBPROTOC="-lprotoc"], [
AC_MSG_WARN([libprotoc not found; cannot build protoc-gen-protobluff])])
AC_CHECK_PROGS([PROTOC], [protoc])
if test -z "$PROTOC"; then
AC_MSG_WARN([protoc not found; cannot build protoc-gen-protobluff])
fi
AM_CONDITIONAL(HAVE_PROTOBUF, [ \
test -n "$LIBPROTOBUF" -a -n "$LIBPROTOC" -a -n "$PROTOC"])
if test -z "$HAVE_PROTOBUF"; then
protobuf_LIBS="$LIBPROTOBUF $LIBPROTOC"
else
protobuf_LIBS=""
fi
AC_SUBST([protobuf_LIBS])
AC_SUBST([PROTOC])
# Check for ability to build and run tests
PKG_CHECK_MODULES([check], [check >= 0.9.10], [],
AC_MSG_WARN([check not found; cannot build tests]))
AM_CONDITIONAL(HAVE_CHECK, [test -n "$check_LIBS"])
# Additional compiler flags for check
if test "${CC}" = "clang"; then
check_CFLAGS+=" -g -Wno-incompatible-pointer-types-discards-qualifiers"
else
check_CFLAGS+=" -g"
fi
# Check for ability to build coverage report
AC_CHECK_PROGS([LCOV], [lcov])
if test -z "$LCOV"; then
AC_MSG_WARN([lcov not found; cannot build coverage report])
fi
AC_CHECK_PROGS([GENHTML], [genhtml])
if test -z "$GENHTML"; then
AC_MSG_WARN([genhtml not found; cannot build coverage report])
fi
AM_CONDITIONAL(HAVE_COVERAGE, [test -n "$LCOV" -a -n "$GENHTML"])
# Check for ability to run memcheck
AC_CHECK_PROGS([VALGRIND], [valgrind])
if test -z "$VALGRIND"; then
AC_MSG_WARN([valgrind not found; cannot run leak check])
fi
AM_CONDITIONAL(HAVE_VALGRIND, [test -n "$VALGRIND"])
# -----------------------------------------------------------------------------
# Arguments
# -----------------------------------------------------------------------------
# Disable optimized compilation
AC_ARG_ENABLE([optimized],
[AS_HELP_STRING([--disable-optimized],
[no optimizations @<:@default=enabled@:>@])],
[OPTIMIZATIONS="-g"],
[OPTIMIZATIONS="-O3 -DNDEBUG"
OPTIMIZATIONS+=" -fno-exceptions"
OPTIMIZATIONS+=" -fno-unwind-tables"
OPTIMIZATIONS+=" -fno-asynchronous-unwind-tables"
OPTIMIZATIONS+=" -fno-stack-protector"
OPTIMIZATIONS+=" -fomit-frame-pointer"])
AC_SUBST([OPTIMIZATIONS])
# Disable stripped build
AC_ARG_ENABLE([stripped],
[AS_HELP_STRING([--disable-stripped],
[strip internal symbols @<:@default=enabled@:>@])],
[CPPFLAGS+=" -fvisibility=hidden"], [])
# Enable coverage report
AC_ARG_ENABLE([coverage],
[AS_HELP_STRING([--enable-coverage],
[coverage report @<:@default=disabled@:>@])],
[coverage_CPPFLAGS="--coverage" coverage_LDFLAGS="--coverage"],
[coverage_CPPFLAGS="" coverage_LDFLAGS=""])
AC_SUBST([coverage_CPPFLAGS])
AC_SUBST([coverage_LDFLAGS])
# -----------------------------------------------------------------------------
# Header files, types and functions
# -----------------------------------------------------------------------------
# Check for header files
AC_HEADER_STDBOOL
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS([ \
float.h \
limits.h \
stddef.h \
stdint.h \
stdlib.h \
string.h])
# Check for keywords and types
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_CHECK_TYPES([ptrdiff_t])
# Check for library functions
AC_FUNC_ALLOCA
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([ \
localeconv \
memmove \
setlocale \
strchr \
strpbrk \
strtol \
strtoul \
strtoull])
# -----------------------------------------------------------------------------
# Configuration
# -----------------------------------------------------------------------------
# Configuration files
AC_CONFIG_FILES([
Makefile
examples/decoding/Makefile
examples/encoding/Makefile
examples/messages/Makefile
examples/Makefile
include/Makefile
src/core/Makefile
src/generator/Makefile
src/message/Makefile
src/util/Makefile
src/Makefile
src/protobluff-lite.pc
src/protobluff.pc
tests/core/buffer/Makefile
tests/core/decoder/Makefile
tests/core/descriptor/Makefile
tests/core/encoder/Makefile
tests/core/stream/Makefile
tests/core/varint/Makefile
tests/core/Makefile
tests/message/buffer/Makefile
tests/message/cursor/Makefile
tests/message/field/Makefile
tests/message/journal/Makefile
tests/message/message/Makefile
tests/message/nested/Makefile
tests/message/oneof/Makefile
tests/message/part/Makefile
tests/message/Makefile
tests/util/chunk_allocator/Makefile
tests/util/descriptor/Makefile
tests/util/validator/Makefile
tests/util/Makefile
tests/Makefile
])
# Compiler flags
CFLAGS+=" -std=c99"
CXXFLAGS+=" -std=c++11"
CPPFLAGS+=" -Wall -Wno-deprecated-declarations -Wno-address"
# Output result
AC_OUTPUT
# Print build configuration
AC_MSG_RESULT([
$PACKAGE $VERSION
CC: ${CC}
CFLAGS: ${CFLAGS} ${OPTIMIZATIONS}
CXX: ${CXX}
CXXFLAGS: ${CXXFLAGS} ${OPTIMIZATIONS}
CPPFLAGS: ${CPPFLAGS} ${coverage_CPPFLAGS}
LDFLAGS: ${LDFLAGS} ${coverage_LDFLAGS}
prefix: ${prefix}
sysconfdir: ${sysconfdir}
libdir: ${libdir}
includedir: ${includedir}
])