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