]> wimlib.net Git - wimlib/blob - configure.ac
1d3498d21318679e16ff1b98f65195af8140e643
[wimlib] / configure.ac
1 ###############################################################################
2
3 AC_INIT([wimlib], [1.11.0-BETA4], [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 posix_fallocate \
63                 llistxattr lgetxattr fsetxattr lsetxattr])
64
65 # Header checks, most of which are only here to satisfy conditional includes
66 # made by the libntfs-3g headers.
67 AC_CHECK_HEADERS([alloca.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/syscall.h         \
80                   sys/sysctl.h          \
81                   sys/times.h           \
82                   sys/xattr.h           \
83                   time.h                \
84                   utime.h])
85
86 # Does stat() support nanosecond-precision timestamps?  (This is relevant on
87 # UNIX but not on Windows.)
88 AC_CHECK_MEMBER([struct stat.st_mtim],
89                 [AC_DEFINE([HAVE_STAT_NANOSECOND_PRECISION], [1],
90                            [Define to 1 if stat() supports nanosecond precision
91                             timestamps])],
92                 [],
93                 [#include <sys/stat.h>])
94
95 # Check for possible support for the Linux getrandom() system call
96 AC_CHECK_DECL([__NR_getrandom],
97               [AC_DEFINE([HAVE_NR_GETRANDOM], [1], [Define to 1 if the system
98                headers define a system call number for getrandom()])],
99               [],
100               [#include <sys/syscall.h>])
101
102 ###############################################################################
103 #                            Required libraries                               #
104 ###############################################################################
105
106 # ------------------------------ pthreads -------------------------------------
107 AX_PTHREAD([], [AC_MSG_ERROR(["cannot find pthreads library"])])
108
109 # ------------------------------ libxml2 --------------------------------------
110 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
111 PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libxml-2.0"
112
113 ###############################################################################
114 #                         Configuration options                               #
115 ###############################################################################
116
117 # ------------------------- ntfs-3g support -----------------------------------
118
119 AC_MSG_CHECKING([whether to include support for ntfs-3g])
120 AC_ARG_WITH([ntfs-3g],
121             [AS_HELP_STRING([--without-ntfs-3g],
122                             [build without libntfs-3g.  This will disable the
123                              ability to capture or apply a WIM image directly
124                              from/to an unmounted NTFS volume.])],
125             [WITH_NTFS_3G=$withval],
126             [WITH_NTFS_3G=$WITH_NTFS_3G_DEFAULT])
127 AC_MSG_RESULT([$WITH_NTFS_3G])
128
129 if test "$WITH_NTFS_3G" = "yes"; then
130         PKG_CHECK_MODULES([LIBNTFS_3G], [libntfs-3g >= 2011.4.12], [],
131                 [AC_MSG_ERROR([Cannot find libntfs-3g version 2011-4-12 or
132                  later!  Without libntfs-3g, wimlib cannot include support for
133                  capturing or applying a WIM image directly from/to an unmounted
134                  NTFS volume while preserving NTFS-specific data such as
135                  security descriptors and named data streams.  Either install
136                  libntfs-3g, or configure --without-ntfs-3g to disable this
137                  feature.])])
138         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libntfs-3g"
139         AC_DEFINE([WITH_NTFS_3G], [1], [Define to 1 if using NTFS-3G support])
140 fi
141 AM_CONDITIONAL([WITH_NTFS_3G], [test "$WITH_NTFS_3G" = "yes"])
142
143 # ------------------------ FUSE mount support ---------------------------------
144
145 AC_MSG_CHECKING([whether to include support for mounting WIMs])
146 AC_ARG_WITH([fuse],
147             [AS_HELP_STRING([--without-fuse],
148                             [build without libfuse.  This will disable the
149                              ability to mount WIM images.])],
150             [WITH_FUSE=$withval],
151             [WITH_FUSE=$WITH_FUSE_DEFAULT])
152 AC_MSG_RESULT([$WITH_FUSE])
153
154 if test "$WITH_FUSE" = "yes"; then
155
156         PKG_CHECK_MODULES([LIBFUSE], [fuse], [],
157                 [AC_MSG_ERROR([Cannot find libfuse!
158                 Without libfuse, wimlib cannot include support for mounting WIM
159                 images.  Either install libfuse, or configure --without-fuse to
160                 disable this feature.])])
161         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES fuse"
162         AC_DEFINE([WITH_FUSE], [1], [Define to 1 if using FUSE support])
163
164         AC_CHECK_LIB([rt], [mq_open], [],
165                      [AC_MSG_ERROR([Cannot find librt (the POSIX.1b Realtime
166         Extensions Library)!  wimlib needs this for the POSIX message queue
167         functions, which are used in the code for mounting WIM images.  Recent
168         versions of glibc include this library.  Either install this library, or
169         configure --without-fuse to disable support for mounting WIM images.])])
170
171         PKGCONFIG_PRIVATE_LIBS="$PKGCONFIG_PRIVATE_LIBS -lrt"
172         AC_SUBST([LIBRT_LIBS], [-lrt])
173 fi
174 AM_CONDITIONAL([WITH_FUSE], [test "$WITH_FUSE" = "yes"])
175
176 # ------------------------ SHA-1 implementation ---------------------------------
177
178 AC_MSG_CHECKING([whether to use SSSE3-accelerated SHA-1])
179 AC_ARG_ENABLE([ssse3-sha1],
180               [AS_HELP_STRING([--enable-ssse3-sha1],
181                               [Include SSSE3-accelerated SHA-1 implementation by
182                                Intel.  This implies --without-libcrypto.])],
183               [ENABLE_SSSE3_SHA1=$enableval],
184               [ENABLE_SSSE3_SHA1=no])
185 AC_MSG_RESULT([$ENABLE_SSSE3_SHA1])
186
187 if test "$ENABLE_SSSE3_SHA1" = "yes" ; then
188         AC_DEFINE([ENABLE_SSSE3_SHA1], [1],
189                   [Define to 1 if using SSSE3 implementation of SHA-1])
190         AC_PROG_NASM
191         NASM_SYMBOL_PREFIX=""
192         NASM_PLATFORM_FLAGS=""
193         if test "$WINDOWS_NATIVE_BUILD" = "yes"; then
194                 NASM_PLATFORM_FLAGS="-DWIN_ABI"
195         fi
196         case "$host_os" in
197         darwin* | rhapsody* | nextstep* | openstep* | macos*)
198                 NASM_SYMBOL_PREFIX="_"
199                 ;;
200         esac
201         AC_SUBST([NASM_PLATFORM_FLAGS], [$NASM_PLATFORM_FLAGS])
202         AC_SUBST([NASM_SYMBOL_PREFIX], [$NASM_SYMBOL_PREFIX])
203 else
204         AC_MSG_CHECKING([whether to use SHA-1 implementation from system libcrypto])
205         AC_ARG_WITH([libcrypto],
206                     [AS_HELP_STRING([--without-libcrypto],
207                                     [build in the SHA-1 algorithm, rather than
208                                      use external libcrypto from OpenSSL
209                                      (default is autodetect)])],
210                     [WITH_LIBCRYPTO=$withval],
211                     [WITH_LIBCRYPTO=auto])
212         AC_MSG_RESULT([$WITH_LIBCRYPTO])
213         if test "$WITH_LIBCRYPTO" != "no"; then
214                 PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto], [
215                         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libcrypto"
216                         AC_DEFINE([WITH_LIBCRYPTO], [1],
217                                   [Define to 1 if using libcrypto SHA-1])
218                 ], [AC_MSG_WARN([Cannot find libcrypto: using stand-alone SHA-1 code instead])])
219         fi
220 fi
221 AM_CONDITIONAL([ENABLE_SSSE3_SHA1], [test "$ENABLE_SSSE3_SHA1" = "yes"])
222
223 # ----------------------------- Other options ---------------------------------
224
225 AC_MSG_CHECKING([whether to include error messages])
226 AC_ARG_ENABLE([error_messages],
227         AS_HELP_STRING([--disable-error-messages], [do not compile in error messsages]),
228         [ENABLE_ERROR_MESSAGES=$enableval],
229         [ENABLE_ERROR_MESSAGES=yes])
230 AC_MSG_RESULT([$ENABLE_ERROR_MESSAGES])
231 if test "$ENABLE_ERROR_MESSAGES" = "yes"; then
232         AC_DEFINE([ENABLE_ERROR_MESSAGES], [1], [Define to 1 if including error messages])
233 fi
234
235 AC_MSG_CHECKING([whether to include assertions])
236 AC_ARG_ENABLE([assertions],
237         AS_HELP_STRING([--disable-assertions], [do not include assertions]),
238         [ENABLE_ASSERTIONS=$enableval],
239         [ENABLE_ASSERTIONS=yes])
240 AC_MSG_RESULT([$ENABLE_ASSERTIONS])
241 if test "$ENABLE_ASSERTIONS" = "yes"; then
242         AC_DEFINE([ENABLE_ASSERTIONS], [1], [Define to 1 if including assertions])
243 fi
244
245 AC_MSG_CHECKING([whether to include support for multi-threaded compression])
246 AC_ARG_ENABLE([multithreaded-compression],
247         AS_HELP_STRING([--disable-multithreaded-compression],
248                        [disable support for multithreaded compression]),
249         [ENABLE_MULTITHREADED_COMPRESSION=$enableval],
250         [ENABLE_MULTITHREADED_COMPRESSION=yes])
251 AC_MSG_RESULT([$ENABLE_MULTITHREADED_COMPRESSION])
252 if test "$ENABLE_MULTITHREADED_COMPRESSION" = "yes"; then
253         AC_DEFINE([ENABLE_MULTITHREADED_COMPRESSION], [1],
254                   [Define to 1 to support multithreaded compression])
255 fi
256
257 AC_ARG_WITH(pkgconfigdir,
258             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
259             [pkgconfigdir=$withval],
260             [pkgconfigdir='${libdir}/pkgconfig'])
261 AC_SUBST(pkgconfigdir)
262
263 AC_MSG_CHECKING([whether to enable supporting code for tests])
264 AC_ARG_ENABLE([test-support],
265               [AS_HELP_STRING([--enable-test-support],
266                               [Enable supporting code for tests (developers only)])],
267               [ENABLE_TEST_SUPPORT=$enableval],
268               [ENABLE_TEST_SUPPORT=no])
269 AC_MSG_RESULT([$ENABLE_TEST_SUPPORT])
270 if test "$ENABLE_TEST_SUPPORT" = "yes" ; then
271         AC_DEFINE([ENABLE_TEST_SUPPORT], [1],
272                   [Define to 1 to enable supporting code for tests])
273 fi
274 AM_CONDITIONAL([ENABLE_TEST_SUPPORT], [test "$ENABLE_TEST_SUPPORT" = "yes"])
275
276 ###############################################################################
277
278 AC_SUBST([PKGCONFIG_PRIVATE_REQUIRES], [$PKGCONFIG_PRIVATE_REQUIRES])
279 AC_SUBST([PKGCONFIG_PRIVATE_LIBS], [$PKGCONFIG_PRIVATE_LIBS])
280 AC_OUTPUT