#!/bin/sh # $Id: configure,v 1.9 2001/11/21 09:21:59 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 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 "$1" : "-*prefix=\(.*\)"` ;; -lang=en|--lang=en) pref_lang=2 ;; -lang=ja|--lang=ja) pref_lang=1 ;; -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=*) def_dcode=`expr "$1" : "-*code=\(.*\)"` ;; -cflags=*|--cflags=*) dcflags=`echo $1 | sed -e 's/-*cflags=//'` ;; -help|--help) echo "-yes, -nonstop Set all parameters to the default" echo "-prefix=DIR Specify prefix (default: /usr/local)" 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 "-help Display help" exit 0 ;; esac shift done # Version number of Boehm-GC library comes with w3m. # version number: JMMAAA J: major MM: minor AAA: alpha # Alpha number of non-alpha version is 255. # version 4.14alpha1 => 414002 mygcversion=600255 if [ -z "`echo -n aho | grep n`" ] ; then Echo() { echo -n "$*" } else Echo() { echo "$*\c" } fi do_sigtest() { echo "#include " > _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 } save_params() { echo "use_color=$use_color" >> config.param echo "use_menu=$use_menu" >> config.param echo "use_mouse=$use_mouse" >> config.param echo "use_cookie=$use_cookie" >> config.param echo "use_ssl=$use_ssl" >> config.param if [ -n "$dmodel" ]; then echo "dmodel=$dmodel" >> config.param fi } find_ssl() { sslinclude="" for i1 in /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 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 } #-------------------------------------------------------------- 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= 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' use_binstream='#define USE_BINMODE_STREAM' ;; OS/2 ) extension='.exe' 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 if [ -z "$def_bindir" ]; then def_bindir="$topdir/bin" fi echo "Which directory do you want to put the binary?" Echo "(default: $def_bindir) " readdir "$def_bindir" bindir=$_dir echo "def_bindir='$bindir'" >> config.param if [ -z "$def_libdir" ]; then case "$sysname" in *BSD) def_libdir="$topdir/libexec/w3m" ;; *) def_libdir="$topdir/lib/w3m" ;; esac fi echo "Which directory do you want to put the support binary files?" Echo "(default: $def_libdir) " readdir "$def_libdir" suplibdir=$_dir echo "def_libdir='$suplibdir'" >> config.param if [ -z "$def_helpdir" ]; then def_helpdir="$topdir/lib/w3m" fi echo "Which directory do you want to put the helpfile?" Echo "(default: $def_helpdir) " readdir "$def_helpdir" helpdir=$_dir echo "def_helpdir='$helpdir'" >> config.param echo "Which language do you prefer?" echo " 1 - Japanese (charset ISO-2022-JP, EUC-JP, Shift_JIS)" echo " 2 - English (charset US_ASCII, ISO-8859-1, etc.)" if [ "$pref_lang" = 2 ]; then Echo '[2]? ' def_lg=2 else Echo '[1]? ' def_lg=1 fi while : do readanswer lg_ans "$def_lg" if [ "$lg_ans" != 1 -a "$lg_ans" != 2 ]; then echo "Please choose 1 or 2." Echo "[$def_lg]? " continue else : fi break done echo "pref_lang=$lg_ans" >> config.param if [ "$lg_ans" = 1 ]; then use_lang="#define LANG JA" lang=ja else use_lang="#define LANG EN" lang=en fi if [ "$lang" = ja ]; then echo "Input your display kanji code." echo " S - Shift JIS" echo " E - EUC-JP" echo ' j - JIS: ESC $@ - ESC (J' echo ' N - JIS: ESC $B - ESC (J' echo ' n - JIS: ESC $B - ESC (B' echo ' m - JIS: ESC $@ - ESC (B' echo '' while : do if [ -n "$def_dcode" ] ; then Echo "(default: $def_dcode) " fi Echo "Which? " readanswer ncode "$def_dcode" case "$ncode" in [SEjNnm]) ;; *) echo "Illegal code. Try again." continue ;; esac break done echo "def_dcode=$ncode" >> config.param if [ "$ncode" = "S" ]; then scode=S else scode=E fi else ncode=x scode=x fi echo "Do you want to use Lynx-like key binding?" yesno lynx_key "$lynx_key" n echo "lynx_key=$lynx_key" >> config.param if [ "$lynx_key" = y ]; then keymap_file="keybind_lynx" else keymap_file="keybind" fi if [ "$lang" = ja ]; then if [ "$lynx_key" = y ]; then helpfile="w3mhelp-lynx_ja.html" else helpfile="w3mhelp-w3m_ja.html" fi else if [ "$lynx_key" = y ]; then helpfile="w3mhelp-lynx_en.html" else helpfile="w3mhelp-w3m_en.html" fi fi if [ "$lang" = ja ]; then echo "Do you want to use 2-byte character for table border, item, etc." yesno kanji_symbols "$kanji_symbols" y echo "kanji_symbols=$kanji_symbols" >> config.param else kanji_symbols=n fi if [ "$kanji_symbols" = y ]; then def_kanji_symbols="#define KANJI_SYMBOLS" else def_kanji_symbols="#undef KANJI_SYMBOLS" fi echo "Do you want to automatically generate domain parts of passwords for anonymous FTP logins" yesno ftppass_hostnamegen "$ftppass_hostnamegen" n echo "ftppass_hostnamegen=$ftppass_hostnamegen" >> config.param if [ "$ftppass_hostnamegen" = y ]; then def_ftppass_hostnamegen="#define FTPPASS_HOSTNAMEGEN" else def_ftppass_hostnamegen="#undef FTPPASS_HOSTNAMEGEN" fi echo "Do you want listing of options" yesno show_params "$show_params" n echo "show_params=$show_params" >> config.param if [ "$show_params" = y ]; then def_show_params="#define SHOW_PARAMS" else def_show_params="#undef SHOW_PARAMS" fi echo "Do you want NNTP support" yesno use_nntp "$use_nntp" n echo "use_nntp=$use_nntp" >> config.param if [ "$use_nntp" = y ]; then def_use_nntp="#define USE_NNTP" else def_use_nntp="#undef USE_NNTP" fi echo "Do you want ANSI color escape sequences support?" yesno ansi_color "$ansi_color" n echo "ansi_color=$ansi_color" >> config.param if [ "$ansi_color" = y ]; then def_ansi_color="#define ANSI_COLOR" else def_ansi_color="#undef ANSI_COLOR" 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 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; def_color="#undef COLOR" use_menu=n; def_menu="#undef MENU" use_mouse=n; def_mouse="#undef MOUSE" use_cookie=n; def_cookie="#undef USE_COOKIE" use_ssl=n; def_ssl="#undef USE_SSL" save_params customized=y ;; 2) use_color=y; def_color="#define COLOR" use_menu=y; def_menu="#define MENU" use_mouse=n; def_mouse="#undef MOUSE" use_cookie=n; def_cookie="#undef USE_COOKIE" use_ssl=n; def_ssl="#undef USE_SSL" save_params customized=y ;; 3) use_color=y; def_color="#define COLOR" use_menu=y; def_menu="#define MENU" use_mouse=y; def_mouse="#define MOUSE" use_cookie=n; def_cookie="#undef USE_COOKIE" use_ssl=n; def_ssl="#undef USE_SSL" save_params customized=y ;; 4) use_color=y; def_color="#define COLOR" use_menu=y; def_menu="#define MENU" use_mouse=y; def_mouse="#define MOUSE" use_cookie=y; def_cookie="#define USE_COOKIE" use_ssl=n; def_ssl="#undef USE_SSL" save_params customized=y ;; 5) use_color=y; def_color="#define COLOR" use_menu=y; def_menu="#define MENU" use_mouse=y; def_mouse="#define MOUSE" use_cookie=y; def_cookie="#define USE_COOKIE" use_ssl=y; def_ssl="#define USE_SSL" find_ssl save_params customized=y ;; 6) if [ "X$dmodel_save" = X6 ] then if [ "X$use_ssl" = Xy ] then find_ssl fi save_params customized=n fi ;; *) echo "Please input 1-6." Echo "Which? " continue ;; esac break done if [ "$customized" != y ]; then echo "Do you want to use color ESC sequence for kterm/pxvt " yesno use_color "$use_color" y echo "use_color=$use_color" >> config.param if [ "$use_color" = y ]; then def_color="#define COLOR" else def_color="#undef COLOR" fi echo 'Do you want to use mouse? (It requires xterm/kterm)' yesno use_mouse "$use_mouse" n echo "use_mouse=$use_mouse" >> config.param if [ "$use_mouse" = y ]; then def_mouse="#define MOUSE" else def_mouse="#undef MOUSE" fi echo "Do you want to use popup menu?" yesno use_menu "$use_menu" y echo "use_menu=$use_menu" >> config.param if [ "$use_menu" = y ]; then def_menu="#define MENU" else def_menu="#undef MENU" fi #echo "Do you want to use matrix in rendering table?" #if [ "$use_matrix" = n ]; then # Echo '[n]? ' # read ks_ans # if [ "$ks_ans" = 'y' ]; then # use_matrix='y' # fi #else # Echo '[y]? ' # read ks_ans # if [ "$ks_ans" = 'n' ]; then # use_matrix='n' # else # use_matrix='y' # fi #fi #use_matrix=y #echo "use_matrix=$use_matrix" >> config.param #if [ "$use_matrix" = y ]; then # def_matrix="#define MATRIX 1" #else # def_matrix="#undef MATRIX" #fi echo "Do you want to use cookie?" yesno use_cookie "$use_cookie" n echo "use_cookie=$use_cookie" >> config.param if [ "$use_cookie" = y ]; then def_cookie="#define USE_COOKIE" else def_cookie="#undef USE_COOKIE" fi echo "Do you want to use SSL?" echo '(You need OpenSSL library; Please see http://www.openssl.org/)' yesno use_ssl "$use_ssl" n echo "use_ssl=$use_ssl" >> config.param if [ "$use_ssl" = y ]; then def_ssl="#define USE_SSL" find_ssl else def_ssl="#undef USE_SSL" ssllib="" sslinclude="" fi fi if [ "$use_ssl" = y ]; then echo "Do you want SSL verification support" echo '(Your SSL library must be version 0.8 or later)' yesno use_ssl_verify "$use_ssl_verify" n echo "use_ssl_verify=$use_ssl_verify" >> config.param if [ "$use_ssl_verify" = y ]; then def_use_ssl_verify="#define USE_SSL_VERIFY" else def_use_ssl_verify="#undef USE_SSL_VERIFY" fi else use_ssl_verify=n def_use_ssl_verify="#undef USE_SSL_VERIFY" fi 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 [ -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 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 if [ -z "$dcc" ] ; then if ./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="-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 libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib do if [ -f $libdir/lib$lib.a -o -f $libdir/lib$lib.$so_ext ] ; then # check if the lib works... Echo "Terminal library -l$lib found at $libdir, " 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 libdir in /lib /usr/lib /usr/local/lib $prefix/lib do if [ -f $libdir/libgpm.a -o -f $libdir/libgpm.so ]; then echo "GPM library found." use_gpm="#define USE_GPM" gpmlib="-lgpm" fi done fi case $sysname in freebsd|FreeBSD) use_sysmouse="#define USE_SYSMOUSE" ;; *) 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 libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib do if [ -f $libdir/lib$lib.a -o -f $libdir/lib$lib.$so_ext ] ; then bsdlib="$bsdlib -l$lib" break fi done done extlib='' searchlibs="socket nsl" for lib in $searchlibs do for libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib do if [ -f $libdir/lib$lib.a -o -f $libdir/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 ## Search zlib zlib= for libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib /usr/X11R6/lib $prefix/lib ${HOME}/lib do if [ -f $libdir/libz.a -o -f $libdir/libz.$so_ext ] ; then echo "$libdir/libz found" zlib="-L$libdir -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 gclib='' gcinclude='' gctarget='' for libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib ${HOME}/lib do if [ -f $libdir/libgc.a -o -f $libdir/libgc.$so_ext ] ; then echo "$libdir/libgc found" gclib="-L$libdir -lgc" break fi done for inc in /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) # 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 if [ -n "$gclib" -a -n "$gcinclude" ]; then Echo GC library found on your system... cat > _zmachdep.c << EOF #include 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." echo "Do you want to use GC library comes with w3m?" yesno ans y y if [ "$ans" = 'n' -o "$ans" = 'N' ]; then cflags="$cflags -I$gcinclude" else cflags="$cflags -I./gc/include" gclib="gc/gc.a" gctarget=$gclib fi else cflags="$cflags -I$gcinclude" fi else echo "but it doesn't seem to work." cflags="$cflags -I./gc/include" gclib="gc/gc.a" gctarget=$gclib fi fi if [ -z "$gclib" -o -z "$gcinclude" ]; then cflags="$cflags -I./gc/include" gclib="gc/gc.a" gctarget="$gclib" fi # Apply patch. gc_cflags='' if [ "$gclib" = "gc/gc.a" -a ! -f patch_done ]; then patchfile="" case "$platform:$sysname" in R3000:*System_V*|R4000:UNIX_SYSV|R*000:UNIX_SV) # EWS-4800 patchfile=Patches/ews4800 gc_cflags=-Dmips ;; esac if [ -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 [ -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="" 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" fi done 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 else echo "You have perl." fi ####### strcasecmp cat > _zmachdep.c << EOF #include main() { int i; i = strcasecmp("abc","def"); } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have strcasecmp()." strcasecmp_flg="#define HAVE_STRCASECMP" else echo "You don't have strcasecmp()." strcasecmp_flg="#undef HAVE_STRCASECMP" fi ####### strchr cat > _zmachdep.c << EOF #include 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()." strchr_flg="#define HAVE_STRCHR" else echo "You don't have strchr()." strchr_flg="#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()." strerror_flg="#define HAVE_STRERROR" else echo "You don't have strerror()." strerror_flg="#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[]." syserrlist_flg="#define HAVE_SYS_ERRLIST" else echo "You don't have sys_errlist[]." syserrlist_flg="#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()." bcopy_flg="#define HAVE_BCOPY" else echo "You don't have bcopy()." bcopy_flg="#undef HAVE_BCOPY" fi ####### waitpid cat > _zmachdep.c << EOF #include #include 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()." waitpid_flg="#define HAVE_WAITPID" else echo "You don't have waitpid()." waitpid_flg="#undef HAVE_WAITPID" fi ####### wait3 cat > _zmachdep.c << EOF #include #include #include #include #include #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()." wait3_flg="#define HAVE_WAIT3" else echo "You don't have wait3()." wait3_flg="#undef HAVE_WAIT3" fi ####### strftime cat > _zmachdep.c << EOF #include 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()." strftime_flg="#define HAVE_STRFTIME" else echo "You don't have strftime()." strftime_flg="#undef HAVE_STRFTIME" fi ####### getcwd cat > _zmachdep.c << EOF #include #include main() { char path[MAXPATHLEN]; getcwd(path,MAXPATHLEN); } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have getcwd()." getcwd_flg="#define HAVE_GETCWD" else echo "You don't have getcwd()." getcwd_flg="#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()." getwd_flg="#define HAVE_GETWD" else echo "You don't have getwd()." getwd_flg="#undef HAVE_GETWD" 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()." readlink_flg="#define HAVE_READLINK" else echo "You don't have readlink()." readlink_flg="#undef HAVE_READLINK" fi ####### setenv cat > _zmachdep.c << EOF #include main() { setenv("HOGE","hoge",1); } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have setenv()." setenv_flg="#define HAVE_SETENV" else echo "You don't have setenv()." setenv_flg="#undef HAVE_SETENV" fi ####### putenv cat > _zmachdep.c << EOF #include main() { putenv("HOGE=hoge"); } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have putenv()." putenv_flg="#define HAVE_PUTENV" else echo "You don't have putenv()." putenv_flg="#undef HAVE_PUTENV" fi ####### sigsetjmp cat > _zmachdep.c << EOF #include 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()." setjmp_def="#define SETJMP(env) sigsetjmp(env,1)" longjmp_def="#define LONGJMP(env,val) siglongjmp(env,val)" jmpbuf_def="#define JMP_BUF sigjmp_buf" else echo "You don't have sigsetjmp()." setjmp_def="#define SETJMP(env) setjmp(env)" longjmp_def="#define LONGJMP(env,val) longjmp(env)" jmpbuf_def="#define JMP_BUF jmp_buf" fi ####### srand48 cat > _zmachdep.c << EOF #include main() { srand48(0); } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have srand48()." srand48_flg="#define HAVE_SRAND48" else echo "You don't have srand48()." srand48_flg="#undef HAVE_SRAND48" fi ####### srandom cat > _zmachdep.c << EOF #include main() { srandom(0); } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have srandom()." srandom_flg="#define HAVE_SRANDOM" else echo "You don't have srandom()." srandom_flg="#undef HAVE_SRANDOM" fi ####### getpassphrase cat > _zmachdep.c << EOF #include main() { getpassphrase(""); } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have getpassphrase()." getpassphrase_flg="#define HAVE_GETPASSPHRASE" else echo "You don't have getpassphrase()." getpassphrase_flg="#undef HAVE_GETPASSPHRASE" fi ####### fclose cat > _zmachdep.c << EOF #include #include main() { void (*c)() = fclose; } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "fclose() is declared." fclose_dcl='' else echo "fclose() is not declared." fclose_dcl='void fclose(FILE*);' fi ####### pclose cat > _zmachdep.c << EOF #include #include main() { void (*c)() = pclose; } EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "pclose() is declared." pclose_dcl='' else echo "pclose() is not declared." pclose_dcl='void pclose(FILE*);' fi ####### termios/termio/sgtty term_if='#define SGTTY' if [ $sysname = "HP-UX" ]; then echo "Your OS is HP-UX; using termio" term_if="#define HAVE_TERMIO_H" elif [ $sysname = "CYGWIN" ]; then echo "Your OS is CYGWIN; using termios" term_if="#define HAVE_TERMIOS_H" elif [ $sysname = "OS/2" ]; then echo "Your OS is OS/2; using termios" term_if='#define HAVE_TERMIOS_H' elif [ -r /usr/include/termios.h ]; then echo "You have termios." term_if='#define HAVE_TERMIOS_H' elif [ -r /usr/include/termio.h ]; then echo "You have termio." term_if='#define HAVE_TERMIO_H' elif [ -r /usr/include/sgtty.h ]; then echo "You have sgtty." 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 dir_if='' if [ $sysname = "CYGWIN" ]; then echo "Your OS is CYGWIN; using dirent.h" dir_if='#define HAVE_DIRENT_H' elif [ $sysname = "OS/2" ]; then echo "Your OS is OS/2; using dirent.h" dir_if='#define HAVE_DIRENT_H' elif [ -r /usr/include/dirent.h ]; then echo "You have dirent.h." dir_if='#define HAVE_DIRENT_H' elif [ -r /usr/include/sys/dir.h ]; then echo "You have sys/dir.h." 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).' sig_type='typedef int MySignalHandler;' sig_arg='#define SIGNAL_ARG int _dummy' sig_arglist='#define SIGNAL_ARGLIST 0' 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).' sig_type='typedef int MySignalHandler;' sig_arg='#define SIGNAL_ARG void' sig_arglist='#define SIGNAL_ARGLIST' 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).' sig_type='typedef void MySignalHandler;' sig_arg='#define SIGNAL_ARG int _dummy' sig_arglist='#define SIGNAL_ARGLIST 0' 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 sig_type='typedef void MySignalHandler;' sig_arg='#define SIGNAL_ARG void' sig_arglist='#define SIGNAL_ARGLIST' sig_return='#define SIGNAL_RETURN return' fi fi fi # check for float.h cat > _zmachdep.c << EOF #include main() { ; } EOF if $cc $cflags -c _zmachdep.c > /dev/null 2>&1 then echo "You have float.h." no_float_h='#define HAVE_FLOAT_H' else no_float_h='#undef HAVE_FLOAT_H' fi ####### setpgrp(pid, pgrp) or setpgrp() ? cat > _zmachdep.c << EOF #include 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()." have_setpgrp='#define HAVE_SETPGRP' else cat > _zmachdep.c << EOF #include 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 )." have_setpgrp='#define HAVE_SETPGRP' setpgrp='#define setpgrp() setpgrp( 0, 0 )' else have_setpgrp='' fi fi ###### atexit/on_exit # cat > _zmachdep.c < /dev/null 2>&1 # then # echo "You have atexit()." # atexit_flg="#define HAVE_ATEXIT" # else # cat > _zmachdep.c < # 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 < #include main() { if (socket(AF_INET6, SOCK_STREAM, 0) < 0) exit(1); else exit(0); } EOF ipv6="#undef INET6" v6_ss_family="" v6lib='' if $cc $cflags -o _zmachdep _zmachdep.c $extlib > /dev/null 2>&1 then if ./_zmachdep; then ipv6="#define INET6" fi case $sysname in *BSD|*bsd) cat > _zmachdep.c < #include #include 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 libdir in /usr/local/v6/lib /usr/local/lib /usr/lib $prefix/lib do if [ -e $libdir/libinet6.a ]; then if [ "$libdir" != "/usr/lib" ]; then v6lib="-L$libdir" 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()." ipv6="#undef INET6" fi fi ;; CYGWIN*) ipv6="#undef INET6" ;; esac fi ####### ss_family or __ss_family ? if [ "$ipv6" = "#define INET6" ]; then cat > _zmachdep.c < #include 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 < #include 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." ipv6_ss_family="#define ss_family __ss_family" else echo "You don't have ss_family." ipv6="#undef INET6" fi fi fi if [ "$ipv6" = "#undef INET6" ]; then echo "You don't have IPv6 support." else echo "You have IPv6 support." 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 cat > extrvers.c << EOF #include #include #include "version.c" main() { char *p = strchr(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. */ #undef DICT /* If you define USE_MARK, you can use set-mark (C-SPC), goto-next-mark (ESC p), goto-next-mark (ESC n) and mark-by-regexp ("). */ #undef USE_MARK /* If you want to load and save URL history. */ #define USE_HISTORY /* BG_COLOR enables w3m to set background color. */ #define BG_COLOR /* VIEW_UNSEENOBJECTS enables w3m to make a link to unseen objects. e.g. background image. */ #undef VIEW_UNSEENOBJECTS /* VI_PREC_NUM enables vi-like behavior for '2 SPC' or '2 b' */ #undef VI_PREC_NUM /* * Do word fill */ #undef FORMAT_NICE /* * Support Gopher protocol */ #undef USE_GOPHER /* * Support NNTP */ $def_use_nntp /* * Support ANSI color escape sequences */ $def_ansi_color /* * Enable id attribute */ #define ID_EXT /* * Save Current-buffer Information */ #define BUFINFO /* * Support EGD (Entropy Gathering Daemon) */ #undef USE_EGD /* * Use Emacs-like key binding for file name completion */ #undef EMACS_LIKE_LINEEDIT /* * Remove line trailing spaces in html buffer. */ #undef ENABLE_REMOVE_TRAILINGSPACES /* * Move cursor to top line when going to label. */ #undef LABEL_TOPLINE /* * Move cursor to top line when moving to next page. */ #undef NEXTPAGE_TOPLINE /* Use alarm function. */ #undef USE_ALARM /**********************************************************/ #ifdef makefile_parameter BIN_DIR = $bindir HELP_DIR = $helpdir LIB_DIR = $suplibdir HELP_FILE = $helpfile SYS_LIBRARIES = $gpmlib $extlib $termlib $ssllib $v6lib LOCAL_LIBRARIES = $bsdlib $ldflags CC = $cc MYCFLAGS = $cflags $bsdinclude $sslinclude 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 EXT_TARGETS=\$(BOOKMARKER) \$(HELPER) $inflate GC_CFLAGS=$gc_cflags GCLIB=$gclib GCTARGET=$gctarget RANLIB=$ranlib_cmd MKDIR=$MKDIR PERL=$perl VERSION=$w3mversion MODEL=$sysname.$platform-$modelname-$lang #else $special_sys #define DISPLAY_CODE '$ncode' #define SYSTEM_CODE '$scode' #define JA 0 #define EN 1 $use_lang $def_kanji_symbols $def_color $def_mouse $use_gpm $use_sysmouse $def_menu $def_cookie $def_ssl $def_use_ssl_verify $def_ftppass_hostnamegen $def_show_params #define DEF_EDITOR "$editor" #define DEF_MAILER "$mailer" #define DEF_EXT_BROWSER "$brz" #define LIB_DIR "$suplibdir" #define HELP_DIR "$helpdir" #define HELP_FILE "w3mhelp.html" #define W3MCONFIG "w3mconfig" #define RC_DIR "~/.w3m/" #define BOOKMARK "bookmark.html" #define CONFIG_FILE "config" #define KEYMAP_FILE "keymap" #define MENU_FILE "menu" #define COOKIE_FILE "cookie" #define HISTORY_FILE "history" #define USER_MAILCAP RC_DIR "/mailcap" #define SYS_MAILCAP "/etc/mailcap" #define USER_MIMETYPES "~/.mime.types" #define SYS_MIMETYPES "$MIME_TYPES" #define DEF_SAVE_FILE "index.html" $use_binstream $term_if $dir_if $strcasecmp_flg $strchr_flg $strerror_flg $syserrlist_flg $bcopy_flg $waitpid_flg $wait3_flg $strftime_flg $getdtablesize_flg $getcwd_flg $getwd_flg $readlink_flg $setenv_flg $putenv_flg $srand48_flg $srandom_flg $getpassphrase_flg $fclose_dcl $pclose_dcl $setjmp_def $longjmp_def $jmpbuf_def $sig_type $sig_arg $sig_arglist $sig_return $have_setpgrp $setpgrp /* If you want to use IPv6, define this symbol. */ $ipv6 $ipv6_ss_family #undef TABLE_EXPAND #undef TABLE_NO_COMPACT #define NOWRAP 1 #define MATRIX 1 $no_float_h #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 #endif #endif /* makefile_parameter */ #endif /* _CONFIGURED_ */ END_OF_CONFIG_H echo '' echo 'config.h is created. See config.h for further configuration.' echo '' echo 'Generating scripts/dirlist.cgi' echo 'Configuration done. Just type "make".'