Add randomized testing program
[wimlib] / configure.ac
1 ###############################################################################
2
3 AC_INIT([wimlib], [1.9.1], [ebiggers3@gmail.com])
4 AC_CONFIG_SRCDIR([src/wim.c])
5 AC_CONFIG_MACRO_DIR([m4])
6 AC_CONFIG_AUX_DIR([build-aux])
7 AM_INIT_AUTOMAKE([-Wall -Werror subdir-objects foreign])
8 AM_SILENT_RULES([yes])
9 AC_C_BIGENDIAN
10 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
11 LT_INIT
12
13 AC_CONFIG_HEADERS([config.h])
14 AC_CONFIG_FILES([Makefile] [doc/Doxyfile] [wimlib.pc])
15 AC_CONFIG_FILES([programs/mkwinpeimg], [chmod +x programs/mkwinpeimg])
16
17 PKGCONFIG_PRIVATE_REQUIRES=""
18 PKGCONFIG_PRIVATE_LIBS=""
19
20 ###############################################################################
21 #                         General platform features                           #
22 ###############################################################################
23
24 AC_PROG_CC
25 AM_PROG_CC_C_O
26 AC_CANONICAL_HOST
27
28 WINDOWS_NATIVE_BUILD="no"
29 PLATFORM_CPPFLAGS=""
30 PLATFORM_CFLAGS="-fvisibility=hidden"
31 PLATFORM_LDFLAGS=""
32
33 case "$host_os" in
34 mingw*)
35         # Native Windows
36         WINDOWS_NATIVE_BUILD="yes"
37         PLATFORM_CPPFLAGS="-D_POSIX -D_POSIX_THREAD_SAFE_FUNCTIONS -DUNICODE -D_UNICODE -D_CRT_NON_CONFORMING_SWPRINTFS"
38         PLATFORM_CFLAGS="-municode -mno-ms-bitfields"
39         PLATFORM_LDFLAGS="-no-undefined"
40         WITH_NTFS_3G_DEFAULT="no"
41         WITH_FUSE_DEFAULT="no"
42         ;;
43 linux*)
44         # Linux
45         WITH_NTFS_3G_DEFAULT="yes"
46         WITH_FUSE_DEFAULT="yes"
47         ;;
48 *)
49         # Other UNIX
50         WITH_NTFS_3G_DEFAULT="yes"
51         WITH_FUSE_DEFAULT="no"
52         ;;
53 esac
54
55 AC_SUBST([PLATFORM_CPPFLAGS], [$PLATFORM_CPPFLAGS])
56 AC_SUBST([PLATFORM_CFLAGS], [$PLATFORM_CFLAGS])
57 AC_SUBST([PLATFORM_LDFLAGS], [$PLATFORM_LDFLAGS])
58 AM_CONDITIONAL([WINDOWS_NATIVE_BUILD], [test "$WINDOWS_NATIVE_BUILD" = "yes"])
59
60 # Useful functions which we can do without.
61 AC_CHECK_FUNCS([futimens utimensat flock mempcpy        \
62                 openat fstatat readlinkat fdopendir])
63
64 # Header checks, most of which are only here to satisfy conditional includes
65 # made by the libntfs-3g headers.
66 AC_CHECK_HEADERS([alloca.h              \
67                   attr/xattr.h          \
68                   byteswap.h            \
69                   endian.h              \
70                   errno.h               \
71                   glob.h                \
72                   machine/endian.h      \
73                   stdarg.h              \
74                   stddef.h              \
75                   stdlib.h              \
76                   sys/byteorder.h       \
77                   sys/endian.h          \
78                   sys/file.h            \
79                   sys/param.h           \
80                   sys/sysctl.h          \
81                   sys/times.h           \
82                   time.h                \
83                   utime.h])
84
85 # Does stat() support nanosecond-precision timestamps?  (This is relevant on
86 # UNIX but not on Windows.)
87 AC_CHECK_MEMBER([struct stat.st_mtim],
88                 [AC_DEFINE([HAVE_STAT_NANOSECOND_PRECISION], [1],
89                            [Define to 1 if stat() supports nanosecond precision
90                             timestamps])],
91                 [],
92                 [#include <sys/stat.h>])
93
94 ###############################################################################
95 #                            Required libraries                               #
96 ###############################################################################
97
98 # ------------------------------ pthreads -------------------------------------
99 AX_PTHREAD([], [AC_MSG_ERROR(["cannot find pthreads library"])])
100
101 # ------------------------------ libxml2 --------------------------------------
102 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
103 PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libxml-2.0"
104
105 # ------------------------------ libiconv -------------------------------------
106 AM_ICONV
107 if test "$am_cv_func_iconv" != "yes"; then
108         AC_MSG_ERROR([Cannot find the iconv() function.  iconv() is used to
109                       convert between encodings of WIM filenames and XML data.
110                       wimlib cannot be compiled without it.  iconv() is
111                       available in the latest version of glibc and sometimes in
112                       other libraries.])
113 fi
114
115 ###############################################################################
116 #                         Configuration options                               #
117 ###############################################################################
118
119 # ------------------------- ntfs-3g support -----------------------------------
120
121 AC_MSG_CHECKING([whether to include support for ntfs-3g])
122 AC_ARG_WITH([ntfs-3g],
123             [AS_HELP_STRING([--without-ntfs-3g],
124                             [build without libntfs-3g.  This will disable the
125                              ability to capture or apply a WIM image directly
126                              from/to an unmounted NTFS volume.])],
127             [WITH_NTFS_3G=$withval],
128             [WITH_NTFS_3G=$WITH_NTFS_3G_DEFAULT])
129 AC_MSG_RESULT([$WITH_NTFS_3G])
130
131 if test "$WITH_NTFS_3G" = "yes"; then
132         PKG_CHECK_MODULES([LIBNTFS_3G], [libntfs-3g >= 2011.4.12], [],
133                 [AC_MSG_ERROR([Cannot find libntfs-3g version 2011-4-12 or
134                  later!  Without libntfs-3g, wimlib cannot include support for
135                  capturing or applying a WIM image directly from/to an unmounted
136                  NTFS volume while preserving NTFS-specific data such as
137                  security descriptors and named data streams.  Either install
138                  libntfs-3g, or configure --without-ntfs-3g to disable this
139                  feature.])])
140         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libntfs-3g"
141         AC_DEFINE([WITH_NTFS_3G], [1], [Define to 1 if using NTFS-3G support])
142 fi
143 AM_CONDITIONAL([WITH_NTFS_3G], [test "$WITH_NTFS_3G" = "yes"])
144
145 # ------------------------ FUSE mount support ---------------------------------
146
147 AC_MSG_CHECKING([whether to include support for mounting WIMs])
148 AC_ARG_WITH([fuse],
149             [AS_HELP_STRING([--without-fuse],
150                             [build without libfuse.  This will disable the
151                              ability to mount WIM images.])],
152             [WITH_FUSE=$withval],
153             [WITH_FUSE=$WITH_FUSE_DEFAULT])
154 AC_MSG_RESULT([$WITH_FUSE])
155
156 if test "$WITH_FUSE" = "yes"; then
157
158         PKG_CHECK_MODULES([LIBFUSE], [fuse], [],
159                 [AC_MSG_ERROR([Cannot find libfuse!
160                 Without libfuse, wimlib cannot include support for mounting WIM
161                 images.  Either install libfuse, or configure --without-fuse to
162                 disable this feature.])])
163         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES fuse"
164         AC_DEFINE([WITH_FUSE], [1], [Define to 1 if using FUSE support])
165
166         AC_CHECK_LIB([rt], [mq_open], [],
167                      [AC_MSG_ERROR([Cannot find librt (the POSIX.1b Realtime
168         Extensions Library)!  wimlib needs this for the POSIX message queue
169         functions, which are used in the code for mounting WIM images.  Recent
170         versions of glibc include this library.  Either install this library, or
171         configure --without-fuse to disable support for mounting WIM images.])])
172
173         AC_CHECK_LIB([attr], [getxattr], [],
174                      [AC_MSG_ERROR([Cannot find libattr!
175         wimlib needs this for the extended attribute functions, which are used
176         in the code for mounting WIM images.  Either install this library, or
177         configure --without-fuse to disable support for mounting WIM images.])])
178
179         PKGCONFIG_PRIVATE_LIBS="$PKGCONFIG_PRIVATE_LIBS -lrt"
180         AC_SUBST([LIBRT_LIBS], [-lrt])
181 fi
182 AM_CONDITIONAL([WITH_FUSE], [test "$WITH_FUSE" = "yes"])
183
184 # ------------------------ SHA-1 implementation ---------------------------------
185
186 AC_MSG_CHECKING([whether to use SSSE3-accelerated SHA-1])
187 AC_ARG_ENABLE([ssse3-sha1],
188               [AS_HELP_STRING([--enable-ssse3-sha1],
189                               [Include SSSE3-accelerated SHA-1 implementation by
190                                Intel.  This implies --without-libcrypto.])],
191               [ENABLE_SSSE3_SHA1=$enableval],
192               [ENABLE_SSSE3_SHA1=no])
193 AC_MSG_RESULT([$ENABLE_SSSE3_SHA1])
194
195 if test "$ENABLE_SSSE3_SHA1" = "yes" ; then
196         AC_DEFINE([ENABLE_SSSE3_SHA1], [1],
197                   [Define to 1 if using SSSE3 implementation of SHA-1])
198         AC_PROG_NASM
199         NASM_SYMBOL_PREFIX=""
200         NASM_PLATFORM_FLAGS=""
201         if test "$WINDOWS_NATIVE_BUILD" = "yes"; then
202                 NASM_PLATFORM_FLAGS="-DWIN_ABI"
203         fi
204         case "$host_os" in
205         darwin* | rhapsody* | nextstep* | openstep* | macos*)
206                 NASM_SYMBOL_PREFIX="_"
207                 ;;
208         esac
209         AC_SUBST([NASM_PLATFORM_FLAGS], [$NASM_PLATFORM_FLAGS])
210         AC_SUBST([NASM_SYMBOL_PREFIX], [$NASM_SYMBOL_PREFIX])
211 else
212         AC_MSG_CHECKING([whether to use SHA-1 implementation from system libcrypto])
213         AC_ARG_WITH([libcrypto],
214                     [AS_HELP_STRING([--without-libcrypto],
215                                     [build in the SHA-1 algorithm, rather than
216                                      use external libcrypto from OpenSSL
217                                      (default is autodetect)])],
218                     [WITH_LIBCRYPTO=$withval],
219                     [WITH_LIBCRYPTO=auto])
220         AC_MSG_RESULT([$WITH_LIBCRYPTO])
221         if test "$WITH_LIBCRYPTO" != "no"; then
222                 PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto], [
223                         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libcrypto"
224                         AC_DEFINE([WITH_LIBCRYPTO], [1],
225                                   [Define to 1 if using libcrypto SHA-1])
226                 ], [AC_MSG_WARN([Cannot find libcrypto: using stand-alone SHA-1 code instead])])
227         fi
228 fi
229 AM_CONDITIONAL([ENABLE_SSSE3_SHA1], [test "$ENABLE_SSSE3_SHA1" = "yes"])
230
231 # ----------------------------- Other options ---------------------------------
232
233 AC_MSG_CHECKING([whether to include error messages])
234 AC_ARG_ENABLE([error_messages],
235         AS_HELP_STRING([--disable-error-messages], [do not compile in error messsages]),
236         [ENABLE_ERROR_MESSAGES=$enableval],
237         [ENABLE_ERROR_MESSAGES=yes])
238 AC_MSG_RESULT([$ENABLE_ERROR_MESSAGES])
239 if test "$ENABLE_ERROR_MESSAGES" = "yes"; then
240         AC_DEFINE([ENABLE_ERROR_MESSAGES], [1], [Define to 1 if including error messages])
241 fi
242
243 AC_MSG_CHECKING([whether to include assertions])
244 AC_ARG_ENABLE([assertions],
245         AS_HELP_STRING([--disable-assertions], [do not include assertions]),
246         [ENABLE_ASSERTIONS=$enableval],
247         [ENABLE_ASSERTIONS=yes])
248 AC_MSG_RESULT([$ENABLE_ASSERTIONS])
249 if test "$ENABLE_ASSERTIONS" = "yes"; then
250         AC_DEFINE([ENABLE_ASSERTIONS], [1], [Define to 1 if including assertions])
251 fi
252
253 AC_MSG_CHECKING([whether to include support for multi-threaded compression])
254 AC_ARG_ENABLE([multithreaded-compression],
255         AS_HELP_STRING([--disable-multithreaded-compression],
256                        [disable support for multithreaded compression]),
257         [ENABLE_MULTITHREADED_COMPRESSION=$enableval],
258         [ENABLE_MULTITHREADED_COMPRESSION=yes])
259 AC_MSG_RESULT([$ENABLE_MULTITHREADED_COMPRESSION])
260 if test "$ENABLE_MULTITHREADED_COMPRESSION" = "yes"; then
261         AC_DEFINE([ENABLE_MULTITHREADED_COMPRESSION], [1],
262                   [Define to 1 to support multithreaded compression])
263 fi
264
265 AC_ARG_WITH(pkgconfigdir,
266             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
267             [pkgconfigdir=$withval],
268             [pkgconfigdir='${libdir}/pkgconfig'])
269 AC_SUBST(pkgconfigdir)
270
271 AC_MSG_CHECKING([whether to enable supporting code for tests])
272 AC_ARG_ENABLE([test-support],
273               [AS_HELP_STRING([--enable-test-support],
274                               [Enable supporting code for tests (developers only)])],
275               [ENABLE_TEST_SUPPORT=$enableval],
276               [ENABLE_TEST_SUPPORT=no])
277 AC_MSG_RESULT([$ENABLE_TEST_SUPPORT])
278 if test "$ENABLE_TEST_SUPPORT" = "yes" ; then
279         AC_DEFINE([ENABLE_TEST_SUPPORT], [1],
280                   [Define to 1 to enable supporting code for tests])
281 fi
282 AM_CONDITIONAL([ENABLE_TEST_SUPPORT], [test "$ENABLE_TEST_SUPPORT" = "yes"])
283
284 ###############################################################################
285
286 AC_SUBST([PKGCONFIG_PRIVATE_REQUIRES], [$PKGCONFIG_PRIVATE_REQUIRES])
287 AC_SUBST([PKGCONFIG_PRIVATE_LIBS], [$PKGCONFIG_PRIVATE_LIBS])
288 AC_OUTPUT