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