forked from rc0/mairix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·380 lines (338 loc) · 8.34 KB
/
configure
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#!/bin/sh
#########################################################################
#
# mairix - message index builder and finder for maildir folders.
#
# Copyright (C) Richard P. Curnow 2003,2004,2005
# Copyright (C) Paramjit Oberoi 2005
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# =======================================================================
if [ -f config.log ]; then rm -f config.log ; fi
exec 5>config.log
MYCC=${CC:-gcc}
MYCFLAGS=${CFLAGS:--O2 -Wall}
MYCPPFLAGS=${CPPFLAGS:-}
MYLDFLAGS=${LDFLAGS:-}
# =======================================================================
# Functions
#{{{ cleanup
cleanup () {
if [ -f docheck.c ]; then rm -f docheck.c ; fi
if [ -f docheck.o ]; then rm -f docheck.o ; fi
if [ -f docheck ]; then rm -f docheck ; fi
rm -rf docheck.c docheck.o docheck
}
#}}}
#{{{ test_cc : basic compiler sanity check
test_cc () {
printf "Testing whether your compiler \"$MYCC $MYCFLAGS\" works : "
cat >docheck.c <<EOF;
#include <stdio.h>
int main (int argc, char **argv)
{
return 0;
}
EOF
${MYCC} ${MYCFLAGS} -o docheck docheck.c 1>&5 2>&5
if [ $? -eq 0 ]
then
printf "it works\n"
else
printf "it doesn't work\n"
printf "Failed program was\n" 1>&5
cat docheck.c 1>&5
rm -f docheck.c docheck
exit 1
fi
cleanup
}
#}}}
#{{{ test_for_stdint_h
test_for_stdint_h () {
cat >docheck.c <<EOF;
#include <stdint.h>
int main(int argc, char **argv) {
return 0;
}
EOF
${MYCC} ${MYCFLAGS} -c -o docheck.o docheck.c >/dev/null 2>&1
if [ $? -eq 0 ]
then
result=0
else
result=1
fi
rm -f docheck.c docheck.o
echo $result
}
#}}}
#{{{ test_for_inttypes_h
test_for_inttypes_h () {
cat >docheck.c <<EOF;
#include <inttypes.h>
int main(int argc, char **argv) {
return 0;
}
EOF
${MYCC} ${MYCFLAGS} -c -o docheck.o docheck.c >/dev/null 2>&1
if [ $? -eq 0 ]
then
result=0
else
result=1
fi
rm -f docheck.c docheck.o
echo $result
}
#}}}
#{{{ test_for_zlib
test_for_zlib () {
cat > docheck.c <<EOF;
#include <zlib.h>
int main () {
const char *foo;
foo = zlibVersion();
return 0;
}
EOF
echo "Test program is" 1>&5
cat docheck.c 1>&5
${MYCC} ${MYCPPFLAGS} ${MYCFLAGS} ${MYLDFLAGS} -o docheck docheck.c -lz 1>&5 2>&1
if [ $? -eq 0 ]
then
result=0
else
result=1
fi
rm -f docheck.c docheck
echo $result
}
#}}}
#{{{ test_for_bzlib
test_for_bzlib () {
cat > docheck.c <<EOF;
#include <bzlib.h>
int main () {
const char *foo;
foo = BZ2_bzlibVersion();
return 0;
}
EOF
echo "Test program is" 1>&5
cat docheck.c 1>&5
${MYCC} ${MYCPPFLAGS} ${MYCFLAGS} ${MYLDFLAGS} -o docheck docheck.c -lbz2 1>&5 2>&1
if [ $? -eq 0 ]
then
result=0
else
result=1
fi
rm -f docheck.c docheck
echo $result
}
#}}}
#{{{ test_for_bison
test_for_bison () {
bison --help > /dev/null
if [ $? -eq 0 ]
then
result=0
else
result=1
fi
echo $result
}
#}}}
#{{{ test_for_flex
test_for_flex () {
flex --help > /dev/null
if [ $? -eq 0 ]
then
result=0
else
result=1
fi
echo $result
}
#}}}
#{{{ usage
usage () {
cat <<EOF;
\`configure' configures tdl to adapt to many kinds of systems.
Usage: ./configure [OPTION]...
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
By default, \`make install' will install all the files in
\`/usr/local/bin', \`/usr/local/lib' etc. You can specify
an installation prefix other than \`/usr/local' using \`--prefix',
for instance \`--prefix=$HOME'.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--infodir=DIR info documentation [PREFIX/info]
--mandir=DIR man documentation [PREFIX/man]
--docdir=DIR other documentation [PREFIX/doc/mairix-\$version]
Other options:
--enable-gzip-mbox attempt to support gzipped mboxes (requires zlib)
--disable-gzip-mbox don't attempt to support gzipped mboxes
--enable-bzip-mbox attempt to support bzip2ed mboxes (requires bzlib)
--disable-bzip-mbox don't attempt to support bzip2ed mboxes
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
CPPFLAGS Extra C preprocessor flags, e.g. -I<include dir> if you
have header files in a nonstandard directory <include dir>
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
Use these variables to override the choices made by \`configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to <[email protected]>.
EOF
}
#}}}
# =======================================================================
# Defaults for variables
PREFIX=/usr/local
use_readline=yes
bad_options=no
use_gzip_mbox=yes
use_bzip_mbox=yes
# Parse options to configure
for option
do
case "$option" in
--prefix=* | --install-prefix=* )
PREFIX=`echo $option | sed -e 's/[^=]*=//;'`
;;
--bindir=* )
BINDIR=`echo $option | sed -e 's/[^=]*=//;'`
;;
--mandir=* )
MANDIR=`echo $option | sed -e 's/[^=]*=//;'`
;;
--infodir=* )
INFODIR=`echo $option | sed -e 's/[^=]*=//;'`
;;
--docdir=* )
DOCDIR=`echo $option | sed -e 's/[^=]*=//;'`
;;
--enable-gzip-mbox )
use_gzip_mbox=yes
;;
--disable-gzip-mbox )
use_gzip_mbox=no
;;
--enable-bzip-mbox )
use_bzip_mbox=yes
;;
--disable-bzip-mbox )
use_bzip_mbox=no
;;
-h | --help )
usage
exit 1
;;
* )
printf "Unrecognized option : $option\n"
bad_options=yes
;;
esac
done
if [ ${bad_options} = yes ]; then
exit 1
fi
DEFS=""
test_cc
printf "Checking for <stdint.h> : "
if [ `test_for_stdint_h` -eq 0 ]; then
printf "Yes\n"
DEFS="${DEFS} -DHAS_STDINT_H"
else
printf "No\n"
fi
printf "Checking for <inttypes.h> : "
if [ `test_for_inttypes_h` -eq 0 ]; then
printf "Yes\n"
DEFS="${DEFS} -DHAS_INTTYPES_H"
else
printf "No\n"
fi
if [ $use_gzip_mbox = "yes" ]; then
printf "Checking for zlib : "
if [ `test_for_zlib` -eq 0 ]; then
printf "Yes\n";
DEFS="${DEFS} -DUSE_GZIP_MBOX"
LIBS="-lz"
else
printf "No (disabled gzipped mbox support)\n";
fi
fi
if [ $use_bzip_mbox = "yes" ]; then
printf "Checking for bzlib : "
if [ `test_for_bzlib` -eq 0 ]; then
printf "Yes\n";
DEFS="${DEFS} -DUSE_BZIP_MBOX"
LIBS="${LIBS} -lbz2"
else
printf "No (disabled bzip2ed mbox support)\n";
fi
fi
printf "Checking for bison : "
if [ `test_for_bison` -eq 0 ]; then
printf "Yes\n";
else
printf "No\n";
exit 1;
fi
printf "Checking for flex : "
if [ `test_for_flex` -eq 0 ]; then
printf "Yes\n";
else
printf "No\n";
exit 1;
fi
#{{{ Determine version number of the program.
if [ -f version.txt ]; then
revision=`cat version.txt`
else
revision="DEVELOPMENT"
fi
#}}}
if [ "x" = "x${BINDIR}" ]; then BINDIR=${PREFIX}/bin ; fi
if [ "x" = "x${MANDIR}" ]; then MANDIR=${PREFIX}/man ; fi
if [ "x" = "x${INFODIR}" ]; then INFODIR=${PREFIX}/info ; fi
if [ "x" = "x${DOCDIR}" ]; then DOCDIR=${PREFIX}/doc/mairix-${revision} ; fi
echo "Generating Makefile"
rm -f Makefile
sed -e "s%@cc@%${MYCC}%; \
s%@defs@%${DEFS}%; \
s%@cflags@%${MYCFLAGS}%; \
s%@prefix@%${PREFIX}%; \
s%@bindir@%${BINDIR}%; \
s%@mandir@%${MANDIR}%; \
s%@infodir@%${INFODIR}%; \
s%@docdir@%${DOCDIR}%; \
s%@LIBS@%${LIBS}%; \
s%@CPPFLAGS@%${MYCPPFLAGS}%; \
s%@LDFLAGS@%${MYLDFLAGS}%; \
" < Makefile.in > Makefile
# Avoid editing Makefile instead of Makefile.in
chmod ugo-w Makefile
# =======================================================================
# vim:et:sw=2:ht=2:sts=2:fdm=marker:cms=#%s