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