-
Notifications
You must be signed in to change notification settings - Fork 4
/
configure.ac
338 lines (293 loc) · 10.2 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# Copyright (C) 2023 Fredrik Öhrström
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
AC_PREREQ([2.69])
AC_INIT(LIBXMQ, libxmq, oehrstroem@gmail.com,,https://libxmq.org)
AC_CONFIG_AUX_DIR([autoconf])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
SRC_ROOT="$(pwd -L)"
CONF_NAME="${host_cpu}-${host_vendor}-${host_os}"
BUILD_ROOT="$SRC_ROOT/build"
OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}"
AC_CONFIG_HEADERS(${OUTPUT_ROOT}/config.h:autoconf/config.h.in)
AC_SUBST(PLATFORM)
AC_SUBST(PLATFORM_CFLAGS)
AC_SUBST(PATH_SEP)
AC_SUBST(CONF_MNEMONIC)
if test "${host_vendor}" = "w64"; then
PLATFORM=WINAPI
PATH_SEP=';'
PLATFORM_CFLAGS=""
FUSE_DEFAULT="no"
MEDIA_DEFAULT="no"
ASAN_DEFALUT="no"
CONF_MNEMONIC="winapi64"
MNEMONIC="WINAPI64"
CFLAGS_EXTRAS=""
CXXFLAGS_EXTRAS=""
STATIC_XMQ_DEFAULT="yes"
else
PLATFORM=POSIX
PATH_SEP=':'
PLATFORM_CFLAGS="-DUSE_SYSLOG"
FUSE_DEFAULT="yes"
MEDIA_DEFAULT="yes"
ASAN_DEFAULT="yes"
STATIC_XMQ_DEFAULT="no"
if test "${host_cpu}" = "arm"; then
CONF_MNEMONIC="arm32"
MNEMONIC="ARM32"
CFLAGS_EXTRAS=""
CXXFLAGS_EXTRAS=""
fi
if test "${host_vendor}" = "apple"; then
CONF_MNEMONIC="osx64"
MNEMONIC="OSX64"
CFLAGS_EXTRAS=-D_DARWIN_FEATURE_64_BIT_INODE
CXXFLAGS_EXTRAS=-D_DARWIN_FEATURE_64_BIT_INODE
fi
if test "${host_vendor}" = "pc"; then
CONF_MNEMONIC="linux64"
MNEMONIC="LINUX64"
CFLAGS_EXTRAS=""
CXXFLAGS_EXTRAS=""
fi
fi
PKG_CONFIG="$(which pkg-config)"
if test "$PKG_CONFIG" = ""; then
PKG_CONFIG=/bin/false
AC_MSG_ERROR([You need pkg-config to build. Try: sudo apt install pkg-config])
fi
mkdir -p "$OUTPUT_ROOT"
if test ! -d "$OUTPUT_ROOT"; then
AC_MSG_ERROR([Could not create build directory $OUTPUT_ROOT])
fi
rm -f "$SRC_ROOT/build/default"
# Create the link build/default which points to the output root.
# This reduces the need to know the exact output root which might include OS versions etc.
# Useful for CI builds.
ln -s "$OUTPUT_ROOT" "$SRC_ROOT/build/default"
AC_SUBST(CONF_NAME)
AC_SUBST(SRC_ROOT)
AC_SUBST(OUTPUT_ROOT)
AC_SUBST(BUILD_ROOT)
AC_HEADER_STAT
if test "x$CC" = "x"; then
AC_PATH_TOOL([CC], [gcc], [:])
fi
if test "x$CXX" = "x"; then
AC_PATH_TOOL([CXX], [g++], [:])
fi
if test "x$LD" = "x"; then
AC_PATH_TOOL([LD], [ld], [:])
fi
if test "x$STRIP" = "x"; then
AC_PATH_TOOL([STRIP], [strip], [:])
fi
AC_MSG_CHECKING([for address/leak sanitizer and code coverage])
AC_ARG_ENABLE([asan],
[AS_HELP_STRING([--disable-asan-gcov],
[disable address sanitizer and code coverage for debug builds @<:@enabled@:>@])],
[ENABLE_ASAN=${enable_asan}], [ENABLE_ASAN=${ASAN_DEFAULT}])
if test "x$ENABLE_ASAN" = xyes; then
ASAN_CFLAGS="-O0 -ggdb -fsanitize=address -fno-omit-frame-pointer -fprofile-arcs -ftest-coverage"
ASAN_LDFLAGS="-fsanitize=address -static-libasan"
ASAN_LIBS="-lgcov --coverage"
AC_MSG_RESULT([using ${with_asan}])
else
AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_ASAN)
AC_SUBST(ASAN_CFLAGS)
AC_SUBST(ASAN_LDFLAGS)
AC_SUBST(ASAN_LIBS)
AC_MSG_CHECKING([build static xmq binary])
AC_ARG_ENABLE([static-xmq],
[AS_HELP_STRING([--enable-static-xmq],
[build a statically linked xmq binary @<:@enabled@:>@])],
[ENABLE_STATIC_XMQ=${enable_static_xmq}], [ENABLE_STATIC_XMQ=${STATIC_XMQ_DEFAULT}])
if test "x$ENABLE_STATIC_XMQ" = xyes; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_STATIC_XMQ)
AC_MSG_CHECKING([for zlib])
AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
[specify prefix directory for the zlib package
(expecting the libraries under PATH and the headers under PATH)])])
if test "x${with_zlib}" = "x"; then
if ! pkg-config zlib ; then
AC_MSG_ERROR([not found using pkg-config. Try: sudo apt install zlib1g-dev])
exit 0
fi
ZLIB_CFLAGS="$($PKG_CONFIG zlib --cflags)"
ZLIB_LIBS="$($PKG_CONFIG zlib --libs)"
AC_MSG_RESULT([found using pkg-config])
if test "x$ENABLE_STATIC_XMQ" = xyes; then
AC_MSG_ERROR([You specified --enable-static-xmq so you must use --with-zlib=... to find a static libz.a])
fi
else
with_zlib=$(realpath ${with_zlib})
ZLIB_CFLAGS="-I${with_zlib}"
LIBNAME="libz.a"
LIBF=$(find ${with_zlib} -name "${LIBNAME}")
if test -z "$LIBF"; then
AC_MSG_ERROR([Could not find ${LIBNAME} below ${with_zlib}])
fi
ZLIB_LIBS="${LIBF}"
AC_MSG_RESULT([using ${with_zlib}])
fi
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(ZLIB_LIBS)
AC_MSG_CHECKING([for libxml2])
AC_ARG_WITH(libxml2, [AS_HELP_STRING([--with-libxml2],
[specify prefix directory for the libxml2 package
(expecting the libraries under PATH and the headers under PATH)])])
if test "x${with_libxml2}" = "x"; then
LIBXML2_CFLAGS="-I /usr/include/libxml2"
LIBXML2_LIBS="-lxml2"
AC_MSG_RESULT([using -lxml2 and /usr/include/libxml2])
AC_CHECK_LIB(xml2, xmlSAXParseDoc, [], [
echo "Error! You need to have libxml2 available. Try: sudo apt install libxml2-dev"
exit -1
])
if test "x$ENABLE_STATIC_XMQ" = xyes; then
AC_MSG_ERROR([You specified --enable-static-xmq so you must use --with-libxml2=... to find a static libxml2.a])
fi
else
with_libxml2=$(realpath ${with_libxml2})
IDIR=$(find ${with_libxml2} -path "*/libxml/tree.h" | sed 's|/libxml/tree.h||')
LIBXML2_CFLAGS="-I${IDIR}"
if test -z "$IDIR"; then
AC_MSG_ERROR([Could not find libxml/tree.h below ${with_libxml2}])
fi
LIBNAME="libxml2-2.dll"
LIBF=$(find ${with_libxml2} -name "${LIBNAME}")
LIBXML2_LIBS="-Wl,-Bstatic ${LIBF}"
if test -z "$LIBF"; then
LIBNAME="libxml2_la-tree.o"
LIBF=$(find ${with_libxml2}/.libs -name "${LIBNAME}" | head -n 1)
LIBXML2_LIBS=$(find ${with_libxml2}/.libs -name "*.o" | tr '\n' ' ')
fi
if test -z "$LIBF"; then
AC_MSG_ERROR([Could not find ${LIBNAME} below ${with_libxml2}])
fi
AC_MSG_RESULT([using ${with_libxml2}])
fi
AC_SUBST(LIBXML2_CFLAGS)
AC_SUBST(LIBXML2_LIBS)
AC_MSG_CHECKING([for libxslt])
AC_ARG_WITH(libxslt, [AS_HELP_STRING([--with-libxslt],
[specify prefix directory for the libxslt package
(expecting the libraries under PATH and the headers under PATH)])])
if test "x${with_libxslt}" = "x"; then
LIBXSLT_CFLAGS="-I /usr/include/libxslt"
LIBXSLT_LIBS="-lxslt"
AC_MSG_RESULT([using -lxslt and /usr/include/libxslt])
AC_CHECK_LIB(xslt, xsltLibxmlVersion, [], [
echo "Error! You need to have libxslt available. Try: sudo apt install libxslt1-dev"
exit -1
])
if test "x$ENABLE_STATIC_XMQ" = xyes; then
AC_MSG_ERROR([You specified --enable-static-xmq so you must use --with-libxslt=... to find a static libxslt.a])
fi
else
with_libxslt=$(realpath ${with_libxslt})
IDIR=$(find ${with_libxslt} -path "*/libxslt/xslt.h" | sed 's|/libxslt/xslt.h||')
LIBXSLT_CFLAGS="-I${IDIR}"
if test -z "$IDIR"; then
AC_MSG_ERROR([Could not find libxslt/xslt.h below ${with_libxslt}])
fi
LIBNAME="libxslt-1.dll"
LIBF=$(find ${with_libxslt} -name "${LIBNAME}")
LIBXSLT_LIBS="-Wl,-Bstatic ${LIBF}"
if test -z "$LIBF"; then
LIBNAME="xsltutils.o"
LIBF=$(find ${with_libxslt}/libxslt/.libs -name "${LIBNAME}" | head -n 1)
LIBXSLT_LIBS=$(find ${with_libxslt}/libxslt/.libs -name "*.o" | tr '\n' ' ')
fi
if test -z "$LIBF"; then
AC_MSG_ERROR([Could not find ${LIBNAME} below ${with_libxslt}])
fi
AC_MSG_RESULT([using ${with_libxslt}])
fi
AC_SUBST(LIBXSLT_CFLAGS)
AC_SUBST(LIBXSLT_LIBS)
AC_LANG_PUSH([C])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
not clang
#endif
]])],
[CLANG=yes], [CLANG=no])
AC_LANG_POP([C])
AC_SUBST([CLANG])
GCC_EXTRA_CXXFLAGS=""
if test "x$CLANG" = xyes; then
AC_MSG_RESULT([checking type of compiler: using clang])
GCC_EXTRA_CXXFLAGS=""
GCC_EXTRA_CFLAGS=""
else
AC_MSG_RESULT([checking type of compiler: using g++])
GCC_EXTRA_CXXFLAGS="-Wno-maybe-uninitialized"
GCC_EXTRA_CFLAGS=""
fi
CXXFLAGS="-DPLATFORM_${PLATFORM} ${CXXFLAGS_EXTRAS} -D${MNEMONIC} -Wall -Wparentheses -Wmissing-declarations -Wimplicit -Wno-error=deprecated-declarations -fmessage-length=0 -std=c++11 $GCC_EXTRA_CXXFLAGS -Wno-unused-function -Wreturn-type"
CXXFLAGS_release="-Os"
CXXFLAGS_debug="-O0 -g"
CXXFLAGS_asan="-O0 -g ${ASAN_CFLAGS}"
CFLAGS="-DPLATFORM_${PLATFORM} ${CFLAGS_EXTRAS} -D${MNEMONIC} $GCC_EXTRA_CFLAGS -Wall -Wparentheses -Wmissing-declarations -Wimplicit -Wno-error=deprecated-declarations -fmessage-length=0 -Wno-unused-function -Wreturn-type"
CFLAGS_release="-Os"
CFLAGS_debug="-O0 -g"
CFLAGS_asan="-O0 -g ${ASAN_CFLAGS}"
LDFLAGS=""
LDFLAGS_release="-Os"
LDFLAGS_debug="-g ${MEDIA_LIBS}"
LDFLAGSBEGIN_debug="${MEDIA_LIBS}"
LDFLAGSEND_debug=""
LDFLAGS_asan="-g ${ASAN_LDFLAGS} ${MEDIA_LIBS}"
LDFLAGSBEGIN_asan="${ASAN_LIBS} ${MEDIA_LIBS}"
LDFLAGSEND_asan=""
AC_SUBST(CC)
AC_SUBST(CXX)
AC_SUBST(LD)
AC_SUBST(CFLAGS)
AC_SUBST(CFLAGS_release)
AC_SUBST(CFLAGS_debug)
AC_SUBST(CFLAGS_asan)
AC_SUBST(CXXFLAGS)
AC_SUBST(CXXFLAGS_release)
AC_SUBST(CXXFLAGS_debug)
AC_SUBST(CXXCFLAGS_asan)
AC_SUBST(LDFLAGS)
AC_SUBST(LDFLAGS_release)
AC_SUBST(LDFLAGSBEGIN_release)
AC_SUBST(LDFLAGSEND_release)
AC_SUBST(LDFLAGS_debug)
AC_SUBST(LDFLAGSBEGIN_debug)
AC_SUBST(LDFLAGSEND_debug)
AC_SUBST(LDFLAGS_asan)
AC_SUBST(LDFLAGSBEGIN_asan)
AC_SUBST(LDFLAGSEND_asan)
AC_CONFIG_FILES([$OUTPUT_ROOT/spec.mk:$SRC_ROOT/autoconf/spec.mk.in])
AC_CONFIG_FILES([$OUTPUT_ROOT/spec.inc:$SRC_ROOT/autoconf/spec.inc.in])
AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$SRC_ROOT/make/Makefile.in])
# Make sure config.status ends up in the build directory instead of the src root.
CONFIG_STATUS="$OUTPUT_ROOT/config.status"
# Write out spec.gmk and build/Makefile
AC_OUTPUT