]> wimlib.net Git - wimlib/blob - configure.ac
imagex.c: Fix use of uninitialized variable in error path
[wimlib] / configure.ac
1 AC_INIT([wimlib], [1.3.0], [ebiggers3@gmail.com])
2 AC_CONFIG_SRCDIR([src/wim.c])
3 AC_CONFIG_MACRO_DIR([m4])
4 AC_CONFIG_AUX_DIR([build-aux])
5 AM_INIT_AUTOMAKE([-Wall -Werror subdir-objects])
6 AC_C_BIGENDIAN
7 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
8 LT_INIT
9 AC_CONFIG_HEADERS([config.h])
10 AC_CONFIG_FILES([Makefile
11                 doc/Doxyfile
12                 wimlib.pc
13                 doc/imagex.1
14                 doc/imagex-append.1
15                 doc/imagex-apply.1
16                 doc/imagex-capture.1
17                 doc/imagex-delete.1
18                 doc/imagex-dir.1
19                 doc/imagex-export.1
20                 doc/imagex-info.1
21                 doc/imagex-join.1
22                 doc/imagex-mount.1
23                 doc/imagex-mountrw.1
24                 doc/imagex-optimize.1
25                 doc/imagex-split.1
26                 doc/imagex-unmount.1
27                 doc/mkwinpeimg.1
28                 ])
29 AC_PROG_CC
30 AM_PROG_CC_C_O
31
32 AC_CHECK_FUNCS([utimensat lutimes utime flock])
33 AC_CHECK_HEADERS([endian.h byteswap.h sys/byteorder.h sys/endian.h \
34                   sys/param.h machine/endian.h alloca.h stdlib.h stdarg.h \
35                   errno.h attr/xattr.h utime.h sys/file.h])
36
37 AC_CHECK_MEMBER([struct stat.st_mtim],
38                 [AC_DEFINE([HAVE_STAT_NANOSECOND_PRECISION], [1],
39                           [Define to 1 if nanosecond precision timestamps are
40                            supported])],
41                 [],
42                 [[#include <sys/stat.h>]])
43
44 AM_ICONV
45 if test "x$am_cv_func_iconv" != "xyes"; then
46         AC_MSG_ERROR([Cannot find the iconv() function.
47         iconv() is used to convert between UTF-8 and UTF-16 encodings of WIM
48         filenames and XML data.  Wimlib cannot be compiled without it.  iconv()
49         is available in the latest version of glibc and sometimes in other
50         libraries.])
51 fi
52
53
54 AC_ARG_WITH(pkgconfigdir,
55             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
56             [pkgconfigdir=$withval],
57             [pkgconfigdir='${libdir}/pkgconfig'])
58 AC_SUBST(pkgconfigdir)
59
60 AC_CHECK_LIB([xml2], [xmlParseFile], [have_libxml=true],
61              [AC_MSG_ERROR(["cannot find libxml2"])])
62 LIBXML2_LDADD=`pkg-config libxml-2.0 --libs`
63 LIBXML2_CFLAGS=`pkg-config libxml-2.0 --cflags`
64 AC_SUBST([LIBXML2_LDADD], [$LIBXML2_LDADD])
65 AC_SUBST([LIBXML2_CFLAGS], [$LIBXML2_CFLAGS])
66
67 AC_MSG_CHECKING([whether to include debugging messages])
68 AC_ARG_ENABLE([debug],
69         AS_HELP_STRING([--enable-debug], [include lots of debugging messages]),
70         [ENABLE_DEBUG=$enableval],
71         [ENABLE_DEBUG=no]
72         )
73 AC_MSG_RESULT([$ENABLE_DEBUG])
74 if test "x$ENABLE_DEBUG" = "xyes"; then
75         AC_DEFINE([ENABLE_DEBUG], [1],
76                         [Define to 1 if including lots of debug messages.])
77 fi
78
79 AC_MSG_CHECKING([whether to include more debugging messages])
80 AC_ARG_ENABLE([more_debug],
81         AS_HELP_STRING([--enable-more-debug],
82                         [include even more debugging messages]),
83         [ENABLE_MORE_DEBUG=$enableval],
84         [ENABLE_MORE_DEBUG=no]
85         )
86 AC_MSG_RESULT([$ENABLE_MORE_DEBUG])
87 if test "x$ENABLE_MORE_DEBUG" = "xyes"; then
88         AC_DEFINE([ENABLE_MORE_DEBUG], [1],
89                         [Define to 1 if including even more debug messages.])
90 fi
91
92 AC_MSG_CHECKING([whether to include error messages])
93 AC_ARG_ENABLE([error_messages],
94         AS_HELP_STRING([--disable-error-messages],
95                         [do not compile in error messsages]),
96         [ENABLE_ERROR_MESSAGES=$enableval],
97         [ENABLE_ERROR_MESSAGES=yes]
98         )
99 AC_MSG_RESULT([$ENABLE_ERROR_MESSAGES])
100 if test "x$ENABLE_ERROR_MESSAGES" = "xyes"; then
101         AC_DEFINE([ENABLE_ERROR_MESSAGES], [1],
102                         [Define to 1 if including error messages])
103 fi
104
105 AC_MSG_CHECKING([whether to support custom memory allocation functions])
106 AC_ARG_ENABLE([custom_memory_allocator],
107         AS_HELP_STRING([--disable-custom-memory-allocator],
108                        [do not support the use of custom memory allocation
109                         functions]),
110         [ENABLE_CUSTOM_MEMORY_ALLOCATOR=$enableval],
111         [ENABLE_CUSTOM_MEMORY_ALLOCATOR=yes]
112         )
113 AC_MSG_RESULT([$ENABLE_CUSTOM_MEMORY_ALLOCATOR])
114 if test "x$ENABLE_CUSTOM_MEMORY_ALLOCATOR" = "xyes"; then
115         AC_DEFINE([ENABLE_CUSTOM_MEMORY_ALLOCATOR], [1],
116                 [Define to 1 if supporting custom memory allocation functions])
117 fi
118
119 AC_MSG_CHECKING([whether to include assertions])
120 AC_ARG_ENABLE([assertions],
121         AS_HELP_STRING([--disable-assertions], [do not include assertions]),
122         [ENABLE_ASSERTIONS=$enableval],
123         [ENABLE_ASSERTIONS=yes]
124         )
125 AC_MSG_RESULT([$ENABLE_ASSERTIONS])
126 if test "x$ENABLE_ASSERTIONS" = "xyes"; then
127         AC_DEFINE([ENABLE_ASSERTIONS], [1], [Define to 1 if including assertions.])
128 fi
129
130 AC_MSG_CHECKING([whether to include more assertions])
131 AC_ARG_ENABLE([more-assertions],
132         AS_HELP_STRING([--enable-more-assertions], [include even more assertions]),
133         [ENABLE_MORE_ASSERTIONS=$enableval],
134         [ENABLE_MORE_ASSERTIONS=no]
135         )
136 AC_MSG_RESULT([$ENABLE_MORE_ASSERTIONS])
137 if test "x$ENABLE_MORE_ASSERTIONS" = "xyes"; then
138         AC_DEFINE([ENABLE_MORE_ASSERTIONS], [1], [Define to 1 if including more assertions.])
139 fi
140
141
142 AC_MSG_CHECKING([whether to include compression verification])
143 AC_ARG_ENABLE([verify_compression],
144               AS_HELP_STRING([--disable-verify-compression], [disable
145                                 checking if blocks we compress can be correctly
146                                 decompressed]),
147         [ENABLE_VERIFY_COMPRESSION=$enableval],
148         [ENABLE_VERIFY_COMPRESSION=yes]
149         )
150 AC_MSG_RESULT([$ENABLE_VERIFY_COMPRESSION])
151 if test "x$ENABLE_VERIFY_COMPRESSION" = "xyes"; then
152         AC_DEFINE([ENABLE_VERIFY_COMPRESSION], [1], [Define to 1 to verify
153                    compressed data])
154 fi
155
156 AC_MSG_CHECKING([whether to include support for multi-threaded compression])
157 AC_ARG_ENABLE([multithreaded-compression],
158         AS_HELP_STRING([--disable-multithreaded-compression],
159                         [do not compile in the code for multi-threaded compression]),
160         [ENABLE_MULTITHREADED_COMPRESSION=$enableval],
161         [ENABLE_MULTITHREADED_COMPRESSION=yes]
162         )
163 AC_MSG_RESULT([$ENABLE_MULTITHREADED_COMPRESSION])
164 if test "x$ENABLE_MULTITHREADED_COMPRESSION" = "xyes"; then
165         AC_DEFINE([ENABLE_MULTITHREADED_COMPRESSION], [1],
166                         [Define to 1 if including support for multithreaded
167                          compression])
168         PTHREAD_LDADD="-lpthread"
169 else
170         PTHREAD_LDADD=""
171 fi
172 AC_SUBST([PTHREAD_LDADD], [$PTHREAD_LDADD])
173
174 case "$host" in
175         *-*-cygwin*)
176                 dnl -no-undefined is needed to build a DLL in a Cygwin environment.
177                 CYGWIN_EXTRA_LDFLAGS="-no-undefined"
178
179                 dnl -fvisibility=hidden should not be used when building PE
180                 dnl binaries on Windows
181                 VISIBILITY_CFLAGS=""
182
183                 WITH_NTFS_3G_DEFAULT="no"
184                 WITH_FUSE_DEFAULT="no"
185                 WINDOWS_BUILD="yes"
186                 ;;
187         *)
188                 CYGWIN_EXTRA_LDFLAGS=""
189                 VISIBILITY_CFLAGS="-fvisibility=hidden"
190                 WITH_NTFS_3G_DEFAULT="yes"
191                 WITH_FUSE_DEFAULT="yes"
192                 WINDOWS_BUILD="no"
193                 ;;
194 esac
195
196 AC_SUBST([CYGWIN_EXTRA_LDFLAGS], [$CYGWIN_EXTRA_LDFLAGS])
197 AC_SUBST([VISIBILITY_CFLAGS], [$VISIBILITY_CFLAGS])
198 AM_CONDITIONAL([WINDOWS_BUILD], [test "x$WINDOWS_BUILD" = "xyes"])
199
200 AC_MSG_CHECKING([whether to include support for ntfs-3g])
201 AC_ARG_WITH([ntfs-3g],
202               AS_HELP_STRING([--without-ntfs-3g], [build without NTFS-3g.
203                               This will disable the ability to use NTFS-specific
204                               information when capturing or applying WIMs to a
205                               NTFS filesystem.]),
206         [WITH_NTFS_3G=$withval],
207         [WITH_NTFS_3G=$WITH_NTFS_3G_DEFAULT]
208         )
209 AC_MSG_RESULT([$WITH_NTFS_3G])
210 if test "x$WITH_NTFS_3G" = "xyes"; then
211         AC_DEFINE([WITH_NTFS_3G], [1], [Define to 1 to enable support for
212                    NTFS-specific information])
213
214         dnl This effectively checks for NTFS-3g 2011.4.12 or later
215         AC_CHECK_LIB([ntfs-3g], [ntfs_xattr_system_setxattr], [],
216                         [AC_MSG_ERROR([Cannot find libntfs-3g version 2011-4-12
217         or later. Without libntfs-3g, wimlib cannot include support for
218         capturing and applying WIMs on NTFS filesystems while preserving
219         NTFS-specific data such as security descriptors and alternate data
220         streams.  You should either install libntfs-3g, or configure with
221         --without-ntfs-3g to disable support for these NTFS-specific
222         features.])])
223         LIBNTFS_3G_LDADD="`pkg-config --libs libntfs-3g`"
224         LIBNTFS_3G_CFLAGS="`pkg-config --cflags libntfs-3g`"
225
226         dnl This checks for a NTFS-3g interface that was changed in the
227         dnl 2013.1.13 release
228         AC_CHECK_DECL([NTFS_MNT_RDONLY],
229                       [AC_DEFINE([HAVE_NTFS_MNT_RDONLY],
230                                  [1],
231                                  [Define to 1 if ntfs_mount() takes the flag NTFS_MNT_RDONLY])],
232                       ,
233                       [#include <ntfs-3g/volume.h>])
234 else
235         LIBNTFS_3G_LDADD=
236         LIBNTFS_3G_CFLAGS=
237 fi
238 AM_CONDITIONAL([WITH_NTFS_3G], [test "x$WITH_NTFS_3G" = "xyes"])
239
240 AC_SUBST([LIBNTFS_3G_LDADD], [$LIBNTFS_3G_LDADD])
241 AC_SUBST([LIBNTFS_3G_CFLAGS], [$LIBNTFS_3G_CFLAGS])
242
243 AC_MSG_CHECKING([whether to include support for mounting WIMs])
244 AC_ARG_WITH([fuse],
245                 AS_HELP_STRING([--without-fuse], [build without libfuse.
246                                         This will disable the ability to mount
247                                         WIM files.]),
248         [WITH_FUSE=$withval],
249         [WITH_FUSE=$WITH_FUSE_DEFAULT]
250         )
251 AC_MSG_RESULT([$WITH_FUSE])
252 if test "x$WITH_FUSE" = "xyes"; then
253         AC_DEFINE([WITH_FUSE], [1], [Define to 1 if using FUSE.])
254
255
256         AC_CHECK_LIB([fuse], [fuse_main_real], [have_fuse=true],
257                         [AC_MSG_ERROR([Cannot find libfuse.
258         Without libfuse, wimlib cannot include support for mounting WIMs.  You
259         should either install libfuse, or configure with --without-fuse to
260         disable support for mounting WIMs.])
261         ])
262         AC_CHECK_LIB([rt], [mq_open], [have_posix_mq=true],
263                      [AC_MSG_ERROR([Cannot find librt for POSIX message queue
264         functions.  Without these functions, wimlib cannot include support for
265         mounting WIMs.  You should either update your C library to a recent
266         version of glibc, or configure with --without-fuse to disable support
267         for mounting WIMs.])
268         ])
269         LIBFUSE_LDADD="`pkg-config --libs fuse` -lrt"
270         LIBFUSE_CFLAGS="`pkg-config --cflags fuse`"
271 else
272         LIBFUSE_LDADD=
273         LIBFUSE_CFLAGS=
274 fi
275 AM_CONDITIONAL([WITH_FUSE], [test "x$WITH_FUSE" = "xyes"])
276 AC_SUBST([LIBFUSE_LDADD], [$LIBFUSE_LDADD])
277 AC_SUBST([LIBFUSE_CFLAGS], [$LIBFUSE_CFLAGS])
278
279 ENABLE_XATTR=no
280 AC_ARG_ENABLE([xattr],
281         [AS_HELP_STRING([--enable-xattr], [Enable the xattr interface to access WIM
282                         alternate data streams (default: autodetect)])],
283         [ENABLE_XATTR=$enableval],
284         [AC_CHECK_FUNC([setxattr],
285                 [AC_CHECK_HEADER([attr/xattr.h],
286                         [ENABLE_XATTR=yes],
287                         [AC_MSG_WARN([Cannot find the "attr/xattr.h" header.  You will not be
288                          able to use the xattr interface to access WIM alternate data
289                          streams.])])],
290                 [AC_MSG_WARN([Cannot find the setxattr() function.  You will not be
291                  able to use the xattr interface to access WIM alternate data
292                  streams.])])])
293
294 if test "x$ENABLE_XATTR" = "xyes"; then
295         AC_DEFINE([ENABLE_XATTR], [1], [Define to 1 if using the xattr
296                         interface to WIM alternate data streams])
297 fi
298
299 AC_MSG_CHECKING([whether to use SSSE3-accelerated SHA1 ])
300 AC_ARG_ENABLE([ssse3-sha1],
301             AS_HELP_STRING([--enable-ssse3-sha1], [use assembly language implementation
302                                 of SHA1 from Intel, accelerated with vector
303                                 instructions (SSSE3-enabled CPU required)]),
304         [ENABLE_SSSE3_SHA1=$enableval],
305         [ENABLE_SSSE3_SHA1=no]
306         )
307
308 AC_MSG_RESULT([$ENABLE_SSSE3_SHA1])
309 if test "x$ENABLE_SSSE3_SHA1" = "xyes"; then
310         AC_DEFINE([ENABLE_SSSE3_SHA1], [1],
311                         [Define to 1 if using vectorized implementation of SHA1])
312         SSSE3_SHA1_OBJ=sha1-ssse3.lo
313         AX_PROG_NASM
314         AC_SUBST([NASM], [$nasm])
315 else
316         SSSE3_SHA1_OBJ=
317 fi
318 AC_SUBST([SSSE3_SHA1_OBJ], [$SSSE3_SHA1_OBJ])
319
320 if test "x$ENABLE_SSSE3_SHA1" = "xyes"; then
321         WITH_LIBCRYPTO=no
322 else
323         AC_ARG_WITH([libcrypto],
324             AS_HELP_STRING([--without-libcrypto], [build in the SHA1 algorithm,
325                                         rather than use external libcrypto from
326                                         OpenSSL (default is autodetect)]),
327         [WITH_LIBCRYPTO=$withval],
328         [AC_CHECK_LIB([crypto], [SHA1],
329                      [WITH_LIBCRYPTO=yes],
330                      [AC_MSG_WARN([Cannot find libcrypto: using stand-alone SHA1 code instead of OpenSSL])
331                      WITH_LIBCRYPTO=no
332                      ])])
333 fi
334 AC_MSG_CHECKING([whether to use SHA1 function from system libcrypto])
335 AC_MSG_RESULT([$WITH_LIBCRYPTO])
336
337 if test "x$WITH_LIBCRYPTO" = "xyes" -a "x$ENABLE_SSSE3_SHA1" = "xno"; then
338         AC_DEFINE([WITH_LIBCRYPTO], [1], [Define to 1 if using libcrypto SHA1])
339         LIBCRYPTO_LDADD=`pkg-config --libs libcrypto 2>/dev/null`
340         if test $? -ne 0; then
341                 LIBCRYPTO_LDADD=-lcrypto;
342         fi
343         LIBCRYPTO_CFLAGS=`pkg-config --cflags libcrypto 2>/dev/null`
344 else
345         LIBCRYPTO_LDADD=
346         LIBCRYPTO_CFLAGS=
347 fi
348 AC_SUBST([LIBCRYPTO_LDADD], [$LIBCRYPTO_LDADD])
349 AC_SUBST([LIBCRYPTO_CFLAGS], [$LIBCRYPTO_CFLAGS])
350 AC_SUBST([SHA1_SOURCES], [$SHA1_SOURCES])
351
352 AC_OUTPUT