#!/bin/sh
# $Id: configure,v 1.91 2002/12/13 02:27:23 ukai Exp $
# Configuration.
#
#
if ./which uname > /dev/null ; then
sysname=`uname -s`
sysversion=`uname -r`
platform=`uname -m`
elif [ -f /usr/sony/bin/machine -a -f /etc/osversion ]; then
sysname='NEWS-OS'
sysversion=`sed 's/[^ ]* [^ ]* //' /etc/osversion`
platform=`/usr/sony/bin/machine`
fi
host=`hostname`
sysversion1=`echo $sysversion | awk -F. '{print $1}'`
sysversion2=`echo $sysversion | awk -F. '{print $2}'`
sysversion3=`echo $sysversion | awk -F. '{print $3}'`
echo $sysname $sysversion1 $sysversion2 $sysversion3 /$platform at $host
if [ -f config.param ] ; then
confhost=`awk 'NR==1{print $4}' config.param`
if [ "$confhost" = "$host" ] ; then
. ./config.param
fi
fi
echo "# Configuration at $host" > config.param
# parameters:
prefix=/usr/local
ssl_includedir=
ssl_libdir=
gc_includedir=
gc_libdir=
mimetypes=
all_yes=0
while [ $# -gt 0 ]
do
case "$1" in
-yes|--yes|-nonstop|--nonstop)
all_yes=1
echo "Setting all parameters to the default..."
;;
-prefix|--prefix)
prefix=$2
shift
;;
-prefix=*|--prefix=*)
prefix=`expr "X$1" : "X-*prefix=\(.*\)"`
;;
-bindir=*|--bindir=*)
bindir=`expr "X$1" : "X-*bindir=\(.*\)"`
;;
-auxbindir=*|--auxbindir=*)
auxbindir=`expr "X$1" : "X-*auxbindir=\(.*\)"`
;;
-libdir=*|--libdir=*)
libdir=`expr "X$1" : "X-*libdir=\(.*\)"`
;;
-helpdir=*|--helpdir=*)
helpdir=`expr "X$1" : "X-*helpdir=\(.*\)"`
;;
-mandir=*|--mandir=*)
mandir=`expr "X$1" : "X-*mandir=\(.*\)"`
;;
-sysconfdir=*|--sysconfdir=*)
sysconfdir=`expr "X$1" : "X-*sysconfdir=\(.*\)"`
;;
-lang=en|--lang=en|-lang=EN|--lang=EN)
lang=EN
;;
-lang=ja|--lang=ja|-lang=ja|--lang=JA)
lang=JA
;;
-model=baby|--model=baby)
dmodel=1
;;
-model=little|--model=little)
dmodel=2
;;
-model=mouse|--model=mouse)
dmodel=3
;;
-model=cookie|--model=cookie)
dmodel=4
;;
-model=monster|--model=monster)
dmodel=5
;;
-model=custom|--model=custom)
dmodel=6
;;
-code=*|--code=*)
display_code=`expr "X$1" : "X-*code=\(.*\)"`
;;
-cflags=*|--cflags=*)
dcflags=`echo $1 | sed -e 's/-*cflags=//'`
;;
-ldflags=*|--ldflags=*)
dldflags=`echo $1 | sed -e 's/-*ldflags=//'`
;;
--ssl-includedir=*)
ssl_includedir=`expr "X$1" : "X--ssl-includedir=\(.*\)"`
;;
--ssl-libdir=*)
ssl_libdir=`expr "X$1" : "X--ssl-libdir=\(.*\)"`
;;
--gc-includedir=*)
gc_includedir=`expr "X$1" : "X--gc-includedir=\(.*\)"`
;;
--gc-libdir=*)
gc_libdir=`expr "X$1" : "X--gc-libdir=\(.*\)"`
;;
--mimetypes=*)
mimetypes=`expr "X$1" : "X--mimetypes=\(.*\)"`
;;
-help|--help)
echo "-yes, -nonstop Set all parameters to the default"
echo "-prefix=DIR Specify prefix (default: /usr/local)"
echo "-bindir=DIR user executable in DIR (default: PREFIX/bin)"
echo "-auxbindir=DIR support programs in DIR (default: PREFIX/lib/w3m)"
echo "-libdir=DIR local cgi in DIR (default: PREFIX/lib/w3m/cgi-bin)"
echo "-helpdir=DIR help file in DIR (default: PREFIX/share/w3m)"
echo "-mandir=DIR manual in DIR (default: PREFIX/man)"
echo "-sysconfdir=DIR w3mconfig in DIR [PREFIX/etc/w3m]"
echo "-lang=(en|ja) Specify default language"
echo "-model=(baby|little|mouse|cookie|monster|custom)"
echo " Specify default model"
echo "-code=(S|E|j|N|n|m)"
echo " Specify default kanji code"
echo "-cflags=FLAGS Specify C flags"
echo "-ldflags=FLAGS Specify LD flags"
echo "--ssl-includedir=DIR specify OpenSSL include dir"
echo "--ssl-libdir=DIR specify OpenSSL lib dir"
echo "--gc-includedir=DIR specify Boehm-GC include dir"
echo "--gc-libdir=DIR specify Boehm-GC lib dir"
echo "--mimetypes=PATH specify mime.types path"
echo "-help Display help"
exit 0
;;
esac
shift
done
if [ "x$IMLIB_CONFIG" = x ]; then
IMLIB_CONFIG=imlib-config
fi
if [ "x$IMLIB2_CONFIG" = x ]; then
IMLIB2_CONFIG=imlib2-config
fi
if [ "x$GDKPIXBUF_CONFIG" = x ]; then
GDKPIXBUF_CONFIG=gdk-pixbuf-config
fi
if [ -z "`echo -n aho | grep n`" ] ; then
Echo()
{
echo -n "$*"
}
else
Echo()
{
echo "$*\c"
}
fi
do_sigtest()
{
echo "#include <signal.h>" > _zmachdep.c
if [ "$2" = void ]; then
echo "$1 _handler($2) {}" >> _zmachdep.c
else
echo "$1 _handler($2 x) {}" >> _zmachdep.c
fi
echo "int main(void) { $1 (*hdl)($2); hdl = signal(SIGINT,_handler); return 0; }" >> _zmachdep.c
$cc $cflags -o _zmachdep _zmachdep.c > _zwarning 2>&1
stat=$?
warning=`cat _zwarning`
rm -f _zwarning
}
readdir() {
if [ "$all_yes" = 0 ]; then
read __dir
else
__dir=$1
echo "$1"
fi
if [ -z "$__dir" ]; then
_dir=$1
else
_dir=`echo "$__dir"|sed -e "s;^~;$HOME;"`
fi
}
readanswer() {
var=$1
dflt=$2
ok=$3
if [ "$all_yes" = 0 -o -z "$dflt$ok" ]; then
read ans
if [ -z "$ans" ]; then
ans=$dflt
fi
else
ans=$dflt
echo "$ans"
fi
eval $var='$ans'
}
yesno() {
var=$1
dflt=$2
ddflt=$3
if [ -z "$dflt" ]; then
dflt=$ddflt
fi
if [ "$dflt" = y ]; then
ndflt=n
else
ndflt=y
fi
Echo "[$dflt]? "
if [ "$all_yes" = 0 ]; then
read ks_ans
else
ks_ans=$dflt
echo "$dflt"
fi
if [ "$ks_ans" = "$ndflt" ]; then
eval $var='$ndflt'
else
eval $var='$dflt'
fi
}
#
# def_param "name" "default_value"
# =>
# $name=${name:-$default_value}
# def_$name='#define $NAME' (if $name=y)
# def_$name='#undef $NAME' (otherwise)
#
def_param() {
flag=$1
eval "fvar=\$$flag"
dflt=$2
if [ -z "$fvar" ]; then
fvar=$dflt
eval $flag='$fvar'
fi
def=`echo $flag | tr '[a-z]' '[A-Z]'`
if [ "$fvar" = "y" ]; then
eval "def_$flag='#define $def'"
else
eval "def_$flag='#undef $def'"
fi
echo "$flag=$fvar" >> config.param
}
#
# ask_choice "prompt" "var"
# "choice-1" "value-1" "description-1" .. .
# "choice-2" "value-2" "description-2" .. .
# =>
# $var=${value-<n>}
# def_$var='#define $VAR ${value-<n>}'
#
ask_choice() {
prompt=$1
var=$2
def=`echo $var | tr '[a-z]' '[A-Z]'`
shift; shift
list="$@"
echo "$prompt"
dvar=
varvar=
# check old value
eval "old_dvar=\$$var"
set -- $list
while [ -n "$1" -a -n "$2" ]; do
c=$1; v=$2; shift; shift;
case $v in
$old_dvar) dc=$c; dvar=$old_dvar;;
*) ;;
esac
while [ "$1" != "." ]; do
shift;
done
shift
done
if [ "$all_yes" = 1 ]; then
eval "varvar=$dc"
fi
while [ -z "$varvar" ];
do
set -- $list
prompt="["
while [ -n "$1" -a -n "$2" ]; do
c=$1; v=$2;
shift; shift;
Echo "$c .."
while [ "$1" != "." ]; do
Echo " $1"; shift
done
echo " ($def=$v)"
shift
prompt="$prompt$c"
done
prompt="$prompt]? "
Echo "$prompt"
if [ -n "$dvar" ]; then
Echo "(default: $dc - $dvar)"
fi
read REPLY
if [ -z "$REPLY" ]; then
REPLY=$dc
fi
set -- $list
while [ -n "$1" -a -n "$2" ]; do
case $REPLY in
$1) eval "varvar=$1"
break
;;
esac
shift; shift;
while [ "$1" != "." ]; do
shift;
done
shift
done
done
Echo "You select"
set -- $list
while [ -n "$1" -a -n "$2" ]; do
c=$1; v=$2; shift; shift
case $varvar in
$c)
while [ "$1" != "." ]; do
Echo " $1"; shift
done
shift
eval "def_$var='#define $def $v'"
eval "$var=$v"
echo "$var=$v" >> config.param
echo " $def=$v"
break
;;
*) while [ "$1" != "." ]; do
shift;
done
shift
;;
esac
done
}
#
# ask_param "prompt" "name" "default_value"
# =>
# ask user
# def_param "name" "default_value"
#
ask_param() {
prompt=$1
flag=$2
eval "fvar=\$$flag"
dflt=$3
Echo "$prompt "
if [ "$all_yes" = 0 ]; then
yesno $flag $fvar $dflt
fi
def_param $flag $dflt
if [ "$all_yes" = 1 ]; then
eval "fvar=\$$flag"
if [ "$fvar" = y ]; then
echo ".... yes"
else
echo ".... no"
fi
fi
}
find_ssl() {
sslinclude=""
for i1 in $ssl_includedir /usr /usr/local $prefix
do
for i2 in /openssl /ssl /
do
if [ "$i2" = "/" ]; then i2=''; fi
dirname=${i1}${i2}
if [ -f $dirname/include/ssl.h ]; then
sslinclude="-I${dirname}/include"
elif [ -f $dirname/include/openssl/ssl.h ]; then
sslinclude="-I${dirname}/include/openssl -I${dirname}/include"
fi
for i3 in lib/openssl lib
do
dirname=${i1}${i2}/${i3}
for ext in a $so_ext
do
if [ -f $dirname/libssl.$ext -o -f $dirname/libcrypto.$ext ]; then
if [ "$ssllib" = -L${dirname} ]; then
ssllib="-L${dirname}"
else
ssllib="$ssllib -L${dirname}"
fi
fi
done
done
done
done
if [ -f "$ssl_libdir/libssl.$ext" -o -f "$ssl_libdir/libcrypto.$ext" ]; then
ssllib="-L$ssl_libdir $ssllib"
fi
ssllib="$ssllib -lssl -lcrypto"
if [ "$sslinclude" = "" ]; then
echo "Where is ssl.h? (for example, /usr/crypto/include)"
Echo ":"
read ks_ans
sslinclude="-I${ks_ans}"
if [ -d $ks_ans/openssl ]; then
sslinclude="${sslinclude} -I${ks_ans}/openssl"
fi
echo "Where is libssl.a? (for example, /usr/crypto/lib)"
Echo ":"
read ks_ans
ssllib="-L${ks_ans} -lssl -lcrypto"
fi
}
find_imlib() {
imlib_major=1
imlib_minor=9
imlib_micro=8
imlib_version=$imlib_major.$imlib_minor.$imlib_micro
echo "Checking Imlib."
version=`$IMLIB_CONFIG --version`
if [ "x$version" = x ]; then
echo "You don't have Imlib. Install Imlib (version >= $imlib_version)."
return 1
fi
major=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'`
minor=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'`
micro=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
echo "The version of Imlib is $version."
if [ "$major" -ne $imlib_major -o "$minor" -ne $imlib_minor -o "$micro" -lt $imlib_micro ]; then
echo "Imlib is too old. Install Imlib (version >= $imlib_version)."
return 1
fi
return 0
}
find_imlib2() {
imlib_major=1
imlib_minor=0
imlib_micro=5
imlib_version=$imlib_major.$imlib_minor.$imlib_micro
echo "Checking Imlib 2."
version=`$IMLIB2_CONFIG --version`
if [ "x$version" = x ]; then
echo "You don't have Imlib 2. Install Imlib 2 (version >= $imlib_version)."
return 1
fi
major=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'`
minor=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'`
micro=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
echo "The version of Imlib 2 is $version."
if [ "$major" -ne $imlib_major -o "$minor" -lt $imlib_minor -o "$micro" -lt $imlib_micro ]; then
echo "Imlib 2 is too old. Install Imlib 2 (version >= $imlib_version)."
return 1
fi
return 0
}
find_gdkpixbuf() {
gdkpixbuf_major=0
gdkpixbuf_minor=16
gdkpixbuf_micro=0
gdkpixbuf_version=$gdkpixbuf_major.$gdkpixbuf_minor.$gdkpixbuf_micro
echo "Checking GdkPixbuf ."
if ./which $GDKPIXBUF_CONFIG > /dev/null
then
version=`$GDKPIXBUF_CONFIG --version`
else
version=""
fi
if [ "x$version" = x ]; then
echo "You don't have GdkPixbuf. Install GdkPixbuf (version >= $gdkpixbuf_version)."
return 1
fi
major=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'`
minor=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'`
micro=`echo "$version" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
echo "The version of GdkPixbuf is $version."
if [ "$major" -ne $gdkpixbuf_major -o "$minor" -lt $gdkpixbuf_minor -o "$micro" -lt $gdkpixbuf_micro ]; then
echo "GdkPixbuf is too old. Install GdkPixbuf (version >= $gdkpixbuf_version)."
return 1
fi
return 0
}
#--------------------------------------------------------------
if [ -n "$USER" ]; then
user=$USER
elif [ -n "$LOGNAME" ]; then
user=$LOGNAME
elif [ -n "`whoami`" ]; then
user=`whoami`
else
# Echo "Who are you? "
# read user
user=nobody
fi
echo "%"
echo "% Hello $user. Let's start configuration process for w3m."
echo "% Please answer some questions."
echo "%"
extension=
def_use_binstream='#undef USE_BINMODE_STREAM'
topdir=$prefix
special_sys=''
case "$sysname" in
aix | AIX )
special_sys="#define AIX"
;;
CYGWIN* )
sysname='CYGWIN'
special_sys="#define CYGWIN $sysversion1"
if [ $sysversion1 -eq 0 ]; then
topdir=/cygnus/cygwin-b20/H-i586-cygwin32
fi
extension='.exe'
def_use_binstream='#define USE_BINMODE_STREAM'
;;
OS/2 )
extension='.exe'
def_use_binstream='#define USE_BINMODE_STREAM'
;;
NetBSD )
# Newer NetBSD system doesn't define 'unix' symbol anymore, but GC library
# requires it.
special_sys="#define unix"
;;
esac
# determine shared object extension
so_ext=so
case "$sysname" in
HP-UX )
so_ext=sl
;;
Darwin )
so_ext=dylib
;;
esac
d_bindir=$bindir
if [ -z "$d_bindir" ]; then
d_bindir="$topdir/bin"
fi
echo "Which directory do you want to put the binary?"
Echo "(default: $d_bindir) "
readdir "$d_bindir"
bindir=$_dir
echo "bindir='$bindir'" >> config.param
d_auxbindir=$auxbindir
if [ -z "$d_auxbindir" ]; then
case "$sysname" in
*BSD)
d_auxbindir="$topdir/libexec/w3m"
;;
*)
d_auxbindir="$topdir/lib/w3m"
;;
esac
fi
echo "Which directory do you want to put the support binary files?"
Echo "(default: $d_auxbindir) "
readdir "$d_auxbindir"
auxbindir=$_dir
echo "auxbindir='$auxbindir'" >> config.param
d_libdir=$libdir
if [ -z "$d_libdir" ]; then
case "$sysname" in
*BSD)
d_libdir="$topdir/libexec/w3m/cgi-bin"
;;
*)
d_libdir="$topdir/lib/w3m/cgi-bin"
;;
esac
fi
echo "Which directory do you want to use local cgi?"
Echo "(default: $d_libdir) "
readdir "$d_libdir"
libdir=$_dir
echo "libdir='$libdir'" >> config.param
d_helpdir=$helpdir
if [ -z "$d_helpdir" ]; then
d_helpdir="$topdir/share/w3m"
fi
echo "Which directory do you want to put the helpfile?"
Echo "(default: $d_helpdir) "
readdir "$d_helpdir"
helpdir=$_dir
echo "helpdir='$helpdir'" >> config.param
d_mandir=$mandir
if [ -z "$d_mandir" ]; then
d_mandir="$topdir/man"
fi
echo "Which directory do you want to put the manfile?"
Echo "(default: $d_mandir) "
readdir "$d_mandir"
mandir=$_dir
echo "mandir='$mandir'" >> config.param
d_sysconfdir=$sysconfdir
if [ -z "$d_sysconfdir" ]; then
d_sysconfdir="$topdir/etc/w3m"
fi
echo "Which directory do you want to put the system wide w3m configuration file?"
Echo "(default: $d_sysconfdir) "
readdir "$d_sysconfdir"
sysconfdir=$_dir
echo "sysconfdir='$sysconfdir'" >> config.param
ask_choice "Which language do you prefer?" lang \
1 JA "Japanese (charset ISO-2022-JP, EUC-JP, Shift_JIS)" . \
2 EN "English (charset US_ASCII, ISO-8859-1, etc)" .
if [ "$lang" = JA ]; then
ask_choice "What is your display kanji code?" display_code \
S S "Shift JIS" . \
E E "EUC-JP" . \
j j 'JIS: ESC $@ - ESC (J' . \
N N 'JIS: ESC $B - ESC (J' . \
n n 'JIS: ESC $B - ESC (B' . \
m m 'JIS: ESC $@ - ESC (B' .
system_code=
if [ "$display_code" = "S" ]; then
system_code=S
def_param system_code S
else
system_code=E
def_param system_code E
fi
else
display_code=x
system_code=x
def_param display_code x
def_param system_code x
fi
if [ "$lang" = "JA" ]; then
ask_param "Use 2-byte character for table border, item, etc." kanji_symbols y
else
kanji_symbols=n
def_param kanji_symbols n
fi
ask_param "Use Lynx-like key binding as default" use_lynx_key n
if [ "$use_lynx_key" = y ]; then
keymap_file="keybind_lynx"
else
keymap_file="keybind"
fi
if [ "$lang" = "JA" ]; then
if [ "$use_lynx_key" = y ]; then
helpfile="w3mhelp-lynx_ja.html"
else
helpfile="w3mhelp-w3m_ja.html"
fi
else
if [ "$use_lynx_key" = y ]; then
helpfile="w3mhelp-lynx_en.html"
else
helpfile="w3mhelp-w3m_en.html"
fi
fi
###
echo ""
echo "Let's do some configurations. Choose config option among the list."
echo ""
echo "1 - Baby model (no color, no menu, no mouse, no cookie, no SSL)"
echo "2 - Little model (color, menu, no mouse, no cookie, no SSL)"
echo "3 - Mouse model (color, menu, mouse, no cookie, no SSL)"
echo "4 - Cookie model (color, menu, mouse, cookie, no SSL)"
echo "5 - Monster model (with everything; you need openSSL library)"
echo "6 - Customize"
echo ""
Echo "Which? "
if [ -n "$dmodel" ]; then
Echo "(default: $dmodel) "
fi
include_opt=y
while :
do
readanswer ans "$dmodel"
if [ -z "$ans" -a -n "$dmodel" ]; then
ans=$dmodel
fi
dmodel_save="$dmodel"
dmodel=$ans
case "$ans" in
1)
use_color=n;
use_menu=n;
use_mouse=n;
use_cookie=n;
use_ssl=n;
include_opt=n
customized=y
;;
2)
use_color=y;
use_menu=y;
use_mouse=n;
use_cookie=n;
use_ssl=n;
customized=y
;;
3)
use_color=y;
use_menu=y;
use_mouse=y;
use_cookie=n;
use_ssl=n;
customized=y
;;
4)
use_color=y;
use_menu=y;
use_mouse=y;
use_cookie=y;
use_ssl=n;
customized=y
;;
5)
use_color=y;
use_menu=y;
use_mouse=y;
use_cookie=y;
use_ssl=y;
customized=y
;;
6)
if [ "$dmodel_save" = 6 ]; then
customized=y
else
customized=n
fi
;;
*)
echo "Please input 1-6."
Echo "Which? "
continue
;;
esac
break
done
if [ -n "$dmodel" ]; then
echo "dmodel=$dmodel" >> config.param
fi
save_all_yes=$all_yes
if [ "$customized" = y ]; then
all_yes=1
fi
ask_param "Use color ESC sequence for kterm/pxvt" use_color y
ask_param "Use mouse (requires xterm/kterm/gpm/sysmouse)" use_mouse n
ask_param "Use popup menu" use_menu y
ask_param "Use cookie" use_cookie n
ask_param "Use SSL (need OpenSSL library; Please see http://www.openssl.org/)" use_ssl n
all_yes=$save_all_yes
if [ "$use_ssl" = y ]; then
find_ssl
fi
if [ "$use_ssl" = y ]; then
ask_param "SSL verification support (SSL library >= version 0.8)" use_ssl_verify n
ask_param "Digest Auth support" use_digest_auth y
else
use_ssl_verify=n
def_param "use_ssl_verify" n
use_digest_auth=n
def_param "use_digest_auth" n
fi
ask_param "Inline image support" use_image n
if [ "$use_image" = y ]; then
def_use_image="#define USE_IMAGE"
imgtarget='$(IMGDISPLAY)'
ask_param "X11 inline image support (you need Imlib1 or GdkPixbuf library)" use_w3mimg_x11 y
d_w3mimg_fb=n
case $sysname in
Linux|linux|LINUX)
if test -c /dev/fb0; then
d_w3mimg_fb=y
fi
ask_param "Linux Framebuffer inline image support (you need Imlib2 or GdkPixbuf)" use_w3mimg_fb $d_w3mimg_fb
if [ "$use_w3mimg_fb" = y ]; then
ask_param "setuid w3mimgdisplay to open /dev/fb0?" w3mimgdisplay_setuid y
fi
;;
esac
else
def_use_image="#undef USE_IMAGE"
imgtarget=''
use_w3mimg_x11=n
use_w3mimg_fb=n
fi
if [ "$use_color" = y ]; then
ask_param "ANSI color escape sequences support" use_ansi_color n
else
use_ansi_color=n
def_param "use_ansi_color" n
fi
ask_param "Use Migemo (Roma-ji search; Please see http://migemo.namazu.org/)" use_migemo n
def_migemo_command=${def_migemo_command:-"migemo -t egrep /usr/local/share/migemo/migemo-dict"}
echo "def_migemo_command='$def_migemo_command'" >> config.param
# protocols?
ask_param "External URI loader support" use_external_uri_loader y
if [ "$use_external_uri_loader" = y ]; then
ask_param "Use w3mmail.cgi" use_w3mmailer y
fi
ask_param "NNTP support" use_nntp $include_opt
ask_param "Gopher support" use_gopher $include_opt
# obsoleted?
# ask_param "Use matrix in rendering table" use_matrix n
ask_param "Use alarm support code" use_alarm $include_opt
ask_param "Use mark operation" use_mark $include_opt
if [ "$use_image" = y ]; then
ask_param "X-Face support (you need uncompface)" use_xface n
else
use_xface=n
fi
### only use config.param
def_param use_dict y
def_param use_history y
def_param use_bg_color y
def_param format_nice n
def_param id_ext y
def_param use_bufinfo n
def_param use_egd y
def_param enable_remove_trailingspaces n
def_param menu_thin_frame n
def_param emacs_like_lineedit $include_opt
def_param vi_prec_num $include_opt
def_param label_topline $include_opt
def_param nextpage_topline $include_opt
def_param ftppass_hostnamegen $include_opt
def_param table_expand n
def_param table_no_compact n
def_param nowrap y
def_param matrix y
if [ -z "$ded" ] ; then ded=`./which \vi` ; fi
if [ -n "`echo $ded | grep 'no'`" ] ; then ded=vi ; fi
echo "Input your favorite editor program."
Echo "(Default: $ded) "
readdir "$ded"
editor=$_dir
echo "ded='$editor'" >> config.param
if [ "$use_w3mmailer" != 'y' ]; then
if [ -z "$dmail" ] ; then
if ./which \mailx > /dev/null
then
dmail=`./which \mailx`
else
dmail=`./which \mail`
fi
if [ -n "`echo $dmail | grep 'no'`" ] ; then dmail=mailx ; fi
fi
echo "Input your favorite mailer program."
Echo "(Default: $dmail) "
readdir "$dmail"
mailer=$_dir
else
mailer="$dmail"
fi
echo "dmail='$mailer'" >> config.param
if [ -z "$dbrowser" ] ; then
if ./which netscape > /dev/null
then
dbrowser=`./which netscape`
elif ./which iexplore > /dev/null
then
dbrowser=`./which iexplore`
else
dbrowser=`./which lynx`
fi
if [ -n "`echo $dbrowser | grep 'no'`" ] ; then dbrowser=netscape ; fi
fi
echo "Input your favorite external browser program."
Echo "(Default: $dbrowser) "
readdir "$dbrowser"
brz=$_dir
echo "dbrowser='$brz'" >> config.param
def_image_viewer=${def_image_viewer:-xv}
echo "def_image_viewer='$def_image_viewer'" >> config.param
def_audio_player=${def_audio_player:-showaudio}
echo "def_audio_player='$def_audio_player'" >> config.param
if [ -z "$dcc" ]; then
if [ -n "$CC" ]; then
dcc="$CC"
elif ./which gcc >/dev/null ; then
dcc=gcc
else
dcc=cc
fi
fi
echo "Input your favorite C-compiler."
Echo "(Default: $dcc) "
readanswer cc "$dcc"
echo "dcc='$cc'" >> config.param
if [ -z "$dcflags" ]; then
dcflags=${CFLAGS-"-O"}
fi
echo "Input your favorite C flags."
Echo "(Default: $dcflags) "
readanswer cflags "$dcflags"
echo "dcflags='$cflags'" >> config.param
bsdinclude=''
if [ ! -f /usr/include/netinet/in.h ] ; then
if [ -f /usr/include/bsd/netinet/in.h ] ; then
bsdinclude='-I/usr/include/bsd'
elif [ -f /usr/bsdinclude/netinet/in.h ] ; then
bsdinclude='-I/usr/bsdinclude'
else
echo "It seems you don't have some include files for networking."
fi
fi
termlib=''
cat > _zmachdep.c << EOF
main()
{
char bp[100];
tgetent(bp,getenv("TERM"));
}
EOF
if [ -z "$dtermlib" ]; then
TERM_LIBS='termcap termlib terminfo mytinfo curses ncurses'
for lib in $TERM_LIBS
do
for tlibdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib
do
if [ -f $tlibdir/lib$lib.a -o -f $tlibdir/lib$lib.$so_ext ] ; then
# check if the lib works...
Echo "Terminal library -l$lib found at $tlibdir, "
if $cc $cflags -o _zmachdep _zmachdep.c -l$lib > /dev/null 2>&1
then
echo "and it seems to work."
termlib=-l$lib
else
echo "but it doesn't seem to work."
fi
fi
done
done
if [ -z "$termlib" ]; then
Echo "termcap/curses library not found; I hope -ltermcap works."
termlib='-ltermcap'
fi
dtermlib=$termlib
fi
echo 'Which terminal library do you want to use? (type "none" if you do not need one)'
Echo "(default: $dtermlib) "
readanswer termlib "$dtermlib"
if [ "$termlib" = none ]; then
termlib=""
else
echo "dtermlib='$termlib'" >> config.param
fi
## Setup for math library
if [ $sysname = Rhapsody -o $sysname = "Mac OS" ]; then
echo "MacOS X doesn't need -lm."
mathlib=""
else
mathlib="-lm"
fi
## look for GPM library
use_gpm=""
gpmlib=""
if [ "$use_mouse" = y ]; then
for tlibdir in /lib /usr/lib /usr/local/lib $prefix/lib
do
if [ -f $tlibdir/libgpm.a -o -f $tlibdir/libgpm.so ]; then
echo "GPM library found."
def_use_gpm="#define USE_GPM"
gpmlib="-lgpm"
fi
done
fi
case $sysname in
freebsd|FreeBSD)
def_use_sysmouse="#define USE_SYSMOUSE"
;;
*)
def_use_sysmouse="#undef USE_SYSMOUSE"
;;
esac
extlib=''
case $sysname in
*bsd|*BSD)
searchlibs=""
;;
*)
searchlibs="bsd BSD 44bsd socket nsl"
;;
esac
for lib in $searchlibs
do
for tlibdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib
do
if [ -f $tlibdir/lib$lib.a -o -f $tlibdir/lib$lib.$so_ext ] ; then
extlib="$extlib -l$lib"
break
fi
done
done
if [ $sysname = "HP-UX" ]; then
extlib="$extlib -ldld"
fi
if [ -n "$extlib" ]; then
echo "additional library found: $extlib"
fi
extlib="$extlib $ldflags"
## Search zlib
zlib=
for tlibdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib /usr/X11R6/lib $prefix/lib ${HOME}/lib
do
if [ -f $tlibdir/libz.a -o -f $tlibdir/libz.$so_ext ] ; then
echo "$tlibdir/libz found"
zlib="-L$tlibdir -lz"
break
fi
done
z_cflags=
for inc in /usr/include /usr/local/include $prefix/include ${HOME}/include
do
if [ -f $inc/zlib.h ]; then
echo "$inc/zlib.h found"
z_cflags="-I$inc"
break
fi
done
if [ -n "$zlib" -a -n "$z_cflags" ]; then
inflate='$(INFLATE)'
else
echo "Warning: It seems you don't have zlib. Inflate cannot be installed."
inflate=
fi
## Search pthread, Linux requires this (at least ia64,alpha,s390?).
## Other platform?
pthreadlib=
case $sysname in
Linux|linux|LINUX)
for tlibdir in /lib /usr/lib
do
if [ -f $tlibdir/libpthread.a -o -f $tlibdir/libpthread.$so_ext ]; then
echo "$tlibdir/libpthread found"
pthreadlib="-L$tlibdir -lpthread"
break
fi
done
;;
esac
gclib=''
gcinclude=''
gctarget=''
for tlibdir in ${gc_libdir} /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib ${HOME}/lib
do
if [ -f $tlibdir/libgc.a -o -f $tlibdir/libgc.$so_ext ] ; then
echo "$tlibdir/libgc found"
gclib="-L$tlibdir -lgc"
break
fi
done
for inc in ${gc_includedir} /usr/include /usr/include/gc /usr/local/include /usr/local/include/gc $prefix/include ${HOME}/include
do
if [ -f $inc/gc.h ]; then
echo "$inc/gc.h found"
gcinclude=$inc
break
fi
done
case $sysname in
linux|Linux|LINUX|aix|Aix|AIX)
if [ ! -f "$gcinclude/private/gc_priv.h" ]; then
case $cflags in
*DEBIAN*)
# on Debian, we can use libgc*.deb
:;;
*)
# these OS requires gcmain.c, which include gc/gc_priv.h
# therefore we use gc library comes with w3m
echo "Your OS is $sysname; using gc library comes with w3m."
gcinclude=""
gclib=""
;;
esac
fi
;;
esac
if [ -n "$gclib" -a -n "$gcinclude" ]; then
Echo GC library found on your system...
cat > _zmachdep.c << EOF
#include "gc/version.h"
main()
{
printf("%d%02d%03d\n",(GC_version>>16)&0xff,(GC_version>>8)&0xff,GC_version&0xff);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
mygcversion=`./_zmachdep`
else
mygcversion=0
fi
cat > _zmachdep.c << EOF
#include <gc.h>
main()
{
extern unsigned GC_version;
printf("%d%02d%03d\n",(GC_version>>16)&0xff,(GC_version>>8)&0xff,GC_version&0xff);
}
EOF
if $cc $cflags -I$gcinclude -o _zmachdep _zmachdep.c $gclib > /dev/null 2>&1
then
echo "and it seems to work."
gcversion=`./_zmachdep`
echo "GC_version is $gcversion."
if [ $gcversion -lt $mygcversion ]; then
echo "GC library on your system seems to be old."
ask_param "Do you want to use GC library comes with w3m?" "use_bundled_gclib" y
if [ "$use_bundled_gclib" = 'n' -o "$use_bundled_gclib" = 'N' ]; then
cflags="$cflags -I$gcinclude"
else
cflags="$cflags -I./gc/include"
gclib="gc/gc.a"
gctarget=$gclib
echo "GC_version is $mygcversion."
fi
else
cflags="$cflags -I$gcinclude"
fi
elif [ $mygcversion -gt 0 ]; then
echo "but it doesn't seem to work."
cflags="$cflags -I./gc/include"
gclib="gc/gc.a"
gctarget=$gclib
echo "GC_version is $mygcversion."
else
echo "It seems you don't have GC library."
echo "Stop."
exit 1
fi
fi
if [ -z "$gclib" -o -z "$gcinclude" ]; then
cflags="$cflags -I./gc/include"
gclib="gc/gc.a"
gctarget="$gclib"
fi
# arch specific flags for libgc
gc_cflags=''
if [ "$gclib" = "gc/gc.a" ]; then
patchfile=""
case "$platform:$sysname" in
ia64:Linux|alpha:Linux|s390*:Linux)
gc_cflags="-DGC_LINUX_THREADS -D_REENTRANT"
;;
R3000:*System_V*|R4000:UNIX_SYSV|R*000:UNIX_SV)
# EWS-4800
# patchfile=Patches/ews4800
gc_cflags=-Dmips
;;
esac
# Apply patch.
if [ ! -f patch_done -a -n "$patchfile" -a -f "$patchfile" ]; then
patch -lp0 < $patchfile
echo "dpatch='$patch'" >> config.param
touch patch_done
fi
fi
echo "Input additional LD flags other than listed above, if any:"
if [ -z "$dldflags" ]; then
dldflags=${LDFLAGS-""}
fi
if [ -n "$dldflags" ]; then
Echo "(default: $dldflags) : "
else
Echo ": "
fi
readanswer ldflags "$dldflags" ok
if [ -z "$ldflags" ]; then
ldflags=$dldflags
fi
echo "dldflags='$ldflags'" >> config.param
echo "Checking machine dependency."
###### mime.types
MIME_TYPES=""
if [ -n "$mimetypes" ]; then
MIME_TYPES=$mimetypes
else
for d in /etc /usr/lib /usr/local/lib /usr/local/etc $prefix/lib /usr/local/etc/apache /usr/local/lib/mosaic /usr/local/mosaic /usr/local/netscape /usr/local/lib/netscape
do
if [ -f $d/mime.types ]; then
MIME_TYPES="$d/mime.types"
break
fi
done
fi
if [ -z "$MIME_TYPES" ]; then
echo "Global mime.types not found; Hope /usr/local/lib/mime.types works."
MIME_TYPES=/usr/local/lib/mime.types
fi
####### ranlib
if ./which ranlib > /dev/null
then
echo "You have ranlib."
ranlib_cmd=ranlib
else
if [ $sysname = "OS/2" ]; then
ranlib_cmd=rem
else
echo "You don't have ranlib."
ranlib_cmd=:
fi
fi
####### mkdir -p
if mkdir -p hogege
then
echo "You have mkdir -p."
MKDIR="mkdir -p"
else
MKDIR="mkdir"
fi
rm -rf hogege 2>&1 >/dev/null
####### perl
perl=`./which perl`
if [ `expr "$perl" : 'not found'` != 0 ]; then
echo "You don't have perl."
perl=/usr/local/bin/perl
have_perl=n
else
echo "You have perl."
have_perl=y
fi
def_param use_help_cgi $have_perl
####### long long
cat > _zmachdep.c <<EOF
main()
{
int i = sizeof(unsigned long long);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have long long"
def_have_long_long="typedef long long clen_t;"
cat > _zmachdep.c <<EOF
#include <stdlib.h>
main()
{
const char *s = "1";
long long ll = strtoll(s, NULL, 10);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have strtoll()"
def_have_strtoll="#define HAVE_STRTOLL"
else
echo "You don't have strtoll()"
def_have_strtoll="#undef HAVE_STRTOLL"
fi
cat > _zmachdep.c <<EOF
#include <sys/types.h>
#include <stdlib.h>
#include <limits.h>
main()
{
const char *s = "1";
quad_t q = strtoq(s, NULL, 10);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have strtoq()"
def_have_strtoq="#define HAVE_STRTOQ"
else
echo "You don't have strtoq()"
def_have_strtoq="#undef HAVE_STRTOQ"
fi
cat > _zmachdep.c <<EOF
#include <stdlib.h>
main()
{
const char *s = "1";
long long ll = atoll(s);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have atoll()"
def_have_atoll="#define HAVE_ATOLL"
else
echo "You don't have atoll()"
def_have_atoll="#undef HAVE_ATOLL"
fi
cat > _zmachdep.c <<EOF
#include <stdlib.h>
main()
{
const char *s = "1";
long long ll = atoq(s);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have atoq()"
def_have_atoq="#define HAVE_ATOQ"
else
echo "You don't have atoq()"
def_have_atoq="#undef HAVE_ATOQ"
fi
else
echo "You don't have long long"
def_have_long_long="typedef long clen_t;"
fi
####### strcasecmp
cat > _zmachdep.c << EOF
#include <string.h>
main()
{
int i;
i = strcasecmp("abc","def");
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have strcasecmp()."
def_have_strcasecmp="#define HAVE_STRCASECMP"
else
echo "You don't have strcasecmp()."
def_have_strcasecmp="#undef HAVE_STRCASECMP"
fi
####### strcasestr
cat > _zmachdep.c << EOF
#include <string.h>
main()
{
int i;
i = strcasestr("abc","def");
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have strcasestr()."
def_have_strcasestr="#define HAVE_STRCASESTR"
else
echo "You don't have strcasestr()."
def_have_strcasestr="#undef HAVE_STRCASESTR"
fi
####### strchr
cat > _zmachdep.c << EOF
#include <string.h>
main()
{
char *p, *q = "abc";
p = strchr(q,'c');
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have strchr()."
def_have_strchr="#define HAVE_STRCHR"
else
echo "You don't have strchr()."
def_have_strchr="#undef HAVE_STRCHR"
fi
####### strerror
cat > _zmachdep.c << EOF
main()
{
int i;
i = strerror(0);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have strerror()."
def_have_strerror="#define HAVE_STRERROR"
else
echo "You don't have strerror()."
def_have_strerror="#undef HAVE_STRERROR"
fi
####### sys_errlist
cat > _zmachdep.c << EOF
main()
{
extern char sys_errlist[];
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have sys_errlist[]."
def_have_syserrlist="#define HAVE_SYS_ERRLIST"
else
echo "You don't have sys_errlist[]."
def_have_syserrlist="#undef HAVE_SYS_ERRLIST"
fi
####### bcopy
cat > _zmachdep.c << EOF
main()
{
char x[1],y[1];
bzero(x,1);
bcopy(x,y,1);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have bcopy()."
def_have_bcopy="#define HAVE_BCOPY"
else
echo "You don't have bcopy()."
def_have_bcopy="#undef HAVE_BCOPY"
fi
####### waitpid
cat > _zmachdep.c << EOF
#include <sys/types.h>
#include <sys/wait.h>
main()
{
pid_t pid;
int status;
if ((pid = fork()) == 0) {
sleep(10);
exit(1);
}
while(waitpid(pid,&status,WNOHANG));
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have waitpid()."
def_have_waitpid="#define HAVE_WAITPID"
else
echo "You don't have waitpid()."
def_have_waitpid="#undef HAVE_WAITPID"
fi
####### wait3
cat > _zmachdep.c << EOF
#include <sys/types.h>
#include <time.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#ifndef NULL
#define NULL 0
#endif
main()
{
int pid;
int status;
if ((pid = fork()) == 0) {
sleep(10);
exit(1);
}
while(wait3(&status,WNOHANG,NULL) > 0);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have wait3()."
def_have_wait3="#define HAVE_WAIT3"
else
echo "You don't have wait3()."
def_have_wait3="#undef HAVE_WAIT3"
fi
####### strftime
cat > _zmachdep.c << EOF
#include <time.h>
main()
{
time_t ct;
struct tm *tm;
char t[80];
time(&ct);
strftime(t, 80, "%a, %d %b %Y %H:%M:%S GMT",gmtime(&ct));
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have strftime()."
def_have_strftime="#define HAVE_STRFTIME"
else
echo "You don't have strftime()."
def_have_strftime="#undef HAVE_STRFTIME"
fi
####### getcwd
cat > _zmachdep.c << EOF
#include <sys/param.h>
#include <unistd.h>
main()
{
#ifdef MAXPATHLEN
char path[MAXPATHLEN];
getcwd(path,MAXPATHLEN);
#else
gwtcwd(NULL, 0);
#endif
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have getcwd()."
def_have_getcwd="#define HAVE_GETCWD"
else
echo "You don't have getcwd()."
def_have_getcwd="#undef HAVE_GETCWD"
fi
####### getwd
cat > _zmachdep.c << EOF
main()
{
char path[64];
getwd(path);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have getwd()."
def_have_getwd="#define HAVE_GETWD"
else
echo "You don't have getwd()."
def_have_getwd="#undef HAVE_GETWD"
fi
####### symlink
cat > _zmachdep.c << EOF
main()
{
char path[64],lpath[64];
symlink(path,lpath);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have symlink()."
def_have_symlink="#define HAVE_SYMLINK"
else
echo "You don't have symlink()."
def_have_symlink="#undef HAVE_SYMLINK"
fi
####### readlink
cat > _zmachdep.c << EOF
main()
{
char path[64],lpath[64];
readlink(path,lpath,64);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have readlink()."
def_have_readlink="#define HAVE_READLINK"
else
echo "You don't have readlink()."
def_have_readlink="#undef HAVE_READLINK"
fi
####### lstat
cat > _zmachdep.c << EOF
#include <sys/types.h>
#include <sys/stat.h>
main()
{
struct stat st;
char path[64];
lstat(path,&st);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have lstat()."
def_have_lstat="#define HAVE_LSTAT"
else
echo "You don't have lstat()."
def_have_lstat="#undef HAVE_LSTAT"
fi
####### setenv
cat > _zmachdep.c << EOF
#include <stdlib.h>
main()
{
setenv("HOGE","hoge",1);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have setenv()."
def_have_setenv="#define HAVE_SETENV"
else
echo "You don't have setenv()."
def_have_setenv="#undef HAVE_SETENV"
fi
####### putenv
cat > _zmachdep.c << EOF
#include <stdlib.h>
main()
{
putenv("HOGE=hoge");
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have putenv()."
def_have_putenv="#define HAVE_PUTENV"
else
echo "You don't have putenv()."
def_have_putenv="#undef HAVE_PUTENV"
fi
####### sigsetjmp
cat > _zmachdep.c << EOF
#include <setjmp.h>
main()
{
jmp_buf env;
if (sigsetjmp(env,1) != 0) {
exit(0);
}
siglongjmp(env,1);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have sigsetjmp()."
def_setjmp="#define SETJMP(env) sigsetjmp(env,1)"
def_longjmp="#define LONGJMP(env,val) siglongjmp(env,val)"
def_jmpbuf="#define JMP_BUF sigjmp_buf"
else
echo "You don't have sigsetjmp()."
def_setjmp="#define SETJMP(env) setjmp(env)"
def_longjmp="#define LONGJMP(env,val) longjmp(env,val)"
def_jmpbuf="#define JMP_BUF jmp_buf"
fi
####### srand48
cat > _zmachdep.c << EOF
#include <stdlib.h>
main()
{
srand48(0);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have srand48()."
def_have_srand48="#define HAVE_SRAND48"
else
echo "You don't have srand48()."
def_have_srand48="#undef HAVE_SRAND48"
fi
####### srandom
cat > _zmachdep.c << EOF
#include <stdlib.h>
main()
{
srandom(0);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have srandom()."
def_have_srandom="#define HAVE_SRANDOM"
else
echo "You don't have srandom()."
def_have_srandom="#undef HAVE_SRANDOM"
fi
####### getpassphrase
cat > _zmachdep.c << EOF
#include <unistd.h>
main()
{
getpassphrase("");
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have getpassphrase()."
def_have_getpassphrase="#define HAVE_GETPASSPHRASE"
else
echo "You don't have getpassphrase()."
def_have_getpassphrase="#undef HAVE_GETPASSPHRASE"
fi
####### chdir
cat > _zmachdep.c <<EOF
#include <stdio.h>
#include <unistd.h>
main()
{
int (*c)() = chdir;
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have chdir()."
def_have_chdir="#define HAVE_CHDIR"
else
echo "You don't have chdir()."
def_have_chdir="#undef HAVE_CHDIR"
fi
####### fclose
cat > _zmachdep.c << EOF
#include <stdio.h>
#include <stdlib.h>
main()
{
void (*c)() = fclose;
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "fclose() is declared."
dcl_fclose=''
else
echo "fclose() is not declared."
dcl_fclose='void fclose(FILE*);'
fi
####### pclose
cat > _zmachdep.c << EOF
#include <stdio.h>
#include <stdlib.h>
main()
{
void (*c)() = pclose;
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "pclose() is declared."
dcl_pclose=''
else
echo "pclose() is not declared."
dcl_pclose='void pclose(FILE*);'
fi
####### termios/termio/sgtty
def_term_if='#define HAVE_SGTTY_H'
if [ $sysname = "HP-UX" ]; then
echo "Your OS is HP-UX; using termio"
def_term_if="#define HAVE_TERMIO_H"
elif [ $sysname = "CYGWIN" ]; then
echo "Your OS is CYGWIN; using termios"
def_term_if="#define HAVE_TERMIOS_H"
elif [ $sysname = "OS/2" ]; then
echo "Your OS is OS/2; using termios"
def_term_if='#define HAVE_TERMIOS_H'
elif [ -r /usr/include/termios.h ]; then
echo "You have termios."
def_term_if='#define HAVE_TERMIOS_H'
elif [ -r /usr/include/termio.h ]; then
echo "You have termio."
def_term_if='#define HAVE_TERMIO_H'
elif [ -r /usr/include/sgtty.h ]; then
echo "You have sgtty."
def_term_if='#define HAVE_SGTTY_H'
else
echo "Do you have tty interface? I can't find one but I hope sgtty works..."
fi
####### dirent/direct
def_dir_if=''
if [ $sysname = "CYGWIN" ]; then
echo "Your OS is CYGWIN; using dirent.h"
def_dir_if='#define HAVE_DIRENT_H'
elif [ $sysname = "OS/2" ]; then
echo "Your OS is OS/2; using dirent.h"
def_dir_if='#define HAVE_DIRENT_H'
elif [ -r /usr/include/dirent.h ]; then
echo "You have dirent.h."
def_dir_if='#define HAVE_DIRENT_H'
elif [ -r /usr/include/sys/dir.h ]; then
echo "You have sys/dir.h."
def_dir_if=''
else
echo "Do you have directory interface? I can't find one but I hope sys/dir.h works..."
fi
# check signal handler
do_sigtest int int
if [ $stat = 0 -a -z "$warning" ]
then
echo 'signal handler is int handler(int).'
def_sighandler='typedef int MySignalHandler;'
def_sig_arg='#define SIGNAL_ARG int _dummy'
def_sig_arglist='#define SIGNAL_ARGLIST 0'
def_sig_return='#define SIGNAL_RETURN return 0'
else
do_sigtest int void
if [ $stat = 0 -a -z "$warning" ]
then
echo 'signal handler is int handler(void).'
def_sighandler='typedef int MySignalHandler;'
def_sig_arg='#define SIGNAL_ARG void'
def_sig_arglist='#define SIGNAL_ARGLIST'
def_sig_return='#define SIGNAL_RETURN return 0'
else
do_sigtest void int
if [ $stat = 0 -a -z "$warning" ]
then
echo 'signal handler is void handler(int).'
def_sighandler='typedef void MySignalHandler;'
def_sig_arg='#define SIGNAL_ARG int _dummy'
def_sig_arglist='#define SIGNAL_ARGLIST 0'
def_sig_return='#define SIGNAL_RETURN return'
else
do_sigtest void void
if [ $stat = 0 -a -z "$warning" ]
then
echo 'signal handler is void handler(void).'
else
echo 'I could not find the type of signal handler. I hope void handler(void) works.'
fi
def_sighandler='typedef void MySignalHandler;'
def_sig_arg='#define SIGNAL_ARG void'
def_sig_arglist='#define SIGNAL_ARGLIST'
def_sig_return='#define SIGNAL_RETURN return'
fi
fi
fi
# check alarm()
if [ "$use_alarm" = y ]; then
cat > _zmachdep.c <<EOF
#include <unistd.h>
#include <signal.h>
main()
{
int sa = SIGALRM;
void (*a)() = alarm;
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have alarm()."
else
echo "You don't have alarm(), disable USE_ALARM"
use_alarm=n
def_use_alarm="#undef USE_ALARM"
fi
fi
# check for float.h
cat > _zmachdep.c << EOF
#include <float.h>
main()
{
;
}
EOF
if $cc $cflags -c _zmachdep.c > /dev/null 2>&1
then
echo "You have float.h."
def_have_float_h='#define HAVE_FLOAT_H'
else
def_have_float_h='#undef HAVE_FLOAT_H'
fi
####### check for sys/select.h
cat > _zmachdep.c <<EOF
#include <sys/select.h>
main()
{
;
}
EOF
if $cc $cflags -c _zmachdep.c > /dev/null 2>&1
then
echo "You have sys/select.h."
def_have_sys_select_h='#define HAVE_SYS_SELECT_H'
else
def_have_sys_select_h='#undef HAVE_SYS_SELECT_H'
fi
####### setpgrp(pid, pgrp) or setpgrp() ?
cat > _zmachdep.c << EOF
#include <unistd.h>
int main(){
int pid;
if((pid = fork()) == 0 )
setpgrp();
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
then
echo "You have setpgrp()."
def_have_setpgrp='#define HAVE_SETPGRP'
def_setpgrp='#define SETPGRP() setpgrp()'
else
cat > _zmachdep.c << EOF
#include <unistd.h>
int main(){
int pid;
if((pid = fork()) == 0 )
setpgrp( 0, 0 );
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c $extlib > /dev/null 2>&1
then
echo "You have setpgrp( pid, pgrp )."
def_have_setpgrp='#define HAVE_SETPGRP'
def_setpgrp='#define SETPGRP() setpgrp( 0, 0 )'
else
def_have_setpgrp=''
def_setpgrp='#define SETPGRP() /* no setpgrp() */'
fi
fi
###### atexit/on_exit
# cat > _zmachdep.c <<EOF
# main()
# {
# atexit( sleep(1) );
# }
# EOF
# if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
# then
# echo "You have atexit()."
# atexit_flg="#define HAVE_ATEXIT"
# else
# cat > _zmachdep.c <<EOF
# #include <stdio.h>
# main()
# {
# on_exit( sleep(1), NULL );
# }
# EOF
# if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
# then
# echo "You have on_exit()."
# atexit_flg="#define atexit(x) on_exit(x, NULL)"
# else
# echo "You don't have atexit()/on_exit()"
# fi
# fi
###### IPv6 support check
cat > _zmachdep.c <<EOF
#include <sys/types.h>
#include <sys/socket.h>
main()
{
if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
exit(1);
else
exit(0);
}
EOF
def_ipv6="#undef INET6"
v6_ss_family=""
v6lib=''
if $cc $cflags -o _zmachdep _zmachdep.c $extlib > /dev/null 2>&1
then
if ./_zmachdep; then
def_ipv6="#define INET6"
else
# even if build machine doesnt have IPv6 support, it may works
# Required for package builds
if [ "$use_ipv6" = "y" ]; then
echo "Your build machine doesn't have IPv6 support, but it is enabled by config.param"
def_ipv6="#define INET6"
echo "use_ipv6=y" >> config.param
fi
fi
case $sysname in
*BSD|*bsd)
cat > _zmachdep.c <<EOF
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
struct addrinfo *hints, **res;
int main() {
getaddrinfo("null", "null", hints, res);
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c $extlib > /dev/null 2>&1
then
echo "You have getaddrinfo() in libc."
else
for tlibdir in /usr/local/v6/lib /usr/local/lib /usr/lib $prefix/lib
do
if [ -f $tlibdir/libinet6.a ]; then
if [ "$tlibdir" != "/usr/lib" ]; then
v6lib="-L$tlibdir"
fi
v6lib="$v6lib -linet6"
if $cc $cflags -o _zmachdep _zmachdep.c $extlib $v6lib > /dev/null 2>&1
then
echo "You have getaddrinfo() in libinet6."
fi
break
fi
done
if [ "X$v6lib" = "X" ]; then
echo "You don't have getaddrinfo()."
def_ipv6="#undef INET6"
fi
fi
;;
CYGWIN*)
def_ipv6="#undef INET6"
;;
esac
fi
####### ss_family or __ss_family ?
if [ "$def_ipv6" = "#define INET6" ]; then
cat > _zmachdep.c <<EOF
#include <sys/types.h>
#include <sys/socket.h>
int main() {
struct sockaddr_storage ss;
int i = ss.ss_family;
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c $extlib > /dev/null 2>&1
then
echo "You have ss_family."
else
cat > _zmachdep.c <<EOF
#include <sys/types.h>
#include <sys/socket.h>
int main() {
struct sockaddr_storage ss;
int i = ss.__ss_family;
}
EOF
if $cc $cflags -o _zmachdep _zmachdep.c $extlib > /dev/null 2>&1
then
echo "You have __ss_family."
def_ipv6_ss_family="#define ss_family __ss_family"
else
echo "You don't have ss_family."
def_ipv6="#undef INET6"
fi
fi
fi
if [ "$def_ipv6" = "#undef INET6" ]; then
echo "You don't have IPv6 support."
else
echo "You have IPv6 support."
fi
def_use_w3mimg_x11="#undef USE_W3MIMG_X11"
def_use_w3mimg_fb="#undef USE_W3MIMG_FB"
def_use_imlib='#undef USE_IMLIB'
def_use_gdkpixbuf='#undef USE_GDKPIXBUF'
def_use_imlib2='#undef USE_IMLIB2'
imgx11cflags=''
imgfbcflags=''
imgx11ldflags=''
imgfbldflags=''
imgobjs='w3mimg/w3mimg.o'
if [ "$use_image" = y ]; then
if [ "$use_w3mimg_x11" = y ]; then
if find_gdkpixbuf; then
def_use_w3mimg_x11="#define USE_W3MIMG_X11"
def_use_gdkpixbuf='#define USE_GDKPIXBUF'
imgobjs="$imgobjs w3mimg/x11/x11_w3mimg.o"
imgx11cflags="`${GDKPIXBUF_CONFIG} --cflags`"
imgx11ldflags="`${GDKPIXBUF_CONFIG} --libs` -lgdk_pixbuf_xlib"
elif find_imlib; then
def_use_w3mimg_x11="#define USE_W3MIMG_X11"
def_use_imlib='#define USE_IMLIB'
imgobjs="$imgobjs w3mimg/x11/x11_w3mimg.o"
imgx11cflags="`${IMLIB_CONFIG} --cflags`"
imgx11ldflags="`${IMLIB_CONFIG} --libs`"
else
use_w3mimg_x11=n
echo "Disable X11 inline image"
fi
fi
if [ "$use_w3mimg_fb" = y ]; then
if find_gdkpixbuf; then
def_use_w3mimg_fb="#define USE_W3MIMG_FB"
imgobjs="$imgobjs w3mimg/fb/fb_w3mimg.o w3mimg/fb/fb.o w3mimg/fb/fb_img.o"
def_use_gdkpixbuf='#define USE_GDKPIXBUF'
imgfbcflags="`${GDKPIXBUF_CONFIG} --cflags`"
imgfbldflags="`${GDKPIXBUF_CONFIG} --libs`"
elif find_imlib2; then
def_use_imlib2='#define USE_IMLIB2'
imgobjs="$imgobjs w3mimg/fb/fb_w3mimg.o w3mimg/fb/fb.o w3mimg/fb/fb_img.o"
def_use_imlib2='#define USE_IMLIB2'
imgfbcflags="`${IMLIB2_CONFIG} --cflags`"
imgfbldflags="`${IMLIB2_CONFIG} --libs`"
else
use_w3mimg_fb=n
echo "Disable Linux framebuffer inline image"
fi
fi
install_w3mimgdisplay='$(INSTALL_PROGRAM)'
if [ "$use_w3mimg_fb" = y ]; then
if [ "$w3mimgdisplay_setuid" = y ]; then
install_w3mimgdisplay='$(INSTALL) -o root -m 4755 -s'
fi
fi
fi
rm -f _zmachdep$extension _zmachdep.c _zmachdep.o
echo "------------ Configuration done ------------"
# set model name
case $dmodel in
1) modelname=baby;;
2) modelname=little;;
3) modelname=mouse;;
4) modelname=cookie;;
5) modelname=monster;;
6) modelname=custom;;
esac
cvsver=`awk '\$1 ~ /[$]Id:/ { print \$3}' ChangeLog`
sed -e 's/^#define CURRENT_VERSION "\(.*\)+cvs/#define CURRENT_VERSION "\1+cvs-'$cvsver'/' version.c.in > version.c
cur_ver=`sed -n 's/^#define CURRENT_VERSION *"w3m\/\([^"]*\)".*$/\1/p' version.c`
for h_in in w3mhelp-*_*.html.in
do
h=`expr "$h_in" : '\(.*\)\.in'`
sed -e 's/@CURRENT_VERSION@/'$cur_ver'/' $h_in > $h
done
cat > extrvers.c << EOF
#include <stdio.h>
#include <string.h>
#include "version.c"
main()
{
char *p = strchr(w3m_version,'/');
if (p == NULL)
printf("unknown\n");
else
printf("%s\n",p+1);
}
EOF
$cc $cflags -o extrvers extrvers.c > /dev/null 2>&1
w3mversion=`./extrvers`
echo "Current w3m version is $w3mversion."
rm -f extrvers.c extrvers$extension
echo "Extracting config.h"
cat > config.h << END_OF_CONFIG_H
/*
* Configuration for w3m
*/
#ifndef _CONFIGURED_
#define _CONFIGURED_
/* User Configuration */
/*
If you define DICT, you can use dictionary look-up function
in w3m. See README.dict for detail.
*/
$def_use_dict
/*
If you want to load and save URL history.
*/
$def_use_history
/*
USE_BG_COLOR enables w3m to set background color.
*/
$def_use_bg_color
/*
* Do word fill
*/
$def_format_nice
/*
* Enable id attribute
*/
$def_id_ext
/*
* Save Current-buffer Information
*/
$def_use_bufinfo
/*
* Support EGD (Entropy Gathering Daemon)
*/
$def_use_egd
/*
* Remove line trailing spaces in html buffer.
*/
$def_enable_remove_trailingspaces
/*
* thin chars for menu frame
*/
$def_menu_thin_frame
/*
*/
$def_table_expand
$def_table_no_compact
$def_nowrap
$def_matrix
/**********************************************************/
#ifdef makefile_parameter
BIN_DIR = $bindir
AUXBIN_DIR = $auxbindir
LIB_DIR = $libdir
HELP_DIR = $helpdir
MAN_DIR = $mandir
MAN1_DIR = \$(MAN_DIR)/man1
MAN1_JA_DIR = \$(MAN_DIR)/ja/man1
ETC_DIR = $sysconfdir
RC_DIR = ~/.w3m
HELP_FILE = $helpfile
SYS_LIBRARIES = $gpmlib $termlib $ssllib $v6lib
LOCAL_LIBRARIES = $extlib
CC = $cc
MYCFLAGS = $cflags $bsdinclude $sslinclude
LDFLAGS = $ldflags
GCCFLAGS = $cflags -I./\$(srcdir)/include -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DSILENT -DALL_INTERIOR_POINTERS
KEYBIND_SRC = $keymap_file.c
KEYBIND_OBJ = $keymap_file.o
EXT=$extension
MATHLIB=$mathlib
Z_CFLAGS=$z_cflags
ZLIB=$zlib
AUXBIN_TARGETS=$inflate $imgtarget
LIB_TARGETS=\$(BOOKMARKER) \$(HELPER)
IMGCFLAGS=$imgx11cflags $imgfbcflags
IMGLDFLAGS=$imgx11ldflags $imgfbldflags
IMGX11CFLAGS=$imgx11cflags
IMGFBCFLAGS=$imgfbcflags
IMGOBJS=$imgobjs
GC_CFLAGS=$gc_cflags
GCLIB=$gclib $pthreadlib
GCTARGET=$gctarget
RANLIB=$ranlib_cmd
MKDIR=$MKDIR
PERL=$perl
VERSION=$w3mversion
MODEL=$sysname.$platform-$modelname-$lang
INSTALL_W3MIMGDISPLAY=$install_w3mimgdisplay
#else
$special_sys
#define DISPLAY_CODE '$display_code'
#define SYSTEM_CODE '$system_code'
#define JA 0
#define EN 1
$def_lang
$def_kanji_symbols
$def_use_color
$def_use_ansi_color
$def_use_migemo
$def_emacs_like_lineedit
$def_vi_prec_num
$def_use_mark
$def_label_topline
$def_nextpage_topline
$def_use_mouse
$def_use_gpm
$def_use_sysmouse
$def_use_menu
$def_use_cookie
$def_use_digest_auth
$def_use_ssl
$def_use_ssl_verify
$def_ftppass_hostnamegen
$def_use_external_uri_loader
$def_use_w3mmailer
$def_use_nntp
$def_use_gopher
$def_use_alarm
$def_use_image
$def_use_w3mimg_x11
$def_use_w3mimg_fb
$def_w3mimgdisplay_setuid
$def_use_imlib
$def_use_gdkpixbuf
$def_use_imlib2
$def_use_help_cgi
$def_use_xface
#define DEF_EDITOR "$editor"
#define DEF_MAILER "$mailer"
#define DEF_EXT_BROWSER "$brz"
/* fallback viewer. mailcap override these configuration */
#define DEF_IMAGE_VIEWER "$def_image_viewer"
#define DEF_AUDIO_PLAYER "$def_audio_player"
/* for USE_MIGEMO */
#define DEF_MIGEMO_COMMAND "$def_migemo_command"
#define AUXBIN_DIR "$auxbindir"
#define LIB_DIR "$libdir"
#define HELP_DIR "$helpdir"
#define ETC_DIR "$sysconfdir"
#define HELP_FILE "w3mhelp.html"
#define HELP_CGI "w3mhelp"
#define W3MCONFIG "w3mconfig"
#define IMGDISPLAY "w3mimgdisplay"
#define XFACE2XPM "xface2xpm"
#define RC_DIR "~/.w3m"
#define BOOKMARK "bookmark.html"
#define CONFIG_FILE "config"
#define KEYMAP_FILE "keymap"
#define MENU_FILE "menu"
#define MOUSE_FILE "mouse"
#define COOKIE_FILE "cookie"
#define HISTORY_FILE "history"
#define PASSWD_FILE RC_DIR "/passwd"
#define PRE_FORM_FILE RC_DIR "/pre_form"
#define USER_MAILCAP RC_DIR "/mailcap"
#define SYS_MAILCAP "/etc/mailcap"
#define USER_MIMETYPES "~/.mime.types"
#define SYS_MIMETYPES "$MIME_TYPES"
#define USER_URIMETHODMAP RC_DIR "/urimethodmap"
#define SYS_URIMETHODMAP ETC_DIR "/urimethodmap"
#define DEF_SAVE_FILE "index.html"
$def_use_binstream
$def_term_if
$def_dir_if
$def_have_long_long
$def_have_strtoll
$def_have_strtoq
$def_have_atoll
$def_have_atoq
$def_have_strcasecmp
$def_have_strcasestr
$def_have_strchr
$def_have_strerror
$def_have_syserrlist
$def_have_bcopy
$def_have_waitpid
$def_have_wait3
$def_have_strftime
$def_have_getcwd
$def_have_getwd
$def_have_symlink
$def_have_readlink
$def_have_lstat
$def_have_setenv
$def_have_putenv
$def_have_srand48
$def_have_srandom
$def_have_getpassphrase
$def_have_chdir
$dcl_fclose
$dcl_pclose
$def_setjmp
$def_longjmp
$def_jmpbuf
$def_have_float_h
$def_have_sys_select_h
$def_sighandler
$def_sig_arg
$def_sig_arglist
$def_sig_return
$def_have_setpgrp
$def_setpgrp
/*
If you want to use IPv6, define this symbol.
*/
$def_ipv6
$def_ipv6_ss_family
/** dont edit below **/
#ifndef HAVE_SRAND48
#ifdef HAVE_SRANDOM
#define srand48 srandom
#define lrand48 random
#else /* HAVE_SRANDOM */
#define USE_INCLUDED_SRAND48
#endif /* HAVE_SRANDOM */
#endif
#if defined( __CYGWIN32__ ) && !defined( __CYGWIN__ )
#define __CYGWIN__
#endif
#if defined( __CYGWIN__ ) || defined( __EMX__ )
#define SUPPORT_DOS_DRIVE_PREFIX 1
#endif
#if defined( __CYGWIN__ )
#define SUPPORT_NETBIOS_SHARE 1
#if LANG == JA
#define SUPPORT_WIN9X_CONSOLE_MBCS 1
#endif
#endif
#if defined(__DJGPP__)
#define DEFAULT_TERM "dosansi"
#else
#define DEFAULT_TERM 0 /* XXX */
#endif
#if defined(__EMX__) /* use \$extension? */
#define GUNZIP_CMDNAME "gzip"
#define BUNZIP2_CMDNAME "bzip2"
#define INFLATE_CMDNAME "inflate.exe"
#define W3MBOOKMARK_CMDNAME "w3mbookmark.exe"
#define W3MHELPERPANEL_CMDNAME "w3mhelperpanel.exe"
#define DEV_NULL_PATH "nul"
#define DEV_TTY_PATH "con"
#define CGI_EXTENSION ".cmd"
#define USE_PATH_ENVVAR
#else
#define GUNZIP_CMDNAME "gunzip"
#define BUNZIP2_CMDNAME "bunzip2"
#define INFLATE_CMDNAME "inflate"
#define W3MBOOKMARK_CMDNAME "w3mbookmark"
#define W3MHELPERPANEL_CMDNAME "w3mhelperpanel"
#define DEV_NULL_PATH "/dev/null"
#define DEV_TTY_PATH "/dev/tty"
#define CGI_EXTENSION ".cgi"
#endif
#define PATH_SEPARATOR ':'
#define GUNZIP_NAME "gunzip"
#define BUNZIP2_NAME "bunzip2"
#define INFLATE_NAME "inflate"
#endif /* makefile_parameter */
#endif /* _CONFIGURED_ */
END_OF_CONFIG_H
echo ''
echo 'config.h is created. See config.h for further configuration.'
echo ''
echo 'Configuration done. Just type "make".'