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