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