]> wimlib.net Git - wimlib/blob - configure.ac
tools: make all shell scripts have the .sh extension
[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
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 -D_WIN32_WINNT=0x0600"
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 ###############################################################################
98 #                            Required libraries                               #
99 ###############################################################################
100
101 # ------------------------------ pthreads -------------------------------------
102 if test "$WINDOWS_NATIVE_BUILD" != "yes"; then
103         AX_PTHREAD([], [AC_MSG_ERROR(["cannot find pthreads library"])])
104 fi
105
106 ###############################################################################
107 #                         Configuration options                               #
108 ###############################################################################
109
110 # ------------------------- ntfs-3g support -----------------------------------
111
112 AC_MSG_CHECKING([whether to include support for ntfs-3g])
113 AC_ARG_WITH([ntfs-3g],
114             [AS_HELP_STRING([--without-ntfs-3g],
115                             [build without libntfs-3g.  This will disable the
116                              ability to capture or apply a WIM image directly
117                              from/to an unmounted NTFS volume.])],
118             [WITH_NTFS_3G=$withval],
119             [WITH_NTFS_3G=$WITH_NTFS_3G_DEFAULT])
120 AC_MSG_RESULT([$WITH_NTFS_3G])
121
122 if test "$WITH_NTFS_3G" = "yes"; then
123         PKG_CHECK_MODULES([LIBNTFS_3G], [libntfs-3g >= 2011.4.12], [],
124                 [AC_MSG_ERROR([Cannot find libntfs-3g version 2011-4-12 or
125                  later!  Without libntfs-3g, wimlib cannot include support for
126                  capturing or applying a WIM image directly from/to an unmounted
127                  NTFS volume while preserving NTFS-specific data such as
128                  security descriptors and named data streams.  Either install
129                  libntfs-3g, or configure --without-ntfs-3g to disable this
130                  feature.])])
131         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libntfs-3g"
132         AC_DEFINE([WITH_NTFS_3G], [1], [Define to 1 if using NTFS-3G support])
133 fi
134 AM_CONDITIONAL([WITH_NTFS_3G], [test "$WITH_NTFS_3G" = "yes"])
135
136 # ------------------------ FUSE mount support ---------------------------------
137
138 AC_MSG_CHECKING([whether to include support for mounting WIMs])
139 AC_ARG_WITH([fuse],
140             [AS_HELP_STRING([--without-fuse],
141                             [build without libfuse.  This will disable the
142                              ability to mount WIM images.])],
143             [WITH_FUSE=$withval],
144             [WITH_FUSE=$WITH_FUSE_DEFAULT])
145 AC_MSG_RESULT([$WITH_FUSE])
146
147 if test "$WITH_FUSE" = "yes"; then
148
149         PKG_CHECK_MODULES([LIBFUSE], [fuse], [],
150                 [AC_MSG_ERROR([Cannot find libfuse!
151                 Without libfuse, wimlib cannot include support for mounting WIM
152                 images.  Either install libfuse, or configure --without-fuse to
153                 disable this feature.])])
154         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES fuse"
155         AC_DEFINE([WITH_FUSE], [1], [Define to 1 if using FUSE support])
156
157         AC_CHECK_LIB([rt], [mq_open], [],
158                      [AC_MSG_ERROR([Cannot find librt (the POSIX.1b Realtime
159         Extensions Library)!  wimlib needs this for the POSIX message queue
160         functions, which are used in the code for mounting WIM images.  Recent
161         versions of glibc include this library.  Either install this library, or
162         configure --without-fuse to disable support for mounting WIM images.])])
163
164         PKGCONFIG_PRIVATE_LIBS="$PKGCONFIG_PRIVATE_LIBS -lrt"
165         AC_SUBST([LIBRT_LIBS], [-lrt])
166 fi
167 AM_CONDITIONAL([WITH_FUSE], [test "$WITH_FUSE" = "yes"])
168
169 # ----------------------------- Other options ---------------------------------
170
171 AC_ARG_WITH(pkgconfigdir,
172             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
173             [pkgconfigdir=$withval],
174             [pkgconfigdir='${libdir}/pkgconfig'])
175 AC_SUBST(pkgconfigdir)
176
177 AC_MSG_CHECKING([whether to enable supporting code for tests])
178 AC_ARG_ENABLE([test-support],
179               [AS_HELP_STRING([--enable-test-support],
180                               [Enable supporting code for tests (developers only)])],
181               [ENABLE_TEST_SUPPORT=$enableval],
182               [ENABLE_TEST_SUPPORT=no])
183 AC_MSG_RESULT([$ENABLE_TEST_SUPPORT])
184 if test "$ENABLE_TEST_SUPPORT" = "yes" ; then
185         AC_DEFINE([ENABLE_TEST_SUPPORT], [1],
186                   [Define to 1 to enable supporting code for tests])
187 fi
188 AM_CONDITIONAL([ENABLE_TEST_SUPPORT], [test "$ENABLE_TEST_SUPPORT" = "yes"])
189
190 ###############################################################################
191
192 AC_SUBST([PKGCONFIG_PRIVATE_REQUIRES], [$PKGCONFIG_PRIVATE_REQUIRES])
193 AC_SUBST([PKGCONFIG_PRIVATE_LIBS], [$PKGCONFIG_PRIVATE_LIBS])
194 AC_OUTPUT