-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·456 lines (400 loc) · 11.3 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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
#!/bin/sh
#########################################################################
#
# $Id: configure,v 1.5.2.2 2004/01/07 00:09:05 richard Exp $
#
# =======================================================================
#
# tdl - A console program for managing to-do lists
#
# Copyright (C) Richard P. Curnow 2003-2004
#
# 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.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# =======================================================================
if [ -f config.log ]; then rm -f config.log ; fi
exec 5>config.log
if [ "x${CC}" = "x" ]; then
MYCC="gcc"
else
MYCC="${CC}"
fi
if [ "x${CFLAGS}" = "x" ]; then
MYCFLAGS="-O2 -Wall"
else
MYCFLAGS="${CFLAGS}"
fi
# =======================================================================
# 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${BINEXT} ]; then rm -f docheck${BINEXT} ; 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${BINEXT} 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${BINEXT}
exit 1
fi
cleanup
}
#}}}
#{{{ test_readline_include
test_readline_include () {
# Objective : test whether we can compile and link a program using
# readline, and if so how.
# As for includes, is it <readline.h> or <readline/readline.h>
# As for linking, do we need -ltermcap, -lncurses etc
printf "Testing what to include for readline : "
cat >docheck.c <<EOF;
#include <stdio.h>
#include <readline.h>
int main (int argc, char **argv) {
printf("%s\n", rl_library_version);
return 0;
}
EOF
${MYCC} ${MYCFLAGS} ${readline_inc_arg} -c -o docheck.o docheck.c 1>&5 2>&5
if [ $? -eq 0 ]; then
printf "<readline.h>\n"
READLINE_DEFINE="-DBARE_READLINE_H=1"
else
rm -f docheck.c
cat >docheck.c <<EOF;
#include <stdio.h>
#include <readline/readline.h>
int main (int argc, char **argv) {
printf("%s\n", rl_library_version);
return 0;
}
EOF
${MYCC} ${MYCFLAGS} ${readline_inc_arg} -c -o docheck.o docheck.c 1>&5 2>&5
if [ $? -eq 0 ]; then
printf "<readline/readline.h>\n"
READLINE_DEFINE="-DBARE_READLINE_H=0"
else
printf "FAILED\n"
printf "Can't include readline.h, giving up on readline"
use_readline="no"
fi
fi
cleanup
return
}
#}}}
#{{{ test_readline_lib
test_readline_lib () {
printf "Testing extra libraries to link with readline : "
cat >docheck.c <<EOF;
#include <stdio.h>
#if BARE_READLINE_H
#include <readline.h>
#else
#include <readline/readline.h>
#endif
int main (int argc, char **argv) {
printf("%s\n", rl_library_version);
return 0;
}
EOF
${MYCC} ${MYCFLAGS} ${readline_inc_arg} ${READLINE_DEFINE} -c -o docheck.o docheck.c 1>&5 2>&5
if [ $? -ne 0 ]; then
printf "unexpected compile failure, giving up on readline\n"
use_readline="no"
cleanup
return
fi
# Now try to link it
${MYCC} ${MYCFLAGS} -o docheck${BINEXT} docheck.o ${readline_lib_arg} -lreadline 1>&5 2>&5
if [ $? -eq 0 ]; then
extra_readline_libs=""
printf "(none)\n"
cleanup
return
fi
${MYCC} ${MYCFLAGS} -o docheck${BINEXT} docheck.o ${readline_lib_arg} -lreadline -ltermcap 1>&5 2>&5
if [ $? -eq 0 ]; then
extra_readline_libs="-ltermcap"
printf -- "-ltermcap\n"
cleanup
return
fi
${MYCC} ${MYCFLAGS} -o docheck${BINEXT} docheck.o ${readline_lib_arg} -lreadline -lncurses 1>&5 2>&5
if [ $? -eq 0 ]; then
extra_readline_libs="-lncurses"
printf -- "-lncurses\n"
cleanup
return
fi
printf "can't link a readline program\n"
use_readline="no"
return
}
#}}}
#{{{ test_completion_matches
test_completion_matches () {
# See if the readline library has completion_matches()
printf "Testing for completion_matches in readline : "
cat >docheck.c <<EOF;
#include <stdio.h>
#if BARE_READLINE_H
#include <readline.h>
#else
#include <readline/readline.h>
#endif
int main (int argc, char **argv) {
void *x = &completion_matches;
printf("%p\n", x);
return 0;
}
EOF
${MYCC} ${MYCFLAGS} ${readline_inc_arg} ${READLINE_DEFINE} -c -o docheck.o docheck.c 1>&5 2>&5
if [ $? -ne 0 ]; then
printf "no\n";
has_completion_matches=no
cleanup
return
fi
${MYCC} ${MYCFLAGS} -o docheck${BINEXT} docheck.o ${readline_lib_arg} -lreadline ${extra_readline_libs} 1>&5 2>&5
if [ $? -eq 0 ]; then
printf "yes\n"
has_completion_matches=yes
else
printf "no\n"
has_completion_matches=no
fi
cleanup
}
#}}}
#{{{ test_rl_completion_matches
test_rl_completion_matches () {
# See if the readline library has completion_matches()
printf "Testing for rl_completion_matches in readline : "
cat >docheck.c <<EOF;
#include <stdio.h>
#if BARE_READLINE_H
#include <readline.h>
#else
#include <readline/readline.h>
#endif
int main (int argc, char **argv) {
void *x = &rl_completion_matches;
printf("%p\n", x);
return 0;
}
EOF
${MYCC} ${MYCFLAGS} ${readline_inc_arg} ${READLINE_DEFINE} -c -o docheck.o docheck.c 1>&5 2>&5
if [ $? -ne 0 ]; then
printf "no\n"
has_rl_completion_matches=no
cleanup
return
fi
${MYCC} ${MYCFLAGS} -o docheck${BINEXT} docheck.o ${readline_lib_arg} -lreadline ${extra_readline_libs} 1>&5 2>&5
if [ $? -eq 0 ]; then
printf "yes\n"
has_rl_completion_matches=yes
else
printf "no\n"
has_rl_completion_matches=no
fi
cleanup
}
#}}}
#{{{ get_binext
get_binext() {
test "$OSTYPE" = "cygwin" && BINEXT=.exe
}
#}}}
#{{{ 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'.
For better control, use the options below.
--without-readline Don't try to use GNU readline
--readline-dir=DIR Specify parent of readline include and lib directories
--readline-inc-dir=DIR Specify where readline include directory is
--readline-lib-dir=DIR Specify where readline lib directory is
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--infodir=DIR info documentation [PREFIX/info]
--mandir=DIR man documentation [PREFIX/man]
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
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
BINEXT=""
use_readline=yes
bad_options=no
use_dotlock=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/[^=]*=//;'`
;;
--without-readline )
use_readline=no
;;
--readline-dir=* )
readline_dir=`echo $option | sed -e 's/[^=]*=//;'`
;;
--readline-inc-dir=* )
readline_inc_dir=`echo $option | sed -e 's/[^=]*=//;'`
;;
--readline-lib-dir=* )
readline_lib_dir=`echo $option | sed -e 's/[^=]*=//;'`
;;
--disable-dotlock )
use_dotlock=no
;;
-h | --help )
usage
exit 1
;;
* )
printf "Unrecognized option : $option\n"
bad_options=yes
;;
esac
done
if [ ${bad_options} = yes ]; then
exit 1
fi
#{{{ process readline-related arguments
if [ "$use_readline" = "yes" ]; then
if [ "x$readline_dir" != "x" ]; then
if [ "x$readline_inc_dir" = "x" ]; then
readline_inc_dir="${readline_dir}/include"
fi
if [ "x$readline_lib_dir" = "x" ]; then
readline_lib_dir="${readline_dir}/lib"
fi
fi
if [ "x$readline_inc_dir" != "x" ]; then
readline_inc_arg="-I${readline_inc_dir}"
else
readline_inc_arg=""
fi
if [ "x$readline_lib_dir" != "x" ]; then
readline_lib_arg="-L${readline_lib_dir} -R${readline_lib_dir}"
else
readline_lib_arg=""
fi
fi
#}}}
get_binext
test_cc
if [ "${use_readline}" = "yes" ]; then test_readline_include ; fi
if [ "${use_readline}" = "yes" ]; then test_readline_lib ; fi
if [ "${use_readline}" = "yes" ]; then test_completion_matches ; fi
if [ "${use_readline}" = "yes" ]; then test_rl_completion_matches ; fi
case "${use_readline}-${has_rl_completion_matches}-${has_completion_matches}" in
yes-yes-* )
READLINE_DEFINE="-DUSE_READLINE=1 ${READLINE_DEFINE} -DUSE_RL_COMPLETION_MATCHES=1"
;;
yes-*-yes )
READLINE_DEFINE="-DUSE_READLINE=1 ${READLINE_DEFINE} -DUSE_RL_COMPLETION_MATCHES=0"
;;
yes-* )
printf "Can't find a completion function in readline\n"
exit 1
;;
no-* )
READLINE_DEFINE="-UUSE_READLINE"
printf "Not using readline\n";
esac
case "${use_dotlock}" in
yes )
DOTLOCK_DEFINE="-DUSE_DOTLOCK=1"
;;
no )
DOTLOCK_DEFINE=""
;;
esac
DEFINES=${DOTLOCK_DEFINE}
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${use_readline}" = "xno" ]; then
lib_readline=""
else
lib_readline="${readline_lib_arg} -lreadline ${extra_readline_libs}"
fi
echo "Generating Makefile"
rm -f Makefile
sed -e "s%@cc@%${MYCC}%; \
s%@cflags@%${MYCFLAGS}%; \
s%@prefix@%${PREFIX}%; \
s%@bindir@%${BINDIR}%; \
s%@mandir@%${MANDIR}%; \
s%@infodir@%${INFODIR}%; \
s%@binext@%${BINEXT}%; \
s%@readline_define@%${READLINE_DEFINE}%; \
s%@defines@%${DEFINES}%; \
s%@inc_readline@%${readline_inc_arg}%; \
s%@lib_readline@%${lib_readline}%; \
" < Makefile.in > Makefile
# =======================================================================
# vim:et:sw=2:ht=2:sts=2:fdm=marker:cms=#%s