-
Notifications
You must be signed in to change notification settings - Fork 68
/
configure.ac
255 lines (212 loc) · 6.75 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
AC_PREREQ(2.68)
AC_INIT([try], [0.2.0], [https://github.com/binpash/try/issues])
# make sure we're in the right place
AC_CONFIG_SRCDIR([try])
AC_REQUIRE_AUX_FILE([docs/try.1.md])
AC_ARG_ENABLE([utils],
[AS_HELP_STRING([--disable-utils],
[don't compile C utilities for summarizing and committing changes (default is yes)])],
[enable_utils=${enableval}], [enable_utils=yes])
if test "$enable_utils" = "yes"
then
AC_REQUIRE_AUX_FILE([utils/try-commit.c])
# build tools
AC_PROG_CC
# CFLAGS and CPPFLAGGS
if test -z "$CFLAGS"
then
AUTO_CFLAGS="-g -Wall -O2"
else
AUTO_CFLAGS=""
fi
AUTO_CPPFLAGS=""
CFLAGS=${CFLAGS-"$AUTO_CFLAGS"}
CPPFLAGS=${CPPFLAGS-"$AUTO_CPPFLAGS"}
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
# needed C types
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# needed C functions
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_FORK
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_CHECK_HEADERS([fcntl.h unistd.h fts.h])
AC_CHECK_FUNCS([regcomp perror strerror getline getxattr fts_open])
missing_funs=""
for fun in regcomp perror strerror getline getxattr fts_open
do
varname="\$ac_cv_func_$fun"
if test "$(eval "echo ${varname-no}")" != "yes"
then
missing_funs="$missing_funs $fun"
fi
done
if ! test -z "$missing_funs"
then
AC_MSG_NOTICE([
------------------------------------------------------------------------
WARNING:
Some critical functions are missing, so utilities cannot be compiled.
Missing functions:$missing_funs
Continuing as if --disable-utils was passed.
------------------------------------------------------------------------
]);
enable_utils=no
fi
fi
AC_SUBST(enable_utils)
# install
AC_PROG_INSTALL
dnl TRY_REQUIRE_PROG(progname, checking_msg, pre, true_if_failed, post, fail_msg)
AC_DEFUN([TRY_REQUIRE_PROG], [
AC_MSG_CHECKING([ifelse([$2], [], [for $1], [$2])])
$3
if ifelse([$4], [], [! type -p $1 >/dev/null 2>&1], [$4])
then
AC_MSG_RESULT([no])
AC_MSG_ERROR([try needs $1 to work, but ifelse([$6], [], [it could not be found], [$6]).])
else
AC_MSG_RESULT([yes])
$5
fi
])
# symlinks
AC_PROG_LN_S
if test "$LN_S" != "ln -s"
then
AC_MSG_NOTICE([
----------------------------------------------------------------------
WARNING
Your system seems to not have a working implementation of symbolic
links. `try` may behave strangely.
----------------------------------------------------------------------
])
fi
#mktemp
TRY_REQUIRE_PROG([mktemp])
TRY_REQUIRE_PROG([mktemp -d], [whether mktemp -d works], [d=$(mktemp -d 2>/dev/null)], [test "$?" != 0 || ! test -d "$d"], [rmdir "$d"], [your mktemp does not support the -d option])
TRY_REQUIRE_PROG([df])
TRY_REQUIRE_PROG([find])
TRY_REQUIRE_PROG([grep])
TRY_REQUIRE_PROG([findmnt])
TRY_REQUIRE_PROG([sort])
TRY_REQUIRE_PROG([getfattr])
TRY_REQUIRE_PROG([overlayfs],[for overlayfs],[],[! lsmod | grep -q overlay], [], [the overlay module did not appear in the output of lsmod])
AC_CHECK_PROG([mergerfs], [mergerfs], [yes], [no])
AC_CHECK_PROG([unionfs], [unionfs], [yes], [no])
AC_MSG_CHECKING([for union helpers (unionfs or mergerfs)])
if test "$ac_cv_prog_mergerfs" = "no" && test "$ac_cv_prog_unionfs" = "no"
then
AC_MSG_RESULT([no; try may issue warnings and error messages])
else
AC_MSG_RESULT([yes])
fi
TRY_REQUIRE_PROG([readlink])
TRY_REQUIRE_PROG([unshare], [for unshare], [
res=$(unshare --mount --map-root-user --user --pid --fork -- ls $PWD/try 2>/dev/null)
], [
test "$?" != 0 || test "$res" != "$PWD/try"
], [], [could not run unshare])
# for manpages
if test -f man/try.1.gz
then
need_manpage=no
else
need_manpage=yes
fi
AC_ARG_ENABLE([manpage],
[AS_HELP_STRING([--enable-manpage],
[generate the manpage instead of using the cached version (requires pandoc, default is no when man/try.1.gz is present)])],
[enable_manpage=${enableval}], [enable_manpage=${need_manpage}])
if test "$enable_manpage" = "yes"
then
AC_MSG_CHECKING([for pandoc (for manpage)])
if ! type -p pandoc >/dev/null 2>&1
then
AC_MSG_RESULT([no])
enable_manpage="no"
else
AC_MSG_RESULT([yes])
fi
AC_MSG_CHECKING([for gzip (for manpage)])
if ! type -p gzip >/dev/null 2>&1
then
AC_MSG_RESULT([no])
enable_manpage="no"
else
AC_MSG_RESULT([yes])
fi
if test "$enable_manpage" = no
then
if test -f man/try.1.gz
then
AC_MSG_NOTICE([
------------------------------------------------------------------------
WARNING
Your system is missing some programs used to generate the manpage, so
the cached version will be used instead.
------------------------------------------------------------------------
])
else
AC_MSG_ERROR([
------------------------------------------------------------------------
WARNING
Your system is missing some programs used to generate the manpage and
no cached manpage is available.
------------------------------------------------------------------------
])
fi
fi
fi
AC_SUBST(enable_manpage)
# programs just used in tests
missing_test_programs=0
AC_PROG_AWK
AC_MSG_CHECKING([whether awk is gawk (for tests)])
if test "$(stat -L -c %i "$(type -p "$AWK")")" != "$(stat -L -c %i "$(type -p awk)")"
then
AC_MSG_RESULT([no; some tests may behave strangely])
: $((missing_test_programs += 1))
else
AC_MSG_RESULT([yes])
fi
dnl TRY_REQUIRE_PROG(progname)
AC_DEFUN([TRY_TEST_PROG], [
AC_MSG_CHECKING([for $1 (for tests)])
if ! type -p $1 >/dev/null 2>&1
then
AC_MSG_RESULT([no; some tests may fail])
: $((missing_test_programs += 1))
else
AC_MSG_RESULT([yes])
fi
])
TRY_TEST_PROG([expect])
TRY_TEST_PROG([curl])
TRY_TEST_PROG([diff])
TRY_TEST_PROG([touch])
TRY_TEST_PROG([gunzip])
if test "$missing_test_programs" -ne 0
then
AC_MSG_NOTICE([
------------------------------------------------------------------------
WARNING
Your system is missing some programs used in tests, so some tests may
fail.
------------------------------------------------------------------------
])
fi
AC_CONFIG_FILES([Makefile:Makefile.in])
AC_OUTPUT
cat <<EOF
------------------------------------------------------------------------
${PACKAGE_NAME} version ${PACKAGE_VERSION}
Prefix: ${prefix}
Compiling utilities: $enable_utils
To build and install, run:
make && make install
------------------------------------------------------------------------
EOF