-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
222 lines (191 loc) · 6.2 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
m4_define([erofs_utils_version], m4_esyscmd([sed -n '1p' VERSION | tr -d '\n']))
m4_define([erofs_utils_date], m4_esyscmd([sed -n '2p' VERSION | tr -d '\n']))
AC_INIT([erofs-utils], [erofs_utils_version], [[email protected]])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
# Checks for programs.
AM_PROG_AR
AC_PROG_CC
AC_PROG_INSTALL
LT_INIT
# Test presence of pkg-config
AC_MSG_CHECKING([pkg-config m4 macros])
if test m4_ifdef([PKG_CHECK_MODULES], [yes], [no]) = "yes"; then
AC_MSG_RESULT([yes]);
else
AC_MSG_RESULT([no]);
AC_MSG_ERROR([pkg-config is required. See pkg-config.freedesktop.org])
fi
dnl EROFS_UTILS_PARSE_DIRECTORY
dnl Input: $1 = a string to a relative or absolute directory
dnl Output: $2 = the variable to set with the absolute directory
AC_DEFUN([EROFS_UTILS_PARSE_DIRECTORY],
[
dnl Check if argument is a directory
if test -d $1 ; then
dnl Get the absolute path of the directory
dnl in case of relative directory.
dnl If realpath is not a valid command,
dnl an error is produced and we keep the given path.
local_tmp=`realpath $1 2>/dev/null`
if test "$local_tmp" != "" ; then
if test -d "$local_tmp" ; then
$2="$local_tmp"
else
$2=$1
fi
else
$2=$1
fi
dnl Check for space in the directory
if test `echo $1|cut -d' ' -f1` != $1 ; then
AC_MSG_ERROR($1 directory shall not contain any space.)
fi
else
AC_MSG_ERROR($1 shall be a valid directory)
fi
])
AC_ARG_ENABLE(lz4,
[AS_HELP_STRING([--disable-lz4], [disable LZ4 compression support @<:@default=enabled@:>@])],
[enable_lz4="$enableval"], [enable_lz4="yes"])
AC_ARG_WITH(uuid,
[AS_HELP_STRING([--without-uuid],
[Ignore presence of libuuid and disable uuid support @<:@default=enabled@:>@])])
# Checks for libraries.
# Use customized LZ4 library path when specified.
AC_ARG_WITH(lz4-incdir,
[AS_HELP_STRING([--with-lz4-incdir=DIR], [LZ4 include directory])], [
EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])])
AC_ARG_WITH(lz4-libdir,
[AS_HELP_STRING([--with-lz4-libdir=DIR], [LZ4 lib directory])], [
EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])])
AC_ARG_VAR([LZ4_CFLAGS], [C compiler flags for lz4])
AC_ARG_VAR([LZ4_LIBS], [linker flags for lz4])
# Checks for header files.
AC_CHECK_HEADERS(m4_flatten([
dirent.h
fcntl.h
getopt.h
inttypes.h
linux/falloc.h
linux/fs.h
linux/types.h
linux/xattr.h
limits.h
stddef.h
stdint.h
stdlib.h
string.h
sys/ioctl.h
sys/stat.h
sys/sysmacros.h
sys/time.h
unistd.h
]))
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_TYPE_UINT64_T
#
# Check to see if llseek() is declared in unistd.h. On some libc's
# it is, and on others it isn't..... Thank you glibc developers....
#
AC_CHECK_DECL(llseek,
[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1,
[Define to 1 if llseek declared in unistd.h])],,
[#include <unistd.h>])
#
# Check to see if lseek64() is declared in unistd.h. Glibc's header files
# are so convoluted that I can't tell whether it will always be defined,
# and if it isn't defined while lseek64 is defined in the library,
# disaster will strike.
#
# Warning! Use of --enable-gcc-wall may throw off this test.
#
AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
[Define to 1 if lseek64 declared in unistd.h])],,
[#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#include <unistd.h>])
# Checks for library functions.
AC_CHECK_FUNCS([fallocate gettimeofday memset realpath strdup strerror strrchr strtoull])
# Configure libuuid
AS_IF([test "x$with_uuid" != "xno"], [
PKG_CHECK_MODULES([libuuid], [uuid])
# Paranoia: don't trust the result reported by pkgconfig before trying out
saved_LIBS="$LIBS"
saved_CPPFLAGS=${CPPFLAGS}
CPPFLAGS="${libuuid_CFLAGS} ${CPPFLAGS}"
LIBS="${libuuid_LIBS} $LIBS"
AC_MSG_CHECKING([libuuid usability])
AC_TRY_LINK([
#include <uuid.h>
], [
uuid_t tmp;
uuid_generate(tmp);
return 0;
], [have_uuid="yes"
AC_MSG_RESULT([yes])], [
have_uuid="no"
AC_MSG_RESULT([no])
AC_MSG_ERROR([libuuid doesn't work properly])])
LIBS="${saved_LIBS}"
CPPFLAGS="${saved_CPPFLAGS}"], [have_uuid="no"])
# Configure lz4
test -z $LZ4_LIBS && LZ4_LIBS='-llz4'
if test "x$enable_lz4" = "xyes"; then
test -z "${with_lz4_incdir}" || LZ4_CFLAGS="-I$with_lz4_incdir $LZ4_CFLAGS"
test -z "${with_lz4_libdir}" || LZ4_LIBS="-L$with_lz4_libdir $LZ4_LIBS"
saved_CPPFLAGS=${CPPFLAGS}
CPPFLAGS="${LZ4_CFLAGS} ${CPPFLAGS}"
AC_CHECK_HEADERS([lz4.h],[have_lz4h="yes"], [])
if test "x${have_lz4h}" = "xyes" ; then
saved_LDFLAGS=${LDFLAGS}
test -z "${with_lz4_libdir}" || LDFLAGS="-L$with_lz4_libdir ${LDFLAGS}"
AC_CHECK_LIB(lz4, LZ4_compress_destSize, [
have_lz4="yes"
have_lz4hc="yes"
AC_CHECK_LIB(lz4, LZ4_compress_HC_destSize, [], [
AC_CHECK_DECL(LZ4_compress_HC_destSize, [lz4_force_static="yes"],
[have_lz4hc="no"], [[
#define LZ4_HC_STATIC_LINKING_ONLY (1)
#include <lz4hc.h>
]])
])
], [AC_MSG_ERROR([Cannot find proper lz4 version (>= 1.8.0)])])
LDFLAGS=${saved_LDFLAGS}
fi
CPPFLAGS=${saved_CPPFLAGS}
fi
# Set up needed symbols, conditionals and compiler/linker flags
AM_CONDITIONAL([ENABLE_LZ4], [test "x${have_lz4}" = "xyes"])
AM_CONDITIONAL([ENABLE_LZ4HC], [test "x${have_lz4hc}" = "xyes"])
if test "x$have_uuid" = "xyes"; then
AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found])
fi
if test "x${have_lz4}" = "xyes"; then
AC_DEFINE([LZ4_ENABLED], [1], [Define to 1 if lz4 is enabled.])
if test "x${have_lz4hc}" = "xyes"; then
AC_DEFINE([LZ4HC_ENABLED], [1], [Define to 1 if lz4hc is enabled.])
fi
if test "x${lz4_force_static}" = "xyes"; then
LDFLAGS="-all-static ${LDFLAGS}"
else
test -z "${with_lz4_libdir}" || LZ4_LIBS="-R ${with_lz4_libdir} $LZ4_LIBS"
fi
LIBS="$LZ4_LIBS $LIBS"
fi
AC_CONFIG_FILES([Makefile
man/Makefile
lib/Makefile
mkfs/Makefile])
AC_OUTPUT