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