Changes to compile wimlib on FreeBSD.
[wimlib] / configure.ac
1 AC_INIT([wimlib], [0.6.3], [ebiggers3@gmail.com])
2 AC_CONFIG_SRCDIR([src/wim.c])
3 AM_INIT_AUTOMAKE([-Wall -Werror])
4 AC_CONFIG_MACRO_DIR([m4])
5 AC_C_BIGENDIAN
6 AM_PROG_AR
7 LT_INIT
8 AC_CONFIG_HEADERS([config.h])
9 AC_CONFIG_FILES([Makefile 
10                 doc/Makefile 
11                 doc/Doxyfile
12                 src/Makefile 
13                 programs/Makefile
14                 wimlib.pc
15                 doc/imagex.1
16                 doc/imagex-append.1
17                 doc/imagex-apply.1
18                 doc/imagex-capture.1
19                 doc/imagex-delete.1
20                 doc/imagex-dir.1
21                 doc/imagex-export.1
22                 doc/imagex-info.1
23                 doc/imagex-mount.1
24                 doc/imagex-mountrw.1
25                 doc/imagex-unmount.1
26                 doc/mkwinpeimg.1
27                 rpm/wimlib.spec
28                 archlinux/PKGBUILD
29                 ])
30 AC_PROG_CC
31
32
33 AM_ICONV
34 if test "x$am_cv_func_iconv" != "xyes"; then
35         AC_MSG_ERROR([Cannot find the iconv() function.
36         iconv() is used to convert between UTF-8 and UTF-16 encodings of WIM
37         filenames and XML data.  Wimlib cannot be compiled without it.  iconv()
38         is available in the latest version of glibc and sometimes in other
39         libraries.])
40 fi
41
42 AC_ARG_WITH(pkgconfigdir,
43             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
44             [pkgconfigdir=$withval],
45             [pkgconfigdir='${libdir}/pkgconfig'])
46 AC_SUBST(pkgconfigdir)
47
48 AC_CHECK_LIB([xml2], [xmlParseFile], [have_libxml=true],
49              [AC_MSG_ERROR(["cannot find libxml2"])])
50 LIBXML2_LDADD=`pkg-config libxml-2.0 --libs`
51 LIBXML2_CFLAGS=`pkg-config libxml-2.0 --cflags`
52 AC_SUBST([LIBXML2_LDADD], [$LIBXML2_LDADD])
53 AC_SUBST([LIBXML2_CFLAGS], [$LIBXML2_CFLAGS])
54
55 AC_MSG_CHECKING([whether to include debugging messages])
56 AC_ARG_ENABLE([debug], 
57         AS_HELP_STRING([--enable-debug], [include lots of debugging messages]),
58         [ENABLE_DEBUG=$enableval],
59         [ENABLE_DEBUG=no]
60         )
61 AC_MSG_RESULT([$ENABLE_DEBUG])
62 if test "x$ENABLE_DEBUG" = "xyes"; then
63         AC_DEFINE([ENABLE_DEBUG], [1], 
64                         [Define to 1 if including lots of debug messages.])
65 fi
66
67 AC_MSG_CHECKING([whether to include more debugging messages])
68 AC_ARG_ENABLE([more_debug], 
69         AS_HELP_STRING([--enable-more-debug], 
70                         [include even more debugging messages]),
71         [ENABLE_MORE_DEBUG=$enableval],
72         [ENABLE_MORE_DEBUG=no]
73         )
74 AC_MSG_RESULT([$ENABLE_MORE_DEBUG])
75 if test "x$ENABLE_MORE_DEBUG" = "xyes"; then
76         AC_DEFINE([ENABLE_MORE_DEBUG], [1], 
77                         [Define to 1 if including even more debug messages.])
78 fi
79
80 AC_MSG_CHECKING([whether to include error messages])
81 AC_ARG_ENABLE([error_messages], 
82         AS_HELP_STRING([--disable-error-messages], 
83                         [do not compile in error messsages]),
84         [ENABLE_ERROR_MESSAGES=$enableval],
85         [ENABLE_ERROR_MESSAGES=yes]
86         )
87 AC_MSG_RESULT([$ENABLE_ERROR_MESSAGES])
88 if test "x$ENABLE_ERROR_MESSAGES" = "xyes"; then
89         AC_DEFINE([ENABLE_ERROR_MESSAGES], [1], 
90                         [Define to 1 if including error messages])
91 fi
92
93 AC_MSG_CHECKING([whether to support custom memory allocation functions])
94 AC_ARG_ENABLE([custom_memory_allocator], 
95         AS_HELP_STRING([--disable-custom-memory-allocator], 
96                        [do not support the use of custom memory allocation
97                         functions]),
98         [ENABLE_CUSTOM_MEMORY_ALLOCATOR=$enableval],
99         [ENABLE_CUSTOM_MEMORY_ALLOCATOR=yes]
100         )
101 AC_MSG_RESULT([$ENABLE_CUSTOM_MEMORY_ALLOCATOR])
102 if test "x$ENABLE_CUSTOM_MEMORY_ALLOCATOR" = "xyes"; then
103         AC_DEFINE([ENABLE_CUSTOM_MEMORY_ALLOCATOR], [1], 
104                 [Define to 1 if supporting custom memory allocation functions])
105 fi
106
107 AC_MSG_CHECKING([whether to include assertions])
108 AC_ARG_ENABLE([assertions],
109         AS_HELP_STRING([--disable-assertions], [do not include assertions]),
110         [ENABLE_ASSERTIONS=$enableval],
111         [ENABLE_ASSERTIONS=yes]
112         )
113 AC_MSG_RESULT([$ENABLE_ASSERTIONS])
114 if test "x$ENABLE_ASSERTIONS" = "xyes"; then
115         AC_DEFINE([ENABLE_ASSERTIONS], [1], [Define to 1 if including assertions.])
116 fi
117
118
119 AC_MSG_CHECKING([whether to include compression verification])
120 AC_ARG_ENABLE([verify_compression],
121               AS_HELP_STRING([--disable-verify-compression], [disable
122                                 checking if blocks we compress can be correctly
123                                 decompressed]),
124         [ENABLE_VERIFY_COMPRESSION=$enableval],
125         [ENABLE_VERIFY_COMPRESSION=yes]
126         )
127 AC_MSG_RESULT([$ENABLE_VERIFY_COMPRESSION])
128 if test "x$ENABLE_VERIFY_COMPRESSION" = "xyes"; then
129         AC_DEFINE([ENABLE_VERIFY_COMPRESSION], [1], [Define to 1 to verify
130                    compressed data])
131 fi
132
133 AC_MSG_CHECKING([whether to include support for mounting WIMs])
134 AC_ARG_WITH([fuse],
135                 AS_HELP_STRING([--without-fuse], [build without libfuse.  
136                                         This will disable the ability to mount 
137                                         WIM files.]),
138         [WITH_FUSE=$withval],
139         [WITH_FUSE=yes]
140         )
141 AC_MSG_RESULT([$WITH_FUSE])
142 if test "x$WITH_FUSE" = "xyes"; then
143         AC_DEFINE([WITH_FUSE], [1], [Define to 1 if using FUSE.])
144
145
146         AC_CHECK_LIB([fuse], [fuse_main_real], [have_fuse=true],
147                         [AC_MSG_ERROR([Cannot find libfuse.  
148         Without libfuse, WIMLIB cannot include support for mounting WIMs.  You
149         should either install libfuse, or configure with --without-fuse to
150         disable support for mounting WIMs.])
151         ])
152         AC_CHECK_LIB([rt], [mq_open], [have_posix_mq=true],
153                      [AC_MSG_ERROR([Cannot find librt for POSIX message queue
154         functions.  Without these functions, WIMLIB cannot include support for
155         mounting WIMs.  You should either update your C library to a recent
156         version of glibc, or configure with --without-fuse to disable support
157         for mounting WIMs.])
158         ])
159         LIBFUSE_LDADD="`pkg-config --libs fuse` -lrt"
160         LIBFUSE_CFLAGS="`pkg-config --cflags fuse`"
161 else
162         LIBFUSE_LDADD=
163         LIBFUSE_CFLAGS=
164 fi
165 AC_SUBST([LIBFUSE_LDADD], [$LIBFUSE_LDADD])
166 AC_SUBST([LIBFUSE_CFLAGS], [$LIBFUSE_CFLAGS])
167
168 AC_MSG_CHECKING([whether to use SSSE3-accelerated SHA1 ])
169 AC_ARG_ENABLE([ssse3-sha1],
170             AS_HELP_STRING([--enable-ssse3-sha1], [use assembly language implementation
171                                 of SHA1 from Intel, accelerated with vector
172                                 instructions (SSSE3-enabled CPU required)]),
173         [ENABLE_SSSE3_SHA1=$enableval],
174         [ENABLE_SSSE3_SHA1=no]
175         )
176         
177 AC_MSG_RESULT([$ENABLE_SSSE3_SHA1])
178 if test "x$ENABLE_SSSE3_SHA1" = "xyes"; then
179         AC_DEFINE([ENABLE_SSSE3_SHA1], [1], 
180                         [Define to 1 if using vectorized implementation of SHA1])
181         SSSE3_SHA1_OBJ=sha1-ssse3.lo
182         AX_PROG_NASM
183         AC_SUBST([NASM], [$nasm])
184 else
185         SSSE3_SHA1_OBJ=
186 fi
187 AC_SUBST([SSSE3_SHA1_OBJ], [$SSSE3_SHA1_OBJ])
188
189 if test "x$ENABLE_SSSE3_SHA1" = "xyes"; then
190         WITH_LIBCRYPTO=no
191 else
192         AC_ARG_WITH([libcrypto],
193             AS_HELP_STRING([--without-libcrypto], [build in the SHA1 algorithm,
194                                         rather than use external libcrypto from
195                                         OpenSSL (default is autodetect)]),
196         [WITH_LIBCRYPTO=$withval],
197         [AC_CHECK_LIB([crypto], [SHA1], 
198                      [WITH_LIBCRYPTO=yes],
199                      [AC_MSG_WARN([Cannot find libcrypto: using stand-alone SHA1 code instead of OpenSSL])
200                      WITH_LIBCRYPTO=no
201                      ])])
202 fi
203 AC_MSG_CHECKING([whether to use SHA1 function from system libcrypto])
204 AC_MSG_RESULT([$WITH_LIBCRYPTO])
205
206 if test "x$WITH_LIBCRYPTO" = "xyes" -a "x$ENABLE_SSSE3_SHA1" = "xno"; then
207         AC_DEFINE([WITH_LIBCRYPTO], [1], [Define to 1 if using libcrypto SHA1])
208         LIBCRYPTO_LDADD=`pkg-config --libs libcrypto 2>/dev/null`
209         if test $? -ne 0; then
210                 LIBCRYPTO_LDADD=-lcrypto;
211         fi
212         LIBCRYPTO_CFLAGS=`pkg-config --cflags libcrypto 2>/dev/null`
213 else
214         LIBCRYPTO_LDADD=
215         LIBCRYPTO_CFLAGS=
216 fi
217 AC_SUBST([LIBCRYPTO_LDADD], [$LIBCRYPTO_LDADD])
218 AC_SUBST([LIBCRYPTO_CFLAGS], [$LIBCRYPTO_CFLAGS])
219 AC_SUBST([SHA1_SOURCES], [$SHA1_SOURCES])
220
221 AC_OUTPUT