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