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