forked from bfabiszewski/libmobi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
280 lines (254 loc) · 8.36 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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([1.10])
AC_INIT([libmobi], [0.1])
AC_CONFIG_SRCDIR([src/buffer.c])
# Enable automake
AM_INIT_AUTOMAKE([-Wall foreign])
# all defined C macros (HAVE_*) will be saved to this file
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_PROG_INSTALL
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
# Init libtool
#LT_INIT
AC_PROG_LIBTOOL
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_HEADERS([string.h])
AC_CHECK_HEADERS([utime.h])
AC_CHECK_HEADERS([sys/resource.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INT8_T
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MKTIME
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memmove memset mkdir strdup strpbrk strrchr strstr strtoul utime])
# test for --with-zlib
AC_MSG_CHECKING([whether compile with zlib])
AC_ARG_WITH(zlib,
AC_HELP_STRING([--with-zlib],[Use zlib instead of included miniz @<:@default=yes@:>@]),
[if test "$withval" = yes; then use_zlib=yes; else use_zlib=no; fi],
[use_zlib=yes])
AC_MSG_RESULT($use_zlib)
AM_CONDITIONAL(USE_ZLIB,[test x$use_zlib = xyes])
AM_CONDITIONAL(USE_MINIZ,[test x$use_zlib = xno])
if test x$use_zlib = xyes; then
AC_CHECK_HEADER([zlib.h],
[AC_DEFINE(USE_ZLIB, 1, [Define if you want to use system zlib library])
LIBZ_LDFLAGS=-lz
MINIZ_CFLAGS=],
[AC_MSG_ERROR([couldn't find zlib header])])
else
AC_DEFINE(USE_MINIZ, 1, [Define if you want to use included miniz library])
MINIZ_CFLAGS="-D_POSIX_C_SOURCE=200112L"
LIBZ_LDFLAGS=
fi
AC_SUBST(LIBZ_LDFLAGS)
AC_SUBST(MINIZ_CFLAGS)
# test for --with-libxml2
AC_MSG_CHECKING([whether compile with libxml2])
AC_ARG_WITH(libxml2,
AC_HELP_STRING([--with-libxml2],[Compile with libxml2 @<:@default=yes@:>@]),
[if test "$withval" = yes; then use_libxml2=yes; else use_libxml2=no; fi],
[use_libxml2=yes])
AC_MSG_RESULT($use_libxml2)
AM_CONDITIONAL(USE_LIBXML2,[test x$use_libxml2 = xyes])
if test x$use_libxml2 = xyes; then
old_CPPFLAGS=$CPPFLAGS
AC_CHECK_PROGS(XML2_CONFIG, xml2-config)
if test -n "$XML2_CONFIG"
then
CPPFLAGS="`$XML2_CONFIG --cflags`"
LIBXML2_CFLAGS="`$XML2_CONFIG --cflags`"
LIBXML2_LDFLAGS="`$XML2_CONFIG --libs`"
else
CPPFLAGS=-I/usr/include/libxml2
LIBXML2_CFLAGS=-I/usr/include/libxml2
LIBXML2_LDFLAGS=-lxml2
fi
AC_CHECK_HEADER([libxml/xmlwriter.h],
[AC_DEFINE(USE_LIBXML2, 1, [Define if you want to use libxml2 library])],
[AC_MSG_ERROR([couldn't find libxml2])])
CPPFLAGS=$old_CPPFLAGS
else
LIBXML2_LDFLAGS=
LIBXML2_CFLAGS=
fi
AC_SUBST(LIBXML2_LDFLAGS)
AC_SUBST(LIBXML2_CFLAGS)
# Check for oracle solaris studio c compiler
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
# Check for -fvisibility=hidden to determine if we can do GNU-style
# visibility attributes for symbol export control
AC_MSG_CHECKING([for visibility hidden compiler flag])
VISIBILITY_HIDDEN=
if test "x$SUNCC" = "xyes"; then
# check if we can use -xldscope=hidden
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="-xldscope=hidden"
AC_TRY_COMPILE([], [],
enable_fvisibility_hidden=yes,
enable_fvisibility_hidden=no)
CFLAGS="${SAVED_CFLAGS}"
AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
VISIBILITY_HIDDEN="-xldscope=hidden"
])
else
case "$host" in
*-*-mingw*)
# on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
VISIBILITY_HIDDEN="-fvisibility=hidden"
;;
*)
# on other compilers, check if we can do -fvisibility=hidden
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="-fvisibility=hidden -Werror"
AC_TRY_COMPILE([], [],
enable_fvisibility_hidden=yes,
enable_fvisibility_hidden=no)
CFLAGS="${SAVED_CFLAGS}"
AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
VISIBILITY_HIDDEN="-fvisibility=hidden"
])
;;
esac
fi
AC_MSG_RESULT($VISIBILITY_HIDDEN)
AC_SUBST(VISIBILITY_HIDDEN)
# MinGW seems to need this
case "$host" in
*-*-mingw*)
NO_UNDEFINED="-no-undefined"
AVOID_VERSION="-avoid-version"
ISO99_SOURCE="-D_ISOC99_SOURCE=1"
;;
*)
NO_UNDEFINED=
AVOID_VERSION=
ISO99_SOURCE=
;;
esac
AC_SUBST(NO_UNDEFINED)
AC_SUBST(AVOID_VERSION)
AC_SUBST(ISO99_SOURCE)
# Override default versioning of Darwin linker
case "$host" in
*-*-darwin*)
case "$host" in
# exclude ppc as it breaks linker
ppc-* | powerpc-*)
DARWIN_LDFLAGS=
;;
*)
MAJOR=`echo "${PACKAGE_VERSION}" | cut -d . -f 1`
DARWIN_LDFLAGS="-Wl,-compatibility_version,${MAJOR} -Wl,-current_version,${PACKAGE_VERSION}"
;;
esac
;;
*)
DARWIN_LDFLAGS=
;;
esac
AC_SUBST(DARWIN_LDFLAGS)
# Check for non-broken inline under various spellings
AC_MSG_CHECKING([for inline keyword])
def_inline=""
AC_TRY_COMPILE([], [} __inline__ int foo() { return 0; }
int bar() { return foo();], def_inline="__inline__",
[AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
int bar() { return foo();], def_inline="__inline",
[AC_TRY_COMPILE(, [} inline int foo() { return 0; }
int bar() { return foo();], def_inline="inline")])])
AC_MSG_RESULT($def_inline)
AC_DEFINE_UNQUOTED([MOBI_INLINE], [$def_inline],
[How to obtain function inlining.])
# Check --enable-encryption
ENCRYPTION_OPT=""
AC_MSG_CHECKING([whether enable encryption])
AC_ARG_ENABLE([encryption],
AS_HELP_STRING([--enable-encryption],
[enable encryption @<:@default=yes@:>@]),
[case "${enableval}" in
yes) encryption=yes ;;
no) encryption=no ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-encryption]) ;;
esac],
[encryption=yes])
AC_MSG_RESULT($encryption)
AM_CONDITIONAL(USE_ENCRYPTION,[test x$encryption = xyes])
if test x$encryption = xyes; then
AC_DEFINE([USE_ENCRYPTION], 1, [Enable encryption])
ENCRYPTION_OPT="yes"
fi
AC_SUBST(ENCRYPTION_OPT)
# Check --enable-debug
AC_MSG_CHECKING([whether enable debugging])
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug],
[enable debugging @<:@default=no@:>@]),
[case "${enableval}" in
yes) debug=yes ;;
no) debug=no ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],[debug=no])
AC_MSG_RESULT($debug)
DEBUG_CFLAGS=
if test x$debug = xyes; then
AC_DEFINE([MOBI_DEBUG], 1, [Enable debugging])
if test "x$SUNCC" = "xyes"; then
DEBUG_CFLAGS="-v -errwarn"
else
DEBUG_CFLAGS="-pedantic -Wall -Wextra -Werror"
fi
fi
AC_SUBST(DEBUG_CFLAGS)
# Check --enable-debug-alloc
AC_MSG_CHECKING([whether enable alloc debugging])
AC_ARG_ENABLE([debug_alloc],
AS_HELP_STRING([--enable-debug-alloc],
[enable memory allocation debugging @<:@default=no@:>@]),
[case "${enableval}" in
yes) debug_alloc=yes ;;
no) debug_alloc=no ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug-alloc]) ;;
esac],[debug_alloc=no])
AC_MSG_RESULT($debug_alloc)
if test x$debug_alloc = xyes; then
AC_DEFINE([MOBI_DEBUG_ALLOC], 1, [Enable alloc debugging])
fi
# Check --enable-mobitool-static
AC_MSG_CHECKING([whether link mobitool against static libmobi])
AC_ARG_ENABLE([mobitool_static],
AS_HELP_STRING([--enable-mobitool-static],
[link mobitool against static libmobi @<:@default=no@:>@]),
[case "${enableval}" in
yes) mobitool_static=yes ;;
no) mobitool_static=no ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-mobitool-static]) ;;
esac],[mobitool_static=no])
AC_MSG_RESULT($mobitool_static)
MOBITOOL_STATIC=
if test x$mobitool_static = xyes; then
MOBITOOL_STATIC="-static"
fi
AC_SUBST(MOBITOOL_STATIC)
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([libmobi.pc])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([tools/Makefile])
AC_CONFIG_FILES([tools/mobitool.1])
AC_OUTPUT