-
Notifications
You must be signed in to change notification settings - Fork 13
/
configure.ac
375 lines (296 loc) · 11.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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# Process this file with autoconf to produce a configure script.
# Now you only need to update the version number in two places - below,
# and in the README
AC_INIT([wandio],[4.2.6],[[email protected]],[wandio])
WANDIO_MAJOR=4
WANDIO_MID=2
WANDIO_MINOR=5
# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
# searched by default - add it to LDFLAGS so we at least have a chance of
# finding it
if test -d "/usr/gnu/lib"; then
LDFLAGS+=" -L/usr/gnu/lib"
fi
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(lib/wandio.c)
AM_INIT_AUTOMAKE([subdir-objects])
# Make sure we use the relatively silent automake output
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# Define our wandio version number externally so we can use it in the source
# as well, if needed.
AC_DEFINE([WANDIO_MAJOR],${WANDIO_MAJOR},[wandio major version])
AC_DEFINE([WANDIO_MID],${WANDIO_MID},[wandio mid version])
AC_DEFINE([WANDIO_MINOR],${WANDIO_MINOR},[wandio minor version])
# These are all the files we want to be built for us by configure
AC_CONFIG_FILES([Makefile lib/Makefile tools/wandiocat/Makefile])
# Function that checks if the C++ compiler actually works - there's a bit of
# oversight in autoconf that will set the C++ compiler to g++ if no compiler
# is found, even if g++ is not present! So we need an extra test to make sure
# that the compiler works :(
AC_DEFUN([rw_PROG_CXX_WORKS],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_CACHE_CHECK([whether the C++ compiler works],
[rw_cv_prog_cxx_works],
[AC_LANG_PUSH([C++])
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[rw_cv_prog_cxx_works=yes],
[rw_cv_prog_cxx_works=no])
AC_LANG_POP([C++])])
])
# Put all our automake definitions in config.h
AC_CONFIG_HEADERS([config.h])
# Checks for C and C++ compilers
AC_PROG_CC
AC_PROG_CXX
rw_PROG_CXX_WORKS
if test "$rw_cv_prog_cxx_works" = "no"; then
AC_MSG_ERROR("Failed to find working C++ compiler")
fi
# Checking for 'install'
AC_PROG_INSTALL
# All our source files for function replacements are in lib/
AC_CONFIG_LIBOBJ_DIR(lib)
# Check for various "replacement" functions
AC_FUNC_MALLOC
AC_FUNC_REALLOC
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN
AC_TYPE_SIZE_T
AC_CHECK_HEADERS_ONCE([sys/time.h])
AC_SYS_LARGEFILE
ADD_INCLS=""
ADD_LDFLAGS="$ADD_LDFLAGS -L\$(abs_top_srcdir)/lib"
LIBWANDIO_LIBS=""
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wextra -DLT_BUILDING_DLL=1"
CXXFLAGS="$CXXFLAGS -Wall -DLT_BUILDING_DLL=1"
# Check for -fvisibility
gl_VISIBILITY
gcc_PACKED
gcc_DEPRECATED
gcc_UNUSED
gcc_PURE
gcc_FORMAT
# Check for libtool
LT_INIT
# Checks for library functions.
AC_PROG_GCC_TRADITIONAL
# Fail if any of these functions are missing
#AC_CHECK_FUNCS()
AC_CHECK_SIZEOF([long int])
AC_CHECK_HEADERS(stddef.h inttypes.h sys/prctl.h)
# Checks for various "optional" libraries
AC_CHECK_LIB(pthread, pthread_create, have_pthread=1, have_pthread=0)
if test "$have_pthread" = 1; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lpthread"
AC_DEFINE(HAVE_LIBPTHREAD, 1, [Set to 1 if pthreads are supported])
fi
# Stupid AC_SEARCH_LIB appends stuff to LIBS even when I don't want it to, so
# just set libs to null here to avoid linking against them by default
LIBS=
AC_ARG_WITH([bzip2],
AS_HELP_STRING([--with-bzip2],[build with support for bzip2 compressed files]))
AS_IF([test "x$with_bzip2" != "xno"],
[
AC_CHECK_LIB(bz2, BZ2_bzDecompressInit, have_bzip=yes, have_bzip=no)
], [have_bzip=no])
AS_IF([test "x$have_bzip" = "xyes"], [
if test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lbz2"
fi
with_bzip2=yes
AC_DEFINE(HAVE_LIBBZ2, 1, "Compiled with bzip2 support")],
[AS_IF([test "x$with_bzip2" = "xyes"],
[AC_MSG_ERROR([bzip2 requested but not found])])
AC_DEFINE(HAVE_LIBBZ2, 0, "Compiled with bzip2 support")
with_bzip2=no]
)
AC_ARG_WITH([zlib],
AS_HELP_STRING([--with-zlib],[build with support for zlib compressed files]))
AS_IF([test "x$with_zlib" != "xno"],
[
AC_CHECK_LIB(z, deflate, have_zlib=yes, have_zlib=no)
], [have_zlib=no])
AS_IF([test "x$have_zlib" = "xyes"], [
if test "$ac_cv_lib_z_deflate" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lz"
fi
AC_DEFINE(HAVE_LIBZ, 1, "Compiled with zlib support")
with_zlib=yes],
[AS_IF([test "x$with_zlib" = "xyes"],
[AC_MSG_ERROR([zlib requested but not found])])
AC_DEFINE(HAVE_LIBZ, 0, "Compiled with zlib support")
with_zlib=no]
)
AC_ARG_WITH([lzo],
AS_HELP_STRING([--with-lzo],[build with support for writing lzo compressed files]))
AS_IF([test "x$with_lzo" != "xno"],
[
AC_CHECK_LIB(lzo2, lzo1x_1_compress, have_lzo=yes, have_lzo=no)
], [have_lzo=no])
AS_IF([test "x$have_lzo" = "xyes"], [
if test "$ac_cv_lib_lzo2_lzo1x_1_compress" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llzo2"
fi
AC_DEFINE(HAVE_LIBLZO2, 1, "Compiled with lzo2 support")
with_lzo=yes],
[AS_IF([test "x$with_lzo" = "xyes"],
[AC_MSG_ERROR([lzo requested but not found])])
AC_DEFINE(HAVE_LIBLZO2, 0, "Compiled with lzo2 support")
with_lzo=no]
)
AC_ARG_WITH([lzma],
AS_HELP_STRING([--with-lzma],[build with support for lzma compressed files]))
AS_IF([test "x$with_lzma" != "xno"],
[
AC_CHECK_HEADER(lzma.h, have_lzma=yes, have_lzma=no)
], [have_lzma=no])
AS_IF([test "x$have_lzma" = "xyes"], [
if test "$ac_cv_lib_lzma_code" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llzma"
fi
AC_DEFINE(HAVE_LIBLZMA, 1, "Compiled with lzma support")
with_lzma=yes],
[AS_IF([test "x$with_lzma" = "xyes"],
[AC_MSG_ERROR([lzma requested but not found])])
AC_DEFINE(HAVE_LIBLZMA, 0, "Compiled with lzma support")
with_lzma=no]
)
AC_ARG_WITH([zstd],
AS_HELP_STRING([--with-zstd],[build with support for zstd compressed files]))
AS_IF([test "x$with_zstd" != "xno"],
[
AC_CHECK_LIB(zstd, ZSTD_createDStream, have_zstd=yes, have_zstd=no)
], [have_zstd=no])
AS_IF([test "x$have_zstd" = "xyes"], [
if test "$ac_cv_lib_zstd_code" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lzstd"
fi
AC_DEFINE(HAVE_LIBZSTD, 1, "Compiled with zstd support")
with_zstd=yes],
[AS_IF([test "x$with_zstd" = "xyes"],
[AC_MSG_ERROR([zstd requested but not found])])
AC_DEFINE(HAVE_LIBZSTD, 0, "Compiled with zstd support")
with_zstd=no]
)
AC_ARG_WITH([qatzip],
AS_HELP_STRING([--with-qatzip],[build with support for Intel QuickAssist compression]))
AS_IF([test "x$with_qatzip" != "xno"],
[
AC_CHECK_LIB(qatzip, qzCompress, have_qatzip=yes, have_qatzip=no)
], [have_qatzip=no])
AS_IF([test "x$have_qatzip" = "xyes"], [
if test "$ac_cv_lib_qatzip_qzCompress" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lqatzip"
fi
AC_DEFINE(HAVE_LIBQATZIP, 1, "Compiled with QATzip support")
with_qatzip=yes],
[AS_IF([test "x$with_qatzip" = "xyes"],
[AC_MSG_ERROR([QATzip requested but not found])])
AC_DEFINE(HAVE_LIBQATZIP, 0, "Compiled with QATzip support")
with_qatzip=no]
)
AC_ARG_WITH([lz4],
AS_HELP_STRING([--with-lz4],[build with support for lz4 compressed files]))
AS_IF([test "x$with_lz4" != "xno"],
[
AC_CHECK_LIB(lz4, LZ4F_createDecompressionContext, have_lz4f=yes, have_lz4f=no)
], [have_lz4f=no])
AS_IF([test "x$have_lz4f" = "xyes"], [
if test "$ac_cv_lib_lz4_code" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llz4"
fi
AC_DEFINE(HAVE_LIBLZ4F, 1, "Compiled with lz4 frame support")
AC_CHECK_LIB(lz4, LZ4F_getVersion, have_lz4_173=yes, have_lz4_173=no)
if test "x$have_lz4_173" = "xyes"; then
AC_DEFINE(HAVE_LIBLZ4_MOVABLE, 1, "If defined then liblz4 does NOT have the ERROR_srcPtr_wrong bug")
fi
with_lz4=frameapi],
[
AC_DEFINE(HAVE_LIBLZ4F, 0, "Compiled with lz4 frame support")
AC_CHECK_LIB(lz4, LZ4_decompress_safe_continue, have_lz4s=yes, have_lz4s=no)
AS_IF([test "x$have_lz4s" = "xyes"], [
if test "$ac_cv_lib_lz4_code" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llz4"
fi
AC_DEFINE(HAVE_LIBLZ4S, 1, "Compiled with lz4 stream support")
with_lz4=streamapi
], [
AC_DEFINE(HAVE_LIBLZ4S, 0, "Compiled with lz4 stream support")
with_lz4=no])
AS_IF([test "x$with_lz4" = "xyes"], [
AC_MSG_ERROR([lz4 requested but frame API was not found])])
]
)
AC_ARG_WITH([http],
AS_HELP_STRING([--with-http],[build with support for reading files over http (using libcurl)]))
AS_IF([test "x$with_http" != "xno"],
[
# we need curl_easy_pause which was added in 7.18.0
AC_CHECK_LIB(curl, curl_easy_pause, have_curl=yes, have_curl=no)
], [have_curl=no])
AS_IF([test "x$have_curl" = "xyes"], [
if test "$ac_cv_lib_curl_curl_easy_pause" != "none required"; then
LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lcurl"
fi
AC_DEFINE(HAVE_HTTP, 1, "Compiled with http support")
with_http=yes],
[AS_IF([test "x$with_http" = "xyes"],
[AC_MSG_ERROR([http requested but libcurl (> 7.18.0) not found])])
AC_DEFINE(HAVE_HTTP, 0, "Compiled with http support")
with_http=no]
)
# Define automake conditionals for use in our Makefile.am files
AM_CONDITIONAL([HAVE_BZLIB], [test "x$with_bzip2" != "xno"])
AM_CONDITIONAL([HAVE_ZLIB], [test "x$with_zlib" != "xno"])
AM_CONDITIONAL([HAVE_LZO], [ test "x$with_lzo" != "xno"])
AM_CONDITIONAL([HAVE_LZMA], [ test "x$with_lzma" != "xno"])
AM_CONDITIONAL([HAVE_ZSTD], [ test "x$with_zstd" != "xno"])
AM_CONDITIONAL([HAVE_QATZIP], [ test "x$with_qatzip" != "xno"])
AM_CONDITIONAL([HAVE_LZ4], [ test "x$with_lz4" != "xno"])
AM_CONDITIONAL([HAVE_ZSTD_OR_LZ4], [ test "x$with_zstd" != "xno" -o "x$with_lz4" != "xno"])
AM_CONDITIONAL([HAVE_HTTP], [ test "x$with_http" != "xno"])
# Set all our output variables
AC_SUBST([LIBWANDIO_LIBS])
#AC_SUBST([ADD_LIBS])
AC_SUBST([ADD_INCLS])
AC_SUBST([ADD_LDFLAGS])
AC_SUBST([LTLIBOBJS])
AC_SUBST([PACKAGE_VERSION])
AC_SUBST([WANDIO_MAJOR])
AC_SUBST([WANDIO_MID])
AC_SUBST([WANDIO_MINOR])
AC_SUBST([LIBCFLAGS])
AC_SUBST([LIBCXXFLAGS])
# Finally, output our Makefiles
AC_OUTPUT
# Function for reporting whether an option was set or not
reportopt() {
if test x"$2" = xtrue -o x"$2" = xyes; then
AC_MSG_NOTICE([$1: Yes])
else
AC_MSG_NOTICE([$1: No])
fi
}
reportlz4opt() {
if test x"$2" = xframeapi; then
AC_MSG_NOTICE([$1: Yes])
else
if test x"$2" = xstreamapi; then
AC_MSG_NOTICE([$1: No, API is too old])
else
AC_MSG_NOTICE([$1: No])
fi
fi
}
# Report which configure options were set
echo
AC_MSG_NOTICE([WANDIO version $PACKAGE_VERSION])
reportopt "Compiled with compressed file (zlib) support" $with_zlib
reportopt "Compiled with compressed file (bz2) support" $with_bzip2
reportopt "Compiled with compressed file (lzo write only) support" $with_lzo
reportopt "Compiled with compressed file (lzma) support" $with_lzma
reportopt "Compiled with compressed file (zstd) support" $with_zstd
reportlz4opt "Compiled with compressed file (lz4) support" $with_lz4
reportopt "Compiled with Intel QuickAssist Technology support" $with_qatzip
reportopt "Compiled with http read (libcurl) support" $with_http