forked from cyrusimap/zeroskip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
257 lines (222 loc) · 6.82 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
# version
m4_define([zs_version_major],[0])
m4_define([zs_version_minor],[1])
m4_define([zs_version_micro],[0])
m4_define([zs_version_suffix],[devel])
m4_define([zs_version], zs_version_major.zs_version_minor.zs_version_micro[]m4_ifset([zs_version_suffix],-[zs_version_suffix]))
# libtool version
m4_define([zs_version_lt_current],[0])
m4_define([zs_version_lt_revision],[0])
m4_define([zs_version_lt_age],[0])
# autoconf intialisation
AC_PREREQ([2.60])
AC_INIT([libzeroskip],[zs_version])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# automake initialisation
# NOTE: No -Werror and have no portability (-Wno-portability)
# with automake since I wanted to support GNU extensions
# for flymake.
AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign])
AC_CANONICAL_HOST
# Autoconf automatically uses CFLAGS="-O2 -g". So clear CFLAGS
: ${CFLAGS=""}
# fix for automake >= 1.12
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
# libtool intialisation
LT_PREREQ([2.2.0])
LT_INIT
# zeroskip tool
AC_ARG_ENABLE([tool],
[AS_HELP_STRING([--enable-tool=@<:@yes/no@:>@],
[Build the zeroskip tool @<:@default=yes@:>@])],
[], [enable_tool=yes])
AM_CONDITIONAL([ENABLE_TOOL], [test "x$enable_tool" = "xyes"])
# documentation
AC_ARG_ENABLE([doc],
[AS_HELP_STRING([--enable-doc=@<:@yes/no@:>@],
[Build documentation @<:@default=yes@:>@])],
[], [enable_doc=yes])
AM_CONDITIONAL([ENABLE_DOC], [test "x$enable_doc" = "xyes"])
# examples
AC_ARG_ENABLE([examples],
[AS_HELP_STRING([--enable-examples=@<:@yes/no@:>@],
[Build example applications @<:@default=yes@:>@])],
[], [enable_examples=yes])
AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = "xyes"])
# benchmark
AC_ARG_ENABLE([benchmark],
[AS_HELP_STRING([--enable-benchmark=@<:@yes/no@:>@],
[Build the benchmark tool @<:@default=yes@:>@])],
[], [enable_benchmark=yes])
AM_CONDITIONAL([ENABLE_BENCH], [test "x$enable_benchmark" = "xyes"])
# tests
AC_ARG_ENABLE([tests],
[AS_HELP_STRING([--enable-tests=@<:@yes/no@:>@],
[Build the tests @<:@default=yes@:>@])],
[], [enable_tests=yes])
AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"])
PKG_CHECK_MODULES([CHECK], [check >= 0.9.6])
AC_ARG_ENABLE([debug],
[AC_HELP_STRING([--enable-debug=@<:@yes/no@:>@],
[Enable debug build flags @<:@default=yes@:>@])],
[], [enable_debug=yes])
AM_CONDITIONAL([IS_DEBUG], [test "x$enable_debug" = xyes])
# check for programs
AC_PROG_CC
AC_PROG_CC_C99
AC_CHECK_PROGS([DOXYGEN], [doxygen])
AC_CHECK_PROGS([MANDOC], [mandoc])
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AM_CONDITIONAL([HAVE_MANDOC], [test -n "$MANDOC"])
# Detect platform
AC_MSG_CHECKING(platform)
case "$host_os" in
*darwin*)
AC_MSG_RESULT(darwin)
PLATFORM=darwin
;;
*dragonfly*)
AC_MSG_RESULT(dragonfly)
PLATFORM=dragonfly
;;
*linux*)
AC_MSG_RESULT(linux)
PLATFORM=linux
;;
*freebsd*)
AC_MSG_RESULT(freebsd)
PLATFORM=freebsd
;;
*netbsd*)
AC_MSG_RESULT(netbsd)
PLATFORM=netbsd
;;
*openbsd*)
AC_MSG_RESULT(openbsd)
PLATFORM=openbsd
;;
*sunos*)
AC_MSG_RESULT(sunos)
PLATFORM=sunos
;;
*solaris*)
AC_MSG_RESULT(sunos)
PLATFORM=sunos
;;
*cygwin*)
AC_MSG_RESULT(cygwin)
PLATFORM=cygwin
;;
*)
AC_MSG_RESULT(unknown)
PLATFORM=unknown
;;
esac
AC_SUBST(PLATFORM)
AM_CONDITIONAL(IS_DARWIN, test "x$PLATFORM" = xdarwin)
AM_CONDITIONAL(IS_DRAGONFLY, test "x$PLATFORM" = xdragonfly)
AM_CONDITIONAL(IS_LINUX, test "x$PLATFORM" = xlinux)
AM_CONDITIONAL(IS_FREEBSD, test "x$PLATFORM" = xfreebsd)
AM_CONDITIONAL(IS_NETBSD, test "x$PLATFORM" = xnetbsd)
AM_CONDITIONAL(IS_OPENBSD, test "x$PLATFORM" = xopenbsd)
AM_CONDITIONAL(IS_SUNOS, test "x$PLATFORM" = xsunos)
AM_CONDITIONAL(IS_UNKNOWN, test "x$PLATFORM" = xunknown)
# silent build rules
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# check for dependencies
DEPENDENCIES=""
# check for libuuid
AC_SUBST(LIBUUID_CFLAGS)
AC_SUBST(LIBUUID_LIBS)
if pkg-config uuid; then
LIBUUID_CFLAGS=`pkg-config --cflags uuid`
LIBUUID_LIBS=`pkg-config --libs uuid`
AC_DEFINE([HAVE_LIBUUID], [1], [libuuid library])
DEPENDENCIES="$DEPENDENCIES uuid"
else
AC_MSG_ERROR("You need libuuid to be able to build libzeroskip")
fi
# check for libzlib
AC_SUBST(LIBZLIB_CFLAGS)
AC_SUBST(LIBZLIB_LIBS)
if pkg-config zlib; then
LIBZLIB_CFLAGS=`pkg-config --cflags zlib`
LIBZLIB_LIBS=`pkg-config --libs zlib`
AC_DEFINE([HAVE_LIBZLIB], [1], [libzlib library])
DEPENDENCIES="$DEPENDENCIES zlib"
else
AC_MSG_ERROR("You need libzlib to be able to build libzeroskip")
fi
dnl CRC32 optimisations
dnl if the compiler has support for SSE4.2 then we can compile a hardware
dnl implementation of CRC32C
AC_MSG_CHECKING(for compiler support for SSE4.2 instruction)
AC_CACHE_VAL(zs_cv_sse42, AC_TRY_COMPILE([
#include <stdint.h>
],[
uint64_t a = 0, b = 1;
__asm__("crc32q\t" "(%1), %0"
: "=r"(b)
: "r"(b), "0"(a));
return b;
], zs_cv_sse42=yes, zs_cv_sse42=no))
if test "$zs_cv_sse42" = "yes" ; then
AC_DEFINE([HAVE_SSE42], [1],["SSE4.2 extensions"])
AC_SUBST(SSE42)
fi
AC_MSG_RESULT($zs_cv_sse42)
AC_SUBST([DEPENDENCIES])
# check for header file
AC_CHECK_HEADERS([getopt.h])
# check for structures
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec],,,[
#include <time.h>
])
# check for library functions
AC_CHECK_FUNCS([getopt_long])
AC_CHECK_FUNCS([memmem])
# checks for supported compiler options
AX_APPEND_COMPILE_FLAGS([ \
-pedantic \
-Wall \
-Wextra \
-Wshadow \
-Wrestrict \
-Wformat=2 \
-Wwrite-strings \
-Wcast-qual \
-Wpointer-arith \
-Wstrict-prototypes \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wno-unused-parameter \
-fstack-protector \
],,[-Werror])
# versioning
AC_SUBST([ZS_VERSION],[zs_version])
AC_SUBST([ZS_VERSION_MAJOR],[zs_version_major])
AC_SUBST([ZS_VERSION_MINOR],[zs_version_minor])
AC_SUBST([ZS_VERSION_MICRO],[zs_version_micro])
AC_SUBST([ZS_VERSION_LIBTOOL],[zs_version_lt_current:zs_version_lt_revision:zs_version_lt_age])
# version suffix
m4_ifset([zs_version_suffix],[
AC_DEFINE(HAVE_VERSION_SUFFIX, [1], [Define if a version suffix is present.])
])
AC_CONFIG_FILES([
libzeroskip.pc
Makefile
include/Makefile
include/libzeroskip/Makefile
include/libzeroskip/version.h
src/Makefile
doc/Makefile
doc/doxygen.cfg
doc/man/Makefile
tool/Makefile
examples/Makefile
tests/Makefile
benchmark/Makefile
])
AC_OUTPUT