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