]> wimlib.net Git - wimlib/blob - configure.ac
21fec5bfe59481b21cabc77e6420a258ca2d2611
[wimlib] / configure.ac
1 ###############################################################################
2
3 AC_INIT([wimlib], m4_esyscmd_s([tools/get-version-number.sh]),
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 PKG_PROG_PKG_CONFIG
14
15 AC_CONFIG_HEADERS([config.h])
16 AC_CONFIG_FILES([Makefile] [doc/Doxyfile] [wimlib.pc])
17 AC_CONFIG_FILES([programs/mkwinpeimg], [chmod +x programs/mkwinpeimg])
18
19 PKGCONFIG_PRIVATE_REQUIRES=""
20 PKGCONFIG_PRIVATE_LIBS=""
21
22 ###############################################################################
23 #                         General platform features                           #
24 ###############################################################################
25
26 AC_PROG_CC
27 AM_PROG_CC_C_O
28 AC_CANONICAL_HOST
29
30 WINDOWS_NATIVE_BUILD="no"
31 PLATFORM_CPPFLAGS=""
32 PLATFORM_CFLAGS="-fvisibility=hidden"
33 PLATFORM_LDFLAGS=""
34
35 case "$host_os" in
36 mingw*)
37         # Native Windows
38         WINDOWS_NATIVE_BUILD="yes"
39         # -D__MINGW_USE_VC2005_COMPAT: make time_t 64-bit on 32-bit Windows.
40         PLATFORM_CPPFLAGS="-D_POSIX -D_POSIX_THREAD_SAFE_FUNCTIONS -DUNICODE -D_UNICODE -D_CRT_NON_CONFORMING_SWPRINTFS -D__MINGW_USE_VC2005_COMPAT -D_WIN32_WINNT=0x0600"
41         PLATFORM_CFLAGS="-municode -mno-ms-bitfields"
42         PLATFORM_LDFLAGS="-no-undefined"
43         WITH_NTFS_3G_DEFAULT="no"
44         WITH_FUSE_DEFAULT="no"
45         ;;
46 linux*)
47         # Linux
48         WITH_NTFS_3G_DEFAULT="yes"
49         WITH_FUSE_DEFAULT="yes"
50         ;;
51 *)
52         # Other UNIX
53         WITH_NTFS_3G_DEFAULT="yes"
54         WITH_FUSE_DEFAULT="no"
55         ;;
56 esac
57
58 AC_SUBST([PLATFORM_CPPFLAGS], [$PLATFORM_CPPFLAGS])
59 AC_SUBST([PLATFORM_CFLAGS], [$PLATFORM_CFLAGS])
60 AC_SUBST([PLATFORM_LDFLAGS], [$PLATFORM_LDFLAGS])
61 AM_CONDITIONAL([WINDOWS_NATIVE_BUILD], [test "$WINDOWS_NATIVE_BUILD" = "yes"])
62
63 # Useful functions which we can do without.
64 AC_CHECK_FUNCS([futimens utimensat flock mempcpy        \
65                 openat fstatat readlinkat fdopendir posix_fallocate \
66                 llistxattr lgetxattr fsetxattr lsetxattr getopt_long_only])
67
68 # Header checks, most of which are only here to satisfy conditional includes
69 # made by the libntfs-3g headers.
70 AC_CHECK_HEADERS([alloca.h              \
71                   byteswap.h            \
72                   endian.h              \
73                   errno.h               \
74                   glob.h                \
75                   machine/endian.h      \
76                   stdarg.h              \
77                   stddef.h              \
78                   stdlib.h              \
79                   sys/byteorder.h       \
80                   sys/endian.h          \
81                   sys/file.h            \
82                   sys/syscall.h         \
83                   sys/sysctl.h          \
84                   sys/times.h           \
85                   sys/xattr.h           \
86                   time.h                \
87                   utime.h])
88
89 # Does stat() support nanosecond-precision timestamps?  (This is relevant on
90 # UNIX but not on Windows.)
91 AC_CHECK_MEMBER([struct stat.st_mtim],
92                 [AC_DEFINE([HAVE_STAT_NANOSECOND_PRECISION], [1],
93                            [Define to 1 if stat() supports nanosecond precision
94                             timestamps])],
95                 [],
96                 [#include <sys/stat.h>])
97
98 ###############################################################################
99 #                            Required libraries                               #
100 ###############################################################################
101
102 # ------------------------------ pthreads -------------------------------------
103 if test "$WINDOWS_NATIVE_BUILD" != "yes"; then
104         AX_PTHREAD([], [AC_MSG_ERROR(["cannot find pthreads library"])])
105 fi
106
107 ###############################################################################
108 #                         Configuration options                               #
109 ###############################################################################
110
111 # ------------------------- ntfs-3g support -----------------------------------
112
113 AC_MSG_CHECKING([whether to include support for ntfs-3g])
114 AC_ARG_WITH([ntfs-3g],
115             [AS_HELP_STRING([--without-ntfs-3g],
116                             [build without libntfs-3g.  This will disable the
117                              ability to capture or apply a WIM image directly
118                              from/to an unmounted NTFS volume.])],
119             [WITH_NTFS_3G=$withval],
120             [WITH_NTFS_3G=$WITH_NTFS_3G_DEFAULT])
121 AC_MSG_RESULT([$WITH_NTFS_3G])
122
123 if test "$WITH_NTFS_3G" = "yes"; then
124         PKG_CHECK_MODULES([LIBNTFS_3G], [libntfs-3g >= 2011.4.12], [],
125                 [AC_MSG_ERROR([Cannot find libntfs-3g version 2011-4-12 or
126                  later!  Without libntfs-3g, wimlib cannot include support for
127                  capturing or applying a WIM image directly from/to an unmounted
128                  NTFS volume while preserving NTFS-specific data such as
129                  security descriptors and named data streams.  Either install
130                  libntfs-3g, or configure --without-ntfs-3g to disable this
131                  feature.  If your operating system packages development files
132                  separately, the package you need to install may be called
133                  ntfs-3g-dev, ntfs-3g-devel, or similar.])])
134         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libntfs-3g"
135         AC_DEFINE([WITH_NTFS_3G], [1], [Define to 1 if using NTFS-3G support])
136 fi
137 AM_CONDITIONAL([WITH_NTFS_3G], [test "$WITH_NTFS_3G" = "yes"])
138
139 # ------------------------ FUSE mount support ---------------------------------
140
141 AC_MSG_CHECKING([whether to include support for mounting WIMs])
142 AC_ARG_WITH([fuse],
143             [AS_HELP_STRING([--without-fuse],
144                             [build without libfuse3.  This will disable the
145                              ability to mount WIM images.])],
146             [WITH_FUSE=$withval],
147             [WITH_FUSE=$WITH_FUSE_DEFAULT])
148 AC_MSG_RESULT([$WITH_FUSE])
149
150 if test "$WITH_FUSE" = "yes"; then
151
152         PKG_CHECK_MODULES([LIBFUSE], [fuse3], [],
153                 [AC_MSG_ERROR([Cannot find libfuse3!
154                 Without libfuse3, wimlib cannot include support for mounting WIM
155                 images.  Either install libfuse3, or configure --without-fuse to
156                 disable this feature.  If your operating system packages
157                 development files separately, the package you need to install
158                 may be called libfuse3-dev, fuse-devel, or similar.])])
159         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES fuse"
160         AC_DEFINE([WITH_FUSE], [1], [Define to 1 if using FUSE support])
161
162         AC_CHECK_LIB([rt], [mq_open], [],
163                      [AC_MSG_ERROR([Cannot find librt (the POSIX.1b Realtime
164         Extensions Library)!  wimlib needs this for the POSIX message queue
165         functions, which are used in the code for mounting WIM images.  Recent
166         versions of glibc include this library.  Either install this library, or
167         configure --without-fuse to disable support for mounting WIM images.])])
168
169         PKGCONFIG_PRIVATE_LIBS="$PKGCONFIG_PRIVATE_LIBS -lrt"
170         AC_SUBST([LIBRT_LIBS], [-lrt])
171 fi
172 AM_CONDITIONAL([WITH_FUSE], [test "$WITH_FUSE" = "yes"])
173
174 # ----------------------------- Other options ---------------------------------
175
176 AC_ARG_WITH(pkgconfigdir,
177             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
178             [pkgconfigdir=$withval],
179             [pkgconfigdir='${libdir}/pkgconfig'])
180 AC_SUBST(pkgconfigdir)
181
182 AC_MSG_CHECKING([whether to enable supporting code for tests])
183 AC_ARG_ENABLE([test-support],
184               [AS_HELP_STRING([--enable-test-support],
185                               [Enable supporting code for tests (developers only)])],
186               [ENABLE_TEST_SUPPORT=$enableval],
187               [ENABLE_TEST_SUPPORT=no])
188 AC_MSG_RESULT([$ENABLE_TEST_SUPPORT])
189 if test "$ENABLE_TEST_SUPPORT" = "yes" ; then
190         AC_DEFINE([ENABLE_TEST_SUPPORT], [1],
191                   [Define to 1 to enable supporting code for tests])
192 fi
193 AM_CONDITIONAL([ENABLE_TEST_SUPPORT], [test "$ENABLE_TEST_SUPPORT" = "yes"])
194
195 ###############################################################################
196
197 AC_SUBST([PKGCONFIG_PRIVATE_REQUIRES], [$PKGCONFIG_PRIVATE_REQUIRES])
198 AC_SUBST([PKGCONFIG_PRIVATE_LIBS], [$PKGCONFIG_PRIVATE_LIBS])
199 AC_OUTPUT