2 #########################################################################
4 # $Id: configure,v 1.5.2.2 2004/01/07 00:09:05 richard Exp $
6 # =======================================================================
8 # tdl - A console program for managing to-do lists
10 # Copyright (C) Richard P. Curnow 2003-2004
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of version 2 of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 # General Public License for more details.
21 # You should have received a copy of the GNU General Public License along
22 # with this program; if not, write to the Free Software Foundation, Inc.,
23 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25 # =======================================================================
27 if [ -f config.log ]; then rm -f config.log ; fi
30 if [ "x${CC}" = "x" ]; then
36 if [ "x${CFLAGS}" = "x" ]; then
42 # =======================================================================
47 if [ -f docheck.c ]; then rm -f docheck.c ; fi
48 if [ -f docheck.o ]; then rm -f docheck.o ; fi
49 if [ -f docheck ]; then rm -f docheck ; fi
50 rm -rf docheck.c docheck.o docheck
54 #{{{ test_cc : basic compiler sanity check
56 printf "Testing whether your compiler \"$MYCC $MYCFLAGS\" works : "
59 int main (int argc, char **argv)
64 ${MYCC} ${MYCFLAGS} -o docheck docheck.c 1>&5 2>&5
69 printf "it doesn't work\n"
70 printf "Failed program was\n" 1>&5
72 rm -f docheck.c docheck
78 #{{{ test_readline_include
79 test_readline_include () {
80 # Objective : test whether we can compile and link a program using
81 # readline, and if so how.
83 # As for includes, is it <readline.h> or <readline/readline.h>
85 # As for linking, do we need -ltermcap, -lncurses etc
87 printf "Testing what to include for readline : "
91 int main (int argc, char **argv) {
92 printf("%s\n", rl_library_version);
96 ${MYCC} ${MYCFLAGS} ${readline_inc_arg} -c -o docheck.o docheck.c 1>&5 2>&5
98 printf "<readline.h>\n"
99 READLINE_DEFINE="-DBARE_READLINE_H=1"
102 cat >docheck.c <<EOF;
104 #include <readline/readline.h>
105 int main (int argc, char **argv) {
106 printf("%s\n", rl_library_version);
110 ${MYCC} ${MYCFLAGS} ${readline_inc_arg} -c -o docheck.o docheck.c 1>&5 2>&5
111 if [ $? -eq 0 ]; then
112 printf "<readline/readline.h>\n"
113 READLINE_DEFINE="-DBARE_READLINE_H=0"
116 printf "Can't include readline.h, giving up on readline"
126 #{{{ test_readline_lib
127 test_readline_lib () {
129 printf "Testing extra libraries to link with readline : "
130 cat >docheck.c <<EOF;
133 #include <readline.h>
135 #include <readline/readline.h>
138 int main (int argc, char **argv) {
139 printf("%s\n", rl_library_version);
143 ${MYCC} ${MYCFLAGS} ${readline_inc_arg} ${READLINE_DEFINE} -c -o docheck.o docheck.c 1>&5 2>&5
144 if [ $? -ne 0 ]; then
145 printf "unexpected compile failure, giving up on readline\n"
152 ${MYCC} ${MYCFLAGS} -o docheck docheck.o ${readline_lib_arg} -lreadline 1>&5 2>&5
153 if [ $? -eq 0 ]; then
154 extra_readline_libs=""
160 ${MYCC} ${MYCFLAGS} -o docheck docheck.o ${readline_lib_arg} -lreadline -ltermcap 1>&5 2>&5
161 if [ $? -eq 0 ]; then
162 extra_readline_libs="-ltermcap"
163 printf -- "-ltermcap\n"
168 ${MYCC} ${MYCFLAGS} -o docheck docheck.o ${readline_lib_arg} -lreadline -lncurses 1>&5 2>&5
169 if [ $? -eq 0 ]; then
170 extra_readline_libs="-lncurses"
171 printf -- "-lncurses\n"
176 printf "can't link a readline program\n"
182 #{{{ test_completion_matches
183 test_completion_matches () {
184 # See if the readline library has completion_matches()
186 printf "Testing for completion_matches in readline : "
187 cat >docheck.c <<EOF;
190 #include <readline.h>
192 #include <readline/readline.h>
195 int main (int argc, char **argv) {
196 void *x = &completion_matches;
201 ${MYCC} ${MYCFLAGS} ${readline_inc_arg} ${READLINE_DEFINE} -c -o docheck.o docheck.c 1>&5 2>&5
202 if [ $? -ne 0 ]; then
204 has_completion_matches=no
209 ${MYCC} ${MYCFLAGS} -o docheck docheck.o ${readline_lib_arg} -lreadline ${extra_readline_libs} 1>&5 2>&5
210 if [ $? -eq 0 ]; then
212 has_completion_matches=yes
215 has_completion_matches=no
220 #{{{ test_rl_completion_matches
221 test_rl_completion_matches () {
222 # See if the readline library has completion_matches()
224 printf "Testing for rl_completion_matches in readline : "
225 cat >docheck.c <<EOF;
228 #include <readline.h>
230 #include <readline/readline.h>
233 int main (int argc, char **argv) {
234 void *x = &rl_completion_matches;
239 ${MYCC} ${MYCFLAGS} ${readline_inc_arg} ${READLINE_DEFINE} -c -o docheck.o docheck.c 1>&5 2>&5
240 if [ $? -ne 0 ]; then
242 has_rl_completion_matches=no
247 ${MYCC} ${MYCFLAGS} -o docheck docheck.o ${readline_lib_arg} -lreadline ${extra_readline_libs} 1>&5 2>&5
248 if [ $? -eq 0 ]; then
250 has_rl_completion_matches=yes
253 has_rl_completion_matches=no
262 \`configure' configures tdl to adapt to many kinds of systems.
264 Usage: ./configure [OPTION]...
266 Defaults for the options are specified in brackets.
269 -h, --help display this help and exit
271 Installation directories:
272 --prefix=PREFIX install architecture-independent files in PREFIX
275 By default, \`make install' will install all the files in
276 \`/usr/local/bin', \`/usr/local/lib' etc. You can specify
277 an installation prefix other than \`/usr/local' using \`--prefix',
278 for instance \`--prefix=$HOME'.
280 For better control, use the options below.
281 --without-readline Don't try to use GNU readline
282 --readline-dir=DIR Specify parent of readline include and lib directories
283 --readline-inc-dir=DIR Specify where readline include directory is
284 --readline-lib-dir=DIR Specify where readline lib directory is
286 Fine tuning of the installation directories:
287 --bindir=DIR user executables [EPREFIX/bin]
288 --infodir=DIR info documentation [PREFIX/info]
289 --mandir=DIR man documentation [PREFIX/man]
291 Some influential environment variables:
292 CC C compiler command
293 CFLAGS C compiler flags
294 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
295 nonstandard directory <lib dir>
297 Use these variables to override the choices made by \`configure' or to help
298 it to find libraries and programs with nonstandard names/locations.
300 Report bugs to <rc@rc0.org.uk>.
304 # =======================================================================
306 # Defaults for variables
313 # Parse options to configure
318 --prefix=* | --install-prefix=* )
319 PREFIX=`echo $option | sed -e 's/[^=]*=//;'`
322 BINDIR=`echo $option | sed -e 's/[^=]*=//;'`
325 MANDIR=`echo $option | sed -e 's/[^=]*=//;'`
328 INFODIR=`echo $option | sed -e 's/[^=]*=//;'`
334 readline_dir=`echo $option | sed -e 's/[^=]*=//;'`
336 --readline-inc-dir=* )
337 readline_inc_dir=`echo $option | sed -e 's/[^=]*=//;'`
339 --readline-lib-dir=* )
340 readline_lib_dir=`echo $option | sed -e 's/[^=]*=//;'`
350 printf "Unrecognized option : $option\n"
356 if [ ${bad_options} = yes ]; then
360 #{{{ process readline-related arguments
361 if [ "$use_readline" = "yes" ]; then
362 if [ "x$readline_dir" != "x" ]; then
363 if [ "x$readline_inc_dir" = "x" ]; then
364 readline_inc_dir="${readline_dir}/include"
366 if [ "x$readline_lib_dir" = "x" ]; then
367 readline_lib_dir="${readline_dir}/lib"
371 if [ "x$readline_inc_dir" != "x" ]; then
372 readline_inc_arg="-I${readline_inc_dir}"
377 if [ "x$readline_lib_dir" != "x" ]; then
378 readline_lib_arg="-L${readline_lib_dir} -R${readline_lib_dir}"
386 if [ "${use_readline}" = "yes" ]; then test_readline_include ; fi
387 if [ "${use_readline}" = "yes" ]; then test_readline_lib ; fi
388 if [ "${use_readline}" = "yes" ]; then test_completion_matches ; fi
389 if [ "${use_readline}" = "yes" ]; then test_rl_completion_matches ; fi
391 case "${use_readline}-${has_rl_completion_matches}-${has_completion_matches}" in
393 READLINE_DEFINE="-DUSE_READLINE=1 ${READLINE_DEFINE} -DUSE_RL_COMPLETION_MATCHES=1"
396 READLINE_DEFINE="-DUSE_READLINE=1 ${READLINE_DEFINE} -DUSE_RL_COMPLETION_MATCHES=0"
399 printf "Can't find a completion function in readline\n"
403 READLINE_DEFINE="-UUSE_READLINE"
404 printf "Not using readline\n";
407 case "${use_dotlock}" in
409 DOTLOCK_DEFINE="-DUSE_DOTLOCK=1"
416 DEFINES=${DOTLOCK_DEFINE}
418 if [ "x" = "x${BINDIR}" ]; then BINDIR=${PREFIX}/bin ; fi
419 if [ "x" = "x${MANDIR}" ]; then MANDIR=${PREFIX}/man ; fi
420 if [ "x" = "x${INFODIR}" ]; then INFODIR=${PREFIX}/info ; fi
422 if [ "x${use_readline}" = "xno" ]; then
425 lib_readline="${readline_lib_arg} -lreadline ${extra_readline_libs}"
428 echo "Generating Makefile"
431 sed -e "s%@cc@%${MYCC}%; \
432 s%@cflags@%${MYCFLAGS}%; \
433 s%@prefix@%${PREFIX}%; \
434 s%@bindir@%${BINDIR}%; \
435 s%@mandir@%${MANDIR}%; \
436 s%@infodir@%${INFODIR}%; \
437 s%@readline_define@%${READLINE_DEFINE}%; \
438 s%@defines@%${DEFINES}%; \
439 s%@inc_readline@%${readline_inc_arg}%; \
440 s%@lib_readline@%${lib_readline}%; \
441 " < Makefile.in > Makefile
443 # =======================================================================
444 # vim:et:sw=2:ht=2:sts=2:fdm=marker:cms=#%s