]> wimlib.net Git - wimlib/blob - configure.ac
configure.ac: explicitly call PKG_PROG_PKG_CONFIG
[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.])])
132         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libntfs-3g"
133         AC_DEFINE([WITH_NTFS_3G], [1], [Define to 1 if using NTFS-3G support])
134 fi
135 AM_CONDITIONAL([WITH_NTFS_3G], [test "$WITH_NTFS_3G" = "yes"])
136
137 # ------------------------ FUSE mount support ---------------------------------
138
139 AC_MSG_CHECKING([whether to include support for mounting WIMs])
140 AC_ARG_WITH([fuse],
141             [AS_HELP_STRING([--without-fuse],
142                             [build without libfuse.  This will disable the
143                              ability to mount WIM images.])],
144             [WITH_FUSE=$withval],
145             [WITH_FUSE=$WITH_FUSE_DEFAULT])
146 AC_MSG_RESULT([$WITH_FUSE])
147
148 if test "$WITH_FUSE" = "yes"; then
149
150         PKG_CHECK_MODULES([LIBFUSE], [fuse], [],
151                 [AC_MSG_ERROR([Cannot find libfuse!
152                 Without libfuse, wimlib cannot include support for mounting WIM
153                 images.  Either install libfuse, or configure --without-fuse to
154                 disable this feature.])])
155         PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES fuse"
156         AC_DEFINE([WITH_FUSE], [1], [Define to 1 if using FUSE support])
157
158         AC_CHECK_LIB([rt], [mq_open], [],
159                      [AC_MSG_ERROR([Cannot find librt (the POSIX.1b Realtime
160         Extensions Library)!  wimlib needs this for the POSIX message queue
161         functions, which are used in the code for mounting WIM images.  Recent
162         versions of glibc include this library.  Either install this library, or
163         configure --without-fuse to disable support for mounting WIM images.])])
164
165         PKGCONFIG_PRIVATE_LIBS="$PKGCONFIG_PRIVATE_LIBS -lrt"
166         AC_SUBST([LIBRT_LIBS], [-lrt])
167 fi
168 AM_CONDITIONAL([WITH_FUSE], [test "$WITH_FUSE" = "yes"])
169
170 # ----------------------------- Other options ---------------------------------
171
172 AC_ARG_WITH(pkgconfigdir,
173             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
174             [pkgconfigdir=$withval],
175             [pkgconfigdir='${libdir}/pkgconfig'])
176 AC_SUBST(pkgconfigdir)
177
178 AC_MSG_CHECKING([whether to enable supporting code for tests])
179 AC_ARG_ENABLE([test-support],
180               [AS_HELP_STRING([--enable-test-support],
181                               [Enable supporting code for tests (developers only)])],
182               [ENABLE_TEST_SUPPORT=$enableval],
183               [ENABLE_TEST_SUPPORT=no])
184 AC_MSG_RESULT([$ENABLE_TEST_SUPPORT])
185 if test "$ENABLE_TEST_SUPPORT" = "yes" ; then
186         AC_DEFINE([ENABLE_TEST_SUPPORT], [1],
187                   [Define to 1 to enable supporting code for tests])
188 fi
189 AM_CONDITIONAL([ENABLE_TEST_SUPPORT], [test "$ENABLE_TEST_SUPPORT" = "yes"])
190
191 ###############################################################################
192
193 AC_SUBST([PKGCONFIG_PRIVATE_REQUIRES], [$PKGCONFIG_PRIVATE_REQUIRES])
194 AC_SUBST([PKGCONFIG_PRIVATE_LIBS], [$PKGCONFIG_PRIVATE_LIBS])
195 AC_OUTPUT