configure.ac: fix trailing newline issue
[wimlib] / configure.ac
1 ###############################################################################
2
3 AC_INIT([wimlib], m4_esyscmd([tools/get-version-number]),
4         [https://wimlib.net/forums/])
5 AC_CONFIG_SRCDIR([src/wim.c])
6 AC_CONFIG_MACRO_DIR([m4])
7 AC_CONFIG_AUX_DIR([build-aux])
8 AM_INIT_AUTOMAKE([-Wall -Werror subdir-objects foreign])
9 AM_SILENT_RULES([yes])
10 AC_C_BIGENDIAN
11 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
12 LT_INIT
13
14 AC_CONFIG_HEADERS([config.h])
15 AC_CONFIG_FILES([Makefile] [doc/Doxyfile] [wimlib.pc])
16 AC_CONFIG_FILES([programs/mkwinpeimg], [chmod +x programs/mkwinpeimg])
17
18 PKGCONFIG_PRIVATE_REQUIRES=""
19 PKGCONFIG_PRIVATE_LIBS=""
20
21 ###############################################################################
22 #                         General platform features                           #
23 ###############################################################################
24
25 AC_PROG_CC
26 AM_PROG_CC_C_O
27 AC_CANONICAL_HOST
28
29 WINDOWS_NATIVE_BUILD="no"
30 PLATFORM_CPPFLAGS=""
31 PLATFORM_CFLAGS="-fvisibility=hidden"
32 PLATFORM_LDFLAGS=""
33
34 case "$host_os" in
35 mingw*)
36         # Native Windows
37         WINDOWS_NATIVE_BUILD="yes"
38         # -D__MINGW_USE_VC2005_COMPAT: make time_t 64-bit on 32-bit Windows.
39         PLATFORM_CPPFLAGS="-D_POSIX -D_POSIX_THREAD_SAFE_FUNCTIONS -DUNICODE -D_UNICODE -D_CRT_NON_CONFORMING_SWPRINTFS -D__MINGW_USE_VC2005_COMPAT"
40         PLATFORM_CFLAGS="-municode -mno-ms-bitfields"
41         PLATFORM_LDFLAGS="-no-undefined"
42         WITH_NTFS_3G_DEFAULT="no"
43         WITH_FUSE_DEFAULT="no"
44         ;;
45 linux*)
46         # Linux
47         WITH_NTFS_3G_DEFAULT="yes"
48         WITH_FUSE_DEFAULT="yes"
49         ;;
50 *)
51         # Other UNIX
52         WITH_NTFS_3G_DEFAULT="yes"
53         WITH_FUSE_DEFAULT="no"
54         ;;
55 esac
56
57 AC_SUBST([PLATFORM_CPPFLAGS], [$PLATFORM_CPPFLAGS])
58 AC_SUBST([PLATFORM_CFLAGS], [$PLATFORM_CFLAGS])
59 AC_SUBST([PLATFORM_LDFLAGS], [$PLATFORM_LDFLAGS])
60 AM_CONDITIONAL([WINDOWS_NATIVE_BUILD], [test "$WINDOWS_NATIVE_BUILD" = "yes"])
61
62 # Useful functions which we can do without.
63 AC_CHECK_FUNCS([futimens utimensat flock mempcpy        \
64                 openat fstatat readlinkat fdopendir posix_fallocate \
65                 llistxattr lgetxattr fsetxattr lsetxattr getopt_long_only])
66
67 # Header checks, most of which are only here to satisfy conditional includes
68 # made by the libntfs-3g headers.
69 AC_CHECK_HEADERS([alloca.h              \
70                   byteswap.h            \
71                   endian.h              \
72                   errno.h               \
73                   glob.h                \
74                   machine/endian.h      \
75                   stdarg.h              \
76                   stddef.h              \
77                   stdlib.h              \
78                   sys/byteorder.h       \
79                   sys/endian.h          \
80                   sys/file.h            \
81                   sys/syscall.h         \
82                   sys/sysctl.h          \
83                   sys/times.h           \
84                   sys/xattr.h           \
85                   time.h                \
86                   utime.h])
87
88 # Does stat() support nanosecond-precision timestamps?  (This is relevant on
89 # UNIX but not on Windows.)
90 AC_CHECK_MEMBER([struct stat.st_mtim],
91                 [AC_DEFINE([HAVE_STAT_NANOSECOND_PRECISION], [1],
92                            [Define to 1 if stat() supports nanosecond precision
93                             timestamps])],
94                 [],
95                 [#include <sys/stat.h>])
96
97 # Check for possible support for the Linux getrandom() system call
98 AC_CHECK_DECL([__NR_getrandom],
99               [AC_DEFINE([HAVE_NR_GETRANDOM], [1], [Define to 1 if the system
100                headers define a system call number for getrandom()])],
101               [],
102               [#include <sys/syscall.h>])
103
104 ###############################################################################
105 #                            Required libraries                               #
106 ###############################################################################
107
108 # ------------------------------ pthreads -------------------------------------
109 AX_PTHREAD([], [AC_MSG_ERROR(["cannot find pthreads library"])])
110
111 # ------------------------------ libxml2 --------------------------------------
112 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
113 PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libxml-2.0"
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         PKGCONFIG_PRIVATE_LIBS="$PKGCONFIG_PRIVATE_LIBS -lrt"
174         AC_SUBST([LIBRT_LIBS], [-lrt])
175 fi
176 AM_CONDITIONAL([WITH_FUSE], [test "$WITH_FUSE" = "yes"])
177
178 # ------------------------ SHA-1 implementation ---------------------------------
179
180 AC_MSG_CHECKING([whether to use SSSE3-accelerated SHA-1])
181 AC_ARG_ENABLE([ssse3-sha1],
182               [AS_HELP_STRING([--enable-ssse3-sha1],
183                               [Include SSSE3-accelerated SHA-1 implementation by
184                                Intel.  This implies --without-libcrypto.])],
185               [ENABLE_SSSE3_SHA1=$enableval],
186               [ENABLE_SSSE3_SHA1=no])
187 AC_MSG_RESULT([$ENABLE_SSSE3_SHA1])
188
189 if test "$ENABLE_SSSE3_SHA1" = "yes" ; then
190         AC_DEFINE([ENABLE_SSSE3_SHA1], [1],
191                   [Define to 1 if using SSSE3 implementation of SHA-1])
192         AC_PROG_NASM
193         NASM_SYMBOL_PREFIX=""
194         NASM_PLATFORM_FLAGS=""
195         if test "$WINDOWS_NATIVE_BUILD" = "yes"; then
196                 NASM_PLATFORM_FLAGS="-DWIN_ABI"
197         fi
198         case "$host_os" in
199         darwin* | rhapsody* | nextstep* | openstep* | macos*)
200                 NASM_SYMBOL_PREFIX="_"
201                 ;;
202         esac
203         AC_SUBST([NASM_PLATFORM_FLAGS], [$NASM_PLATFORM_FLAGS])
204         AC_SUBST([NASM_SYMBOL_PREFIX], [$NASM_SYMBOL_PREFIX])
205 else
206         AC_MSG_CHECKING([whether to use SHA-1 implementation from system libcrypto])
207         AC_ARG_WITH([libcrypto],
208                     [AS_HELP_STRING([--without-libcrypto],
209                                     [build in the SHA-1 algorithm, rather than
210                                      use external libcrypto from OpenSSL
211                                      (default is autodetect)])],
212                     [WITH_LIBCRYPTO=$withval],
213                     [WITH_LIBCRYPTO=auto])
214         AC_MSG_RESULT([$WITH_LIBCRYPTO])
215         if test "$WITH_LIBCRYPTO" != "no"; then
216                 PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto], [
217                         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libcrypto"
218                         AC_DEFINE([WITH_LIBCRYPTO], [1],
219                                   [Define to 1 if using libcrypto SHA-1])
220                 ], [AC_MSG_WARN([Cannot find libcrypto: using stand-alone SHA-1 code instead])])
221         fi
222 fi
223 AM_CONDITIONAL([ENABLE_SSSE3_SHA1], [test "$ENABLE_SSSE3_SHA1" = "yes"])
224
225 # ----------------------------- Other options ---------------------------------
226
227 AC_MSG_CHECKING([whether to include error messages])
228 AC_ARG_ENABLE([error_messages],
229         AS_HELP_STRING([--disable-error-messages], [do not compile in error messages]),
230         [ENABLE_ERROR_MESSAGES=$enableval],
231         [ENABLE_ERROR_MESSAGES=yes])
232 AC_MSG_RESULT([$ENABLE_ERROR_MESSAGES])
233 if test "$ENABLE_ERROR_MESSAGES" = "yes"; then
234         AC_DEFINE([ENABLE_ERROR_MESSAGES], [1], [Define to 1 if including error messages])
235 fi
236
237 AC_MSG_CHECKING([whether to include assertions])
238 AC_ARG_ENABLE([assertions],
239         AS_HELP_STRING([--disable-assertions], [do not include assertions]),
240         [ENABLE_ASSERTIONS=$enableval],
241         [ENABLE_ASSERTIONS=yes])
242 AC_MSG_RESULT([$ENABLE_ASSERTIONS])
243 if test "$ENABLE_ASSERTIONS" = "yes"; then
244         AC_DEFINE([ENABLE_ASSERTIONS], [1], [Define to 1 if including assertions])
245 fi
246
247 AC_MSG_CHECKING([whether to include support for multi-threaded compression])
248 AC_ARG_ENABLE([multithreaded-compression],
249         AS_HELP_STRING([--disable-multithreaded-compression],
250                        [disable support for multithreaded compression]),
251         [ENABLE_MULTITHREADED_COMPRESSION=$enableval],
252         [ENABLE_MULTITHREADED_COMPRESSION=yes])
253 AC_MSG_RESULT([$ENABLE_MULTITHREADED_COMPRESSION])
254 if test "$ENABLE_MULTITHREADED_COMPRESSION" = "yes"; then
255         AC_DEFINE([ENABLE_MULTITHREADED_COMPRESSION], [1],
256                   [Define to 1 to support multithreaded compression])
257 fi
258
259 AC_ARG_WITH(pkgconfigdir,
260             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
261             [pkgconfigdir=$withval],
262             [pkgconfigdir='${libdir}/pkgconfig'])
263 AC_SUBST(pkgconfigdir)
264
265 AC_MSG_CHECKING([whether to enable supporting code for tests])
266 AC_ARG_ENABLE([test-support],
267               [AS_HELP_STRING([--enable-test-support],
268                               [Enable supporting code for tests (developers only)])],
269               [ENABLE_TEST_SUPPORT=$enableval],
270               [ENABLE_TEST_SUPPORT=no])
271 AC_MSG_RESULT([$ENABLE_TEST_SUPPORT])
272 if test "$ENABLE_TEST_SUPPORT" = "yes" ; then
273         AC_DEFINE([ENABLE_TEST_SUPPORT], [1],
274                   [Define to 1 to enable supporting code for tests])
275 fi
276 AM_CONDITIONAL([ENABLE_TEST_SUPPORT], [test "$ENABLE_TEST_SUPPORT" = "yes"])
277
278 ###############################################################################
279
280 AC_SUBST([PKGCONFIG_PRIVATE_REQUIRES], [$PKGCONFIG_PRIVATE_REQUIRES])
281 AC_SUBST([PKGCONFIG_PRIVATE_LIBS], [$PKGCONFIG_PRIVATE_LIBS])
282 AC_OUTPUT