From 87b050c8552f5b45c870b8c942ca67fe1da363a5 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 27 Dec 1999 11:49:30 +0000 Subject: [PATCH] Major speed improvement. --- Makefile.in | 42 +-- configure | 840 +++++++++++++++++++++++++++++++--------------------------- configure.in | 142 +++++++--- robot.tcl | 373 +++++++++++++++++--------- 4 files changed, 834 insertions(+), 563 deletions(-) diff --git a/Makefile.in b/Makefile.in index 0deff2f..a764669 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # Makefile for Tcl Web Robot -# $Id: Makefile.in,v 1.3 1999/02/04 21:32:00 adam Exp $ +# $Id: Makefile.in,v 1.4 1999/12/27 11:49:30 adam Exp $ SHELL=/bin/sh # Version @@ -11,38 +11,46 @@ prefix=@prefix@ # Directory prefix with machine dependent files exec_prefix=@exec_prefix@ +# RPM Root +BUILD=@build_root@ + +# Install directories BINDIR=$(exec_prefix)/bin LIBDIR=$(exec_prefix)/lib +MANDIR=$(prefix)/man +INCDIR=$(prefix)/include LIBRARY=@(prefix)/lib/tclrobot +CC=@CC@ + +# Tcl libraries and include files TCLLIB=@TCLLIB@ TCLINC=@TCLINC@ -TKLIB=@TKLIB@ -TKINC=@TKINC@ -INCLUDE=$(TCLINC) -DEFS=$(INCLUDE) +# Shared libraries definitions +SHLIB_LD = @SHLIB_LD@ +SHLIB_CFLAGS = @SHLIB_CFLAGS@ +SHLIB_SUFFIX = @SHLIB_SUFFIX@ +SHLIB_VERSION = @SHLIB_VERSION@ +# Other programs INSTALL=@INSTALL@ INSTALL_PROGRAM=@INSTALL_PROGRAM@ INSTALL_DATA=@INSTALL_DATA@ RANLIB=@RANLIB@ -CC=@CC@ -SHLIB_LD = @SHLIB_LD@ -SHLIB_CFLAGS = @SHLIB_CFLAGS@ -SHLIB_SUFFIX = @SHLIB_SUFFIX@ -SHLIB_VERSION = @SHLIB_VERSION@ +# Where are Yaz libraries located? +YAZLIB=@YAZLIB@ +# Where are Yaz header files located? +YAZINC=@YAZINC@ -O=hswitch.o init.o +# Total include +INCLUDE=-I. $(YAZINC) $(TCLINC) -tclrobot: tclrobot.a tclmain.o - $(CC) -o tclrobot $(CFLAGS) tclmain.o tclrobot.a $(TCLLIB) +# All CC options, except CFLAGS +DEFS=@DEFS@ $(INCLUDE) -tclrobot.a: $(O) - rm -f tclrobot.a - ar cr tclrobot.a $(O) - $(RANLIB) tclrobot.a +O=hswitch.o init.o tclrobot$(SHLIB_SUFFIX): $(O) $(SHLIB_LD) -o tclrobot$(SHLIB_SUFFIX) $(O) diff --git a/configure b/configure index 28cbc14..9ac06b3 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -11,6 +11,12 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: +ac_help="$ac_help + --with-buildroot RPM Build root" +ac_help="$ac_help + --with-tclconfig Path for tclConfig.sh/tkConfig.sh" +ac_help="$ac_help + --with-yazconfig Path for yaz-config" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -49,6 +55,7 @@ mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -332,7 +339,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" + echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) @@ -450,7 +457,7 @@ echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=tclrobot.h +ac_unique_file=hswitch.c # Find the source files, if location was not specified. if test -z "$srcdir"; then @@ -502,9 +509,11 @@ ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -526,6 +535,16 @@ fi + + +# Check whether --with-build-root or --without-build-root was given. +if test "${with_build_root+set}" = set; then + withval="$with_build_root" + build_root=$withval +else + build_root="" +fi + ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then @@ -552,28 +571,30 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:560: checking for a BSD compatible install" >&5 +echo "configure:580: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. : else ac_cv_path_install="$ac_dir/$ac_prog -c" @@ -603,226 +624,86 @@ echo "$ac_t""$INSTALL" 1>&6 # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:612: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:641: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 +tclconfig=NONE +tryprefix=NONE +# Check whether --with-tclconfig or --without-tclconfig was given. +if test "${with_tclconfig+set}" = set; then + withval="$with_tclconfig" + tclconfig=$withval fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 +if test "x$tclconfig" = xNONE; then + saveprefix=${prefix} + if test "x$prefix" = xNONE; then +echo $ac_n "checking for prefix by $ac_c" 1>&6 +# Extract the first word of "tclsh", so it can be a program name with args. +set dummy tclsh; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:670: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:647: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - ac_prog_rejected=no - for ac_dir in $PATH; do + case "$TCLSH" in + /*) + ac_cv_path_TCLSH="$TCLSH" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_TCLSH="$TCLSH" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" + ac_cv_path_TCLSH="$ac_dir/$ac_word" break fi done IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi + ;; +esac fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 +TCLSH="$ac_cv_path_TCLSH" +if test -n "$TCLSH"; then + echo "$ac_t""$TCLSH" 1>&6 else echo "$ac_t""no" 1>&6 fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:718: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:752: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:757: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes - ac_test_CFLAGS="${CFLAGS+set}" - ac_save_CFLAGS="$CFLAGS" - CFLAGS= - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:781: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes -else - ac_cv_prog_cc_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 - if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" - elif test $ac_cv_prog_cc_g = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-O2" + if test -n "$ac_cv_path_TCLSH"; then + prefix=`echo $ac_cv_path_TCLSH|sed 's%/[^/][^/]*//*[^/][^/]*$%%'` fi -else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" fi -if test "x$prefix" = xNONE; then + if test "x$prefix" = xNONE; then + if test "x$prefix" = xNONE; then echo $ac_n "checking for prefix by $ac_c" 1>&6 -# Extract the first word of "tclsh", so it can be a program name with args. -set dummy tclsh; ac_word=$2 +# Extract the first word of "tclsh8.2", so it can be a program name with args. +set dummy tclsh8.2; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:813: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then +echo "configure:690: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_TCLSH8.2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - case "$TCLSH" in + case "$TCLSH8.2" in /*) - ac_cv_path_TCLSH="$TCLSH" # Let the user override the test with a path. + ac_cv_path_TCLSH8.2="$TCLSH8.2" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_TCLSH8.2="$TCLSH8.2" # Let the user override the test with a dos path. ;; *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then - ac_cv_path_TCLSH="$ac_dir/$ac_word" + ac_cv_path_TCLSH8.2="$ac_dir/$ac_word" break fi done @@ -830,25 +711,26 @@ else ;; esac fi -TCLSH="$ac_cv_path_TCLSH" -if test -n "$TCLSH"; then - echo "$ac_t""$TCLSH" 1>&6 +TCLSH8.2="$ac_cv_path_TCLSH8.2" +if test -n "$TCLSH8.2"; then + echo "$ac_t""$TCLSH8.2" 1>&6 else echo "$ac_t""no" 1>&6 fi - if test -n "$ac_cv_path_TCLSH"; then - prefix=`echo $ac_cv_path_TCLSH|sed 's%/[^/][^/]*//*[^/][^/]*$%%'` + if test -n "$ac_cv_path_TCLSH8.2"; then + prefix=`echo $ac_cv_path_TCLSH8.2|sed 's%/[^/][^/]*//*[^/][^/]*$%%'` fi fi -if test "x$prefix" = xNONE; then - if test "x$prefix" = xNONE; then + fi + if test "x$prefix" = xNONE; then + if test "x$prefix" = xNONE; then echo $ac_n "checking for prefix by $ac_c" 1>&6 # Extract the first word of "tclsh8.1", so it can be a program name with args. set dummy tclsh8.1; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:852: checking for $ac_word" >&5 +echo "configure:734: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TCLSH8.1'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -856,9 +738,13 @@ else /*) ac_cv_path_TCLSH8.1="$TCLSH8.1" # Let the user override the test with a path. ;; + ?:/*) + ac_cv_path_TCLSH8.1="$TCLSH8.1" # Let the user override the test with a dos path. + ;; *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_path_TCLSH8.1="$ac_dir/$ac_word" @@ -881,14 +767,14 @@ fi fi fi -fi -if test "x$prefix" = xNONE; then - if test "x$prefix" = xNONE; then + fi + if test "x$prefix" = xNONE; then + if test "x$prefix" = xNONE; then echo $ac_n "checking for prefix by $ac_c" 1>&6 # Extract the first word of "tclsh8.0", so it can be a program name with args. set dummy tclsh8.0; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:892: checking for $ac_word" >&5 +echo "configure:778: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TCLSH8.0'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -896,9 +782,13 @@ else /*) ac_cv_path_TCLSH8.0="$TCLSH8.0" # Let the user override the test with a path. ;; + ?:/*) + ac_cv_path_TCLSH8.0="$TCLSH8.0" # Let the user override the test with a dos path. + ;; *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_path_TCLSH8.0="$ac_dir/$ac_word" @@ -921,14 +811,14 @@ fi fi fi -fi -if test "x$prefix" = xNONE; then - if test "x$prefix" = xNONE; then + fi + if test "x$prefix" = xNONE; then + if test "x$prefix" = xNONE; then echo $ac_n "checking for prefix by $ac_c" 1>&6 # Extract the first word of "tclsh7.6", so it can be a program name with args. set dummy tclsh7.6; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:932: checking for $ac_word" >&5 +echo "configure:822: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TCLSH7.6'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -936,9 +826,13 @@ else /*) ac_cv_path_TCLSH7.6="$TCLSH7.6" # Let the user override the test with a path. ;; + ?:/*) + ac_cv_path_TCLSH7.6="$TCLSH7.6" # Let the user override the test with a dos path. + ;; *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_path_TCLSH7.6="$ac_dir/$ac_word" @@ -961,14 +855,14 @@ fi fi fi -fi -if test "x$prefix" = xNONE; then - if test "x$prefix" = xNONE; then + fi + if test "x$prefix" = xNONE; then + if test "x$prefix" = xNONE; then echo $ac_n "checking for prefix by $ac_c" 1>&6 # Extract the first word of "tclsh7.5", so it can be a program name with args. set dummy tclsh7.5; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:972: checking for $ac_word" >&5 +echo "configure:866: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TCLSH7.5'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -976,9 +870,13 @@ else /*) ac_cv_path_TCLSH7.5="$TCLSH7.5" # Let the user override the test with a path. ;; + ?:/*) + ac_cv_path_TCLSH7.5="$TCLSH7.5" # Let the user override the test with a dos path. + ;; *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_path_TCLSH7.5="$ac_dir/$ac_word" @@ -1001,204 +899,371 @@ fi fi fi + fi + if test "x$prefix" = xNONE; then + prefix=/usr/local + fi + tclconfig=${prefix}/lib + tryprefix=${prefix} + prefix=${saveprefix} fi -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1007: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then +if test -r ${tclconfig}/tclConfig.sh; then + echo $ac_n "checking for Tcl""... $ac_c" 1>&6 +echo "configure:913: checking for Tcl" >&5 + . ${tclconfig}/tclConfig.sh + TCLLIB="${TCL_LIB_SPEC} ${TCL_LIBS}" + TCLINC=-I${TCL_PREFIX}/include + RANLIB=$TCL_RANLIB + SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS + SHLIB_LD=$TCL_SHLIB_LD + SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX + SHLIB_VERSION=$TCL_SHLIB_VERSION + echo "$ac_t""$TCL_VERSION" 1>&6 + CC=$TCL_CC +else + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:928: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1028: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1045: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:958: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi fi -rm -f conftest* fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" fi - CPP="$ac_cv_prog_CPP" +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 else - ac_cv_prog_CPP="$CPP" + echo "$ac_t""no" 1>&6 fi -echo "$ac_t""$CPP" 1>&6 -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1068: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1009: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - cat > conftest.$ac_ext <&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:1041: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 1052 "configure" #include "confdefs.h" -#include -#include -#include -#include + +main(){return(0);} EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1081: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes +if { (eval echo configure:1057: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi else - echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no + ac_cv_prog_cc_works=no fi -rm -f conftest* +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:1083: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:1088: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5 | - egrep "memchr" >/dev/null 2>&1; then - : +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1097: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes else - rm -rf conftest* - ac_cv_header_stdc=no + ac_cv_prog_gcc=no +fi fi -rm -f conftest* +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= fi -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:1116: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else - rm -rf conftest* - ac_cv_header_stdc=no + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no fi rm -f conftest* fi -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi else - cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi -EOF -if { (eval echo configure:1148: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -then - : + SHLIB_CFLAGS="" + SHLIB_LD="shared-linker" + SHLIB_SUFFIX="" + SHLIB_VERSION="" + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1154: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no -fi -rm -fr conftest* + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" fi - fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 fi -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - + echo $ac_n "checking for Tcl""... $ac_c" 1>&6 +echo "configure:1182: checking for Tcl" >&5 + TCL_VERSION=nope + for i in "" 7.4 7.5 7.6 8.0; do + if test -r ${tryprefix}/lib/libtcl${i}.a; then + TCL_VERSION=$i + fi + done + if test "$TCL_VERSION" = nope; then + echo "configure: warning: Didn't find Tcl" 1>&2 + TCL_LIB_SPEC=-ltcl + TCLINC=" # -I.. Tcl/Tk include path" + else + if test "$TCL_VERSION" = ""; then + echo "$ac_t""7.3" 1>&6 + else + echo "$ac_t""$TCL_VERSION" 1>&6 + fi + TCL_LIB_SPEC=${tryprefix}/lib/libtcl${TCL_VERSION}.a + TCLINC=-I${tryprefix}/include + fi + TCLLIB="${TCL_LIB_SPEC} ${LIBS} -lm" fi - -if test "$ac_cv_header_stdc" = no; then - echo "configure: warning: Your system doesn't seem to support ANSI C" 1>&2 +yazconfig=NONE +yazpath=NONE +# Check whether --with-yazconfig or --without-yazconfig was given. +if test "${with_yazconfig+set}" = set; then + withval="$with_yazconfig" + yazpath=$withval fi -if test "x$prefix" = xNONE; then - tryprefix=/usr/local + +if test "x$yazpath" != "xNONE"; then + yazconfig=$yazpath/yaz-config else - tryprefix=${prefix} + for i in ../yaz* ../yaz; do + if test -d $i; then + if test -r $i/include/yaz/yaz-version.h; then + yazconfig=$i/yaz-config + fi + fi + done + if test "x$yazconfig" = "xNONE"; then + # Extract the first word of "yaz-config", so it can be a program name with args. +set dummy yaz-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1226: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_yazconfig'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$yazconfig" in + /*) + ac_cv_path_yazconfig="$yazconfig" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_yazconfig="$yazconfig" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_yazconfig="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_yazconfig" && ac_cv_path_yazconfig="NONE" + ;; +esac fi -if test -r ${tryprefix}/lib/tclConfig.sh; then - echo $ac_n "checking for Tcl""... $ac_c" 1>&6 -echo "configure:1181: checking for Tcl" >&5 - . ${tryprefix}/lib/tclConfig.sh - TCLLIB="${TCL_LIB_SPEC} ${TCL_LIBS}" - TCLINC=-I${TCL_PREFIX}/include - RANLIB=${TCL_RANLIB} - SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS - SHLIB_LD=$TCL_SHLIB_LD - SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX - SHLIB_VERSION=$TCL_SHLIB_VERSION - echo "$ac_t""$TCL_VERSION" 1>&6 +yazconfig="$ac_cv_path_yazconfig" +if test -n "$yazconfig"; then + echo "$ac_t""$yazconfig" 1>&6 else - echo "configure: warning: Didn't find Tcl" 1>&2 + echo "$ac_t""no" 1>&6 fi -echo $ac_n "checking for Tk""... $ac_c" 1>&6 -echo "configure:1195: checking for Tk" >&5 -if test -r ${tryprefix}/lib/tkConfig.sh; then - . ${tryprefix}/lib/tkConfig.sh - echo "$ac_t""$TK_VERSION" 1>&6 - TKINC=${TK_XINCLUDES} - TKLIB="${TK_PREFIX}/lib/${TK_LIB_FILE} ${TK_LIBS}" + + fi +fi +echo $ac_n "checking for YAZ""... $ac_c" 1>&6 +echo "configure:1262: checking for YAZ" >&5 +if test -r $yazconfig; then + . $yazconfig + echo "$ac_t""$yazconfig" 1>&6 else - echo "configure: warning: Didn't find Tk" 1>&2 + echo "$ac_t""Not found" 1>&6 fi trap '' 1 2 15 cat > confcache <<\EOF @@ -1223,7 +1288,7 @@ EOF # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -1302,7 +1367,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -1322,9 +1387,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF $ac_vpsub $extrasub +s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g @@ -1343,24 +1410,27 @@ s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g +s%@CC@%$CC%g s%@TCLLIB@%$TCLLIB%g -s%@TKLIB@%$TKLIB%g s%@TCLINC@%$TCLINC%g -s%@TKINC@%$TKINC%g s%@SHLIB_CFLAGS@%$SHLIB_CFLAGS%g s%@SHLIB_LD@%$SHLIB_LD%g s%@SHLIB_SUFFIX@%$SHLIB_SUFFIX%g s%@SHLIB_VERSION@%$SHLIB_VERSION%g +s%@YAZLIB@%$YAZLIB%g +s%@YAZINC@%$YAZINC%g +s%@build_root@%$build_root%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@RANLIB@%$RANLIB%g -s%@CC@%$CC%g s%@TCLSH@%$TCLSH%g +s%@TCLSH8.2@%$TCLSH8.2%g s%@TCLSH8.1@%$TCLSH8.1%g s%@TCLSH8.0@%$TCLSH8.0%g s%@TCLSH7.6@%$TCLSH7.6%g s%@TCLSH7.5@%$TCLSH7.5%g -s%@CPP@%$CPP%g +s%@RANLIB@%$RANLIB%g +s%@yazconfig@%$yazconfig%g CEOF EOF diff --git a/configure.in b/configure.in index 5f22980..66ba230 100644 --- a/configure.in +++ b/configure.in @@ -1,66 +1,122 @@ -dnl Web robot toolkit for tcl -dnl (c) Index Data 1996-1998 +dnl (c) Index Data 1996-2000 dnl See the file LICENSE for details. -dnl $Id: configure.in,v 1.3 1999/02/04 21:32:02 adam Exp $ -AC_INIT(tclrobot.h) +dnl $Id: configure.in,v 1.4 1999/12/27 11:49:31 adam Exp $ +AC_INIT(hswitch.c) dnl ------ Substitutions +AC_SUBST(CC) AC_SUBST(TCLLIB) -AC_SUBST(TKLIB) AC_SUBST(TCLINC) -AC_SUBST(TKINC) AC_SUBST(SHLIB_CFLAGS) AC_SUBST(SHLIB_LD) AC_SUBST(SHLIB_SUFFIX) AC_SUBST(SHLIB_VERSION) +AC_SUBST(YAZLIB) +AC_SUBST(YAZINC) +dnl +dnl ------ Build root +AC_SUBST(build_root) +AC_ARG_WITH(build-root, [ --with-buildroot RPM Build root],[build_root=$withval],[build_root=""]) +dnl dnl ------ Preliminary settings AC_PROG_INSTALL -AC_PROG_RANLIB -AC_PROG_CC -AC_PREFIX_PROGRAM(tclsh) -if test "x$prefix" = xNONE; then - AC_PREFIX_PROGRAM(tclsh8.1) -fi -if test "x$prefix" = xNONE; then - AC_PREFIX_PROGRAM(tclsh8.0) -fi -if test "x$prefix" = xNONE; then - AC_PREFIX_PROGRAM(tclsh7.6) -fi -if test "x$prefix" = xNONE; then - AC_PREFIX_PROGRAM(tclsh7.5) -fi -AC_STDC_HEADERS -if test "$ac_cv_header_stdc" = no; then - AC_MSG_WARN(Your system doesn't seem to support ANSI C) -fi dnl ------ look for Tcl -if test "x$prefix" = xNONE; then - tryprefix=/usr/local -else +tclconfig=NONE +tryprefix=NONE +AC_ARG_WITH(tclconfig, [ --with-tclconfig Path for tclConfig.sh/tkConfig.sh], [tclconfig=$withval]) +if test "x$tclconfig" = xNONE; then + saveprefix=${prefix} + AC_PREFIX_PROGRAM(tclsh) + if test "x$prefix" = xNONE; then + AC_PREFIX_PROGRAM(tclsh8.2) + fi + if test "x$prefix" = xNONE; then + AC_PREFIX_PROGRAM(tclsh8.1) + fi + if test "x$prefix" = xNONE; then + AC_PREFIX_PROGRAM(tclsh8.0) + fi + if test "x$prefix" = xNONE; then + AC_PREFIX_PROGRAM(tclsh7.6) + fi + if test "x$prefix" = xNONE; then + AC_PREFIX_PROGRAM(tclsh7.5) + fi + if test "x$prefix" = xNONE; then + prefix=/usr/local + fi + tclconfig=${prefix}/lib tryprefix=${prefix} + prefix=${saveprefix} fi -if test -r ${tryprefix}/lib/tclConfig.sh; then +if test -r ${tclconfig}/tclConfig.sh; then AC_MSG_CHECKING(for Tcl) - . ${tryprefix}/lib/tclConfig.sh + . ${tclconfig}/tclConfig.sh TCLLIB="${TCL_LIB_SPEC} ${TCL_LIBS}" TCLINC=-I${TCL_PREFIX}/include - RANLIB=${TCL_RANLIB} - SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS + RANLIB=$TCL_RANLIB + SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS SHLIB_LD=$TCL_SHLIB_LD - SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX - SHLIB_VERSION=$TCL_SHLIB_VERSION + SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX + SHLIB_VERSION=$TCL_SHLIB_VERSION AC_MSG_RESULT($TCL_VERSION) + CC=$TCL_CC +else + AC_PROG_CC + SHLIB_CFLAGS="" + SHLIB_LD="shared-linker" + SHLIB_SUFFIX="" + SHLIB_VERSION="" + AC_PROG_RANLIB + AC_MSG_CHECKING(for Tcl) + TCL_VERSION=nope + for i in "" 7.4 7.5 7.6 8.0; do + if test -r ${tryprefix}/lib/libtcl${i}.a; then + TCL_VERSION=$i + fi + done + if test "$TCL_VERSION" = nope; then + AC_MSG_WARN(Didn't find Tcl) + TCL_LIB_SPEC=-ltcl + TCLINC=" # -I.. Tcl/Tk include path" + else + if test "$TCL_VERSION" = ""; then + AC_MSG_RESULT(7.3) + else + AC_MSG_RESULT($TCL_VERSION) + fi + TCL_LIB_SPEC=${tryprefix}/lib/libtcl${TCL_VERSION}.a + TCLINC=-I${tryprefix}/include + fi + TCLLIB="${TCL_LIB_SPEC} ${LIBS} -lm" +fi +dnl +dnl ------ Look for Yaz +dnl See if user specified location of yaz-config; otherwise +dnl use ../yaz if is a directory (internal development); otherwise +dnl use yaz-config found in PATH. +yazconfig=NONE +yazpath=NONE +AC_ARG_WITH(yazconfig, [ --with-yazconfig Path for yaz-config], [yazpath=$withval]) +if test "x$yazpath" != "xNONE"; then + yazconfig=$yazpath/yaz-config else - AC_MSG_WARN(Didn't find Tcl) + for i in ../yaz* ../yaz; do + if test -d $i; then + if test -r $i/include/yaz/yaz-version.h; then + yazconfig=$i/yaz-config + fi + fi + done + if test "x$yazconfig" = "xNONE"; then + AC_PATH_PROG(yazconfig, yaz-config, NONE) + fi fi -dnl ------ look for Tk -AC_MSG_CHECKING(for Tk) -if test -r ${tryprefix}/lib/tkConfig.sh; then - . ${tryprefix}/lib/tkConfig.sh - AC_MSG_RESULT($TK_VERSION) - TKINC=${TK_XINCLUDES} - TKLIB="${TK_PREFIX}/lib/${TK_LIB_FILE} ${TK_LIBS}" +AC_MSG_CHECKING(for YAZ) +if test -r $yazconfig; then + . $yazconfig + AC_MSG_RESULT($yazconfig) else - AC_MSG_WARN(Didn't find Tk) + AC_MSG_RESULT(Not found) fi +dnl AC_OUTPUT(Makefile) diff --git a/robot.tcl b/robot.tcl index c539a04..ab3cef4 100755 --- a/robot.tcl +++ b/robot.tcl @@ -1,5 +1,5 @@ #!/usr/bin/tclsh -# $Id: robot.tcl,v 1.4 1999/02/04 20:37:25 perhans Exp $ +# $Id: robot.tcl,v 1.5 1999/12/27 11:49:31 adam Exp $ # proc RobotFileNext {area} { if {[catch {set ns [glob ${area}/*]}]} { @@ -7,6 +7,7 @@ proc RobotFileNext {area} { } set off [string first / $area] incr off + foreach n $ns { if {[file isfile $n]} { if {[string first :.html $n] > 0} { @@ -30,6 +31,10 @@ proc RobotFileExist {area host path} { incr l -1 if {![string length [lindex $comp $l]]} { set comp [split $area/$host$path:.html /] + } elseif {[file exists [join $comp /]]} { + return 1 + } else { + set comp [split $area/$host$path/:.html /] } return [file exists [join $comp /]] } @@ -52,7 +57,14 @@ proc RobotFileUnlink {area host path} { proc RobotFileOpen {area host path} { set orgPwd [pwd] + global workdir + #puts "RobotFileOpen orgPwd=$orgPwd area=$area host=$host path=$path" + if {[string compare $orgPwd $workdir]} { + puts "workdir = $workdir" + puts "pwd = $orgPwd" + exit 1 + } set comp [split $area/$host$path /] set len [llength $comp] incr len -1 @@ -70,17 +82,22 @@ proc RobotFileOpen {area host path} { set out [open :.html w] } cd $orgPwd + #puts "RobotFileStop" return $out } proc RobotRestart {} { global URL - + while {1} { set url [RobotFileNext unvisited] - if {![string length $url]} break + if {![string length $url]} { + puts "No more unvisited" + break + } set r [RobotGetUrl $url {}] if {!$r} { + puts "RobotGetUrl returned 0 on url=$url" return } else { RobotFileUnlink unvisited $URL($url,host) $URL($url,path) @@ -91,7 +108,7 @@ proc RobotRestart {} { proc headSave {url out title} { global URL - + puts $out {} puts $out "$title" if {[info exists URL($url,head,last-modified)]} { @@ -116,13 +133,122 @@ proc headSave {url out title} { puts $out {} } -proc RobotSave {url} { +proc RobotHref {url hrefx hostx pathx} { + global URL domains + upvar $hrefx href + upvar $hostx host + upvar $pathx path + + # puts "Ref url = $url href=$href" + # get method (if any) + if {![regexp {^([^/:]+):(.*)} $href x method hpath]} { + set hpath $href + set method http + } else { + if {[string compare $method http]} { + return 0 + } + } + # get host (if any) + if {![regexp {^//([^/]+)(.*)} $hpath x host epath]} { + set epath $hpath + set host $URL($url,host) + } else { + if {![string length $epath]} { + set epath / + } + set ok 0 + foreach domain $domains { + if {[string match $domain $host]} { + set ok 1 + break + } + } + if {!$ok} { + return 0 + } + } + if {[regexp {^(\#|\?)} $epath]} { + # within page + return 0 + } elseif {![regexp {^([/][^\#?]*)} $epath x path]} { + # relative path + set ext [file extension $URL($url,path)] + if {[string compare $ext {}]} { + set dpart [file dirname $URL($url,path)] + } else { + set dpart $URL($url,path) + } + regexp {^([^\#?]+)} $epath x path + set path [string trimright $dpart /]/$path + } + set c [split $path /] + set i [llength $c] + incr i -1 + set path [lindex $c $i] + incr i -1 + while {$i >= 0} { + switch -- [lindex $c $i] { + .. { + incr i -2 + } + . { + incr i -1 + } + default { + set path [lindex $c $i]/$path + incr i -1 + } + } + } + set href "$method://$host$path" + # puts "Ref href = $href" + return 1 +} + +proc Robot401 {url} { + global URL + + puts "Bad link $url" + RobotFileUnlink unvisited $URL($url,host) $URL($url,path) + if {![RobotFileExist forbidden $URL($url,host) $URL($url,path)]} { + set outf [RobotFileOpen forbidden $URL($url,host) $URL($url,path)] + close $outf + } +} + +proc Robot404 {url} { + global URL + + puts "Bad link $url" + RobotFileUnlink unvisited $URL($url,host) $URL($url,path) + if {![RobotFileExist bad $URL($url,host) $URL($url,path)]} { + set outf [RobotFileOpen bad $URL($url,host) $URL($url,path)] + close $outf + } +} + +proc Robot301 {url tourl} { + global URL + + puts "Redirecting from $url to $tourl" + RobotFileUnlink unvisited $URL($url,host) $URL($url,path) + if {[RobotHref $url tourl host path]} { + if {![RobotFileExist unvisited $host $path]} { + set outf [RobotFileOpen unvisited $host $path] + close $outf + } + } +} + +proc Robot200 {url} { global URL domains + # puts "Parsing $url" set out [RobotFileOpen visited $URL($url,host) $URL($url,path)] set ti 0 - if {[info exists URL($url,line)]} { - set htmlContent [join $URL($url,line) \n] + if {[info exists URL($url,buf)]} { + set htmlContent $URL($url,buf) htmlSwitch $htmlContent \ title { @@ -145,130 +271,136 @@ proc RobotSave {url} { headSave $url $out "untitled" set ti 1 } - - if {[regexp {^\#} $parm(href)]} { - continue - } elseif {[regexp {^([^:]+):([^#]+)} $parm(href) x method hpath]} { - set ok 0 - if {![string compare $method http]} { - if {![regexp {^//([^/]+)(.*)} $hpath x host path]} { - set host $URL($url,host) - set path $hpath - } - foreach domain $domains { - if {[string match $domain $host]} { - set ok 1 - break - } - } - } - if {!$ok} continue - } elseif {[regexp {^([/~][^#]*)} $parm(href) x path]} { - set host $URL($url,host) - set method http - } else { - set ext [file extension $URL($url,path)] - if {[string compare $ext {}]} { - set dpart [file dirname $URL($url,path)] - } else { - set dpart $URL($url,path) - } - regexp {^([^#]+)} $parm(href) x path - set host $URL($url,host) - set path [string trimright $dpart /]/$path - set method http - } - set ext [file extension $path] - if {![string length $ext]} { - set path [string trimright $path /]/ - } else { - set path [string trimright $path /] - } - set c [split $path /] - set i [llength $c] - incr i -1 - set path [lindex $c $i] - incr i -1 - while {$i >= 0} { - switch -- [lindex $c $i] { - .. { - incr i -2 - } - . { - incr i -1 - } - default { - set path [lindex $c $i]/$path - incr i -1 - } - } - } - set href "$method://$host$path" - - puts $out "" - puts $out "$href" - puts $out "$body" - puts $out "" - - if {![regexp {/.*bin/} $href)]} { - if {![RobotFileExist visited $host $path]} { - set outf [RobotFileOpen unvisited $host $path] - close $outf - } - } + if {1} { + set href $parm(href) + if {![RobotHref $url href host path]} continue + + puts $out "" + puts $out "$href" + puts $out "$body" + puts $out "" + + if {![RobotFileExist visited $host $path]} { + if {[catch {set outf [RobotFileOpen unvisited $host $path]} msg]} { + puts "--- Error $msg" + exit 1 + } + close $outf + } + } } } if {!$ti} { - headSave $url $out "untitled" - set ti 1 + headSave $url $out "untitled" + set ti 1 } puts $out "" close $out + # puts "Parsing done" RobotFileUnlink unvisited $URL($url,host) $URL($url,path) } -proc RobotRead {url sock} { +proc RobotReadBody {url sock} { global URL - set readCount [gets $sock line] - if {$readCount < 0} { - if [eof $sock] { - close $sock - RobotSave $url - RobotRestart - } - } elseif {$readCount > 0} { - switch $URL($url,state) { - head { - puts "head: $line" - if {[regexp {([^:]+):[ ]+(.*)} $line x name value]} { - set URL($url,head,[string tolower $name]) $value - } - } - html { - lappend URL($url,line) $line - } - skip { - close $sock - RobotSave $url - RobotRestart - } - } + set buffer [read $sock 16384] + set readCount [string length $buffer] + + if {$readCount <= 0} { + close $sock + Robot200 $url + RobotRestart } else { - set URL($url,state) html - if {[info exists URL($url,head,content-type)]} { - if {![string compare $URL($url,head,content-type) text/html]} { - set URL($url,state) html - } - } + # puts "Got $readCount bytes" + set URL($url,buf) $URL($url,buf)$buffer + } +} + +proc RobotReadHead {url sock} { + global URL + + set buffer [read $sock 8192] + set readCount [string length $buffer] + + if {$readCount <= 0} { + Robot404 $url + close $sock + RobotRestart + } else { + # puts "Got $readCount bytes" + set URL($url,buf) $URL($url,buf)$buffer + + set n [string first \n\n $URL($url,buf)] + if {$n > 1} { + set code 0 + set version {} + set headbuf [string range $URL($url,buf) 0 $n] + incr n + incr n + set URL($url,buf) [string range $URL($url,buf) $n end] + + regexp {^HTTP/([0-9.]+)[ ]+([0-9]+)} $headbuf x version code + set lines [split $headbuf \n] + foreach line $lines { + if {[regexp {^([^:]+):[ ]+(.*)} $line x name value]} { + set URL($url,head,[string tolower $name]) $value + } + } + puts "code = $code" + set URL($url,state) skip + switch $code { + 301 { + Robot301 $url $URL($url,head,location) + close $sock + RobotRestart + } + 302 { + Robot301 $url $URL($url,head,location) + close $sock + RobotRestart + } + 404 { + Robot404 $url + close $sock + RobotRestart + } + 401 { + Robot401 $url + close $sock + RobotRestart + } + 200 { + if {[info exists URL($url,head,content-type)]} { + if {![string compare $URL($url,head,content-type) text/html]} { + set URL($url,state) html + } + } + if {[string compare $URL($url,state) html]} { + close $sock + Robot200 $url + RobotRestart + } else { + fileevent $sock readable [list RobotReadBody $url $sock] + } + } + default { + Robot404 $url + close $sock + RobotRestart + } + } + } } } proc RobotConnect {url sock} { global URL - fileevent $sock readable [list RobotRead $url $sock] + fconfigure $sock -translation {auto crlf} -blocking 0 + puts "Reading $url" + fileevent $sock readable [list RobotReadHead $url $sock] puts $sock "GET $URL($url,path) HTTP/1.0" + puts $sock "Host: $URL($url,host)" puts $sock "" flush $sock } @@ -279,23 +411,24 @@ proc RobotNop {} { proc RobotGetUrl {url phost} { global URL - set port 80 puts "---------" puts $url - if {[regexp {([^:]+)://([^/]+)([^ ]*)} $url x method host path]} { - puts "method=$method host=$host path=$path" - } else { + if {![regexp {([^:]+)://([^/]+)([^ ]*)} $url x method hostport path]} { return -1 } + if {![regexp {([^:]+):([0-9]+)} $hostport x host port]} { + set port 80 + set host $hostport + } set URL($url,method) $method set URL($url,host) $host set URL($url,port) $port set URL($url,path) $path set URL($url,state) head + set URL($url,buf) {} if [catch {set sock [socket -async $host $port]}] { return -1 } - fconfigure $sock -translation {auto crlf} RobotConnect $url $sock return 0 @@ -304,7 +437,7 @@ proc RobotGetUrl {url phost} { if {![llength [info commands htmlSwitch]]} { set e [info sharedlibextension] if {[catch {load ./tclrobot$e}]} { - load tclrobot$e + load tclrobot$e } } @@ -313,6 +446,9 @@ if {[llength $argv] < 2} { puts " Example: '*.dk' www.indexdata.dk" exit 1 } + +set workdir [pwd] + set domains [lindex $argv 0] set site [lindex $argv 1] if {[string length $site]} { @@ -320,5 +456,6 @@ if {[string length $site]} { close $x } + RobotRestart vwait forever -- 1.7.10.4