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