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