Many hint file updates.
+ Improve and simplify detection of local libraries and header files.
+
+ Expand documentation of installation process in new INSTALL file.
+
Upgrade Traps and Pitfalls:
Since a lot has changed in the build process, you are probably best off
Therefore, you are probably better off ignoring your old config.sh, as
in the following:
- make distclean # (if you've built perl before)
+ make distclean # (if you've built perl before)
+ rm -f config.sh # (in case distclean mysteriously fails)
sh Configure [whatever options you like]
make depend
make
# archive site. Check with Archie if you don't know where that can be.)
#
-# $Id: Head.U,v 3.0.1.7 1995/03/21 08:46:15 ram Exp $
+# $Id: Head.U,v 3.0.1.8 1995/07/25 13:40:02 ram Exp $
#
-# Generated on Thu Jun 22 10:38:35 EDT 1995 [metaconfig 3.0 PL55]
+# Generated on Thu Oct 19 10:47:09 EDT 1995 [metaconfig 3.0 PL58]
cat >/tmp/c1$$ <<EOF
ARGGGHHHH!!!!!
;;
esac
+: Proper PATH separator
+p_=:
+: On OS/2 this directory should exist if this is not floppy only system :-]
+if test -d c:/.; then
+ p_=\;
+ PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
+ OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
+fi
: Proper PATH setting
paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
for p in $paths
do
- case ":$PATH:" in
- *:$p:*) ;;
- *) test -d $p && PATH=$PATH:$p ;;
+ case "$p_$PATH$p_" in
+ *$p_$p$p_*) ;;
+ *) test -d $p && PATH=$PATH$p_$p ;;
esac
done
-PATH=.:$PATH
+PATH=.$p_$PATH
export PATH
: Sanity checks
: Configure runs within the UU subdirectory
test -d UU || mkdir UU
-cd UU && rm -f *
+cd UU && rm -f ./*
dynamic_ext=''
extensions=''
cppflags=''
ldflags=''
lkflags=''
+locincpth=''
optimize=''
+cf_email=''
cf_by=''
cf_time=''
contains=''
d_pathconf=''
d_pause=''
d_pipe=''
+d_poll=''
d_portable=''
d_readdir=''
d_rewinddir=''
db_prefixtype=''
i_db=''
i_dbm=''
+i_rpcsvcdbm=''
d_dirnamlen=''
direntrytype=''
i_dirent=''
libc=''
glibpth=''
libpth=''
+loclibpth=''
plibpth=''
xlibpth=''
libs=''
phostname=''
c=''
n=''
+d_eofnblk=''
+eagain=''
+o_nonblock=''
+rd_nodata=''
groupcat=''
hostcat=''
passcat=''
package=''
spackage=''
patchlevel=''
+perladmin=''
prefix=''
prefixexp=''
installprivlib=''
scriptdirexp=''
selecttype=''
sig_name=''
+sig_max=''
+sig_num=''
d_sitelib=''
installsitelib=''
sitelib=''
groupstype=''
i_whoami=''
+: default library list
+libswanted=''
+: set useposix=false in your hint file to disable the POSIX extension.
+useposix=true
+: Possible local include directories to search.
+locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
+locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
+:
+: no include file wanted by default
+inclwanted=''
+
: change the next line if compiling for Xenix/286 on Xenix/386
xlibpth='/usr/lib/386 /lib/386'
+: Possible local library directories to search.
+loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
+loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
+
: general looking path for locating libraries
-glibpth="/lib/pa1.1 /usr/lib/large /lib /usr/lib $xlibpth"
-glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
-glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib /usr/shlib"
+glibpth="/lib/pa1.1 /usr/shlib /usr/lib/large /lib /usr/lib"
+glibpth="$glibpth $xlibpth /lib/large /usr/lib/small /lib/small"
+glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/shlib"
: Private path used by Configure to find libraries. Its value
: is prepended to libpth. This variable takes care of special
: machines, like the mips. Usually, it should be empty.
plibpth=''
-: default library list
-libswanted=''
: full support for void wanted by default
defvoidused=15
-: set useposix=false in your hint file to disable the POSIX extension.
-useposix=true
-: no include file wanted by default
-inclwanted=''
-
: List of libraries we want.
libswanted='net socket inet nsl nm ndbm gdbm dbm db malloc dl'
libswanted="$libswanted dld ld sun m c cposix posix ndir dir crypt"
glibpth="/usr/shlib $glibpth"
: Do not use vfork unless overridden by a hint file.
usevfork=false
-: We might as well always be portable. It makes no difference for
-: perl5, and makes people happy.
-d_portable=define
: script used to extract .SH files with variable substitutions
cat >extract <<'EOS'
esac
shift
;;
- -V) echo "$me generated by metaconfig 3.0 PL55." >&2
+ -V) echo "$me generated by metaconfig 3.0 PL58." >&2
exit 0;;
--) break;;
-*) echo "$me: unknown option $1" >&2; shift; error=true;;
rm
sed
sort
+tail
touch
tr
uniq
test
uname
"
-pth=`echo $PATH | sed -e 's/:/ /g'`
+pth=`echo $PATH | sed -e "s/$p_/ /g"`
pth="$pth /lib /usr/lib"
for file in $loclist; do
xxx=`./loc $file $file $pth`
/*)
echo $file is in $xxx.
;;
+ ?:[\\/]*)
+ echo $file is in $xxx.
+ ;;
*)
echo "I don't know where $file is. I hope it's in everyone's PATH."
;;
/*)
echo $file is in $xxx.
;;
+ ?:[\\/]*)
+ echo $file is in $xxx.
+ ;;
*)
echo "I don't see $file out there, $say."
say=either
osname=news_os
fi
$rm -f ../UU/kernel.what
+ elif test -d c:/.; then
+ set X $myuname
+ osname=os2
+ osvers="$5"
fi
fi
1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
esac
-: decide how portable to be
+: decide how portable to be. Allow command line overrides.
case "$d_portable" in
-"$define") dflt=y;;
-*) dflt=n;;
-esac
-$cat <<'EOH'
-
-I can set things up so that your shell scripts and binaries are more portable,
-at what may be a noticable cost in performance. In particular, if you
-ask to be portable, the following happens:
-
- 1) Shell scripts will rely on the PATH variable rather than using
- the paths derived above.
- 2) ~username interpretations will be done at run time rather than
- by Configure.
-
-EOH
-rp="Do you expect to run these scripts and binaries on multiple machines?"
-. ./myread
-case "$ans" in
- y*) d_portable="$define"
- ;;
- *) d_portable="$undef" ;;
+"$undef") ;;
+*) d_portable="$define" ;;
esac
: set up shell script to do ~ expansion
fi
$rm -f usr.c usr.out
echo "and you're compiling with the $mips_type compiler and libraries."
+ xxx_prompt=y
echo "exit 0" >mips
else
echo "Doesn't look like a MIPS system."
+ xxx_prompt=n
echo "exit 1" >mips
fi
chmod +x mips
'') ;;
*) dflt="$usrinc";;
esac
-fn=d/
-rp='Where are the include files you want to use?'
-. ./getfile
-usrinc="$ans"
+case "$xxx_prompt" in
+y) fn=d/
+ rp='Where are the include files you want to use?'
+ . ./getfile
+ usrinc="$ans"
+ ;;
+*) usrinc="$dflt"
+ ;;
+esac
: see how we invoke the C preprocessor
echo " "
esac
$rm -f testcpp.c testcpp.out
-: determine optimize, if desired, or use for debug flag also
-case "$optimize" in
-' ') dflt='none';;
-'') dflt='-O';;
-*) dflt="$optimize";;
+: Set private lib path
+case "$plibpth" in
+'') if ./mips; then
+ plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
+ fi;;
+esac
+case "$libpth" in
+' ') dlist='';;
+'') dlist="$loclibpth $plibpth $glibpth";;
+*) dlist="$libpth";;
esac
-$cat <<EOH
-Some C compilers have problems with their optimizers, by default, $package
-compiles with the -O flag to use the optimizer. Alternately, you might want
-to use the symbolic debugger, which uses the -g flag (on traditional Unix
-systems). Either flag can be specified here. To use neither flag, specify
-the word "none".
+: Now check and see which directories actually exist, avoiding duplicates
+libpth=''
+for xxx in $dlist
+do
+ if $test -d $xxx; then
+ case " $libpth " in
+ *" $xxx "*) ;;
+ *) libpth="$libpth $xxx";;
+ esac
+ fi
+done
+$cat <<'EOM'
-EOH
-rp="What optimizer/debugger flag should be used?"
+Some systems have incompatible or broken versions of libraries. Among
+the directories listed in the question below, please remove any you
+know not to be holding relevant libraries, and add any that are needed.
+Say "none" for none.
+
+EOM
+case "$libpth" in
+'') dflt='none';;
+*)
+ set X $libpth
+ shift
+ dflt=${1+"$@"}
+ ;;
+esac
+rp="Directories to use for library searches?"
. ./myread
-optimize="$ans"
-case "$optimize" in
-'none') optimize=" ";;
+case "$ans" in
+none) libpth=' ';;
+*) libpth="$ans";;
esac
-dflt=''
-case "$ccflags" in
-'')
- case "$gccversion" in
- 1*) dflt='-fpcc-struct-return' ;;
- esac
- case "$optimize" in
- *-g*) dflt="$dflt -DDEBUGGING";;
- esac
- case "$gccversion" in
- 2*) if test -d /etc/conf/kconfig.d &&
- $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
- then
- dflt="$dflt -posix"
- fi
- ;;
- esac
+: determine root of directory hierarchy where package will be installed.
+case "$prefix" in
+'')
+ dflt=`./loc . /usr/local /usr/local /local /opt /usr`
+ ;;
+*)
+ dflt="$prefix"
;;
esac
+$cat <<EOM
-case "$mips_type" in
-*BSD*) ;;
+By default, $package will be installed in $dflt/bin, manual
+pages under $dflt/man, etc..., i.e. with $dflt as prefix for
+all installation directories. Typically set to /usr/local, but you
+may choose /usr if you wish to install $package among your system
+binaries. If you wish to have binaries under /bin but manual pages
+under /usr/local/man, that's ok: you will be prompted separately
+for each of the installation directories, the prefix being only used
+to set the defaults.
+
+EOM
+fn=d~
+rp='Installation prefix to use?'
+. ./getfile
+oldprefix=''
+case "$prefix" in
'') ;;
-*) inclwanted="$inclwanted $usrinc/bsd";;
+*)
+ case "$ans" in
+ "$prefix") ;;
+ *) oldprefix="$prefix";;
+ esac
+ ;;
esac
-for thisincl in $inclwanted; do
- if $test -d $thisincl; then
- if $test x$thisincl != x$usrinc; then
- case "$dflt" in
- *$thisincl*);;
- *) dflt="$dflt -I$thisincl";;
- esac
- fi
- fi
-done
+prefix="$ans"
+prefixexp="$ansexp"
-inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
- xxx=true;
-elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
- xxx=true;
-else
- xxx=false;
-fi;
-if $xxx; then
- case "$dflt" in
- *$2*);;
- *) dflt="$dflt -D$2";;
- esac;
-fi'
+: set the prefixit variable, to compute a suitable default value
+prefixit='case "$3" in
+""|none)
+ case "$oldprefix" in
+ "") eval "$1=\"\$$2\"";;
+ *)
+ case "$3" in
+ "") eval "$1=";;
+ none)
+ eval "tp=\"\$$2\"";
+ case "$tp" in
+ ""|" ") eval "$1=\"\$$2\"";;
+ *) eval "$1=";;
+ esac;;
+ esac;;
+ esac;;
+*)
+ eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
+ case "$tp" in
+ --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
+ /*-$oldprefix/*|\~*-$oldprefix/*)
+ eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
+ *) eval "$1=\"\$$2\"";;
+ esac;;
+esac'
-if ./osf1; then
- set signal.h __LANGUAGE_C__; eval $inctest
+: is AFS running?
+echo " "
+if test -d /afs; then
+ echo "AFS may be running... I'll be extra cautious then..." >&4
+ afs=true
else
- set signal.h LANGUAGE_C; eval $inctest
+ echo "AFS does not seem to be running..." >&4
+ afs=false
fi
-set signal.h NO_PROTOTYPE; eval $inctest
-set signal.h _NO_PROTO; eval $inctest
-case "$dflt" in
-'') dflt=none;;
-esac
-case "$ccflags" in
-'') ;;
-*) dflt="$ccflags";;
-esac
-$cat <<EOH
+: determine where public executables go
+echo " "
+set dflt bin bin
+eval $prefixit
+fn=d~
+rp='Pathname where the public executables will reside?'
+. ./getfile
+if $test "X$ansexp" != "X$binexp"; then
+ installbin=''
+fi
+bin="$ans"
+binexp="$ansexp"
+if $afs; then
+ $cat <<EOM
-Your C compiler may want other flags. For this question you should include
--I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
-but you should NOT include libraries or ld flags like -lwhatever. If you
-want $package to honor its debug switch, you should include -DDEBUGGING here.
-Your C compiler might also need additional flags, such as -D_POSIX_SOURCE,
--DHIDEMYMALLOC or -DCRIPPLED_CC.
+Since you are running AFS, I need to distinguish the directory in which
+executables reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
-To use no flags, specify the word "none".
+EOM
+ case "$installbin" in
+ '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
+ *) dflt="$installbin";;
+ esac
+ fn=de~
+ rp='Where will public executables be installed?'
+ . ./getfile
+ installbin="$ans"
+else
+ installbin="$binexp"
+fi
-EOH
-set X $dflt
-shift
-dflt=${1+"$@"}
-rp="Any additional cc flags?"
-. ./myread
-case "$ans" in
-none) ccflags='';;
-*) ccflags="$ans";;
-esac
+: set the prefixup variable, to restore leading tilda escape
+prefixup='case "$prefixexp" in
+"$prefix") ;;
+*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
+esac'
+
+: determine where public executable scripts go
+set scriptdir scriptdir
+eval $prefixit
+case "$scriptdir" in
+'')
+ dflt="$bin"
+ : guess some guesses
+ $test -d /usr/share/scripts && dflt=/usr/share/scripts
+ $test -d /usr/share/bin && dflt=/usr/share/bin
+ $test -d /usr/local/script && dflt=/usr/local/script
+ $test -d $prefixexp/script && dflt=$prefixexp/script
+ set dflt
+ eval $prefixup
+ ;;
+*) dflt="$scriptdir"
+ ;;
+esac
+$cat <<EOM
+
+Some installations have a separate directory just for executable scripts so
+that they can mount it across multiple architectures but keep the scripts in
+one spot. You might, for example, have a subdirectory of /usr/share for this.
+Or you might just lump your scripts in with all your other executables.
+
+EOM
+fn=d~
+rp='Where do you keep publicly executable scripts?'
+. ./getfile
+if $test "X$ansexp" != "X$scriptdirexp"; then
+ installscript=''
+fi
+scriptdir="$ans"
+scriptdirexp="$ansexp"
+if $afs; then
+ $cat <<EOM
+
+Since you are running AFS, I need to distinguish the directory in which
+scripts reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
+
+EOM
+ case "$installscript" in
+ '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
+ *) dflt="$installscript";;
+ esac
+ fn=de~
+ rp='Where will public scripts be installed?'
+ . ./getfile
+ installscript="$ans"
+else
+ installscript="$scriptdirexp"
+fi
+
+: determine where private executables go
+set dflt privlib lib/$package
+eval $prefixit
+$cat <<EOM
+
+There are some auxiliary files for $package that need to be put into a
+private library directory that is accessible by everyone.
+
+EOM
+fn=d~+
+rp='Pathname where the private library files will reside?'
+. ./getfile
+if $test "X$privlibexp" != "X$ansexp"; then
+ installprivlib=''
+fi
+privlib="$ans"
+privlibexp="$ansexp"
+if $afs; then
+ $cat <<EOM
+
+Since you are running AFS, I need to distinguish the directory in which
+private files reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
+
+EOM
+ case "$installprivlib" in
+ '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
+ *) dflt="$installprivlib";;
+ esac
+ fn=de~
+ rp='Where will private files be installed?'
+ . ./getfile
+ installprivlib="$ans"
+else
+ installprivlib="$privlibexp"
+fi
+
+: determine the architecture name
+echo " "
+if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
+ tarch=`arch`"-$osname"
+elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
+ if uname -m > tmparch 2>&1 ; then
+ tarch=`$sed -e 's/ /_/g' -e 's/$/'"-$osname/" tmparch`
+ else
+ tarch="$osname"
+ fi
+ $rm -f tmparch
+else
+ tarch="$osname"
+fi
+case "$myarchname" in
+''|"$tarch") ;;
+*)
+ echo "(Your architecture name used to be $myarchname.)"
+ archname=''
+ ;;
+esac
+case "$archname" in
+'') dflt="$tarch";;
+*) dflt="$archname";;
+esac
+rp='What is your architecture name'
+. ./myread
+archname="$ans"
+myarchname="$tarch"
+
+: determine where public architecture dependent libraries go
+set archlib archlib
+eval $prefixit
+case "$archlib" in
+'')
+ case "$privlib" in
+ '')
+ dflt=`./loc . "." $prefixexp/lib /usr/local/lib /usr/lib /lib`
+ set dflt
+ eval $prefixup
+ ;;
+ *) dflt="$privlib/$archname";;
+ esac
+ ;;
+*) dflt="$archlib";;
+esac
+cat <<EOM
+
+$spackage contains architecture-dependent library files. If you are
+sharing libraries in a heterogeneous environment, you might store
+these files in a separate location. Otherwise, you can just include
+them with the rest of the public library files.
+
+EOM
+fn=d~
+rp='Where do you want to put the public architecture-dependent libraries?'
+. ./getfile
+archlib="$ans"
+archlibexp="$ansexp"
+
+if $afs; then
+ $cat <<EOM
+
+Since you are running AFS, I need to distinguish the directory in which
+private files reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
+
+EOM
+ case "$installarchlib" in
+ '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
+ *) dflt="$installarchlib";;
+ esac
+ fn=de~
+ rp='Where will architecture-dependent library files be installed?'
+ . ./getfile
+ installarchlib="$ans"
+else
+ installarchlib="$archlibexp"
+fi
+if $test X"$archlib" = X"$privlib"; then
+ d_archlib="$undef"
+else
+ d_archlib="$define"
+fi
+
+: determine whether the user wants to include a site-specific library
+: in addition to privlib.
+$cat <<EOM
+
+Some sites may wish to specify a local directory for $package
+to search by default in addition to $privlib.
+If you don't want to use such an additional directory, answer 'none'.
+
+EOM
+case "$sitelib" in
+'') dflt=none ;;
+*) dflt="$sitelib" ;;
+esac
+fn=d~+n
+rp='Local directory for additional library files?'
+. ./getfile
+if $test "X$sitelibexp" != "X$ansexp"; then
+ installsitelib=''
+fi
+sitelib="$ans"
+sitelibexp="$ansexp"
+if $afs; then
+ case "$sitelib" in
+ '') installsitelib="$sitelibexp"
+ ;;
+ *) $cat <<EOM
+
+Since you are running AFS, I need to distinguish the directory in which
+private files reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
+
+EOM
+ case "$installsitelib" in
+ '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
+ *) dflt="$installsitelib";;
+ esac
+ fn=de~
+ rp='Where will additional local files be installed?'
+ . ./getfile
+ installsitelib="$ans"
+ ;;
+ esac
+else
+ installsitelib="$sitelibexp"
+fi
+
+case "$sitelibexp" in
+'') d_sitelib=undef ;;
+*) d_sitelib=define ;;
+esac
+
+: determine where manual pages go
+set man1dir man1dir none
+eval $prefixit
+$cat <<EOM
+
+$spackage has manual pages available in source form.
+EOM
+case "$nroff" in
+nroff)
+ echo "However, you don't have nroff, so they're probably useless to you."
+ case "$man1dir" in
+ '') man1dir="none";;
+ esac;;
+esac
+echo "If you don't want the manual sources installed, answer 'none'."
+case "$man1dir" in
+'')
+ lookpath="$prefixexp/man/man1 $prefixexp/man/u_man/man1"
+ lookpath="$lookpath $prefixexp/man/l_man/man1"
+ lookpath="$lookpath /usr/local/man/man1 /opt/man/man1 /usr/man/manl"
+ lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
+ lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
+ lookpath="$lookpath /usr/man/man.L"
+ man1dir=`./loc . $prefixexp/man/man1 $lookpath`
+ if $test -d "$man1dir"; then
+ dflt="$man1dir"
+ else
+ dflt="$sysman"
+ fi
+ set dflt
+ eval $prefixup
+ ;;
+' ') dflt=none;;
+*) dflt="$man1dir"
+ ;;
+esac
+echo " "
+fn=dn~
+rp="Where do the main $spackage manual pages (source) go?"
+. ./getfile
+if test "X$man1direxp" != "X$ansexp"; then
+ installman1dir=''
+fi
+man1dir="$ans"
+man1direxp="$ansexp"
+case "$man1dir" in
+'') man1dir=' '
+ installman1dir='';;
+esac
+if $afs; then
+ $cat <<EOM
+
+Since you are running AFS, I need to distinguish the directory in which
+manual pages reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
+
+EOM
+ case "$installman1dir" in
+ '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
+ *) dflt="$installman1dir";;
+ esac
+ fn=de~
+ rp='Where will man pages be installed?'
+ . ./getfile
+ installman1dir="$ans"
+else
+ installman1dir="$man1direxp"
+fi
+
+: What suffix to use on installed man pages
+
+case "$man1dir" in
+' ')
+ man1ext='0'
+ ;;
+*)
+ rp="What suffix should be used for the main $spackage man pages?"
+ case "$man1dir" in
+ *1) dflt=1 ;;
+ *1p) dflt=1p ;;
+ *1pm) dflt=1pm ;;
+ *l) dflt=l;;
+ *n) dflt=n;;
+ *o) dflt=o;;
+ *p) dflt=p;;
+ *C) dflt=C;;
+ *L) dflt=L;;
+ *L1) dflt=L1;;
+ *) dflt=1;;
+ esac
+ . ./myread
+ man1ext="$ans"
+ ;;
+esac
+
+: set up the script used to warn in case of inconsistency
+cat <<'EOSC' >whoa
+dflt=y
+echo " "
+echo "*** WHOA THERE!!! ***" >&4
+echo " The $hint value for \$$var on this machine was \"$was\"!" >&4
+rp=" Keep the $hint value?"
+. ./myread
+case "$ans" in
+y) td=$was; tu=$was;;
+esac
+EOSC
+
+: function used to set $1 to $val
+setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
+case "$val$was" in
+$define$undef) . ./whoa; eval "$var=\$td";;
+$undef$define) . ./whoa; eval "$var=\$tu";;
+*) eval "$var=$val";;
+esac'
+
+: see if we can have long filenames
+echo " "
+rmlist="$rmlist /tmp/cf$$"
+$test -d /tmp/cf$$ || mkdir /tmp/cf$$
+first=123456789abcdef
+second=/tmp/cf$$/$first
+$rm -f $first $second
+if (echo hi >$first) 2>/dev/null; then
+ if $test -f 123456789abcde; then
+ echo 'You cannot have filenames longer than 14 characters. Sigh.' >&4
+ val="$undef"
+ else
+ if (echo hi >$second) 2>/dev/null; then
+ if $test -f /tmp/cf$$/123456789abcde; then
+ $cat <<'EOM'
+That's peculiar... You can have filenames longer than 14 characters, but only
+on some of the filesystems. Maybe you are using NFS. Anyway, to avoid problems
+I shall consider your system cannot support long filenames at all.
+EOM
+ val="$undef"
+ else
+ echo 'You can have filenames longer than 14 characters.' >&4
+ val="$define"
+ fi
+ else
+ $cat <<'EOM'
+How confusing! Some of your filesystems are sane enough to allow filenames
+longer than 14 characters but some others like /tmp can't even think about them.
+So, for now on, I shall assume your kernel does not allow them at all.
+EOM
+ val="$undef"
+ fi
+ fi
+else
+ $cat <<'EOM'
+You can't have filenames longer than 14 chars. You can't even think about them!
+EOM
+ val="$undef"
+fi
+set d_flexfnam
+eval $setvar
+$rm -rf /tmp/cf$$ 123456789abcde*
+
+: determine where library module manual pages go
+set man3dir man3dir none
+eval $prefixit
+$cat <<EOM
+
+$spackage has manual pages for many of the library modules.
+EOM
+
+case "$nroff" in
+nroff)
+ $cat <<'EOM'
+However, you don't have nroff, so they're probably useless to you.
+You can use the supplied perldoc script instead.
+EOM
+ case "$man3dir" in
+ '') man3dir="none";;
+ esac;;
+esac
+
+case "$d_flexfnam" in
+undef)
+ $cat <<'EOM'
+However, your system can't handle the long file names like File::Basename.3.
+You can use the supplied perldoc script instead.
+EOM
+ case "$man3dir" in
+ '') man3dir="none";;
+ esac;;
+esac
+
+echo "If you don't want the manual sources installed, answer 'none'."
+case "$man3dir" in
+'') dflt="$privlib/man/man3" ;;
+' ') dflt=none;;
+*) dflt="$man3dir" ;;
+esac
+echo " "
+
+fn=dn~
+rp="Where do the $spackage library man pages (source) go?"
+. ./getfile
+if test "X$man3direxp" != "X$ansexp"; then
+ installman3dir=''
+fi
+
+man3dir="$ans"
+man3direxp="$ansexp"
+case "$man3dir" in
+'') man3dir=' '
+ installman3dir='';;
+esac
+if $afs; then
+ $cat <<EOM
+
+Since you are running AFS, I need to distinguish the directory in which
+manual pages reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
+
+EOM
+ case "$installman3dir" in
+ '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
+ *) dflt="$installman3dir";;
+ esac
+ fn=de~
+ rp='Where will man pages be installed?'
+ . ./getfile
+ installman3dir="$ans"
+else
+ installman3dir="$man3direxp"
+fi
+
+: What suffix to use on installed man pages
+
+case "$man3dir" in
+' ')
+ man3ext='0'
+ ;;
+*)
+ rp="What suffix should be used for the $spackage library man pages?"
+ case "$man3dir" in
+ *3) dflt=3 ;;
+ *3p) dflt=3p ;;
+ *3pm) dflt=3pm ;;
+ *l) dflt=l;;
+ *n) dflt=n;;
+ *o) dflt=o;;
+ *p) dflt=p;;
+ *C) dflt=C;;
+ *L) dflt=L;;
+ *L3) dflt=L3;;
+ *) dflt=3;;
+ esac
+ . ./myread
+ man3ext="$ans"
+ ;;
+esac
+
+: see if we have to deal with yellow pages, now NIS.
+if $test -d /usr/etc/yp || $test -d /etc/yp; then
+ if $test -f /usr/etc/nibindd; then
+ echo " "
+ echo "I'm fairly confident you're on a NeXT."
+ echo " "
+ rp='Do you get the hosts file via NetInfo?'
+ dflt=y
+ case "$hostcat" in
+ nidump*) ;;
+ '') ;;
+ *) dflt=n;;
+ esac
+ . ./myread
+ case "$ans" in
+ y*) hostcat='nidump hosts .';;
+ *) case "$hostcat" in
+ nidump*) hostcat='';;
+ esac
+ ;;
+ esac
+ fi
+ case "$hostcat" in
+ nidump*) ;;
+ *)
+ case "$hostcat" in
+ *ypcat*) dflt=y;;
+ '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
+ dflt=y
+ else
+ dflt=n
+ fi;;
+ *) dflt=n;;
+ esac
+ echo " "
+ rp='Are you getting the hosts file via yellow pages?'
+ . ./myread
+ case "$ans" in
+ y*) hostcat='ypcat hosts';;
+ *) hostcat='cat /etc/hosts';;
+ esac
+ ;;
+ esac
+fi
+
+: now get the host name
+echo " "
+echo "Figuring out host name..." >&4
+case "$myhostname" in
+'') cont=true
+ echo 'Maybe "hostname" will work...'
+ if tans=`sh -c hostname 2>&1` ; then
+ myhostname=$tans
+ phostname=hostname
+ cont=''
+ fi
+ ;;
+*) cont='';;
+esac
+if $test "$cont"; then
+ if ./xenix; then
+ echo 'Oh, dear. Maybe "/etc/systemid" is the key...'
+ if tans=`cat /etc/systemid 2>&1` ; then
+ myhostname=$tans
+ phostname='cat /etc/systemid'
+ echo "Whadyaknow. Xenix always was a bit strange..."
+ cont=''
+ fi
+ elif $test -r /etc/systemid; then
+ echo "(What is a non-Xenix system doing with /etc/systemid?)"
+ fi
+fi
+if $test "$cont"; then
+ echo 'No, maybe "uuname -l" will work...'
+ if tans=`sh -c 'uuname -l' 2>&1` ; then
+ myhostname=$tans
+ phostname='uuname -l'
+ else
+ echo 'Strange. Maybe "uname -n" will work...'
+ if tans=`sh -c 'uname -n' 2>&1` ; then
+ myhostname=$tans
+ phostname='uname -n'
+ else
+ echo 'Oh well, maybe I can mine it out of whoami.h...'
+ if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
+ myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
+ phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
+ else
+ case "$myhostname" in
+ '') echo "Does this machine have an identity crisis or something?"
+ phostname='';;
+ *)
+ echo "Well, you said $myhostname before..."
+ phostname='echo $myhostname';;
+ esac
+ fi
+ fi
+ fi
+fi
+: you do not want to know about this
+set $myhostname
+myhostname=$1
+
+: verify guess
+if $test "$myhostname" ; then
+ dflt=y
+ rp='Your host name appears to be "'$myhostname'".'" Right?"
+ . ./myread
+ case "$ans" in
+ y*) ;;
+ *) myhostname='';;
+ esac
+fi
+
+: bad guess or no guess
+while $test "X$myhostname" = X ; do
+ dflt=''
+ rp="Please type the (one word) name of your host:"
+ . ./myread
+ myhostname="$ans"
+done
+
+: translate upper to lower if necessary
+case "$myhostname" in
+*[A-Z]*)
+ echo "(Normalizing case in your host name)"
+ myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
+ ;;
+esac
+
+case "$myhostname" in
+*.*)
+ dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
+ myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
+ echo "(Trimming domain name from host name--host name is now $myhostname)"
+ ;;
+*) case "$mydomain" in
+ '')
+ $hostcat >hosts
+ dflt=.`$awk "/[0-9].*$myhostname/ {for(i=2; i<=NF;i++) print \\\$i}" \
+ hosts | $sort | $uniq | \
+ $sed -n -e "s/$myhostname\.\([a-zA-Z_.]\)/\1/p"`
+ case "$dflt" in
+ .) echo "(You do not have fully-qualified names in /etc/hosts)"
+ tans=`./loc resolv.conf X /etc /usr/etc`
+ if $test -f "$tans"; then
+ echo "(Attempting domain name extraction from $tans)"
+ dflt=.`egrep '^domain' $tans | $sed 's/domain[ ]*\(.*\)/\1/' \
+ | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
+ fi
+ ;;
+ esac
+ case "$dflt" in
+ .) echo "(No help from resolv.conf either -- attempting clever guess)"
+ dflt=.`sh -c domainname 2>/dev/null`
+ case "$dflt" in
+ '') dflt='.';;
+ .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
+ esac
+ ;;
+ esac
+ case "$dflt" in
+ .) echo "(Lost all hope -- silly guess then)"
+ dflt='.uucp'
+ ;;
+ esac
+ $rm -f hosts
+ ;;
+ *) dflt="$mydomain";;
+ esac;;
+esac
+echo " "
+rp="What is your domain name?"
+. ./myread
+tans="$ans"
+case "$ans" in
+'') ;;
+.*) ;;
+*) tans=".$tans";;
+esac
+mydomain="$tans"
+
+: translate upper to lower if necessary
+case "$mydomain" in
+*[A-Z]*)
+ echo "(Normalizing case in your domain name)"
+ mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
+ ;;
+esac
+
+: a little sanity check here
+case "$phostname" in
+'') ;;
+*)
+ case `$phostname | ./tr '[A-Z]' '[a-z]'` in
+ $myhostname$mydomain|$myhostname) ;;
+ *)
+ case "$phostname" in
+ sed*)
+ echo "(That doesn't agree with your whoami.h file, by the way.)"
+ ;;
+ *)
+ echo "(That doesn't agree with your $phostname command, by the way.)"
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+esac
+
+$cat <<EOM
+
+I need to get your e-mail address in Internet format if possible, i.e.
+something like user@host.domain. Please answer accurately since I have
+no easy means to double check it. The default value provided below
+is most probably close to the reality but may not be valid from outside
+your organization...
+
+EOM
+cont=x
+while test "$cont"; do
+ case "$cf_email" in
+ '') dflt="$cf_by@$myhostname$mydomain";;
+ *) dflt="$cf_email";;
+ esac
+ rp='What is your e-mail address?'
+ . ./myread
+ cf_email="$ans"
+ case "$cf_email" in
+ *@*.*) cont='' ;;
+ *)
+ rp='Address does not look like an Internet one. Use it anyway?'
+ case "$fastread" in
+ yes) dflt=y ;;
+ *) dflt=n ;;
+ esac
+ . ./myread
+ case "$ans" in
+ y*) cont='' ;;
+ *) echo " " ;;
+ esac
+ ;;
+ esac
+done
+
+$cat <<EOM
+
+If you or somebody else will be maintaining perl at your site, please
+fill in the correct e-mail address here so that they may be contacted
+if necessary. Currently, the "perlbug" program included with perl
+will send mail to this address in addition to perlbug@perl.com. You may
+enter "none" for no administrator.
+
+EOM
+case "$perladmin" in
+'') dflt="$cf_email";;
+*) dflt="$perladmin";;
+esac
+rp='Perl administrator e-mail address'
+. ./myread
+perladmin="$ans"
+
+
+: determine optimize, if desired, or use for debug flag also
+case "$optimize" in
+' ') dflt='none';;
+'') dflt='-O';;
+*) dflt="$optimize";;
+esac
+$cat <<EOH
+
+Some C compilers have problems with their optimizers, by default, $package
+compiles with the -O flag to use the optimizer. Alternately, you might want
+to use the symbolic debugger, which uses the -g flag (on traditional Unix
+systems). Either flag can be specified here. To use neither flag, specify
+the word "none".
+
+EOH
+rp="What optimizer/debugger flag should be used?"
+. ./myread
+optimize="$ans"
+case "$optimize" in
+'none') optimize=" ";;
+esac
+
+dflt=''
+case "$ccflags" in
+'')
+ case "$gccversion" in
+ 1*) dflt='-fpcc-struct-return' ;;
+ esac
+ case "$optimize" in
+ *-g*) dflt="$dflt -DDEBUGGING";;
+ esac
+ case "$gccversion" in
+ 2*) if test -d /etc/conf/kconfig.d &&
+ $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
+ then
+ dflt="$dflt -posix"
+ fi
+ ;;
+ esac
+ ;;
+esac
+
+case "$mips_type" in
+*BSD*|'') inclwanted="$locincpth $usrinc";;
+*) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
+esac
+for thisincl in $inclwanted; do
+ if $test -d $thisincl; then
+ if $test x$thisincl != x$usrinc; then
+ case "$dflt" in
+ *$thisincl*);;
+ *) dflt="$dflt -I$thisincl";;
+ esac
+ fi
+ fi
+done
+
+inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
+ xxx=true;
+elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
+ xxx=true;
+else
+ xxx=false;
+fi;
+if $xxx; then
+ case "$dflt" in
+ *$2*);;
+ *) dflt="$dflt -D$2";;
+ esac;
+fi'
+
+if ./osf1; then
+ set signal.h __LANGUAGE_C__; eval $inctest
+else
+ set signal.h LANGUAGE_C; eval $inctest
+fi
+set signal.h NO_PROTOTYPE; eval $inctest
+set signal.h _NO_PROTO; eval $inctest
+
+case "$dflt" in
+'') dflt=none;;
+esac
+case "$ccflags" in
+'') ;;
+*) dflt="$ccflags";;
+esac
+$cat <<EOH
+
+Your C compiler may want other flags. For this question you should include
+-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
+but you should NOT include libraries or ld flags like -lwhatever. If you
+want $package to honor its debug switch, you should include -DDEBUGGING here.
+Your C compiler might also need additional flags, such as -D_POSIX_SOURCE,
+-DHIDEMYMALLOC or -DCRIPPLED_CC.
+
+To use no flags, specify the word "none".
+
+EOH
+set X $dflt
+shift
+dflt=${1+"$@"}
+rp="Any additional cc flags?"
+. ./myread
+case "$ans" in
+none) ccflags='';;
+*) ccflags="$ans";;
+esac
: the following weeds options from ccflags that are of no interest to cpp
cppflags="$ccflags"
esac
: flags used in final linking phase
+
case "$ldflags" in
'') if ./venix; then
dflt='-i -z'
case "$ccflags" in
*-posix*) dflt="$dflt -posix" ;;
esac
- case "$dflt" in
- '') dflt='none' ;;
- esac
;;
*) dflt="$ldflags";;
esac
-echo " "
+
+: Try to guess additional flags to pick up local libraries.
+for thislibdir in $libpth; do
+ case " $loclibpth " in
+ *" $thislibdir "*)
+ case "$dflt " in
+ "-L$thislibdir ") ;;
+ *) dflt="$dflt -L$thislibdir" ;;
+ esac
+ ;;
+ esac
+done
+
+case "$dflt" in
+'') dflt='none' ;;
+esac
+
+$cat <<EOH
+
+Your C linker may need flags. For this question you should
+include -L/whatever and any other flags used by the C linker, but you
+should NOT include libraries like -lwhatever.
+
+Make sure you include the appropriate -L/path flags if your C linker
+does not normally search all of the directories you specified above,
+namely
+ $libpth
+To use no flags, specify the word "none".
+
+EOH
+
rp="Any additional ld flags (NOT including libraries)?"
. ./myread
case "$ans" in
: coherency check
echo " "
echo "Checking your choice of C compiler and flags for coherency..." >&4
-set X $cc $optimize $ccflags try.c -o try $ldflags
+set X $cc $optimize $ccflags $ldflags try.c -o try
shift
$cat >try.msg <<EOM
I've tried to compile and run a simple program with:
esac
$rm -f try try.* core
-: Set private lib path
-case "$plibpth" in
-'') if ./mips; then
- plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
- fi;;
-esac
-case "$libpth" in
-' ') dlist='';;
-'') dlist="$plibpth $glibpth";;
-*) dlist="$libpth";;
-esac
-
-: Now check and see which directories actually exist, avoiding duplicates
-libpth=''
-for xxx in $dlist
-do
- if $test -d $xxx; then
- case " $libpth " in
- *" $xxx "*) ;;
- *) libpth="$libpth $xxx";;
- esac
- fi
-done
-$cat <<'EOM'
-
-Some systems have incompatible or broken versions of libraries. Among
-the directories listed in the question below, please remove any you
-know not to be holding relevant libraries, and add any that are needed.
-Say "none" for none.
-
-EOM
-case "$libpth" in
-'') dflt='none';;
-*)
- set X $libpth
- shift
- dflt=${1+"$@"}
- ;;
-esac
-rp="Directories to use for library searches?"
-. ./myread
-case "$ans" in
-none) libpth=' ';;
-*) libpth="$ans";;
-esac
-
: compute shared library extension
case "$so" in
'')
*"-l$thislib "*);;
*) dflt="$dflt -l$thislib";;
esac
+ elif xxx=`./loc $thislib.a X $libpth`; $test -f "$xxx"; then
+ echo "Found -l$thislib."
+ case " $dflt " in
+ *"-l$thislib "*);;
+ *) dflt="$dflt -l$thislib";;
+ esac
elif xxx=`./loc lib${thislib}_s.a X $libpth`; $test -f "$xxx"; then
echo "Found -l${thislib}_s."
case " $dflt " in
eval $xscan;\
$contains '^fprintf$' libc.list >/dev/null 2>&1; then
eval $xrun
+elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
+ eval $xscan;\
+ $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+ eval $xrun
else
nm -p $* 2>/dev/null >libc.tmp
$grep fprintf libc.tmp > libc.ptf
csym='tlook=$1;
case "$3" in
-v) tf=libc.tmp; tc=""; tdc="";;
--a) tf=libc.tmp; tc="[0]"; tdc=[];;
+-a) tf=libc.tmp; tc="[0]"; tdc="[]";;
*) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
esac;
tx=yes;
fi;;
*)
echo "main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
- if $cc $ccflags -o t t.c $ldflags $libs >/dev/null 2>&1;
+ if $cc $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
then tval=true;
else tval=false;
fi;
esac;;
*)
case "$tval" in
- $define) tval=true;;
- *) tval=false;;
- esac;;
-esac;
-eval "$2=$tval"'
-
-: set up the script used to warn in case of inconsistency
-cat <<'EOSC' >whoa
-dflt=y
-echo " "
-echo "*** WHOA THERE!!! ***" >&4
-echo " The $hint value for \$$var on this machine was \"$was\"!" >&4
-rp=" Keep the $hint value?"
-. ./myread
-case "$ans" in
-y) td=$was; tu=$was;;
-esac
-EOSC
+ $define) tval=true;;
+ *) tval=false;;
+ esac;;
+esac;
+eval "$2=$tval"'
: define an is-in-libc? function
inlibc='echo " "; td=$define; tu=$undef;
esac;;
esac'
-: see if gconvert exists
-: On some SVR4 systems, gconvert is present but can not be used
-: because it requires some other unavailable functions.
-: Therefore, do not use the nm extraction, but use a real compile
-: and link test instead.
-xxx_runnm="$runnm"
-runnm=false
-set gconvert d_gconvert
-eval $inlibc
-runnm="$xxx_runnm"
-
-case "$d_gconvert" in
-$define)
- echo "We'll use it to convert floats into a string then." >&4
- d_Gconvert="gconvert((x),(n),(t),(b))"
- ;;
-*)
- : Maybe we can emulate it with gcvt.
- set gcvt d_gcvt
- eval $inlibc
-
- case "$d_gcvt" in
- $define)
- : Test whether gcvt drops a trailing decimal point
- $cat >try.c <<'EOP'
+: Check how to convert floats to strings.
+echo " "
+echo "Checking for an efficient way to convert floats to strings."
+$cat >try.c <<'EOP'
+#ifdef TRY_gconvert
+#define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
+#endif
+#ifdef TRY_gcvt
+#define Gconvert(x,n,t,b) gcvt((x),(n),(b))
+#endif
+#ifdef TRY_sprintf
+#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
+#endif
main() {
char buf[64];
- gcvt(1.0, 8, buf);
+ Gconvert(1.0, 8, 0, buf);
if (buf[0] != '1' || buf[1] != '\0')
exit(1);
- gcvt(0.0, 8, buf);
+ Gconvert(0.0, 8, 0, buf);
if (buf[0] != '0' || buf[1] != '\0')
exit(1);
- gcvt(-1.0, 8, buf);
+ Gconvert(-1.0, 8, 0, buf);
if (buf[0] != '-' || buf[1] != '1' || buf[2] != '\0')
exit(1);
exit(0);
}
EOP
- if $cc $ccflags $ldflags -o try try.c $libs > /dev/null 2>&1; then
- if ./try; then
- echo "Good, your gcvt() drops a trailing decimal point."
- echo "We'll use it to convert floats into a string." >&4
- d_Gconvert="gcvt((x),(n),(b))"
- else
- echo "But your gcvt() keeps a trailing decimal point".
- d_Gconvert=''
- fi
+case "$d_Gconvert" in
+gconvert*) xxx_list='gconvert gcvt sprintf' ;;
+gcvt*) xxx_list='gcvt gconvert sprintf' ;;
+sprintf*) xxx_list='sprintf gconvert gcvt' ;;
+*) xxx_list='gconvert gcvt sprintf' ;;
+esac
+
+for xxx_convert in $xxx_list; do
+ echo "Trying $xxx_convert"
+ $rm -f try try.o
+ if $cc $ccflags -DTRY_$xxx_convert $ldflags -o try \
+ try.c $libs > /dev/null 2>&1 ; then
+ echo "$xxx_convert" found. >&4
+ if ./try; then
+ echo "Good, $xxx_convert drops a trailing decimal point."
+ echo "I'll use $xxx_convert to convert floats into a string." >&4
+ break;
else
- echo "Hmm. I can't compile the gcvt test program."
- d_Gconvert=''
+ echo "But $xxx_convert keeps a trailing decimal point".
fi
- $rm -f try.c try
- ;;
- esac
- case "$d_Gconvert" in
- '')
- echo "I'll use sprintf instead to convert floats into a string." >&4
- d_Gconvert='sprintf((b),"%.*g",(n),(x))'
- ;;
- esac
+ else
+ echo "$xxx_convert NOT found." >&4
+ fi
+done
+
+case "$xxx_convert" in
+gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
+gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
+*) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
esac
: Initialize h_fcntl
#endif
main() {
exit(R_OK);
-}
-EOCP
- : check sys/file.h first, no particular reason here
- if $test `./findhdr sys/file.h` && \
- $cc $cppflags -DI_SYS_FILE access.c -o access >/dev/null 2>&1 ; then
- h_sysfile=true;
- echo "<sys/file.h> defines the *_OK access constants." >&4
- elif $test `./findhdr fcntl.h` && \
- $cc $cppflags -DI_FCNTL access.c -o access >/dev/null 2>&1 ; then
- h_fcntl=true;
- echo "<fcntl.h> defines the *_OK access constants." >&4
- elif $test `./findhdr unistd.h` && \
- $cc $cppflags -DI_UNISTD access.c -o access >/dev/null 2>&1 ; then
- echo "<unistd.h> defines the *_OK access constants." >&4
- else
- echo "I can't find the four *_OK access constants--I'll use mine." >&4
- fi
- ;;
-esac
-$rm -f access*
-
-: see if alarm exists
-set alarm d_alarm
-eval $inlibc
-
-: determine the architecture name
-echo " "
-if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
- tarch=`arch`"-$osname"
-elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
- if uname -m > tmparch 2>&1 ; then
- tarch=`$sed -e 's/ /_/g' -e 's/$/'"-$osname/" tmparch`
- else
- tarch="$osname"
- fi
- $rm -f tmparch
-else
- tarch="$osname"
-fi
-case "$myarchname" in
-''|"$tarch") ;;
-*)
- echo "(Your architecture name used to be $myarchname.)"
- archname=''
- ;;
-esac
-case "$archname" in
-'') dflt="$tarch";;
-*) dflt="$archname";;
-esac
-rp='What is your architecture name'
-. ./myread
-archname="$ans"
-myarchname="$tarch"
-
-: is AFS running?
-echo " "
-if test -d /afs; then
- echo "AFS may be running... I'll be extra cautious then..." >&4
- afs=true
-else
- echo "AFS does not seem to be running..." >&4
- afs=false
-fi
-
-: determine root of directory hierarchy where package will be installed.
-case "$prefix" in
-'')
- dflt=`./loc . /usr/local /usr/local /local /opt /usr`
- ;;
-*)
- dflt="$prefix"
- ;;
-esac
-$cat <<EOM
-
-By default, $package will be installed in $dflt/bin, manual
-pages under $dflt/man, etc..., i.e. with $dflt as prefix for
-all installation directories. Typically set to /usr/local, but you
-may choose /usr if you wish to install $package among your system
-binaries. If you wish to have binaries under /bin but manual pages
-under /usr/local/man, that's ok: you will be prompted separately
-for each of the installation directories, the prefix being only used
-to set the defaults.
-
-EOM
-fn=d~
-rp='Installation prefix to use?'
-. ./getfile
-oldprefix=''
-case "$prefix" in
-'') ;;
-*)
- case "$ans" in
- "$prefix") ;;
- *) oldprefix="$prefix";;
- esac
- ;;
-esac
-prefix="$ans"
-prefixexp="$ansexp"
-
-: set the prefixit variable, to compute a suitable default value
-prefixit='case "$3" in
-""|none)
- case "$oldprefix" in
- "") eval "$1=\"\$$2\"";;
- *)
- case "$3" in
- "") eval "$1=";;
- none)
- eval "tp=\"\$$2\"";
- case "$tp" in
- ""|" ") eval "$1=\"\$$2\"";;
- *) eval "$1=";;
- esac;;
- esac;;
- esac;;
-*)
- eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
- case "$tp" in
- --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
- /*-$oldprefix/*|\~*-$oldprefix/*)
- eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
- *) eval "$1=\"\$$2\"";;
- esac;;
-esac'
-
-: determine where private executables go
-set dflt privlib lib/$package
-eval $prefixit
-$cat <<EOM
-
-There are some auxiliary files for $package that need to be put into a
-private library directory that is accessible by everyone.
-
-EOM
-fn=d~+
-rp='Pathname where the private library files will reside?'
-. ./getfile
-if $test "X$privlibexp" != "X$ansexp"; then
- installprivlib=''
-fi
-privlib="$ans"
-privlibexp="$ansexp"
-if $afs; then
- $cat <<EOM
-
-Since you are running AFS, I need to distinguish the directory in which
-private files reside from the directory in which they are installed (and from
-which they are presumably copied to the former directory by occult means).
-
-EOM
- case "$installprivlib" in
- '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
- *) dflt="$installprivlib";;
- esac
- fn=de~
- rp='Where will private files be installed?'
- . ./getfile
- installprivlib="$ans"
-else
- installprivlib="$privlibexp"
-fi
-
-: set the prefixup variable, to restore leading tilda escape
-prefixup='case "$prefixexp" in
-"$prefix") ;;
-*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
-esac'
-
-: determine where public architecture dependent libraries go
-set archlib archlib
-eval $prefixit
-case "$archlib" in
-'')
- case "$privlib" in
- '')
- dflt=`./loc . "." $prefixexp/lib /usr/local/lib /usr/lib /lib`
- set dflt
- eval $prefixup
- ;;
- *) dflt="$privlib/$archname";;
- esac
- ;;
-*) dflt="$archlib";;
-esac
-cat <<EOM
-
-$spackage contains architecture-dependent library files. If you are
-sharing libraries in a heterogeneous environment, you might store
-these files in a separate location. Otherwise, you can just include
-them with the rest of the public library files.
-
-EOM
-fn=d~
-rp='Where do you want to put the public architecture-dependent libraries?'
-. ./getfile
-archlib="$ans"
-archlibexp="$ansexp"
-
-if $afs; then
- $cat <<EOM
-
-Since you are running AFS, I need to distinguish the directory in which
-private files reside from the directory in which they are installed (and from
-which they are presumably copied to the former directory by occult means).
-
-EOM
- case "$installarchlib" in
- '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
- *) dflt="$installarchlib";;
- esac
- fn=de~
- rp='Where will architecture-dependent library files be installed?'
- . ./getfile
- installarchlib="$ans"
-else
- installarchlib="$archlibexp"
-fi
-if $test X"$archlib" = X"$privlib"; then
- d_archlib="$undef"
-else
- d_archlib="$define"
-fi
+}
+EOCP
+ : check sys/file.h first, no particular reason here
+ if $test `./findhdr sys/file.h` && \
+ $cc $cppflags -DI_SYS_FILE access.c -o access >/dev/null 2>&1 ; then
+ h_sysfile=true;
+ echo "<sys/file.h> defines the *_OK access constants." >&4
+ elif $test `./findhdr fcntl.h` && \
+ $cc $cppflags -DI_FCNTL access.c -o access >/dev/null 2>&1 ; then
+ h_fcntl=true;
+ echo "<fcntl.h> defines the *_OK access constants." >&4
+ elif $test `./findhdr unistd.h` && \
+ $cc $cppflags -DI_UNISTD access.c -o access >/dev/null 2>&1 ; then
+ echo "<unistd.h> defines the *_OK access constants." >&4
+ else
+ echo "I can't find the four *_OK access constants--I'll use mine." >&4
+ fi
+ ;;
+esac
+$rm -f access*
-: function used to set $1 to $val
-setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
-case "$val$was" in
-$define$undef) . ./whoa; eval "$var=\$td";;
-$undef$define) . ./whoa; eval "$var=\$tu";;
-*) eval "$var=$val";;
-esac'
+: see if alarm exists
+set alarm d_alarm
+eval $inlibc
: Look for GNU-cc style attribute checking
echo " "
exit(0);
}
EOP
- if $cc $ccflags -o set set.c $ldflags $libs >/dev/null 2>&1; then
+ if $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1; then
./set 2>/dev/null
case $? in
0) echo "You have to use setpgrp() instead of setpgrp(pid, pgrp)." >&4
main()
{
printf("%d\n", sizeof(int));
+ exit(0);
}
EOCP
- if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
- dflt=`./try`
+ if $cc $ccflags try.c -o try >/dev/null 2>&1 && ./try > /dev/null; then
+ intsize=`./try`
+ echo "Your integers are $intsize bytes long."
else
dflt='4'
echo "(I can't seem to compile the test program. Guessing...)"
+ rp="What is the size of an integer (in bytes)?"
+ . ./myread
+ intsize="$ans"
fi
;;
-*)
- dflt="$intsize"
- ;;
esac
-rp="What is the size of an integer (in bytes)?"
-. ./myread
-intsize="$ans"
$rm -f try.c try
: see if signal is declared as pointer to function returning int or void
$rm -f try.c
: see if dlerror exists
-: On NetBSD and FreeBSD, dlerror might be available, but it is in
-: /usr/lib/crt0.o, not in any of the libraries. Therefore, do not
-: use the nm extraction, but use a real compile and link test instead.
xxx_runnm="$runnm"
runnm=false
set dlerror d_dlerror
eval $inhdr
: see if dlopen exists
-: On NetBSD and FreeBSD, dlopen is available, but it is in
-: /usr/lib/crt0.o, not in any of the libraries. Therefore, do not
-: use the nm extraction, but use a real compile and link test instead.
xxx_runnm="$runnm"
runnm=false
set dlopen d_dlopen
;;
*) dflt="$lddlflags" ;;
esac
+
+: Try to guess additional flags to pick up local libraries.
+for thisflag in $ldflags; do
+ case "$thisflag" in
+ -L*)
+ case " $dflt " in
+ *" $thisflag "*) ;;
+ *) dflt="$dflt $thisflag" ;;
+ esac
+ ;;
+ esac
+done
+
+case "$dflt" in
+'') dflt='none' ;;
+esac
+
rp="Any special flags to pass to $ld to create a dynamically loaded library?"
. ./myread
case "$ans" in
set dup2 d_dup2
eval $inlibc
+: Locate the flags for 'open()'
+echo " "
+$cat >open3.c <<'EOCP'
+#include <sys/types.h>
+#ifdef I_FCNTL
+#include <fcntl.h>
+#endif
+#ifdef I_SYS_FILE
+#include <sys/file.h>
+#endif
+main() {
+ if(O_RDONLY);
+#ifdef O_TRUNC
+ exit(0);
+#else
+ exit(1);
+#endif
+}
+EOCP
+: check sys/file.h first to get FREAD on Sun
+if $test `./findhdr sys/file.h` && \
+ $cc $cppflags "-DI_SYS_FILE" open3.c -o open3 >/dev/null 2>&1 ; then
+ h_sysfile=true;
+ echo "<sys/file.h> defines the O_* constants..." >&4
+ if ./open3; then
+ echo "and you have the 3 argument form of open()." >&4
+ val="$define"
+ else
+ echo "but not the 3 argument form of open(). Oh, well." >&4
+ val="$undef"
+ fi
+elif $test `./findhdr fcntl.h` && \
+ $cc "-DI_FCNTL" open3.c -o open3 >/dev/null 2>&1 ; then
+ h_fcntl=true;
+ echo "<fcntl.h> defines the O_* constants..." >&4
+ if ./open3; then
+ echo "and you have the 3 argument form of open()." >&4
+ val="$define"
+ else
+ echo "but not the 3 argument form of open(). Oh, well." >&4
+ val="$undef"
+ fi
+else
+ val="$undef"
+ echo "I can't find the O_* constant definitions! You got problems." >&4
+fi
+set d_open3
+eval $setvar
+$rm -f open3*
+
+: check for non-blocking I/O stuff
+case "$h_sysfile" in
+true) echo "#include <sys/file.h>" > head.c;;
+*)
+ case "$h_fcntl" in
+ true) echo "#include <fcntl.h>" > head.c;;
+ *) echo "#include <sys/fcntl.h>" > head.c;;
+ esac
+ ;;
+esac
+echo " "
+echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
+case "$o_nonblock" in
+'')
+ $cat head.c > try.c
+ $cat >>try.c <<'EOCP'
+main() {
+#ifdef O_NONBLOCK
+ printf("O_NONBLOCK\n");
+ exit(0);
+#endif
+#ifdef O_NDELAY
+ printf("O_NDELAY\n");
+ exit(0);
+#endif
+#ifdef FNDELAY
+ printf("FNDELAY\n");
+ exit(0);
+#endif
+ exit(0);
+}
+EOCP
+ if $cc $ccflags $ldflags try.c -o try >/dev/null 2>&1; then
+ o_nonblock=`./try`
+ case "$o_nonblock" in
+ '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
+ *) echo "Seems like we can use $o_nonblock.";;
+ esac
+ else
+ echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
+ fi
+ ;;
+*) echo "Using $hint value $o_nonblock.";;
+esac
+$rm -f try try.* .out core
+
+echo " "
+echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
+case "$eagain" in
+'')
+ $cat head.c > try.c
+ $cat >>try.c <<EOCP
+#include <errno.h>
+#include <sys/types.h>
+#include <signal.h>
+extern int errno;
+$signal_t blech(x) int x; { exit(3); }
+main()
+{
+ int pd[2];
+ int pu[2];
+ char buf[1];
+ char string[100];
+
+ pipe(pd); /* Down: child -> parent */
+ pipe(pu); /* Up: parent -> child */
+ if (0 != fork()) {
+ int ret;
+ close(pd[1]); /* Parent reads from pd[0] */
+ close(pu[0]); /* Parent writes (blocking) to pu[1] */
+ if (-1 == fcntl(pd[0], F_SETFL, $o_nonblock))
+ exit(1);
+ signal(SIGALRM, blech);
+ alarm(5);
+ if ((ret = read(pd[0], buf, 1)) > 0) /* Nothing to read! */
+ exit(2);
+ sprintf(string, "%d\n", ret);
+ write(2, string, strlen(string));
+ alarm(0);
+#ifdef EAGAIN
+ if (errno == EAGAIN) {
+ printf("EAGAIN\n");
+ goto ok;
+ }
+#endif
+#ifdef EWOULDBLOCK
+ if (errno == EWOULDBLOCK)
+ printf("EWOULDBLOCK\n");
+#endif
+ ok:
+ write(pu[1], buf, 1); /* Unblocks child, tell it to close our pipe */
+ sleep(2); /* Give it time to close our pipe */
+ alarm(5);
+ ret = read(pd[0], buf, 1); /* Should read EOF */
+ alarm(0);
+ sprintf(string, "%d\n", ret);
+ write(3, string, strlen(string));
+ exit(0);
+ }
+
+ close(pd[0]); /* We write to pd[1] */
+ close(pu[1]); /* We read from pu[0] */
+ read(pu[0], buf, 1); /* Wait for parent to signal us we may continue */
+ close(pd[1]); /* Pipe pd is now fully closed! */
+ exit(0); /* Bye bye, thank you for playing! */
+}
+EOCP
+ if $cc $ccflags $ldflags try.c -o try >/dev/null; 2>&1; then
+ echo "./try >try.out 2>try.ret 3>try.err || exit 4" >mtry
+ chmod +x mtry
+ ./mtry >/dev/null 2>&1
+ case $? in
+ 0) eagain=`$cat try.out`;;
+ 1) echo "Could not perform non-blocking setting!";;
+ 2) echo "I did a successful read() for something that was not there!";;
+ 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
+ *) echo "Something terribly wrong happened during testing.";;
+ esac
+ rd_nodata=`$cat try.ret`
+ echo "A read() system call with no data present returns $rd_nodata."
+ case "$rd_nodata" in
+ 0|-1) ;;
+ *)
+ echo "(That's peculiar, fixing that to be -1.)"
+ rd_nodata=-1
+ ;;
+ esac
+ case "$eagain" in
+ '')
+ echo "Forcing errno EAGAIN on read() with no data available."
+ eagain=EAGAIN
+ ;;
+ *)
+ echo "Your read() sets errno to $eagain when no data is available."
+ ;;
+ esac
+ status=`$cat try.err`
+ case "$status" in
+ 0) echo "And it correctly returns 0 to signal EOF.";;
+ -1) echo "But it also returns -1 to signal EOF, so be careful!";;
+ *) echo "However, your read() returns '$status' on EOF??";;
+ esac
+ val="$define"
+ if test "$status" -eq "$rd_nodata"; then
+ echo "WARNING: you can't distinguish between EOF and no data!"
+ val="$undef"
+ fi
+ else
+ echo "I can't compile the test program--assuming errno EAGAIN will do."
+ eagain=EAGAIN
+ fi
+ set d_eofnblk
+ eval $setvar
+ ;;
+*)
+ echo "Using $hint value $eagain."
+ echo "Your read() returns $rd_nodata when no data is present."
+ case "$d_eofnblk" in
+ "$define") echo "And you can see EOF because read() returns 0.";;
+ "$undef") echo "But you can't see EOF status from read() returned value.";;
+ *)
+ echo "(Assuming you can't see EOF status from read anyway.)"
+ d_eofnblk=$undef
+ ;;
+ esac
+ ;;
+esac
+$rm -f try try.* .out core head.c mtry
+
: see if fchmod exists
set fchmod d_fchmod
eval $inlibc
set fgetpos d_fgetpos
eval $inlibc
-: see if we can have long filenames
-echo " "
-rmlist="$rmlist /tmp/cf$$"
-$test -d /tmp/cf$$ || mkdir /tmp/cf$$
-first=123456789abcdef
-second=/tmp/cf$$/$first
-$rm -f $first $second
-if (echo hi >$first) 2>/dev/null; then
- if $test -f 123456789abcde; then
- echo 'You cannot have filenames longer than 14 characters. Sigh.' >&4
- val="$undef"
- else
- if (echo hi >$second) 2>/dev/null; then
- if $test -f /tmp/cf$$/123456789abcde; then
- $cat <<'EOM'
-That's peculiar... You can have filenames longer than 14 characters, but only
-on some of the filesystems. Maybe you are using NFS. Anyway, to avoid problems
-I shall consider your system cannot support long filenames at all.
-EOM
- val="$undef"
- else
- echo 'You can have filenames longer than 14 characters.' >&4
- val="$define"
- fi
- else
- $cat <<'EOM'
-How confusing! Some of your filesystems are sane enough to allow filenames
-longer than 14 characters but some others like /tmp can't even think about them.
-So, for now on, I shall assume your kernel does not allow them at all.
-EOM
- val="$undef"
- fi
- fi
-else
- $cat <<'EOM'
-You can't have filenames longer than 14 chars. You can't even think about them!
-EOM
- val="$undef"
-fi
-set d_flexfnam
-eval $setvar
-$rm -rf /tmp/cf$$ 123456789abcde*
-
: see if flock exists
set flock d_flock
eval $inlibc
fi
;;
esac
-echo "Your system uses $freetype free(), it would seem." >&4
-$rm -f malloc.[co]
-: see if nice exists
-set nice d_nice
-eval $inlibc
-
-: Locate the flags for 'open()'
-echo " "
-$cat >open3.c <<'EOCP'
-#include <sys/types.h>
-#ifdef I_FCNTL
-#include <fcntl.h>
-#endif
-#ifdef I_SYS_FILE
-#include <sys/file.h>
-#endif
-main() {
- if(O_RDONLY);
-#ifdef O_TRUNC
- exit(0);
-#else
- exit(1);
-#endif
-}
-EOCP
-: check sys/file.h first to get FREAD on Sun
-if $test `./findhdr sys/file.h` && \
- $cc $cppflags "-DI_SYS_FILE" open3.c -o open3 >/dev/null 2>&1 ; then
- h_sysfile=true;
- echo "<sys/file.h> defines the O_* constants..." >&4
- if ./open3; then
- echo "and you have the 3 argument form of open()." >&4
- val="$define"
- else
- echo "but not the 3 argument form of open(). Oh, well." >&4
- val="$undef"
- fi
-elif $test `./findhdr fcntl.h` && \
- $cc "-DI_FCNTL" open3.c -o open3 >/dev/null 2>&1 ; then
- h_fcntl=true;
- echo "<fcntl.h> defines the O_* constants..." >&4
- if ./open3; then
- echo "and you have the 3 argument form of open()." >&4
- val="$define"
- else
- echo "but not the 3 argument form of open(). Oh, well." >&4
- val="$undef"
- fi
-else
- val="$undef"
- echo "I can't find the O_* constant definitions! You got problems." >&4
-fi
-set d_open3
-eval $setvar
-$rm -f open3*
+echo "Your system uses $freetype free(), it would seem." >&4
+$rm -f malloc.[co]
+: see if nice exists
+set nice d_nice
+eval $inlibc
: see if pause exists
set pause d_pause
set pipe d_pipe
eval $inlibc
+: see if poll exists
+set poll d_poll
+eval $inlibc
+
: see if this is a pwd.h system
set pwd.h i_pwd
eval $inhdr
exit(0);
}
EOCP
- if $cc foo.c -o safebcpy $ccflags $ldflags $libs >/dev/null 2>&1 ; then
+ if $cc $ccflags $ldflags foo.c -o safebcpy $libs >/dev/null 2>&1; then
if ./safebcpy 2>/dev/null; then
echo "Yes, it can."
val="$define"
exit(0);
}
EOCP
- if $cc foo.c -o safemcpy $ccflags $ldflags $libs >/dev/null 2>&1 ; then
+ if $cc $ccflags $ldflags foo.c -o safemcpy $libs >/dev/null 2>&1; then
if ./safemcpy 2>/dev/null; then
echo "Yes, it can."
val="$define"
set d_shm
eval $setvar
-: determine whether the user wants to include a site-specific library
-: in addition to privlib.
-$cat <<EOM
-
-Some sites may wish to specify a local directory for $package
-to search by default in addition to $privlib.
-If you don't want to use such an additional directory, answer 'none'.
-
-EOM
-case "$sitelib" in
-'') dflt=none ;;
-*) dflt="$sitelib" ;;
-esac
-fn=d~+n
-rp='Local directory for additional library files?'
-. ./getfile
-if $test "X$sitelibexp" != "X$ansexp"; then
- installsitelib=''
-fi
-sitelib="$ans"
-sitelibexp="$ansexp"
-if $afs; then
- case "$sitelib" in
- '') installsitelib="$sitelibexp"
- ;;
- *) $cat <<EOM
-
-Since you are running AFS, I need to distinguish the directory in which
-private files reside from the directory in which they are installed (and from
-which they are presumably copied to the former directory by occult means).
-
-EOM
- case "$installsitelib" in
- '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
- *) dflt="$installsitelib";;
- esac
- fn=de~
- rp='Where will additional local files be installed?'
- . ./getfile
- installsitelib="$ans"
- ;;
- esac
-else
- installsitelib="$sitelibexp"
-fi
-
-case "$sitelibexp" in
-'') d_sitelib=undef ;;
-*) d_sitelib=define ;;
-esac
-
socketlib=''
sockethdr=''
: see whether socket exists
'') stdio_ptr='((fp)->_IO_read_ptr)'
ptr_lval=$define
;;
- *) ptr_lval=$d_stdio_ptr_lval
- ;;
+ *) ptr_lval=$d_stdio_ptr_lval;;
esac
case "$stdio_cnt" in
'') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
cnt_lval=$undef
;;
- *) cnt_lval=$d_stdio_cnt_lval
- ;;
+ *) cnt_lval=$d_stdio_cnt_lval;;
esac
case "$stdio_base" in
'') stdio_base='((fp)->_IO_read_base)';;
'') stdio_ptr='((fp)->_ptr)'
ptr_lval=$define
;;
- *) ptr_lval=$d_stdio_ptr_lval
- ;;
+ *) ptr_lval=$d_stdio_ptr_lval;;
esac
case "$stdio_cnt" in
'') stdio_cnt='((fp)->_cnt)'
cnt_lval=$define
;;
- *) cnt_lval=$d_stdio_cnt_lval
- ;;
+ *) cnt_lval=$d_stdio_cnt_lval;;
esac
case "$stdio_base" in
'') stdio_base='((fp)->_base)';;
set d_stdstdio
eval $setvar
-: Can _ptr be used as an lvalue. Only makes sense if we
-: have a known stdio implementation.
+: Can _ptr be used as an lvalue?
case "$d_stdstdio$ptr_lval" in
$define$define) val=$define ;;
*) val=$undef ;;
set d_stdio_ptr_lval
eval $setvar
-
-: Can _cnt be used as an lvalue. Only makes sense if we
-: have a known stdio implementation.
+: Can _cnt be used as an lvalue?
case "$d_stdstdio$cnt_lval" in
$define$define) val=$define ;;
*) val=$undef ;;
set d_stdio_cnt_lval
eval $setvar
-
: see if _base is also standard
val="$undef"
case "$d_stdstdio" in
done;
$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
if $contains $type temp.E >/dev/null 2>&1; then
- eval "$var=$type";
+ eval "$var=\$type";
else
- eval "$var=$def";
+ eval "$var=\$def";
fi;
$rm -f temp.?;;
-*) eval "$var=$varval";;
+*) eval "$var=\$varval";;
esac'
: see if this is a sys/times.h system
set umask d_umask
eval $inlibc
-: see if we have to deal with yellow pages, now NIS.
-if $test -d /usr/etc/yp || $test -d /etc/yp; then
- if $test -f /usr/etc/nibindd; then
- echo " "
- echo "I'm fairly confident you're on a NeXT."
- echo " "
- rp='Do you get the hosts file via NetInfo?'
- dflt=y
- case "$hostcat" in
- nidump*) ;;
- '') ;;
- *) dflt=n;;
- esac
- . ./myread
- case "$ans" in
- y*) hostcat='nidump hosts .';;
- *) case "$hostcat" in
- nidump*) hostcat='';;
- esac
- ;;
- esac
- fi
- case "$hostcat" in
- nidump*) ;;
- *)
- case "$hostcat" in
- *ypcat*) dflt=y;;
- '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
- dflt=y
- else
- dflt=n
- fi;;
- *) dflt=n;;
- esac
- echo " "
- rp='Are you getting the hosts file via yellow pages?'
- . ./myread
- case "$ans" in
- y*) hostcat='ypcat hosts';;
- *) hostcat='cat /etc/hosts';;
- esac
- ;;
- esac
-fi
-
-: now get the host name
-echo " "
-echo "Figuring out host name..." >&4
-case "$myhostname" in
-'') cont=true
- echo 'Maybe "hostname" will work...'
- if tans=`sh -c hostname 2>&1` ; then
- myhostname=$tans
- phostname=hostname
- cont=''
- fi
- ;;
-*) cont='';;
-esac
-if $test "$cont"; then
- if ./xenix; then
- echo 'Oh, dear. Maybe "/etc/systemid" is the key...'
- if tans=`cat /etc/systemid 2>&1` ; then
- myhostname=$tans
- phostname='cat /etc/systemid'
- echo "Whadyaknow. Xenix always was a bit strange..."
- cont=''
- fi
- elif $test -r /etc/systemid; then
- echo "(What is a non-Xenix system doing with /etc/systemid?)"
- fi
-fi
-if $test "$cont"; then
- echo 'No, maybe "uuname -l" will work...'
- if tans=`sh -c 'uuname -l' 2>&1` ; then
- myhostname=$tans
- phostname='uuname -l'
- else
- echo 'Strange. Maybe "uname -n" will work...'
- if tans=`sh -c 'uname -n' 2>&1` ; then
- myhostname=$tans
- phostname='uname -n'
- else
- echo 'Oh well, maybe I can mine it out of whoami.h...'
- if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
- myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
- phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
- else
- case "$myhostname" in
- '') echo "Does this machine have an identity crisis or something?"
- phostname='';;
- *)
- echo "Well, you said $myhostname before..."
- phostname='echo $myhostname';;
- esac
- fi
- fi
- fi
-fi
-: you do not want to know about this
-set $myhostname
-myhostname=$1
-
-: verify guess
-if $test "$myhostname" ; then
- dflt=y
- rp='Your host name appears to be "'$myhostname'".'" Right?"
- . ./myread
- case "$ans" in
- y*) ;;
- *) myhostname='';;
- esac
-fi
-
-: bad guess or no guess
-while $test "X$myhostname" = X ; do
- dflt=''
- rp="Please type the (one word) name of your host:"
- . ./myread
- myhostname="$ans"
-done
-
-: translate upper to lower if necessary
-case "$myhostname" in
-*[A-Z]*)
- echo "(Normalizing case in your host name)"
- myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
- ;;
-esac
-
-: a little sanity check here
-case "$phostname" in
-'') ;;
-*)
- case `$phostname | ./tr '[A-Z]' '[a-z]'` in
- $myhostname$mydomain|$myhostname) ;;
- *)
- case "$phostname" in
- sed*)
- echo "(That doesn't agree with your whoami.h file, by the way.)"
- ;;
- *)
- echo "(That doesn't agree with your $phostname command, by the way.)"
- ;;
- esac
- ;;
- esac
- ;;
-esac
-
: see how we will look up host name
echo " "
if false; then
alignbytes="$ans"
$rm -f try.c try
-: determine where public executables go
-echo " "
-set dflt bin bin
-eval $prefixit
-fn=d~
-rp='Pathname where the public executables will reside?'
-. ./getfile
-if $test "X$ansexp" != "X$binexp"; then
- installbin=''
-fi
-bin="$ans"
-binexp="$ansexp"
-if $afs; then
- $cat <<EOM
-
-Since you are running AFS, I need to distinguish the directory in which
-executables reside from the directory in which they are installed (and from
-which they are presumably copied to the former directory by occult means).
-
-EOM
- case "$installbin" in
- '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
- *) dflt="$installbin";;
- esac
- fn=de~
- rp='Where will public executables be installed?'
- . ./getfile
- installbin="$ans"
-else
- installbin="$binexp"
-fi
-
: check for ordering of bytes in a long
case "$byteorder" in
'')
for (i = 0; i < sizeof(long); i++)
printf("%c", u.c[i]+'0');
printf("\n");
+ exit(0);
}
EOCP
- if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
+ xxx_prompt=y
+ if $cc $ccflags try.c -o try >/dev/null 2>&1 && ./try > /dev/null; then
dflt=`./try`
case "$dflt" in
- ????|????????) echo "(The test program ran ok.)";;
- *) echo "(The test program didn't run right for some reason.)";;
+ [1-4][1-4][1-4][1-4]|12345678|87654321)
+ echo "(The test program ran ok.)"
+ echo "byteorder=$dflt"
+ xxx_prompt=n
+ ;;
+ ????|????????) echo "(The test program ran ok.)" ;;
+ *) echo "(The test program didn't run right for some reason.)" ;;
esac
else
dflt='4321'
(I can't seem to compile the test program. Guessing big-endian...)
EOM
fi
- ;;
-*)
- echo " "
- dflt="$byteorder"
+ case "$xxx_prompt" in
+ y)
+ rp="What is the order of bytes in a long?"
+ . ./myread
+ byteorder="$ans"
+ ;;
+ *) byteorder=$dflt
+ ;;
+ esac
;;
esac
-rp="What is the order of bytes in a long?"
-. ./myread
-byteorder="$ans"
$rm -f try.c try
: how do we catenate cpp tokens here?
fi
fi
esac
-dflt="$voidflags";
-rp="Your void support flags add up to what?"
-. ./myread
-voidflags="$ans"
+: Only prompt user if voidflags is not 15. If voidflags is 15, then
+: we presume all is well.
+case "$voidflags" in
+15) ;;
+*) dflt="$voidflags";
+ rp="Your void support flags add up to what?"
+ . ./myread
+ voidflags="$ans"
+ ;;
+esac
$rm -f try.* .out
: see if dbm.h is available
-set dbm.h t_dbm
-eval $inhdr
-case "$t_dbm" in
+: see if dbmclose exists
+set dbmclose d_dbmclose
+eval $inlibc
+
+case "$d_dbmclose" in
$define)
- : see if dbmclose exists
- set dbmclose d_dbmclose
- eval $inlibc
- case "$d_dbmclose" in
- $undef)
- t_dbm="$undef"
- echo "We won't be including <dbm.h>"
+ set dbm.h i_dbm
+ eval $inhdr
+ case "$i_dbm" in
+ $define)
+ val="$undef"
+ set i_rpcsvcdbm
+ eval $setvar
+ ;;
+ *) set rpcsvc/dbm.h i_rpcsvcdbm
+ eval $inhdr
;;
esac
;;
+*) echo "We won't be including <dbm.h>"
+ val="$undef"
+ set i_dbm
+ eval $setvar
+ val="$undef"
+ set i_rpcsvcdbm
+ eval $setvar
+ ;;
esac
-val="$t_dbm"
-set i_dbm
-eval $setvar
: see if ndbm.h is available
set ndbm.h t_ndbm
$define) avail_ext="$avail_ext $xxx" ;;
esac
;;
- ODBM_File) case "$i_dbm" in
- $define) avail_ext="$avail_ext $xxx" ;;
+ ODBM_File) case "${i_dbm}${i_rpcsvcdbm}" in
+ *"${define}"*) avail_ext="$avail_ext $xxx" ;;
esac
;;
POSIX) case "$useposix" in
. ./myread
lseektype="$ans"
-: determine where manual pages go
-set man1dir man1dir none
-eval $prefixit
-$cat <<EOM
-
-$spackage has manual pages available in source form.
-EOM
-case "$nroff" in
-nroff)
- echo "However, you don't have nroff, so they're probably useless to you."
- case "$man1dir" in
- '') man1dir="none";;
- esac;;
-esac
-echo "If you don't want the manual sources installed, answer 'none'."
-case "$man1dir" in
-'')
- lookpath="$prefixexp/man/man1 $prefixexp/man/u_man/man1"
- lookpath="$lookpath $prefixexp/man/l_man/man1"
- lookpath="$lookpath /usr/local/man/man1 /opt/man/man1 /usr/man/manl"
- lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
- lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
- lookpath="$lookpath /usr/man/man.L"
- man1dir=`./loc . $prefixexp/man/man1 $lookpath`
- if $test -d "$man1dir"; then
- dflt="$man1dir"
- else
- dflt="$sysman"
- fi
- set dflt
- eval $prefixup
- ;;
-' ') dflt=none;;
-*) dflt="$man1dir"
- ;;
-esac
-echo " "
-fn=dn~
-rp="Where do the main $spackage manual pages (source) go?"
-. ./getfile
-if test "X$man1direxp" != "X$ansexp"; then
- installman1dir=''
-fi
-man1dir="$ans"
-man1direxp="$ansexp"
-case "$man1dir" in
-'') man1dir=' '
- installman1dir='';;
-esac
-if $afs; then
- $cat <<EOM
-
-Since you are running AFS, I need to distinguish the directory in which
-manual pages reside from the directory in which they are installed (and from
-which they are presumably copied to the former directory by occult means).
-
-EOM
- case "$installman1dir" in
- '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
- *) dflt="$installman1dir";;
- esac
- fn=de~
- rp='Where will man pages be installed?'
- . ./getfile
- installman1dir="$ans"
-else
- installman1dir="$man1direxp"
-fi
-
-case "$man1dir" in
-' ') man1ext='0';;
-*l) man1ext=l;;
-*n) man1ext=n;;
-*o) man1ext=l;;
-*p) man1ext=n;;
-*C) man1ext=C;;
-*L) man1ext=L;;
-*L1) man1ext=L1;;
-*) man1ext=1;;
-esac
-
-: determine where library module manual pages go
-set man3dir man3dir none
-eval $prefixit
-$cat <<EOM
-
-$spackage has manual pages for many of the library modules.
-EOM
-
-case "$nroff" in
-nroff)
- $cat <<'EOM'
-However, you don't have nroff, so they're probably useless to you.
-You can use the supplied perldoc script instead.
-EOM
- case "$man3dir" in
- '') man3dir="none";;
- esac;;
-esac
-
-case "$d_flexfnam" in
-undef)
- $cat <<'EOM'
-However, your system can't handle the long file names like File::Basename.3.
-You can use the supplied perldoc script instead.
-EOM
- case "$man3dir" in
- '') man3dir="none";;
- esac;;
-esac
-
-echo "If you don't want the manual sources installed, answer 'none'."
-case "$man3dir" in
-'') dflt="$privlib/man/man3" ;;
-' ') dflt=none;;
-*) dflt="$man3dir" ;;
-esac
-echo " "
-
-fn=dn~
-rp="Where do the $spackage library man pages (source) go?"
-. ./getfile
-if test "X$man3direxp" != "X$ansexp"; then
- installman3dir=''
-fi
-
-man3dir="$ans"
-man3direxp="$ansexp"
-case "$man3dir" in
-'') man3dir=' '
- installman3dir='';;
-esac
-if $afs; then
- $cat <<EOM
-
-Since you are running AFS, I need to distinguish the directory in which
-manual pages reside from the directory in which they are installed (and from
-which they are presumably copied to the former directory by occult means).
-
-EOM
- case "$installman3dir" in
- '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
- *) dflt="$installman3dir";;
- esac
- fn=de~
- rp='Where will man pages be installed?'
- . ./getfile
- installman3dir="$ans"
-else
- installman3dir="$man3direxp"
-fi
-
-case "$man3dir" in
-' ') man3ext='0';;
-*l) man3ext=l;;
-*n) man3ext=n;;
-*o) man3ext=l;;
-*p) man3ext=n;;
-*C) man3ext=C;;
-*L) man3ext=L;;
-*L3) man3ext=L3;;
-*) man3ext=3;;
-esac
-
: see what type is used for mode_t
set mode_t modetype int stdio.h sys/types.h
eval $typedef
fi
$rm -f foo* bar*
-: determine where public executable scripts go
-set scriptdir scriptdir
-eval $prefixit
-case "$scriptdir" in
-'')
- dflt="$bin"
- : guess some guesses
- $test -d /usr/share/scripts && dflt=/usr/share/scripts
- $test -d /usr/share/bin && dflt=/usr/share/bin
- $test -d /usr/local/script && dflt=/usr/local/script
- $test -d $prefixexp/script && dflt=$prefixexp/script
- set dflt
- eval $prefixup
- ;;
-*) dflt="$scriptdir"
- ;;
-esac
-$cat <<EOM
-
-Some installations have a separate directory just for executable scripts so
-that they can mount it across multiple architectures but keep the scripts in
-one spot. You might, for example, have a subdirectory of /usr/share for this.
-Or you might just lump your scripts in with all your other executables.
-
-EOM
-fn=d~
-rp='Where do you keep publicly executable scripts?'
-. ./getfile
-if $test "X$ansexp" != "X$scriptdirexp"; then
- installscript=''
-fi
-scriptdir="$ans"
-scriptdirexp="$ansexp"
-if $afs; then
- $cat <<EOM
-
-Since you are running AFS, I need to distinguish the directory in which
-scripts reside from the directory in which they are installed (and from
-which they are presumably copied to the former directory by occult means).
-
-EOM
- case "$installscript" in
- '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
- *) dflt="$installscript";;
- esac
- fn=de~
- rp='Where will public scripts be installed?'
- . ./getfile
- installscript="$ans"
-else
- installscript="$scriptdirexp"
-fi
-
: see if sys/select.h has to be included
set sys/select.h i_sysselct
eval $inhdr
fi
$rm -f try.[co]
;;
-*) selecttype = 'int *'
+*) selecttype='int *'
;;
esac
-: generate list of signal names
-echo " "
-case "$sig_name" in
-'')
- echo "Generating a list of signal names..." >&4
- xxx=`./findhdr signal.h`" "`./findhdr sys/signal.h`
- xxx="$xxx "`./findhdr linux/signal.h`
- set X `cat $xxx 2>&1 | $awk '
-$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
- sig[$3] = substr($2,4,20)
- if (max < $3 && $3 < 60) {
- max = $3
- }
+: Trace out the files included by signal.h, then look for SIGxxx names.
+: Remove SIGARRAYSIZE used by HPUX.
+xxx=`echo '#include <signal.h>' |
+ $cppstdin $cppminus $cppflags 2>/dev/null |
+ $grep '^[ ]*#.*include' |
+ $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
+: Check this list of files to be sure we have parsed the cpp output ok.
+: This will also avoid potentially non-existent files, such
+: as ../foo/bar.h
+xxxfiles=''
+for xx in $xxx /dev/null ; do
+ $test -f "$xx" && xxxfiles="$xxxfiles $xx"
+done
+: If we have found no files, at least try signal.h
+case "$xxxfiles" in
+'') xxxfiles=`./findhdr signal.h` ;;
+esac
+xxx=`awk '
+$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ {
+ print substr($2, 4, 20)
+}
+$1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ {
+ print substr($3, 4, 20)
+}' $xxxfiles`
+: Append some common names just in case the awk scan failed.
+xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
+xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
+xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
+xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
+: generate a few handy files for later
+echo $xxx | $tr ' ' '\012' | $awk '
+BEGIN {
+ printf "#include <signal.h>\n";
+ printf "main() {\n";
+}
+{
+ printf "#ifdef SIG"; printf $1; printf "\n"
+ printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
+ printf $1; printf ");\n"
+ printf "#endif\n"
}
-
END {
- for (i = 1; i <= max; i++) {
- if (sig[i] == "")
- printf "%d", i
- else
- printf "%s", sig[i]
- if (i < max)
- printf " "
- }
- printf "\n"
+ printf "}\n";
}
-'`
+' >signal.c
+$cat >signal.cmd <<EOS
+$startsh
+$test -s signal.lst && exit 0
+if $cc $ccflags signal.c -o signal $ldflags >/dev/null 2>&1; then
+ ./signal | $sort -n +1 | $uniq >signal.lst
+else
+ echo "(I can't seem be able to compile the test program -- Guessing)"
+ echo 'kill -l' >signal
+ set X \`csh -f <signal\`
+ $rm -f signal
shift
- case $# in
- 0)
- echo 'kill -l' >/tmp/foo$$
- set X `csh -f </tmp/foo$$`
- $rm -f /tmp/foo$$
- shift
- case $# in
- 0)set HUP INT QUIT ILL TRAP IOT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
- ;;
- esac
- ;;
+ case \$# in
+ 0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
esac
- sig_name="ZERO $*"
+ echo \$@ | $tr ' ' '\012' | \
+ $awk '{ printf $1; printf " %d\n", ++s; }' >signal.lst
+fi
+$rm -f signal.c signal signal.o
+EOS
+chmod a+x signal.cmd
+$eunicefix signal.cmd
+
+: generate list of signal names
+echo " "
+case "$sig_name" in
+'')
+ echo "Generating a list of signal names..." >&4
+ ./signal.cmd
+ sig_name=`$awk '{printf "%s ", $1}' signal.lst`
+ sig_name="ZERO $sig_name"
;;
esac
echo "The following signals are available:"
echo $sig_name | $awk \
'BEGIN { linelen = 0 }
{
- for (i = 1; i < NF; i++) {
+ for (i = 1; i <= NF; i++) {
name = "SIG" $i " "
linelen = linelen + length(name)
if (linelen > 70) {
}
printf "%s", name
}
+ printf "\n"
}'
+
+: generate list of signal numbers
echo " "
+case "$sig_num" in
+'')
+ echo "Generating a list of signal numbers..." >&4
+ ./signal.cmd
+ sig_num=`$awk '{printf "%d ", $2}' signal.lst`
+ sig_num="0 $sig_num"
+ ;;
+esac
+case "$sig_max" in
+'') sig_max=`$tail -1 signal.lst | $awk '{print $2}'` ;;
+esac
+echo "The maximum signal number defined is $sig_max."
: see what type is used for size_t
set size_t sizetype 'unsigned int' stdio.h sys/types.h
set sys/file.h val
eval $inhdr
-: do we need to #include <sys/file.h> ?
+: do we need to include sys/file.h ?
case "$val" in
"$define")
echo " "
ccdlflags='$ccdlflags'
ccflags='$ccflags'
cf_by='$cf_by'
+cf_email='$cf_email'
cf_time='$cf_time'
chgrp='$chgrp'
chmod='$chmod'
d_dlsymun='$d_dlsymun'
d_dosuid='$d_dosuid'
d_dup2='$d_dup2'
+d_eofnblk='$d_eofnblk'
d_eunice='$d_eunice'
d_fchmod='$d_fchmod'
d_fchown='$d_fchown'
d_pause='$d_pause'
d_phostname='$d_phostname'
d_pipe='$d_pipe'
+d_poll='$d_poll'
d_portable='$d_portable'
d_pwage='$d_pwage'
d_pwchange='$d_pwchange'
dlext='$dlext'
dlsrc='$dlsrc'
dynamic_ext='$dynamic_ext'
+eagain='$eagain'
echo='$echo'
egrep='$egrep'
emacs='$emacs'
i_neterrno='$i_neterrno'
i_niin='$i_niin'
i_pwd='$i_pwd'
+i_rpcsvcdbm='$i_rpcsvcdbm'
i_sgtty='$i_sgtty'
i_stdarg='$i_stdarg'
i_stddef='$i_stddef'
lkflags='$lkflags'
ln='$ln'
lns='$lns'
+locincpth='$locincpth'
+loclibpth='$loclibpth'
lp='$lp'
lpr='$lpr'
ls='$ls'
n='$n'
nm_opt='$nm_opt'
nroff='$nroff'
+o_nonblock='$o_nonblock'
optimize='$optimize'
orderlib='$orderlib'
osname='$osname'
passcat='$passcat'
patchlevel='$patchlevel'
perl='$perl'
+perladmin='$perladmin'
pg='$pg'
phostname='$phostname'
plibpth='$plibpth'
prototype='$prototype'
randbits='$randbits'
ranlib='$ranlib'
+rd_nodata='$rd_nodata'
rm='$rm'
rmail='$rmail'
runnm='$runnm'
shmattype='$shmattype'
shrpdir='$shrpdir'
shsharp='$shsharp'
+sig_max='$sig_max'
sig_name='$sig_name'
+sig_num='$sig_num'
signal_t='$signal_t'
sitelib='$sitelib'
sitelibexp='$sitelibexp'
--- /dev/null
+=head1 NAME
+
+Install - Build and Installation guide for perl5.
+
+=head1 SYNOPSIS
+
+The basic steps to build and install perl5 are:
+
+ rm -f config.sh
+ sh Configure
+ make
+ make test
+ make install
+
+Each of these is explained in further detail below.
+
+=head1 BUILDING PERL5
+
+=head1 Start with a Fresh Distribution.
+
+The results of a Configure run are stored in the config.sh file. If
+you are upgrading from a previous version of perl, or if you change
+systems or compilers or make other significant changes, or if you are
+experiencing difficulties building perl, you should probably I<not>
+re-use your old config.sh. Simply remove it or rename it, e.g.
+
+ mv config.sh config.sh.old
+
+Then run Configure.
+
+=head1 Run Configure.
+
+Configure will figure out various things about your system. Some
+things Configure will figure out for itself, other things it will ask
+you about. To accept the default, just press C<RETURN>. The default
+is almost always ok.
+
+After it runs, Configure will perform variable substitution on all the
+F<*.SH> files and offer to run B<make depend>.
+
+Configure supports a number of useful options. Run B<Configure -h>
+to get a listing. To compile with gcc, for example, you can run
+
+ sh Configure -Dcc=gcc
+
+This is the preferred way to specify gcc (or another alternative
+compiler) so that the hints files can set appropriate defaults.
+
+If you are willing to accept all the defaults, and you want terse
+output, you can run
+
+ sh Configure -des
+
+By default, for most systems, perl will be installed in
+/usr/local/{bin, lib, man}. You can specify a different 'prefix' for
+the default installation directory, when Configure prompts you or by
+using the Configure command line option -Dprefix='/some/directory',
+e.g.
+
+ Configure -Dprefix=/opt/local
+
+By default, Configure will compile perl to use dynamic loading, if
+your system supports it. If you want to force perl to be compiled
+statically, you can either choose this when Configure prompts you or by
+using the Configure command line option -Uusedl.
+
+=head2 GNU-style configure
+
+If you prefer the GNU-style B<configure> command line interface, you can
+use the supplied B<configure> command, e.g.
+
+ CC=gcc ./configure
+
+The B<configure> script emulates several of the more common configure
+options. Try
+
+ ./configure --help
+
+for a listing.
+
+Cross compiling is currently not supported.
+
+=head2 Including locally-installed libraries
+
+Perl5 comes with a number of database extensions, including interfaces
+to dbm, ndbm, gdbm, and Berkeley db. For each extension, if Configure
+can find the appropriate header files and libraries, it will automatically
+include that extension.
+
+I<Note:> If your database header (.h) files are not in a
+directory normally searched by your C compiler, then you will need to
+include the appropriate B<-I/your/directory> option when prompted by
+Configure. If your database library (.a) files are not in a directory
+normally searched by your C compiler and linker, then you will need to
+include the appropriate B<-L/your/directory> option when prompted by
+Configure. See the examples below.
+
+=head2 Examples
+
+=over 4
+
+=item gdbm in /usr/local.
+
+Suppose you have gdbm and want Configure to find it and build the
+GDBM_File extension. This examples assumes you have F<gdbm.h>
+installed in F</usr/local/include/gdbm.h> and F<libgdbm.a> installed in
+F</usr/local/lib/libgdbm.a>. Configure should figure all the
+necessary steps out automatically.
+
+Specifically, when Configure prompts you for flags for
+your C compiler, you should include C<-I/usr/local/include>.
+
+When Configure prompts you for linker flags, you should include
+C<-L/usr/local/lib>.
+
+If you are using dynamic loading, then when Configure prompts you for
+linker flags for dynamic loading, you should again include
+C<-L/usr/local/lib>.
+
+Again, this should all happen automatically. If you want to accept the
+defaults for all the questions and have Configure print out only terse
+messages, then you can just run
+
+ sh Configure -des
+
+and Configure should include the GDBM_File extension automatically.
+
+This should actually work if you have gdbm installed in any of
+(/usr/local, /opt/local, /usr/gnu, /opt/gnu, /usr/GNU, or /opt/GNU).
+
+=item gdbm in /usr/you
+
+Suppose you have gdbm installed in some place other than /usr/local/,
+but you still want Configure to find it. To be specific, assume you
+have F</usr/you/include/gdbm.h> and F</usr/you/lib/libgdbm.a>. You
+still have to add B<-I/usr/you/include> to cc flags, but you have to take
+an extra step to help Configure find F<libgdbm.a>. Specifically, when
+Configure prompts you for library directories, you have to add
+F</usr/you/lib> to the list.
+
+It is possible to specify this from the command line too (all on one
+line):
+
+ sh Configure -des \
+ -Dlocincpth="/usr/you/include" \
+ -Dloclibpth="/usr/you/lib"
+
+C<locincpth> is a space-separated list of include directories to search.
+Configure will automatically add the appropriate B<-I> directives.
+
+C<loclibpth> is a space-separated list of library directories to search.
+Configure will automatically add the appropriate B<-L> directives. If
+you have some libraries under F</usr/local/> and others under
+F</usr/you>, then you have to include both, namely
+
+ sh Configure -des \
+ -Dlocincpth="/usr/you/include /usr/local/include" \
+ -Dloclibpth="/usr/you/lib /usr/local/lib"
+
+=back
+
+=head2 Changing the installation directory
+
+Configure distinguishes between the directory in which perl (and its
+associated files) should be installed and the directory in which it
+will eventually reside. For most sites, these two are the same; for
+sites that use AFS, this distinction is handled automatically.
+However, sites that use software such as B<depot> to manage software
+packages may also wish to install perl into a different directory and
+use that management software to move perl to its final destination.
+This section describes how to do this. Someday, Configure may support
+an option C<-Dinstallprefix=/foo> to simplify this.
+
+Suppose you want to install perl under the F</tmp/perl5> directory.
+You can edit F<config.sh> and change all the install* variables to
+point to F</tmp/perl5> instead of F</usr/local/wherever>. You could
+also set them all from the Configure command line. Or, you can
+automate this process by placing the following lines in a file
+F<config.over> B<before> you run Configure (replace /tmp/perl5 by a
+directory of your choice):
+
+ installprefix=/tmp/perl5
+ test -d $installprefix || mkdir $installprefix
+ test -d $installprefix/bin || mkdir $installprefix/bin
+ installarchlib=`echo $installarchlib | sed "s!$prefix!$installprefix!"`
+ installbin=`echo $installbin | sed "s!$prefix!$installprefix!"`
+ installman1dir=`echo $installman1dir | sed "s!$prefix!$installprefix!"`
+ installman3dir=`echo $installman3dir | sed "s!$prefix!$installprefix!"`
+ installprivlib=`echo $installprivlib | sed "s!$prefix!$installprefix!"`
+ installscript=`echo $installscript | sed "s!$prefix!$installprefix!"`
+ installsitelib=`echo $installsitelib | sed "s!$prefix!$installprefix!"`
+
+Then, you can Configure and install in the usual way:
+
+ sh ./Configure -des
+ make
+ make test
+ make install
+
+=head2 Creating an installable tar archive
+
+If you need to install perl on many identical systems, it is
+convenient to compile it once and create an archive that can be
+installed on multiple systems. Here's one way to do that:
+
+ # Set up config.over to install perl into a different directory,
+ # e.g. /tmp/perl5 (see previous part).
+ sh ./Configure -des
+ make
+ make test
+ make install
+ cd /tmp/perl5
+ tar cvf ../perl5-archive.tar .
+ # Then, on each machine where you want to install perl,
+ cd /usr/local # Or wherever you specified as $prefix
+ tar xvf perl5-archive.tar
+
+=head2 What if it doesn't work?
+
+=over 4
+
+=item Hint files.
+
+The perl distribution includes a number of system-specific hints files
+in the hints/ directory. If one of them matches your system, Configure
+will offer to use that hint file.
+
+Several of the hint files contain additional important information.
+If you have any problems, it is a good idea to read the relevant hint
+file for further information. See F<hints/solaris_2.sh> for an
+extensive example.
+
+=item Changing Compilers
+
+If you change compilers or make other significant changes, you should
+probably I<not> re-use your old config.sh. Simply remove it or
+rename it, e.g. mv config.sh config.sh.old. Then rerun Configure
+with the options you want to use.
+
+This is a common source of problems. If you change from B<cc> to
+B<gcc>, you should almost always remove your old config.sh.
+
+=item Propagating your changes
+
+If you later make any changes to F<config.sh>, you should propagate
+them to all the .SH files by running B<Configure -S>.
+
+=item config.over
+
+You can also supply a shell script config.over to over-ride Configure's
+guesses. It will get loaded up at the very end, just before config.sh
+is created. You have to be careful with this, however, as Configure
+does no checking that your changes make sense.
+
+=item config.h
+
+Many of the system dependencies are contained in F<config.h>.
+F<Configure> builds F<config.h> by running the F<config_h.SH> script.
+The values for the variables are taken from F<config.sh>.
+
+If there are any problems, you can edit F<config.h> directly. Beware,
+though, that the next time you run B<Configure>, your changes will be
+lost.
+
+=item cflags
+
+If you have any additional changes to make to the C compiler command
+line, they can be made in F<cflags.SH>. For instance, to turn off the
+optimizer on F<toke.c>, find the line in the switch structure for
+F<toke.c> and put the command C<optimize='-g'> before the C<;;>. You
+can also edit F<cflags> directly, but beware that your changes will be
+lost the next time you run B<Configure>.
+
+To change the C flags for all the files, edit F<config.sh>
+and change either C<$ccflags> or C<$optimize>,
+and then re-run B<Configure -S ; make depend>.
+
+=item No sh.
+
+If you don't have sh, you'll have to copy the sample file config_H to
+config.h and edit the config.h to reflect your system's peculiarities.
+You'll probably also have to extensively modify the extension building
+mechanism.
+
+=back
+
+=head1 make depend
+
+This will look for all the includes.
+The output is stored in F<makefile>. The only difference between
+F<Makefile> and F<makefile> is the dependencies at the bottom of
+F<makefile>. If you have to make any changes, you should edit
+F<makefile>, not F<Makefile> since the Unix B<make> command reads
+F<makefile>.
+
+Configure will offer to do this step for you, so it isn't listed
+explicitly above.
+
+=head1 make
+
+This will attempt to make perl in the current directory.
+
+If you can't compile successfully, try some of the following ideas.
+
+=over 4
+
+=item *
+
+If you used a hint file, try reading the comments in the hint file
+for further tips and information.
+
+=item *
+
+If you can't compile successfully, try adding a C<-DCRIPPLED_CC> flag.
+(Just because you get no errors doesn't mean it compiled right!)
+This simplifies some complicated expressions for compilers that
+get indigestion easily. If that has no effect, try turning off
+optimization. If you have missing routines, you probably need to
+add some library or other, or you need to undefine some feature that
+Configure thought was there but is defective or incomplete.
+
+=item *
+
+Some compilers will not compile or optimize the larger files without
+some extra switches to use larger jump offsets or allocate larger
+internal tables. You can customize the switches for each file in
+F<cflags>. It's okay to insert rules for specific files into
+F<makefile> since a default rule only takes effect in the absence of a
+specific rule.
+
+=item *
+
+If you can successfully build F<miniperl>, but the process crashes
+during the building of extensions, you should run
+
+ make minitest
+
+to test your version of miniperl.
+
+=item *
+
+Some additional things that have been reported for either perl4 or perl5:
+
+Genix may need to use libc rather than libc_s, or #undef VARARGS.
+
+NCR Tower 32 (OS 2.01.01) may need -W2,-Sl,2000 and #undef MKDIR.
+
+UTS may need one or more of B<-DCRIPPLED_CC>, B<-K> or B<-g>, and undef LSTAT.
+
+If you get syntax errors on '(', try -DCRIPPLED_CC.
+
+Machines with half-implemented dbm routines will need to #undef I_ODBM
+
+SCO prior to 3.2.4 may be missing dbmclose(). An upgrade to 3.2.4
+that includes libdbm.nfs (which includes dbmclose()) may be available.
+
+If you get duplicates upon linking for malloc et al, say -DHIDEMYMALLOC.
+
+If you get duplicate function definitions (a perl function has the
+same name as another function on your system) try -DEMBED.
+
+If you get varags problems with gcc, be sure that gcc is installed
+correctly. When using gcc, you should probably have i_stdarg='define'
+and i_varags='undef' in config.sh. The problem is usually solved
+by running fixincludes correctly.
+
+If you wish to use dynamic loading on SunOS or Solaris, and you
+have GNU as and GNU ld installed, you may need to add B<-B/bin/> to
+your $ccflags and $ldflags so that the system's versions of as
+and ld are used.
+
+If you run into dynamic loading problems, check your setting of
+the LD_LIBRARY_PATH environment variable. Perl should build
+fine with LD_LIBRARY_PATH unset, though that may depend on details
+of your local set-up.
+
+=back
+
+=head1 make test
+
+This will run the regression tests on the perl you just made. If it
+doesn't say "All tests successful" then something went wrong. See the
+file F<t/README> in the F<t> subdirectory. Note that you can't run it
+in background if this disables opening of /dev/tty. If B<make test>
+bombs out, just B<cd> to the F<t> directory and run B<TEST> by hand
+to see if it makes any difference.
+If individual tests bomb, you can run them by hand, e.g.,
+
+ ./perl op/groups.t
+
+=head1 INSTALLING PERL5
+
+=head1 make install
+
+This will put perl into the public directory you specified to
+B<Configure>; by default this is F</usr/local/bin>. It will also try
+to put the man pages in a reasonable place. It will not nroff the man
+page, however. You may need to be root to run B<make install>. If you
+are not root, you must own the directories in question and you should
+ignore any messages about chown not working.
+
+If you want to see exactly what will happen without installing
+anything, you can run
+
+ ./perl installperl -n
+ ./perl installman -n
+
+B<make install> will install the following:
+
+ perl,
+ perl5.nnn where nnn is the current release number. This
+ will be a link to perl.
+ suidperl,
+ sperl5.nnn If you requested setuid emulation.
+ a2p awk-to-perl translator
+ cppstdin This is used by perl -P, if your cc -E can't
+ read from stdin.
+ c2ph, pstruct Scripts for handling C structures in header files.
+ s2p sed-to-perl translator
+ find2perl find-to-perl translator
+ h2xs Converts C .h header files to Perl extensions.
+ perldoc Tool to read perl's pod documentation.
+ pod2html, Converters from perl's pod documentation format
+ pod2latex, and to other useful formats.
+ pod2man
+
+ library files in $privlib and $archlib specified to
+ Configure, usually under /usr/local/lib/perl5/.
+ man pages in the location specified to Configure, usually
+ something like /usr/local/man/man1.
+ module in the location specified to Configure, usually
+ man pages under /usr/local/lib/perl5/man/man3.
+ pod/*.pod in $privlib/pod/.
+
+Perl's *.h header files and the libperl.a library are also
+installed under $archlib so that any user may later build new
+extensions even if the Perl source is no longer available.
+
+The libperl.a library is only needed for building new
+extensions and linking them statically into a new perl executable.
+If you will not be doing that, then you may safely delete
+$archlib/libperl.a after perl is installed.
+
+make install may also offer to install perl in a "standard" location.
+
+Most of the documentation in the pod/ directory is also available
+in HTML and LaTeX format. Type
+
+ cd pod; make html; cd ..
+
+to generate the html versions, and
+
+ cd pod; make tex; cd ..
+
+to generate the LaTeX versions.
+
+=head1 Coexistence with perl4
+
+You can safely install perl5 even if you want to keep perl4 around.
+
+By default, the perl5 libraries go into F</usr/local/lib/perl5/>, so
+they don't override the perl4 libraries in F</usr/local/lib/perl/>.
+
+In your /usr/local/bin directory, you should have a binary named
+F<perl4.036>. That will not be touched by the perl5 installation
+process. Most perl4 scripts should run just fine under perl5.
+However, if you have any scripts that require perl4, you can replace
+the C<#!> line at the top of them by C<#!/usr/local/bin/perl4.036>
+(or whatever the appropriate pathname is).
+
+=head1 DOCUMENTATION
+
+Read the manual entries before running perl. The main documentation is
+in the pod/ subdirectory and should have been installed during the
+build process. Type B<man perl> to get started. Alternatively, you
+can type B<perldoc perl> to use the supplied B<perldoc> script. This
+is sometimes useful for finding things in the library modules.
+
+=head1 AUTHOR
+
+Andy Dougherty <doughera@lafcol.lafayette.edu>, borrowing I<very> heavily
+from the original README by Larry Wall.
+
+18 October 1995
Artistic The "Artistic License"
Changes Differences from previous versions.
Changes.Conf Recent changes in the Configure & build process
+configure Crude emulation of GNU configure
Configure Portability tool
Copying The GNU General Public License
Doc/perl5-notes Samples of new functionality
EXTERN.h Included before foreign .h files
+INSTALL Detailed installation instructions.
INTERN.h Included before domestic .h files
MANIFEST This list of files
Makefile.SH A script that generates Makefile
config_H Sample config.h
config_h.SH Produces config.h
configpm Produces lib/Config.pm
-configure Crude emulation of GNU configure
cop.h Control operator header
cv.h Code value header
deb.c Debugging routines
ext/DB_File/DB_File_BS Berkeley DB extension mkbootstrap fodder
ext/DB_File/Makefile.PL Berkeley DB extension makefile writer
ext/DB_File/typemap Berkeley DB extension interface types
+ext/Devel/DProf/DProf.pm Perl Profiler extension Perl module
+ext/Devel/DProf/DProf.xs Perl Profiler extension external subroutines
+ext/Devel/DProf/Makefile.PL Perl Profiler extension makefile writer
+ext/Devel/DProf/README Perl Profiler extension info
+ext/Devel/DProf/dprofpp Perl Profiler extension utility
+ext/Devel/DProf/test.pl Perl Profiler extension test
ext/DynaLoader/DynaLoader.pm Dynamic Loader perl module
ext/DynaLoader/Makefile.PL Dynamic Loader makefile writer
ext/DynaLoader/README Dynamic Loader notes and intro
hints/freebsd.sh Hints for named architecture
hints/genix.sh Hints for named architecture
hints/greenhills.sh Hints for named architecture
-hints/hpux_9.sh Hints for named architecture
+hints/hpux.sh Hints for named architecture
hints/i386.sh Hints for named architecture
hints/irix_4.sh Hints for named architecture
hints/irix_5.sh Hints for named architecture
pl2pm A pl to pm translator
pod/Makefile Make pods into something else
pod/perl.pod Top level perl man page
-pod/perlapi.pod XS api info
pod/perlbook.pod Book info
pod/perlbot.pod Object-oriented Bag o' Tricks
pod/perlcall.pod Callback info
pod/perlsyn.pod Syntax info
pod/perltrap.pod Trap info
pod/perlvar.pod Variable info
+pod/perlxs.pod XS api info
pod/pod2html.SH Precursor for translator to turn pod into HTML
pod/pod2latex.SH Precursor for translator to turn pod into LaTeX
pod/pod2man.SH Precursor for translator to turn pod into manpage
t/lib/odbm.t See if ODBM_File works
t/lib/posix.t See if POSIX works
t/lib/sdbm.t See if SDBM_File works
+t/lib/socket.t See if Socket works
t/lib/soundex.t See if Soundex works
t/op/append.t See if . works
t/op/array.t See if array operations work
# The following are mentioned only to make metaconfig include the
# appropriate questions in Configure. If you want to change these,
-# edit config.sh instead, or specify --man1dir=/wherever on
+# edit config.sh instead, or specify --man1dir=/wherever on
# installman commandline.
bin = $installbin
scriptdir = $scriptdir
all: makefile miniperl $(private) $(public) $(dynamic_ext)
@echo " "; echo " Making x2p stuff"; cd x2p; $(MAKE) all
-
+
# This is now done by installman only if you actually want the man pages.
# @echo " "; echo " Making docs"; cd pod; $(MAKE) all;
perl keywords.pl
perl opcode.pl
perl embed.pl
-
+
# Extensions:
# Names added to $(dynamic_ext) or $(static_ext) will automatically
# get built. There should ordinarily be no need to change any of
realclean: clean
-cd x2p; $(MAKE) realclean
-cd pod; $(MAKE) realclean
- @for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
+ -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
sh ext/util/make_ext realclean $$x ; \
done
rm -f *.orig */*.orig *~ */*~ core t/core t/c t/perl
This program is free software; you can redistribute it and/or modify
it under the terms of either:
-
+
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
Installation
-1) Run Configure. This will figure out various things about your
- system. Some things Configure will figure out for itself, other
- things it will ask you about. If the test scripts and programs
- run ok, the defaults will usually be right. It will then proceed to
- make config.h, config.sh, and Makefile. You may have to explicitly
- say sh Configure to ensure that Configure is run under sh.
- If you're a hotshot, run Configure -d to take all the defaults
- and edit config.sh to patch up any flaws.
-
- If you later make any changes to config.sh, you should propagate
- them to all the .SH files by running Configure -S.
-
- Configure supports a number of useful options. Run Configure -h
- to get a listing. To compile with gcc, for example, you can run
- Configure -Dcc=gcc, or answer 'gcc' at the cc prompt.
-
- If you wish to use gcc (or another alternative compiler)
- you should use Configure -Dcc=gcc. That way, the the hints
- files can set appropriate defaults.
-
- By default, perl will be installed in /usr/local/{bin, lib, man}.
- You can specify a different 'prefix' for the default installation
- directory, when Configure prompts you or by using the Configure
- command line option -Dprefix='/some/directory'.
-
- By default, perl will use dynamic extensions if your system
- supports it. If you want to force perl to be compiled statically,
- you can either choose this when Configure prompts you or by using
- the Configure command line option -Uusedl
-
- If you change compilers or make other significant changes, you should
- probably _not_ re-use your old config.sh. Simply remove it or
- rename it, e.g. mv config.sh config.sh.old. Then rerun Configure
- with the options you want to use.
-
- You can also supply a file config.over to over-ride Configure's
- guesses. It will get loaded up at the very end, just before
- config.sh is created.
-
- You might possibly have to trim # comments from the front of Configure
- if your sh doesn't handle them, but all other # comments will be taken
- care of.
-
- (If you don't have sh, you'll have to copy the sample file config_H to
- config.h and edit the config.h to reflect your system's peculiarities.)
-
-2) Glance through config.h to make sure system dependencies are correct.
- Most of them should have been taken care of by running the Configure script.
-
- If you have any additional changes to make to the C definitions, they
- can be done in cflags.SH. For instance, to turn off the optimizer
- on toke.c, find the line in the switch structure for toke.c and
- put the command optimize='-g' before the ;;. To change the C flags
- for all the files, edit config.sh and change either $ccflags or $optimize,
- and then re-run Configure -S ; make depend.
-
-
-3) make depend
-
- This will look for all the includes and modify Makefile accordingly.
- Configure will offer to do this for you.
-
-4) make
-
- This will attempt to make perl in the current directory.
-
- If you can't compile successfully, try adding a -DCRIPPLED_CC flag.
- (Just because you get no errors doesn't mean it compiled right!)
- This simplifies some complicated expressions for compilers that
- get indigestion easily. If that has no effect, try turning off
- optimization. If you have missing routines, you probably need to
- add some library or other, or you need to undefine some feature that
- Configure thought was there but is defective or incomplete.
-
- Some compilers will not compile or optimize the larger files without
- some extra switches to use larger jump offsets or allocate larger
- internal tables. You can customize the switches for each file in
- cflags.SH. It's okay to insert rules for specific files into
- Makefile.SH, since a default rule only takes effect in the
- absence of a specific rule.
-
- If you used a hint file, try reading the comments in the hint file
- for further tips and information.
-
- If you can successfully build miniperl, but the process crashes
- during the building of extensions, you should run
- make minitest
- to test your version of miniperl.
-
- Some additional things that have been reported for either perl4 or
- perl5:
-
- Genix may need to use libc rather than libc_s, or #undef VARARGS.
-
- NCR Tower 32 (OS 2.01.01) may need -W2,-Sl,2000 and #undef MKDIR.
-
- UTS may need one or more of -DCRIPPLED_CC, -K or -g, and undef LSTAT.
-
- If you get syntax errors on '(', try -DCRIPPLED_CC.
-
- Machines with half-implemented dbm routines will need to #undef I_ODBM
-
- SCO prior to 3.2.4 may be missing dbmclose(). An upgrade to 3.2.4
- that includes libdbm.nfs (which includes dbmclose()) may be available.
-
- If you get duplicates upon linking for malloc et al, say -DHIDEMYMALLOC.
-
- If you get duplicate function definitions (a perl function has the
- same name as another function on your system) try -DEMBED.
-
- If you get varags problems with gcc, be sure that gcc is installed
- correctly. When using gcc, you should probably have i_stdarg='define'
- and i_varags='undef' in config.sh. The problem is usually solved
- by running fixincludes correctly.
-
- If you wish to use dynamic loading on SunOS or Solaris, and you
- have GNU as and GNU ld installed, you may need to add -B/bin/ to
- your $ccflags and $ldflags so that the system's versions of as
- and ld are used.
-
- If you run into dynamic loading problems, check your setting of
- the LD_LIBRARY_PATH environment variable. Perl should build
- fine with LD_LIBRARY_PATH unset, though that may depend on details
- of your local set-up.
-
-5) make test
-
- This will run the regression tests on the perl you just made.
- If it doesn't say "All tests successful" then something went wrong.
- See the README in the t subdirectory. Note that you can't run it
- in background if this disables opening of /dev/tty. If "make test"
- bombs out, just cd to the t directory and run TEST by hand to see if
- it makes any difference. If individual tests bomb, you can run
- them by hand, e.g., ./perl op/groups.t
-
-6) make install
-
- This will put perl into a public directory (such as
- /usr/local/bin). It will also try to put the man pages in a
- reasonable place. It will not nroff the man page, however. You
- may need to be root to run make install. If you are not root, you
- must own the directories in question and you should ignore any
- messages about chown not working.
-
- make install will install the following:
- perl,
- perl5.nnn where nnn is the current release number. This
- will be a link to perl.
- suidperl,
- sperl5.nnn If you requested setuid emulation.
- a2p awk-to-perl translator
- cppstdin This is used by perl -P, if your cc -E can't
- read from stdin.
- c2ph, pstruct Scripts for handling C structures in header files.
- s2p sed-to-perl translator
- find2perl find-to-perl translator
- h2xs Converts C .h header files to Perl extensions.
- perldoc Tool to read perl's pod documentation.
- pod2html, Converters from perl's pod documentation format
- pod2latex, and to other useful formats.
- pod2man
-
- library files in $privlib and $archlib specified to
- Configure, usually under /usr/local/lib/perl5/.
- man pages in the location specified to Configure, usually
- something like /usr/local/man/man1.
- module in the location specified to Configure, usually
- man pages under /usr/local/lib/perl5/man/man3.
- pod/*.pod in $privlib/pod/.
-
- Perl's *.h header files and the libperl.a library are also
- installed under $archlib so that you may later build new
- extensions even if the Perl source is no longer available.
-
- make install may also offer to install perl in a "standard" location.
-
- Most of the documentation in the pod/ directory is also available
- in HTML and LaTeX format. Type
- cd pod; make html; cd ..
- to generate the html versions, and
- cd pod; make tex; cd ..
- to generate the LaTeX versions.
-
-7) Read the manual entries before running perl.
-
-8) IMPORTANT! Help save the world! Communicate any problems and suggested
- patches to me, lwall@netlabs.com (Larry Wall), so we can
- keep the world in sync. If you have a problem, there's someone else
- out there who either has had or will have the same problem.
-
- If possible, send in patches such that the patch program will apply them.
- Context diffs are the best, then normal diffs. Don't send ed scripts--
- I've probably changed my copy since the version you have. It's also
- helpful if you send the output of "uname -a".
-
- Watch for perl patches in comp.lang.perl. Patches will generally be
- in a form usable by the patch program. If you are just now bringing up
- perl and aren't sure how many patches there are, write to me and I'll
- send any you don't have. Your current patch level is shown in patchlevel.h.
+1) Detailed instructions are in the file INSTALL. In brief, the
+following should work on most systems:
+ rm -f config.sh
+ sh Configure
+ make
+ make test
+ make install
+For most systems, it should be safe to accept all the Configure
+defaults.
+
+2) Read the manual entries before running perl.
+
+3) IMPORTANT! Help save the world! Communicate any problems and suggested
+patches to me, lwall@netlabs.com (Larry Wall), so we can
+keep the world in sync. If you have a problem, there's someone else
+out there who either has had or will have the same problem.
+It's usually helpful if you send the output of the "myconfig" script
+in the main perl directory.
+
+If possible, send in patches such that the patch program will apply them.
+Context diffs are the best, then normal diffs. Don't send ed scripts--
+I've probably changed my copy since the version you have.
+
+Watch for perl patches in comp.lang.perl.announce. Patches will generally
+be in a form usable by the patch program. If you are just now bringing
+up perl and aren't sure how many patches there are, write to me and I'll
+send any you don't have. Your current patch level is shown in
+patchlevel.h.
Just a personal note: I want you to know that I create nice things like this
# See the usage message for more. If this isn't enough, read the code.
#
-$RCSID = 'c2ph.SH';
+$RCSID = '$Id: c2ph,v 1.7 95/10/28 10:41:47 tchrist Exp Locker: tchrist $';
######################################################################
next unless /^\s*\.stabs\s+/;
$line = $_;
s/^\s*\.stabs\s+//;
+ if (s/\\\\"[d,]+$//) {
+ $saveline .= $line;
+ $savebar = $_;
+ next STAB;
+ }
+ if ($saveline) {
+ s/^"//;
+ $_ = $savebar . $_;
+ $line = $saveline;
+ }
&stab;
+ $savebar = $saveline = undef;
}
print STDERR "$.\n" if $trace;
unlink $TMP if $TMP;
$pmask1 = "%-${type_width}s %-${member_width}s";
$pmask2 = "%-${sum}s %${offset_width}${offset_fmt}%s %${size_width}${size_fmt}%s";
+
+
if ($perl) {
# resolve template -- should be in stab define order, but even this isn't enough.
print STDERR "\nbuilding type templates: " if $trace;
for $i (reverse 0..$#type) {
next unless defined($name = $type[$i]);
next unless defined $struct{$name};
+ ($iname = $name) =~ s/\..*//;
$build_recursed = 0;
&build_template($name) unless defined $template{&psou($name)} ||
- $opt_s && !$interested{$name};
+ $opt_s && !$interested{$iname};
}
print STDERR "\n\n" if $trace;
}
print STDERR "dumping structs: " if $trace;
+ local($iam);
+
+
foreach $name (sort keys %struct) {
- next if $opt_s && !$interested{$name};
+ ($iname = $name) =~ s/\..*//;
+ next if $opt_s && !$interested{$iname};
print STDERR "$name " if $trace;
undef @sizeof;
undef @offsetof;
undef @indices;
undef @typeof;
+ undef @fieldnames;
$mname = &munge($name);
}
EOF
+ print <<EOF;
+sub ${mname}'fieldnames {
+ \@${mname}'fieldnames;
+}
+EOF
+
+ $iam = ($isastruct{$name} && 's') || ($isaunion{$name} && 'u');
+
+ print <<EOF;
+sub ${mname}'isastruct {
+ '$iam';
+}
+EOF
print "\$${mname}'typedef = '" . &scrunch($template{$fname})
. "';\n";
join("\n\t", '', @offsetof), "\n );\n\n";
print "\@${mname}'typeof[\@${mname}'indices] = (",
join("\n\t", '', @typeof), "\n );\n\n";
+ print "\@${mname}'fieldnames[\@${mname}'indices] = (",
+ join("\n\t", '', @fieldnames), "\n );\n\n";
$template_printed{$fname}++;
$size_printed{$fname}++;
print STDERR "\n" if $trace;
unless ($perl && $opt_a) {
- print "\n1;\n";
+ print "\n1;\n" if $perl;
exit;
}
print '$',&munge($name),"'typedef = '", $template{$name}, "';\n";
}
- print "\n1;\n";
+ print "\n1;\n" if $perl;
exit;
}
sub stab {
- next unless /:[\$\w]+(\(\d+,\d+\))?=[\*\$\w]+/; # (\d+,\d+) is for sun
+ next unless $continued || /:[\$\w]+(\(\d+,\d+\))?=[\*\$\w]+/; # (\d+,\d+) is for sun
s/"// || next;
s/",([x\d]+),([x\d]+),([x\d]+),.*// || next;
next if /^\s*$/;
$size = $3 if $3;
+ $_ = $continued . $_ if length($continued);
+ if (s/\\\\$//) {
+ # if last 2 chars of string are '\\' then stab is continued
+ # in next stab entry
+ chop;
+ $continued = $_;
+ next;
+ }
+ $continued = '';
$line = $_;
$type[$typeno] = $2;
print STDERR "intrinsic $2 in new type $typeno\n" if $debug;
}
- elsif (s/^=e//) { # blessed by thy compiler; mine won't do this
+ elsif (s/^=e//) { # blessed be thy compiler; mine won't do this
&edecl;
}
else {
}
}
- $template = &fetch_template($type) x
- ($count ? &scripts2count($count) : 1);
+ $template = &fetch_template($type);
+ &repeat_template($template,$count);
if (! $finished_template{$sname}) {
$template{$sname} .= $template;
($bits = $length % 8) ? ".$bits": ""
if !$perl || $verbose;
+ if ($perl) {
+ $template = &fetch_template($type);
+ &repeat_template($template,$count);
+ }
if ($perl && $nesting == 1) {
- $template = &scrunch(&fetch_template($type) x
- ($count ? &scripts2count($count) : 1));
+
push(@sizeof, int($length/8) .",\t# $fieldname");
push(@offsetof, int($offset/8) .",\t# $fieldname");
- push(@typedef, "'$template', \t# $fieldname");
+ local($little) = &scrunch($template);
+ push(@typedef, "'$little', \t# $fieldname");
$type =~ s/(struct|union) //;
- push(@typeof, "'$type" . ($count ? $count : '') .
+ push(@typeof, "'$mytype" . ($count ? $count : '') .
"',\t# $fieldname");
+ push(@fieldnames, "'$fieldname',");
}
print ' ', ' ' x $indent x $nesting, $template
# global $typeno, @type
local($_, $typedef) = @_;
- while (s/^((\d+)=)?ar(\d+);//) {
+ while (s/^((\d+|\(\d+,\d+\))=)?ar(\d+|\(\d+,\d+\));//) {
($arraytype, $unknown) = ($2, $3);
+ $arraytype = &typeno($arraytype);
+ $unknown = &typeno($unknown);
if (s/^(\d+);(\d+);//) {
($lower, $upper) = ($1, $2);
$scripts .= '[' . ($upper+1) . ']';
warn "can't find array bounds: $_";
}
}
- if (s/^([\d*f=]*),(\d+),(\d+);//) {
+ if (s/^([(,)\d*f=]*),(\d+),(\d+);//) {
($start, $length) = ($2, $3);
- local($whatis) = $1;
- if ($whatis =~ /^(\d+)=/) {
- $typeno = $1;
+ $whatis = $1;
+ if ($whatis =~ /^(\d+|\(\d+,\d+\))=/) {
+ $typeno = &typeno($1);
&pdecl($whatis);
} else {
- $typeno = $whatis;
+ $typeno = &typeno($whatis);
}
} elsif (s/^(\d+)(=[*suf]\d*)//) {
local($whatis) = $2;
#$_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
}
- if (/^\d+=ar/) {
+ if (/^(\d+|\(\d+,\d+\))=ar/) {
$_ = &adecl($_);
}
elsif (s/^(\d+|\(\d+,\d+\))?,(\d+),(\d+);//) {
+ ($start, $length) = ($2, $3);
+ &panic("no length?") unless $length;
+ $typeno = &typeno($1) if $1;
+ }
+ elsif (s/^(\d+)=xs\w+:,(\d+),(\d+);//) {
($start, $length) = ($2, $3);
&panic("no length?") unless $length;
$typeno = &typeno($1) if $1;
sub scrunch {
local($_) = @_;
+ return '' if $_ eq '';
+
study;
s/\$//g;
sub buildscrunchlist {
$scrunch_code = "sub quick_scrunch {\n";
for (values %intrinsics) {
- $scrunch_code .= "\ts/($_{2,})/'$_' . length(\$1)/ge;\n";
+ $scrunch_code .= "\ts/($_\{2,})/'$_' . length(\$1)/ge;\n";
}
$scrunch_code .= "}\n";
print "$scrunch_code" if $debug;
EOF
for $type (@intrinsics) {
- next if $type eq 'void';
+ next if !type || $type eq 'void' || $type =~ /complex/; # sun stuff
print <<"EOF";
printf(mask,sizeof($type), "$type");
EOF
$string .= $last if $inseq && $last != -e18;
$string;
}
-!NO!SUBS!
-$eunicefix c2ph
-rm -f pstruct
-ln c2ph pstruct
+
+sub repeat_template {
+ # local($template, $scripts) = @_; have to change caller's values
+
+ if ( $_[1] ) {
+ local($ncount) = &scripts2count($_[1]);
+ if ($_[0] =~ /^\s*c\s*$/i) {
+ $_[0] = "A$ncount ";
+ $_[1] = '';
+ } else {
+ $_[0] = $template x $ncount;
+ }
+ }
+}
* $Id: Config_h.U,v 3.0.1.3 1995/01/30 14:25:39 ram Exp $
*/
-/* Configuration time: Tue Jun 6 12:34:26 EDT 1995
+/* Configuration time: Tue Jul 25 15:36:03 EDT 1995
* Configured by: andy
* Target system: crystal crystal 3.2 2 i386
*/
*/
#define BIN "$bin" /**/
-/* BYTEORDER:
- * This symbol hold the hexadecimal constant defined in byteorder,
- * i.e. 0x1234 or 0x4321, etc...
- */
-#define BYTEORDER 0x$byteorder /* large digits for MSB */
-
/* CAT2:
* This macro catenates 2 tokens together.
*/
*/
#$d_fsetpos HAS_FSETPOS /**/
-/* Gconvert:
- * This preprocessor macro is defined to convert a floating point
- * number to a string without a trailing decimal point. This
- * emulates the behavior of sprintf("%g"), but is sometimes much more
- * efficient. If gconvert() is not available, but gcvt() drops the
- * trailing decimal point, then gcvt() is used. If all else fails,
- * a macro using sprintf("%g") is used. Arguments for the Gconvert
- * macro are: value, number of digits, whether trailing zeros should
- * be retained, and the output buffer.
- * Possible values are:
- * d_Gconvert='gconvert((x),(n),(t),(b))'
- * d_Gconvert='gcvt((x),(n),(b))'
- * d_Gconvert='sprintf((b),"%.*g",(n),(x))'
- * The last two assume trailing zeros should not be kept.
- */
-#define Gconvert(x,n,t,b) $d_Gconvert
-
/* HAS_GETGROUPS:
* This symbol, if defined, indicates that the getgroups() routine is
* available to get the list of process groups. If unavailable, multiple
*/
#$d_pipe HAS_PIPE /**/
+/* HAS_POLL:
+ * This symbol, if defined, indicates that the poll routine is
+ * available to poll active file descriptors.
+ */
+#$d_poll HAS_POLL /**/
+
/* HAS_READDIR:
* This symbol, if defined, indicates that the readdir routine is
* available to read directory entries. You may have to include
*/
#$i_vfork I_VFORK /**/
-/* INTSIZE:
- * This symbol contains the size of an int, so that the C preprocessor
- * can make decisions based on it.
- */
-#define INTSIZE $intsize /**/
-
/* Off_t:
* This symbol holds the type used to declare offsets in the kernel.
* It can be int, long, off_t, etc... It may be necessary to include
*/
#define Mode_t $modetype /* file mode parameter for system calls */
+/* VAL_O_NONBLOCK:
+ * This symbol is to be used during open() or fcntl(F_SETFL) to turn on
+ * non-blocking I/O for the file descriptor. Note that there is no way
+ * back, i.e. you cannot turn it blocking again this way. If you wish to
+ * alternatively switch between blocking and non-blocking, use the
+ * ioctl(FIOSNBIO) call instead, but that is not supported by all devices.
+ */
+/* VAL_EAGAIN:
+ * This symbol holds the errno error code set by read() when no data was
+ * present on the non-blocking file descriptor.
+ */
+/* RD_NODATA:
+ * This symbol holds the return code from read() when no data is present
+ * on the non-blocking file descriptor. Be careful! If EOF_NONBLOCK is
+ * not defined, then you can't distinguish between no data and EOF by
+ * issuing a read(). You'll have to find another way to tell for sure!
+ */
+/* EOF_NONBLOCK:
+ * This symbol, if defined, indicates to the C program that a read() on
+ * a non-blocking file descriptor will return 0 on EOF, and not the value
+ * held in RD_NODATA (-1 usually, in that case!).
+ */
+#define VAL_O_NONBLOCK $o_nonblock
+#define VAL_EAGAIN $eagain
+#define RD_NODATA $rd_nodata
+#$d_eofnblk EOF_NONBLOCK
+
/* PRIVLIB_EXP:
* This symbol contains the ~name expanded version of PRIVLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
#define Select_fd_set_t $selecttype /**/
-/* SIG_NAME:
- * This symbol contains a list of signal names in order. This is intended
- * to be used as a static array initialization, like this:
- * char *sig_name[] = { SIG_NAME };
- * The signals in the list are separated with commas, and each signal
- * is surrounded by double quotes. There is no leading SIG in the signal
- * name, i.e. SIGQUIT is known as "QUIT".
- */
-#define SIG_NAME "`echo $sig_name | sed 's/ /","/g'`" /**/
-
/* Size_t:
* This symbol holds the type used to declare length parameters
* for string functions. It is usually size_t, but may be
*/
#define Uid_t $uidtype /* UID type */
-/* VOIDFLAGS:
- * This symbol indicates how much support of the void type is given by this
- * compiler. What various bits mean:
- *
- * 1 = supports declaration of void
- * 2 = supports arrays of pointers to functions returning void
- * 4 = supports comparisons between pointers to void functions and
- * addresses of void functions
- * 8 = suports declaration of generic void pointers
- *
- * The package designer should define VOIDUSED to indicate the requirements
- * of the package. This can be done either by #defining VOIDUSED before
- * including config.h, or by defining defvoidused in Myinit.U. If the
- * latter approach is taken, only those flags will be tested. If the
- * level of void support necessary is not present, defines void to int.
- */
-#ifndef VOIDUSED
-#define VOIDUSED $defvoidused
-#endif
-#define VOIDFLAGS $voidflags
-#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
-#define void int /* is void to be avoided? */
-#define M_VOID /* Xenix strikes again */
-#endif
-
/* VMS:
* This symbol, if defined, indicates that the program is running under
* VMS. It is currently only set in conjunction with the EUNICE symbol.
*/
#define LOC_SED "$full_sed" /**/
+/* BYTEORDER:
+ * This symbol hold the hexadecimal constant defined in byteorder,
+ * i.e. 0x1234 or 0x4321, etc...
+ */
+#define BYTEORDER 0x$byteorder /* large digits for MSB */
+
/* CSH:
* This symbol, if defined, indicates that the C-shell exists.
* If defined, contains the full pathname of csh.
*/
#$d_dlsymun DLSYM_NEEDS_UNDERSCORE /* */
+/* Gconvert:
+ * This preprocessor macro is defined to convert a floating point
+ * number to a string without a trailing decimal point. This
+ * emulates the behavior of sprintf("%g"), but is sometimes much more
+ * efficient. If gconvert() is not available, but gcvt() drops the
+ * trailing decimal point, then gcvt() is used. If all else fails,
+ * a macro using sprintf("%g") is used. Arguments for the Gconvert
+ * macro are: value, number of digits, whether trailing zeros should
+ * be retained, and the output buffer.
+ * Possible values are:
+ * d_Gconvert='gconvert((x),(n),(t),(b))'
+ * d_Gconvert='gcvt((x),(n),(b))'
+ * d_Gconvert='sprintf((b),"%.*g",(n),(x))'
+ * The last two assume trailing zeros should not be kept.
+ */
+#define Gconvert(x,n,t,b) $d_Gconvert
+
/* USE_DYNAMIC_LOADING:
* This symbol, if defined, indicates that dynamic loading of
* some sort is available.
*/
#$usedl USE_DYNAMIC_LOADING /**/
+/* I_DBM:
+ * This symbol, if defined, indicates that <dbm.h> exists and should
+ * be included.
+ */
+/* I_RPCSVC_DBM:
+ * This symbol, if defined, indicates that <rpcsvc/dbm.h> exists and
+ * should be included.
+ */
+#$i_dbm I_DBM /**/
+#$i_rpcsvcdbm I_RPCSVC_DBM /**/
+
/* I_SYS_STAT:
* This symbol, if defined, indicates to the C program that it should
* include <sys/stat.h>.
*/
#$i_sysstat I_SYS_STAT /**/
+/* INTSIZE:
+ * This symbol contains the size of an int, so that the C preprocessor
+ * can make decisions based on it.
+ */
+#define INTSIZE $intsize /**/
+
/* Free_t:
* This variable contains the return type of free(). It is usually
* void, but occasionally int.
*/
#$d_mymalloc MYMALLOC /**/
+/* SIG_NAME:
+ * This symbol contains a list of signal names in order. This is intended
+ * to be used as a static array initialization, like this:
+ * char *sig_name[] = { SIG_NAME };
+ * The signals in the list are separated with commas, and each signal
+ * is surrounded by double quotes. There is no leading SIG in the signal
+ * name, i.e. SIGQUIT is known as "QUIT". Duplicates are allowed.
+ * The signal number for sig_name[i] is stored in sig_num[i].
+ * The last element is 0 to terminate the list with a NULL. This
+ * corresponds to the 0 at the end of the sig_num list.
+ * See SIG_NUM and SIG_MAX.
+ */
+#define SIG_NAME "`echo $sig_name | sed 's/ /","/g'`",0 /**/
+
+/* SIG_NUM:
+ * This symbol contains a list of signal number, in the same order as the
+ * SIG_NAME list. It is suitable for static array initialization, as in:
+ * int sig_num[] = { SIG_NUM };
+ * The signals in the list are separated with commas, and the indices
+ * within that list and the SIG_NAME list match, so it's easy to compute
+ * the signal name from a number or vice versa at the price of a small
+ * dynamic linear lookup. Duplicates are allowed, so you can't assume
+ * sig_num[i] == i. Instead, the signal number corresponding to
+ * sig_name[i] is sig_number[i].
+ * The last element is 0, corresponding to the 0 at the end of
+ * the sig_name list.
+ */
+#define SIG_NUM `echo $sig_num 0 | sed 's/ /,/g'` /**/
+
/* SITELIB_EXP:
* This symbol contains the ~name expanded version of SITELIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
#$d_sitelib SITELIB_EXP "$sitelibexp" /**/
+/* VOIDFLAGS:
+ * This symbol indicates how much support of the void type is given by this
+ * compiler. What various bits mean:
+ *
+ * 1 = supports declaration of void
+ * 2 = supports arrays of pointers to functions returning void
+ * 4 = supports comparisons between pointers to void functions and
+ * addresses of void functions
+ * 8 = suports declaration of generic void pointers
+ *
+ * The package designer should define VOIDUSED to indicate the requirements
+ * of the package. This can be done either by #defining VOIDUSED before
+ * including config.h, or by defining defvoidused in Myinit.U. If the
+ * latter approach is taken, only those flags will be tested. If the
+ * level of void support necessary is not present, defines void to int.
+ */
+#ifndef VOIDUSED
+#define VOIDUSED $defvoidused
+#endif
+#define VOIDFLAGS $voidflags
+#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
+#define void int /* is void to be avoided? */
+#define M_VOID /* Xenix strikes again */
+#endif
+
#endif
!GROK!THIS!
sub DELETE{ &readonly }
sub CLEAR { &readonly }
+sub config_sh { $config_sh }
1;
ENDOFEND
#! /bin/sh
+#
+# $Id: configure,v 3.0.1.1 1995/07/25 14:16:21 ram Exp $
+#
# GNU configure-like front end to metaconfig's Configure.
#
-# Written by Andy Dougherty (doughera@lafcol.lafayette.edu)
-# and matthew green (mrg@mame.mu.oz.au)
+# Written by Andy Dougherty <doughera@lafcol.lafayette.edu>
+# and Matthew Green <mrg@mame.mu.oz.au>.
+#
+# Reformatted and modified for inclusion in the dist-3.0 package by
+# Raphael Manfredi <ram@hptnos02.grenoble.hp.com>.
+#
+# This script belongs to the public domain and may be freely redistributed.
+#
+# The remaining of this leading shell comment may be removed if you
+# include this script in your own package.
+#
+# $Log: configure,v $
+# Revision 3.0.1.1 1995/07/25 14:16:21 ram
+# patch56: created
#
-# public domain.
+(exit $?0) || exec sh $0 $argv:q
opts=''
-for f in $*
-do
- case $f in
+verbose=''
+create='-e'
+while test $# -gt 0; do
+ case $1 in
--help)
- echo This is GNU configure-like front end for a MetaConfig Configure.
- echo It understands the follow GNU configure options:
- echo " --prefix=PREFIX"
- echo " --help"
- echo ""
- echo And these environment variables:
- echo " CFLAGS"
- echo " CC"
- echo " DEFS"
- echo 0
- ;;
- --prefix=*)
- shift
- arg=`echo $f | sed 's/--prefix=/-Dprefix=/'`
- opts="$opts $arg"
- ;;
- --*)
- opt=`echo $f | sed 's/=.*//'`
- echo This GNU configure front end does not understand $opt
- exit 1
- ;;
- *)
- shift
- opts="$opts $f"
- ;;
- esac
+ cat <<EOM
+Usage: configure [options]
+This is GNU configure-like front end for a metaconfig-generated Configure.
+It emulates the following GNU configure options (must be fully spelled out):
+ --help
+ --no-create
+ --prefix=PREFIX
+ --quiet
+ --silent
+ --verbose
+ --version
+
+And it honours these environment variables: CC, CFLAGS and DEFS.
+EOM
+ exit 0
+ ;;
+ --no-create)
+ create='-E'
+ shift
+ ;;
+ --prefix=*)
+ arg=`echo $1 | sed 's/--prefix=/-Dprefix=/'`
+ opts="$opts $arg"
+ shift
+ ;;
+ --quiet|--silent)
+ exec >/dev/null 2>&1
+ shift
+ ;;
+ --verbose)
+ verbose=true
+ shift
+ ;;
+ --version)
+ copt="$copt -V"
+ shift
+ ;;
+ --*)
+ opt=`echo $1 | sed 's/=.*//'`
+ echo "This GNU configure front end does not understand $opt"
+ exit 1
+ ;;
+ *)
+ opts="$opts $1"
+ shift
+ ;;
+ esac
done
case "$CC" in
- '') ;;
- *) opts="$opts -Dcc='$CC'" ;;
+'') ;;
+*) opts="$opts -Dcc='$CC'";;
esac
-# join DEFS and CFLAGS together.
-
+# Join DEFS and CFLAGS together.
ccflags=''
-if test "x$DEFS" != x
-then
- ccflags=$DEFS
-fi
-if test "x$CFLAGS" != x
-then
- ccflags="$ccflags $CFLAGS"
-fi
+case "$DEFS" in
+'') ;;
+*) ccflags=$DEFS;;
+esac
+case "$CFLAGS" in
+'') ;;
+*) ccflags="$ccflags $CFLAGS";;
+esac
+case "$ccflags" in
+'') ;;
+*) opts="$opts -Dccflags='$ccflags'";;
+esac
-if test "x$ccflags" != x
-then
- opts="$opts -Dccflags='$ccflags'"
-fi
+# Don't use -s if they want verbose mode
+case "$verbose" in
+'') copt="$copt -ds";;
+*) copt="$copt -d";;
+esac
-echo ./Configure "$opts" -des
-./Configure "$opts" -des
+set X ./Configure $copt $create $opts
+shift
+echo "$@"
+exec "$@"
#define sge_amg Perl_sge_amg
#define sgt_amg Perl_sgt_amg
#define sig_name Perl_sig_name
+#define sig_num Perl_sig_num
#define siggv Perl_siggv
#define sighandler Perl_sighandler
#define simple Perl_simple
#define warn Perl_warn
#define watch Perl_watch
#define whichsig Perl_whichsig
+#define whichsigname Perl_whichsigname
#define xiv_arenaroot Perl_xiv_arenaroot
#define xiv_root Perl_xiv_root
#define xnv_root Perl_xnv_root
# DB_File.pm -- Perl 5 interface to Berkeley DB
#
# written by Paul Marquess (pmarquess@bfsec.bt.co.uk)
-# last modified 19th May 1995
-# version 0.2
+# last modified 7th October 1995
+# version 1.0
+
+package DB_File::HASHINFO ;
+use Carp;
+
+sub TIEHASH
+{
+ bless {} ;
+}
+
+%elements = ( 'bsize' => 0,
+ 'ffactor' => 0,
+ 'nelem' => 0,
+ 'cachesize' => 0,
+ 'hash' => 0,
+ 'lorder' => 0
+ ) ;
+
+sub FETCH
+{
+ return $_[0]{$_[1]} if defined $elements{$_[1]} ;
+
+ croak "DB_File::HASHINFO::FETCH - Unknown element '$_[1]'" ;
+}
+
+
+sub STORE
+{
+ if ( defined $elements{$_[1]} )
+ {
+ $_[0]{$_[1]} = $_[2] ;
+ return ;
+ }
+
+ croak "DB_File::HASHINFO::STORE - Unknown element '$_[1]'" ;
+}
+
+sub DELETE
+{
+ if ( defined $elements{$_[1]} )
+ {
+ delete ${$_[0]}{$_[1]} ;
+ return ;
+ }
+
+ croak "DB_File::HASHINFO::DELETE - Unknown element '$_[1]'" ;
+}
+
+
+sub DESTROY {undef %{$_[0]} }
+sub FIRSTKEY { croak "DB_File::HASHINFO::FIRSTKEY is not implemented" }
+sub NEXTKEY { croak "DB_File::HASHINFO::NEXTKEY is not implemented" }
+sub EXISTS { croak "DB_File::HASHINFO::EXISTS is not implemented" }
+sub CLEAR { croak "DB_File::HASHINFO::CLEAR is not implemented" }
+
+package DB_File::BTREEINFO ;
+use Carp;
+
+sub TIEHASH
+{
+ bless {} ;
+}
+
+%elements = ( 'flags' => 0,
+ 'cachesize' => 0,
+ 'maxkeypage' => 0,
+ 'minkeypage' => 0,
+ 'psize' => 0,
+ 'compare' => 0,
+ 'prefix' => 0,
+ 'lorder' => 0
+ ) ;
+
+sub FETCH
+{
+ return $_[0]{$_[1]} if defined $elements{$_[1]} ;
+
+ croak "DB_File::BTREEINFO::FETCH - Unknown element '$_[1]'" ;
+}
+
+
+sub STORE
+{
+ if ( defined $elements{$_[1]} )
+ {
+ $_[0]{$_[1]} = $_[2] ;
+ return ;
+ }
+
+ croak "DB_File::BTREEINFO::STORE - Unknown element '$_[1]'" ;
+}
+
+sub DELETE
+{
+ if ( defined $elements{$_[1]} )
+ {
+ delete ${$_[0]}{$_[1]} ;
+ return ;
+ }
+
+ croak "DB_File::BTREEINFO::DELETE - Unknown element '$_[1]'" ;
+}
+
+
+sub DESTROY {undef %{$_[0]} }
+sub FIRSTKEY { croak "DB_File::BTREEINFO::FIRSTKEY is not implemented" }
+sub NEXTKEY { croak "DB_File::BTREEINFO::NEXTKEY is not implemented" }
+sub EXISTS { croak "DB_File::BTREEINFO::EXISTS is not implemented" }
+sub CLEAR { croak "DB_File::BTREEINFO::CLEAR is not implemented" }
+
+package DB_File::RECNOINFO ;
+use Carp;
+
+sub TIEHASH
+{
+ bless {} ;
+}
+
+%elements = ( 'bval' => 0,
+ 'cachesize' => 0,
+ 'psize' => 0,
+ 'flags' => 0,
+ 'lorder' => 0,
+ 'reclen' => 0,
+ 'bfname' => 0
+ ) ;
+sub FETCH
+{
+ return $_[0]{$_[1]} if defined $elements{$_[1]} ;
+
+ croak "DB_File::RECNOINFO::FETCH - Unknown element '$_[1]'" ;
+}
+
+
+sub STORE
+{
+ if ( defined $elements{$_[1]} )
+ {
+ $_[0]{$_[1]} = $_[2] ;
+ return ;
+ }
+
+ croak "DB_File::RECNOINFO::STORE - Unknown element '$_[1]'" ;
+}
+
+sub DELETE
+{
+ if ( defined $elements{$_[1]} )
+ {
+ delete ${$_[0]}{$_[1]} ;
+ return ;
+ }
+
+ croak "DB_File::RECNOINFO::DELETE - Unknown element '$_[1]'" ;
+}
+
+
+sub DESTROY {undef %{$_[0]} }
+sub FIRSTKEY { croak "DB_File::RECNOINFO::FIRSTKEY is not implemented" }
+sub NEXTKEY { croak "DB_File::RECNOINFO::NEXTKEY is not implemented" }
+sub EXISTS { croak "DB_File::BTREEINFO::EXISTS is not implemented" }
+sub CLEAR { croak "DB_File::BTREEINFO::CLEAR is not implemented" }
+
+
+
+package DB_File ;
+use Carp;
+
+$VERSION = 1.0 ;
+
+#typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
+$DB_BTREE = TIEHASH DB_File::BTREEINFO ;
+$DB_HASH = TIEHASH DB_File::HASHINFO ;
+$DB_RECNO = TIEHASH DB_File::RECNOINFO ;
+
+require TieHash;
+require Exporter;
+use AutoLoader;
+require DynaLoader;
+@ISA = qw(TieHash Exporter DynaLoader);
+@EXPORT = qw(
+ $DB_BTREE $DB_HASH $DB_RECNO
+ BTREEMAGIC
+ BTREEVERSION
+ DB_LOCK
+ DB_SHMEM
+ DB_TXN
+ HASHMAGIC
+ HASHVERSION
+ MAX_PAGE_NUMBER
+ MAX_PAGE_OFFSET
+ MAX_REC_NUMBER
+ RET_ERROR
+ RET_SPECIAL
+ RET_SUCCESS
+ R_CURSOR
+ R_DUP
+ R_FIRST
+ R_FIXEDLEN
+ R_IAFTER
+ R_IBEFORE
+ R_LAST
+ R_NEXT
+ R_NOKEY
+ R_NOOVERWRITE
+ R_PREV
+ R_RECNOSYNC
+ R_SETCURSOR
+ R_SNAPSHOT
+ __R_UNUSED
+);
+
+sub AUTOLOAD {
+ local($constname);
+ ($constname = $AUTOLOAD) =~ s/.*:://;
+ $val = constant($constname, @_ ? $_[0] : 0);
+ if ($! != 0) {
+ if ($! =~ /Invalid/) {
+ $AutoLoader::AUTOLOAD = $AUTOLOAD;
+ goto &AutoLoader::AUTOLOAD;
+ }
+ else {
+ ($pack,$file,$line) = caller;
+ croak "Your vendor has not defined DB macro $constname, used at $file line $line.
+";
+ }
+ }
+ eval "sub $AUTOLOAD { $val }";
+ goto &$AUTOLOAD;
+}
+
+@liblist = ();
+@liblist = split ' ', $Config::Config{"DB_File_loadlibs"}
+ if defined $Config::Config{"DB_File_loadlibs"};
+
+bootstrap DB_File @liblist;
+
+# Preloaded methods go here. Autoload methods go after __END__, and are
+# processed by the autosplit program.
+
+1;
+__END__
+
+=cut
=head1 NAME
=head1 DESCRIPTION
-B<DB_File> is a module which allows Perl programs to make use of
-the facilities provided by Berkeley DB. If you intend to use this
-module you should really have a copy of the Berkeley DB manual
-page at hand. The interface defined here
-mirrors the Berkeley DB interface closely.
+B<DB_File> is a module which allows Perl programs to make use of the
+facilities provided by Berkeley DB. If you intend to use this
+module you should really have a copy of the Berkeley DB manualpage at
+hand. The interface defined here mirrors the Berkeley DB interface
+closely.
-Berkeley DB is a C library which provides a consistent interface to a number of
-database formats.
-B<DB_File> provides an interface to all three of the database types currently
-supported by Berkeley DB.
+Berkeley DB is a C library which provides a consistent interface to a
+number of database formats. B<DB_File> provides an interface to all
+three of the database types currently supported by Berkeley DB.
The file types are:
=item DB_HASH
-This database type allows arbitrary key/data pairs to be stored in data files.
-This is equivalent to the functionality provided by
-other hashing packages like DBM, NDBM, ODBM, GDBM, and SDBM.
-Remember though, the files created using DB_HASH are
-not compatible with any of the other packages mentioned.
+This database type allows arbitrary key/data pairs to be stored in data
+files. This is equivalent to the functionality provided by other
+hashing packages like DBM, NDBM, ODBM, GDBM, and SDBM. Remember though,
+the files created using DB_HASH are not compatible with any of the
+other packages mentioned.
-A default hashing algorithm, which will be adequate for most applications,
-is built into Berkeley DB.
-If you do need to use your own hashing algorithm it is possible to write your
-own in Perl and have B<DB_File> use it instead.
+A default hashing algorithm, which will be adequate for most
+applications, is built into Berkeley DB. If you do need to use your own
+hashing algorithm it is possible to write your own in Perl and have
+B<DB_File> use it instead.
=item DB_BTREE
-The btree format allows arbitrary key/data pairs to be stored in a sorted,
-balanced binary tree.
+The btree format allows arbitrary key/data pairs to be stored in a
+sorted, balanced binary tree.
-As with the DB_HASH format, it is possible to provide a user defined Perl routine
-to perform the comparison of keys. By default, though, the keys are stored
-in lexical order.
+As with the DB_HASH format, it is possible to provide a user defined
+Perl routine to perform the comparison of keys. By default, though, the
+keys are stored in lexical order.
=item DB_RECNO
-DB_RECNO allows both fixed-length and variable-length flat text files to be
-manipulated using
-the same key/value pair interface as in DB_HASH and DB_BTREE.
-In this case the key will consist of a record (line) number.
+DB_RECNO allows both fixed-length and variable-length flat text files
+to be manipulated using the same key/value pair interface as in DB_HASH
+and DB_BTREE. In this case the key will consist of a record (line)
+number.
=back
=head2 How does DB_File interface to Berkeley DB?
B<DB_File> allows access to Berkeley DB files using the tie() mechanism
-in Perl 5 (for full details, see L<perlfunc/tie()>).
-This facility allows B<DB_File> to access Berkeley DB files using
-either an associative array (for DB_HASH & DB_BTREE file types) or an
-ordinary array (for the DB_RECNO file type).
+in Perl 5 (for full details, see L<perlfunc/tie()>). This facility
+allows B<DB_File> to access Berkeley DB files using either an
+associative array (for DB_HASH & DB_BTREE file types) or an ordinary
+array (for the DB_RECNO file type).
-In addition to the tie() interface, it is also possible to use most of the
-functions provided in the Berkeley DB API.
+In addition to the tie() interface, it is also possible to use most of
+the functions provided in the Berkeley DB API.
=head2 Differences with Berkeley DB
-Berkeley DB uses the function dbopen() to open or create a
-database. Below is the C prototype for dbopen().
+Berkeley DB uses the function dbopen() to open or create a database.
+Below is the C prototype for dbopen().
DB*
dbopen (const char * file, int flags, int mode,
I<openinfo> points to a data structure which allows tailoring of the
specific interface method.
-This interface is handled
-slightly differently in B<DB_File>. Here is an equivalent call using
-B<DB_File>.
+This interface is handled slightly differently in B<DB_File>. Here is
+an equivalent call using B<DB_File>.
tie %array, DB_File, $filename, $flags, $mode, $DB_HASH ;
-The C<filename>, C<flags> and C<mode> parameters are the direct equivalent
-of their dbopen() counterparts. The final parameter $DB_HASH
-performs the function of both the C<type> and C<openinfo>
-parameters in dbopen().
+The C<filename>, C<flags> and C<mode> parameters are the direct
+equivalent of their dbopen() counterparts. The final parameter $DB_HASH
+performs the function of both the C<type> and C<openinfo> parameters in
+dbopen().
-In the example above $DB_HASH is actually a reference to a hash object.
-B<DB_File> has three of these pre-defined references.
-Apart from $DB_HASH, there is also $DB_BTREE and $DB_RECNO.
+In the example above $DB_HASH is actually a reference to a hash
+object. B<DB_File> has three of these pre-defined references. Apart
+from $DB_HASH, there is also $DB_BTREE and $DB_RECNO.
-The keys allowed in each of these pre-defined references is limited to the names
-used in the equivalent C structure.
-So, for example, the $DB_HASH reference will only allow keys called C<bsize>,
-C<cachesize>, C<ffactor>, C<hash>, C<lorder> and C<nelem>.
+The keys allowed in each of these pre-defined references is limited to
+the names used in the equivalent C structure. So, for example, the
+$DB_HASH reference will only allow keys called C<bsize>, C<cachesize>,
+C<ffactor>, C<hash>, C<lorder> and C<nelem>.
To change one of these elements, just assign to it like this
=head2 In Memory Databases
-Berkeley DB allows the creation of in-memory databases by using NULL (that is, a
-C<(char *)0 in C) in
-place of the filename.
-B<DB_File> uses C<undef> instead of NULL to provide this functionality.
+Berkeley DB allows the creation of in-memory databases by using NULL
+(that is, a C<(char *)0 in C) in place of the filename. B<DB_File>
+uses C<undef> instead of NULL to provide this functionality.
=head2 Using the Berkeley DB Interface Directly
As well as accessing Berkeley DB using a tied hash or array, it is also
-possible to make direct use of most of the functions defined in the Berkeley DB
-documentation.
+possible to make direct use of most of the functions defined in the
+Berkeley DB documentation.
To do this you need to remember the return value from the tie.
$db = tie %hash, DB_File, "filename"
-Once you have done that, you can access the Berkeley DB API functions directly.
+Once you have done that, you can access the Berkeley DB API functions
+directly.
$db->put($key, $value, R_NOOVERWRITE) ;
-All the functions defined in L<dbx(3X)> are available except
-for close() and dbopen() itself.
-The B<DB_File> interface to these functions have been implemented to mirror
-the the way Berkeley DB works. In particular note that all the functions return
-only a status value. Whenever a Berkeley DB function returns data via one of
-its parameters, the B<DB_File> equivalent does exactly the same.
+All the functions defined in L<dbx(3X)> are available except for
+close() and dbopen() itself. The B<DB_File> interface to these
+functions have been implemented to mirror the the way Berkeley DB
+works. In particular note that all the functions return only a status
+value. Whenever a Berkeley DB function returns data via one of its
+parameters, the B<DB_File> equivalent does exactly the same.
All the constants defined in L<dbopen> are also available.
=item get
-Same as in C<recno> except that the flags parameter is optional.
-Remember the value
-associated with the key you request is returned in the $value parameter.
+Same as in C<recno> except that the flags parameter is optional.
+Remember the value associated with the key you request is returned in
+the $value parameter.
=item put
As usual the flags parameter is optional.
-If you use either the R_IAFTER or
-R_IBEFORE flags, the key parameter will have the record number of the inserted
-key/value pair set.
+If you use either the R_IAFTER or R_IBEFORE flags, the key parameter
+will have the record number of the inserted key/value pair set.
=item del
=head1 EXAMPLES
-It is always a lot easier to understand something when you see a real example.
-So here are a few.
+It is always a lot easier to understand something when you see a real
+example. So here are a few.
=head2 Using HASH
use DB_File ;
use Fcntl ;
- tie %h, DB_File, "hashed", O_RDWR|O_CREAT, 0640, $DB_HASH ;
+ tie %h, "DB_File", "hashed", O_RDWR|O_CREAT, 0640, $DB_HASH ;
# Add a key/value pair to the file
$h{"apple"} = "orange" ;
=head2 Using BTREE
-Here is sample of code which used BTREE. Just to make life more interesting
-the default comparision function will not be used. Instead a Perl sub, C<Compare()>,
-will be used to do a case insensitive comparison.
+Here is sample of code which used BTREE. Just to make life more
+interesting the default comparision function will not be used. Instead
+a Perl sub, C<Compare()>, will be used to do a case insensitive
+comparison.
use DB_File ;
use Fcntl ;
$DB_BTREE->{compare} = 'Compare' ;
- tie %h, DB_File, "tree", O_RDWR|O_CREAT, 0640, $DB_BTREE ;
+ tie %h, 'DB_File', "tree", O_RDWR|O_CREAT, 0640, $DB_BTREE ;
# Add a key/value pair to the file
$h{'Wall'} = 'Larry' ;
errors to be caught at run time. Thanks to Judith Grass
<grass@cybercash.com> for spotting the bug.
+=head2 0.3
+
+Added prototype support for multiple btree compare callbacks.
+
+=head 1.0
+
+B<DB_File> has been in use for over a year. To reflect that, the
+version number has been incremented to 1.0.
+
+Added complete support for multiple concurrent callbacks.
+
+Using the I<push> method on an empty list didn't work properly. This
+has been fixed.
+
=head1 WARNINGS
-If you happen find any other functions defined in the source for this module
-that have not been mentioned in this document -- beware.
-I may drop them at a moments notice.
+If you happen find any other functions defined in the source for this
+module that have not been mentioned in this document -- beware. I may
+drop them at a moments notice.
-If you cannot find any, then either you didn't look very hard or the moment has
-passed and I have dropped them.
+If you cannot find any, then either you didn't look very hard or the
+moment has passed and I have dropped them.
=head1 BUGS
-Some older versions of Berkeley DB had problems with fixed length records
-using the RECNO file format. The newest version at the time of writing
-was 1.85 - this seems to have fixed the problems with RECNO.
+Some older versions of Berkeley DB had problems with fixed length
+records using the RECNO file format. The newest version at the time of
+writing was 1.85 - this seems to have fixed the problems with RECNO.
-I am sure there are bugs in the code. If you do find any, or can suggest any
-enhancements, I would welcome your comments.
+I am sure there are bugs in the code. If you do find any, or can
+suggest any enhancements, I would welcome your comments.
=head1 AVAILABILITY
L<perl(1)>, L<dbopen(3)>, L<hash(3)>, L<recno(3)>, L<btree(3)>
-Berkeley DB is available from F<ftp.cs.berkeley.edu> in the directory F</ucb/4bsd>.
+Berkeley DB is available from F<ftp.cs.berkeley.edu> in the directory
+F</ucb/4bsd>.
=head1 AUTHOR
-The DB_File interface was written by
-Paul Marquess <pmarquess@bfsec.bt.co.uk>.
-Questions about the DB system itself may be addressed to
-Keith Bostic <bostic@cs.berkeley.edu>.
+The DB_File interface was written by Paul Marquess
+<pmarquess@bfsec.bt.co.uk>.
+Questions about the DB system itself may be addressed to Keith Bostic
+<bostic@cs.berkeley.edu>.
=cut
-
-package DB_File::HASHINFO ;
-use Carp;
-
-sub TIEHASH
-{
- bless {} ;
-}
-
-%elements = ( 'bsize' => 0,
- 'ffactor' => 0,
- 'nelem' => 0,
- 'cachesize' => 0,
- 'hash' => 0,
- 'lorder' => 0
- ) ;
-
-sub FETCH
-{
- return $_[0]{$_[1]} if defined $elements{$_[1]} ;
-
- croak "DB_File::HASHINFO::FETCH - Unknown element '$_[1]'" ;
-}
-
-
-sub STORE
-{
- if ( defined $elements{$_[1]} )
- {
- $_[0]{$_[1]} = $_[2] ;
- return ;
- }
-
- croak "DB_File::HASHINFO::STORE - Unknown element '$_[1]'" ;
-}
-
-sub DELETE
-{
- if ( defined $elements{$_[1]} )
- {
- delete ${$_[0]}{$_[1]} ;
- return ;
- }
-
- croak "DB_File::HASHINFO::DELETE - Unknown element '$_[1]'" ;
-}
-
-
-sub DESTROY {undef %{$_[0]} }
-sub FIRSTKEY { croak "DB_File::HASHINFO::FIRSTKEY is not implemented" }
-sub NEXTKEY { croak "DB_File::HASHINFO::NEXTKEY is not implemented" }
-sub EXISTS { croak "DB_File::HASHINFO::EXISTS is not implemented" }
-sub CLEAR { croak "DB_File::HASHINFO::CLEAR is not implemented" }
-
-package DB_File::BTREEINFO ;
-use Carp;
-
-sub TIEHASH
-{
- bless {} ;
-}
-
-%elements = ( 'flags' => 0,
- 'cachesize' => 0,
- 'maxkeypage' => 0,
- 'minkeypage' => 0,
- 'psize' => 0,
- 'compare' => 0,
- 'prefix' => 0,
- 'lorder' => 0
- ) ;
-
-sub FETCH
-{
- return $_[0]{$_[1]} if defined $elements{$_[1]} ;
-
- croak "DB_File::BTREEINFO::FETCH - Unknown element '$_[1]'" ;
-}
-
-
-sub STORE
-{
- if ( defined $elements{$_[1]} )
- {
- $_[0]{$_[1]} = $_[2] ;
- return ;
- }
-
- croak "DB_File::BTREEINFO::STORE - Unknown element '$_[1]'" ;
-}
-
-sub DELETE
-{
- if ( defined $elements{$_[1]} )
- {
- delete ${$_[0]}{$_[1]} ;
- return ;
- }
-
- croak "DB_File::BTREEINFO::DELETE - Unknown element '$_[1]'" ;
-}
-
-
-sub DESTROY {undef %{$_[0]} }
-sub FIRSTKEY { croak "DB_File::BTREEINFO::FIRSTKEY is not implemented" }
-sub NEXTKEY { croak "DB_File::BTREEINFO::NEXTKEY is not implemented" }
-sub EXISTS { croak "DB_File::BTREEINFO::EXISTS is not implemented" }
-sub CLEAR { croak "DB_File::BTREEINFO::CLEAR is not implemented" }
-
-package DB_File::RECNOINFO ;
-use Carp;
-
-sub TIEHASH
-{
- bless {} ;
-}
-
-%elements = ( 'bval' => 0,
- 'cachesize' => 0,
- 'psize' => 0,
- 'flags' => 0,
- 'lorder' => 0,
- 'reclen' => 0,
- 'bfname' => 0
- ) ;
-sub FETCH
-{
- return $_[0]{$_[1]} if defined $elements{$_[1]} ;
-
- croak "DB_File::RECNOINFO::FETCH - Unknown element '$_[1]'" ;
-}
-
-
-sub STORE
-{
- if ( defined $elements{$_[1]} )
- {
- $_[0]{$_[1]} = $_[2] ;
- return ;
- }
-
- croak "DB_File::RECNOINFO::STORE - Unknown element '$_[1]'" ;
-}
-
-sub DELETE
-{
- if ( defined $elements{$_[1]} )
- {
- delete ${$_[0]}{$_[1]} ;
- return ;
- }
-
- croak "DB_File::RECNOINFO::DELETE - Unknown element '$_[1]'" ;
-}
-
-
-sub DESTROY {undef %{$_[0]} }
-sub FIRSTKEY { croak "DB_File::RECNOINFO::FIRSTKEY is not implemented" }
-sub NEXTKEY { croak "DB_File::RECNOINFO::NEXTKEY is not implemented" }
-sub EXISTS { croak "DB_File::BTREEINFO::EXISTS is not implemented" }
-sub CLEAR { croak "DB_File::BTREEINFO::CLEAR is not implemented" }
-
-
-
-package DB_File ;
-use Carp;
-
-#typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
-$DB_BTREE = TIEHASH DB_File::BTREEINFO ;
-$DB_HASH = TIEHASH DB_File::HASHINFO ;
-$DB_RECNO = TIEHASH DB_File::RECNOINFO ;
-
-require TieHash;
-require Exporter;
-use AutoLoader;
-require DynaLoader;
-@ISA = qw(TieHash Exporter DynaLoader);
-@EXPORT = qw(
- $DB_BTREE $DB_HASH $DB_RECNO
- BTREEMAGIC
- BTREEVERSION
- DB_LOCK
- DB_SHMEM
- DB_TXN
- HASHMAGIC
- HASHVERSION
- MAX_PAGE_NUMBER
- MAX_PAGE_OFFSET
- MAX_REC_NUMBER
- RET_ERROR
- RET_SPECIAL
- RET_SUCCESS
- R_CURSOR
- R_DUP
- R_FIRST
- R_FIXEDLEN
- R_IAFTER
- R_IBEFORE
- R_LAST
- R_NEXT
- R_NOKEY
- R_NOOVERWRITE
- R_PREV
- R_RECNOSYNC
- R_SETCURSOR
- R_SNAPSHOT
- __R_UNUSED
-);
-
-sub AUTOLOAD {
- local($constname);
- ($constname = $AUTOLOAD) =~ s/.*:://;
- $val = constant($constname, @_ ? $_[0] : 0);
- if ($! != 0) {
- if ($! =~ /Invalid/) {
- $AutoLoader::AUTOLOAD = $AUTOLOAD;
- goto &AutoLoader::AUTOLOAD;
- }
- else {
- ($pack,$file,$line) = caller;
- croak "Your vendor has not defined DB macro $constname, used at $file line $line.
-";
- }
- }
- eval "sub $AUTOLOAD { $val }";
- goto &$AUTOLOAD;
-}
-
-@liblist = ();
-@liblist = split ' ', $Config::Config{"DB_File_loadlibs"}
- if defined $Config::Config{"DB_File_loadlibs"};
-
-bootstrap DB_File @liblist;
-
-# Preloaded methods go here. Autoload methods go after __END__, and are
-# processed by the autosplit program.
-
-1;
-__END__
DB_File.xs -- Perl 5 interface to Berkeley DB
written by Paul Marquess (pmarquess@bfsec.bt.co.uk)
- last modified 19th May 1995
- version 0.2
+ last modified 7th October 1995
+ version 1.0
All comments/suggestions/problems are welcome
Changes:
0.1 - Initial Release
0.2 - No longer bombs out if dbopen returns an error.
+ 0.3 - Added some support for multiple btree compares
+ 1.0 - Complete support for multiple callbacks added.
+ Fixed a problem with pushing a value onto an empty list.
*/
#include "EXTERN.h"
#include <fcntl.h>
-typedef DB * DB_File;
+typedef struct {
+ DBTYPE type ;
+ DB * dbp ;
+ SV * compare ;
+ SV * prefix ;
+ SV * hash ;
+ } DB_File_type;
+
+typedef DB_File_type * DB_File ;
typedef DBT DBTKEY ;
union INFO {
BTREEINFO btree ;
} ;
-typedef struct {
- SV * sub ;
- } CallBackInfo ;
-
/* #define TRACE */
-#define db_DESTROY(db) (db->close)(db)
-#define db_DELETE(db, key, flags) (db->del)(db, &key, flags)
-#define db_STORE(db, key, value, flags) (db->put)(db, &key, &value, flags)
-#define db_FETCH(db, key, flags) (db->get)(db, &key, &value, flags)
+#define db_DESTROY(db) (db->dbp->close)(db->dbp)
+#define db_DELETE(db, key, flags) (db->dbp->del)(db->dbp, &key, flags)
+#define db_STORE(db, key, value, flags) (db->dbp->put)(db->dbp, &key, &value, flags)
+#define db_FETCH(db, key, flags) (db->dbp->get)(db->dbp, &key, &value, flags)
-#define db_close(db) (db->close)(db)
-#define db_del(db, key, flags) (db->del)(db, &key, flags)
-#define db_fd(db) (db->fd)(db)
-#define db_put(db, key, value, flags) (db->put)(db, &key, &value, flags)
-#define db_get(db, key, value, flags) (db->get)(db, &key, &value, flags)
-#define db_seq(db, key, value, flags) (db->seq)(db, &key, &value, flags)
-#define db_sync(db, flags) (db->sync)(db, flags)
+#define db_close(db) (db->dbp->close)(db->dbp)
+#define db_del(db, key, flags) (db->dbp->del)(db->dbp, &key, flags)
+#define db_fd(db) (db->dbp->fd)(db->dbp)
+#define db_put(db, key, value, flags) (db->dbp->put)(db->dbp, &key, &value, flags)
+#define db_get(db, key, value, flags) (db->dbp->get)(db->dbp, &key, &value, flags)
+#define db_seq(db, key, value, flags) (db->dbp->seq)(db->dbp, &key, &value, flags)
+#define db_sync(db, flags) (db->dbp->sync)(db->dbp, flags)
#define OutputValue(arg, name) \
#define OutputKey(arg, name) \
{ if (RETVAL == 0) \
{ \
- if (db->close != DB_recno_close) \
+ if (db->type != DB_RECNO) \
sv_setpvn(arg, name.data, name.size); \
else \
sv_setiv(arg, (I32)*(I32*)name.data - 1); \
}
/* Internal Global Data */
-
-static recno_t Value ;
-static int (*DB_recno_close)() = NULL ;
-
-static CallBackInfo hash_callback = { 0 } ;
-static CallBackInfo compare_callback = { 0 } ;
-static CallBackInfo prefix_callback = { 0 } ;
+static recno_t Value ;
+static DB_File CurrentDB ;
+static recno_t zero = 0 ;
+static DBTKEY empty = { &zero, sizeof(recno_t) } ;
static int
PUSHs(sv_2mortal(newSVpv(data2,key2->size)));
PUTBACK ;
- count = perl_call_sv(compare_callback.sub, G_SCALAR);
+ count = perl_call_sv(CurrentDB->compare, G_SCALAR);
SPAGAIN ;
PUSHs(sv_2mortal(newSVpv(data2,key2->size)));
PUTBACK ;
- count = perl_call_sv(prefix_callback.sub, G_SCALAR);
+ count = perl_call_sv(CurrentDB->prefix, G_SCALAR);
SPAGAIN ;
XPUSHs(sv_2mortal(newSVpv((char*)data,size)));
PUTBACK ;
- count = perl_call_sv(hash_callback.sub, G_SCALAR);
+ count = perl_call_sv(CurrentDB->hash, G_SCALAR);
SPAGAIN ;
static I32
GetArrayLength(db)
-DB_File db ;
+DB * db ;
{
DBT key ;
DBT value ;
SV ** svp;
HV * action ;
union INFO info ;
- DB_File RETVAL ;
+ DB_File RETVAL = (DB_File)safemalloc(sizeof(DB_File_type)) ;
void * openinfo = NULL ;
- DBTYPE type = DB_HASH ;
+ /* DBTYPE type = DB_HASH ; */
+ RETVAL->hash = RETVAL->compare = RETVAL->prefix = NULL ;
+ RETVAL->type = DB_HASH ;
if (sv)
{
action = (HV*)SvRV(sv);
if (sv_isa(sv, "DB_File::HASHINFO"))
{
- type = DB_HASH ;
+ RETVAL->type = DB_HASH ;
openinfo = (void*)&info ;
svp = hv_fetch(action, "hash", 4, FALSE);
if (svp && SvOK(*svp))
{
info.hash.hash = hash_cb ;
- hash_callback.sub = *svp ;
+ RETVAL->hash = newSVsv(*svp) ;
}
else
info.hash.hash = NULL ;
}
else if (sv_isa(sv, "DB_File::BTREEINFO"))
{
- type = DB_BTREE ;
+ RETVAL->type = DB_BTREE ;
openinfo = (void*)&info ;
svp = hv_fetch(action, "compare", 7, FALSE);
if (svp && SvOK(*svp))
{
info.btree.compare = btree_compare ;
- compare_callback.sub = *svp ;
+ RETVAL->compare = newSVsv(*svp) ;
}
else
info.btree.compare = NULL ;
if (svp && SvOK(*svp))
{
info.btree.prefix = btree_prefix ;
- prefix_callback.sub = *svp ;
+ RETVAL->prefix = newSVsv(*svp) ;
}
else
info.btree.prefix = NULL ;
}
else if (sv_isa(sv, "DB_File::RECNOINFO"))
{
- type = DB_RECNO ;
+ RETVAL->type = DB_RECNO ;
openinfo = (void *)&info ;
svp = hv_fetch(action, "flags", 5, FALSE);
}
- RETVAL = dbopen(name, flags, mode, type, openinfo) ;
+ RETVAL->dbp = dbopen(name, flags, mode, RETVAL->type, openinfo) ;
+#if 0
/* kludge mode on: RETVAL->type for DB_RECNO is set to DB_BTREE
so remember a DB_RECNO by saving the address
of one of it's internal routines
*/
- if (RETVAL && type == DB_RECNO)
- DB_recno_close = RETVAL->close ;
+ if (RETVAL->dbp && type == DB_RECNO)
+ DB_recno_close = RETVAL->dbp->close ;
+#endif
return (RETVAL) ;
int
db_DESTROY(db)
DB_File db
+ INIT:
+ CurrentDB = db ;
+ CLEANUP:
+ if (db->hash)
+ SvREFCNT_dec(db->hash) ;
+ if (db->compare)
+ SvREFCNT_dec(db->compare) ;
+ if (db->prefix)
+ SvREFCNT_dec(db->prefix) ;
+ Safefree(db) ;
int
DB_File db
DBTKEY key
u_int flags
+ INIT:
+ CurrentDB = db ;
int
db_FETCH(db, key, flags=0)
{
DBT value ;
- RETVAL = (db->get)(db, &key, &value, flags) ;
+ CurrentDB = db ;
+ RETVAL = (db->dbp->get)(db->dbp, &key, &value, flags) ;
ST(0) = sv_newmortal();
if (RETVAL == 0)
sv_setpvn(ST(0), value.data, value.size);
DBTKEY key
DBT value
u_int flags
+ INIT:
+ CurrentDB = db ;
int
DBTKEY key ;
DBT value ;
- RETVAL = (db->seq)(db, &key, &value, R_FIRST) ;
+ CurrentDB = db ;
+ RETVAL = (db->dbp->seq)(db->dbp, &key, &value, R_FIRST) ;
ST(0) = sv_newmortal();
if (RETVAL == 0)
{
- if (db->type != DB_RECNO)
+ if (db->dbp->type != DB_RECNO)
sv_setpvn(ST(0), key.data, key.size);
else
sv_setiv(ST(0), (I32)*(I32*)key.data - 1);
{
DBT value ;
- RETVAL = (db->seq)(db, &key, &value, R_NEXT) ;
+ CurrentDB = db ;
+ RETVAL = (db->dbp->seq)(db->dbp, &key, &value, R_NEXT) ;
ST(0) = sv_newmortal();
if (RETVAL == 0)
{
- if (db->type != DB_RECNO)
+ if (db->dbp->type != DB_RECNO)
sv_setpvn(ST(0), key.data, key.size);
else
sv_setiv(ST(0), (I32)*(I32*)key.data - 1);
int i ;
int One ;
+ CurrentDB = db ;
RETVAL = -1 ;
for (i = items-1 ; i > 0 ; --i)
{
One = 1 ;
key.data = &One ;
key.size = sizeof(int) ;
- RETVAL = (db->put)(db, &key, &value, R_IBEFORE) ;
+ RETVAL = (db->dbp->put)(db->dbp, &key, &value, R_IBEFORE) ;
if (RETVAL != 0)
break;
}
DBTKEY key ;
DBT value ;
+ CurrentDB = db ;
/* First get the final value */
- RETVAL = (db->seq)(db, &key, &value, R_LAST) ;
+ RETVAL = (db->dbp->seq)(db->dbp, &key, &value, R_LAST) ;
ST(0) = sv_newmortal();
/* Now delete it */
if (RETVAL == 0)
{
- RETVAL = (db->del)(db, &key, R_CURSOR) ;
+ RETVAL = (db->dbp->del)(db->dbp, &key, R_CURSOR) ;
if (RETVAL == 0)
sv_setpvn(ST(0), value.data, value.size);
}
DBTKEY key ;
DBT value ;
+ CurrentDB = db ;
/* get the first value */
- RETVAL = (db->seq)(db, &key, &value, R_FIRST) ;
+ RETVAL = (db->dbp->seq)(db->dbp, &key, &value, R_FIRST) ;
ST(0) = sv_newmortal();
/* Now delete it */
if (RETVAL == 0)
{
- RETVAL = (db->del)(db, &key, R_CURSOR) ;
+ RETVAL = (db->dbp->del)(db->dbp, &key, R_CURSOR) ;
if (RETVAL == 0)
sv_setpvn(ST(0), value.data, value.size);
}
CODE:
{
DBTKEY key ;
+ DBTKEY * keyptr = &key ;
DBT value ;
int i ;
+ CurrentDB = db ;
/* Set the Cursor to the Last element */
- RETVAL = (db->seq)(db, &key, &value, R_LAST) ;
- if (RETVAL == 0)
+ RETVAL = (db->dbp->seq)(db->dbp, &key, &value, R_LAST) ;
+ if (RETVAL >= 0)
{
- /* for (i = 1 ; i < items ; ++i) */
- for (i = items - 1 ; i > 0 ; --i)
- {
- value.data = SvPV(ST(i), na) ;
- value.size = na ;
- RETVAL = (db->put)(db, &key, &value, R_IAFTER) ;
- if (RETVAL != 0)
- break;
- }
+ if (RETVAL == 1)
+ keyptr = &empty ;
+ for (i = items - 1 ; i > 0 ; --i)
+ {
+ value.data = SvPV(ST(i), na) ;
+ value.size = na ;
+ RETVAL = (db->dbp->put)(db->dbp, keyptr, &value, R_IAFTER) ;
+ if (RETVAL != 0)
+ break;
+ }
}
}
OUTPUT:
length(db)
DB_File db
CODE:
- RETVAL = GetArrayLength(db) ;
+ CurrentDB = db ;
+ RETVAL = GetArrayLength(db->dbp) ;
OUTPUT:
RETVAL
DB_File db
DBTKEY key
u_int flags
+ INIT:
+ CurrentDB = db ;
int
DBTKEY key
DBT value
u_int flags
+ INIT:
+ CurrentDB = db ;
OUTPUT:
value
DBTKEY key
DBT value
u_int flags
+ INIT:
+ CurrentDB = db ;
OUTPUT:
key if (flags & (R_IAFTER|R_IBEFORE)) OutputKey(ST(1), key);
int
db_fd(db)
DB_File db
+ INIT:
+ CurrentDB = db ;
int
db_sync(db, flags=0)
DB_File db
u_int flags
+ INIT:
+ CurrentDB = db ;
int
DBTKEY key
DBT value
u_int flags
+ INIT:
+ CurrentDB = db ;
OUTPUT:
key
value
use ExtUtils::MakeMaker;
-WriteMakefile(LIBS => ["-L/usr/local/lib -ldb"]);
+
+WriteMakefile(
+ NAME => 'DB_File',
+ LIBS => ["-L/usr/local/lib -ldb"],
+ #INC => '-I/usr/local/include',
+ VERSION => 1.0,
+ );
+
INPUT
T_dbtkeydatum
- if (db->close != DB_recno_close)
+ if (db->type != DB_RECNO)
{
$var.data = SvPV($arg, na);
$var.size = (int)na;
--- /dev/null
+# Devel::DProf - a Perl code profiler
+# 5apr95
+# Dean Roehrich
+#
+# changes/bugs fixed since 01mar95 version:
+# - record $pwd and build pathname for tmon.out
+# (so the profile doesn't get lost if the process chdir's)
+# changes/bugs fixed since 03feb95 version:
+# - fixed some doc bugs
+# - added require 5.000
+# - added -w note to bugs section of pod
+# changes/bugs fixed since 31dec94 version:
+# - podified
+#
+
+require 5.000;
+
+=head1 NAME
+
+Devel::DProf - a Perl code profiler
+
+=head1 SYNOPSIS
+
+ PERL5DB="use Devel::DProf;"
+ export PERL5DB
+
+ perl5 -d test.pl
+
+=head1 DESCRIPTION
+
+The Devel::DProf package is a Perl code profiler. This will collect
+information on the execution time of a Perl script and of the subs in that
+script. This information can be used to determine which subroutines are
+using the most time and which subroutines are being called most often. This
+information can also be used to create an execution graph of the script,
+showing subroutine relationships.
+
+To use this package the PERL5DB environment variable must be set to the
+following value:
+
+ PERL5DB="use Devel::DProf;"
+ export PERL5DB
+
+To profile a Perl script run the perl interpreter with the B<-d> debugging
+switch. The profiler uses the debugging hooks. So to profile script
+"test.pl" the following command should be used:
+
+ perl5 -d test.pl
+
+When the script terminates the profiler will dump the profile information
+to a file called I<tmon.out>. The supplied I<dprofpp> tool can be used to
+interpret the information which is in that profile. The following command
+will print the top 15 subroutines which used the most time:
+
+ dprofpp
+
+To print an execution graph of the subroutines in the script use the
+following command:
+
+ dprofpp -T
+
+Consult the "dprofpp" manpage for other options.
+
+=head1 BUGS
+
+If perl5 is invoked with the B<-w> (warnings) flag then Devel::DProf will
+cause a large quantity of warnings to be printed.
+
+=head1 SEE ALSO
+
+L<perl>, L<dprofpp>, times(2)
+
+=cut
+
+package DB;
+
+# So Devel::DProf knows where to drop tmon.out.
+chop($pwd = `pwd`);
+$tmon = "$pwd/tmon.out";
+
+# This sub is replaced by an XS version after the profiler is bootstrapped.
+sub sub {
+# print "nonXS DBsub($sub)\n";
+ $single = 0; # disable DB single-stepping
+ if( wantarray ){
+ @a = &$sub;
+ @a;
+ }
+ else{
+ $a = &$sub;
+ $a;
+ }
+}
+
+# This sub is needed during startup.
+sub DB {
+# print "nonXS DBDB\n";
+}
+
+
+require DynaLoader;
+@Devel::DProf::ISA = qw(DynaLoader);
+
+bootstrap Devel::DProf;
+
+1;
--- /dev/null
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+/*
+# Devel::DProf - a Perl code profiler
+# 5apr95
+# Dean Roehrich
+#
+# changes/bugs fixed since 2apr95 version:
+# -now mallocing an extra byte for the \0 :)
+# changes/bugs fixed since 01mar95 version:
+# -stringified code ref is used for name of anonymous sub.
+# -include stash name with stringified code ref.
+# -use perl.c's DBsingle and DBsub.
+# -now using croak() and warn().
+# -print "timer is on" before turning timer on.
+# -use safefree() instead of free().
+# -rely on PM to provide full path name to tmon.out.
+# -print errno if unable to write tmon.out.
+# changes/bugs fixed since 03feb95 version:
+# -comments
+# changes/bugs fixed since 31dec94 version:
+# -added patches from Andy.
+#
+*/
+
+/*#define DBG_SUB 1 /* */
+/*#define DBG_TIMER 1 /* */
+
+#ifdef DBG_SUB
+# define DBG_SUB_NOTIFY(A,B) warn( A, B )
+#else
+# define DBG_SUB_NOTIFY(A,B) /* nothing */
+#endif
+
+#ifdef DBG_TIMER
+# define DBG_TIMER_NOTIFY(A) warn( A )
+#else
+# define DBG_TIMER_NOTIFY(A) /* nothing */
+#endif
+
+/* HZ == clock ticks per second */
+#ifndef HZ
+#define HZ 60
+#endif
+
+static SV * Sub; /* pointer to $DB::sub */
+static char *Tmon; /* name of tmon.out */
+
+/* Everything is built on times(2). See its manpage for a description
+ * of the timings.
+ */
+
+static
+struct tms prof_start,
+ prof_end;
+
+static
+clock_t rprof_start, /* elapsed real time, in ticks */
+ rprof_end;
+
+union prof_any {
+ clock_t tms_utime; /* cpu time spent in user space */
+ clock_t tms_stime; /* cpu time spent in system */
+ clock_t realtime; /* elapsed real time, in ticks */
+ char *name;
+ opcode ptype;
+};
+
+typedef union prof_any PROFANY;
+
+static PROFANY *profstack;
+static int profstack_max = 128;
+static int profstack_ix = 0;
+
+
+static void
+prof_mark( ptype )
+opcode ptype;
+{
+ struct tms t;
+ clock_t realtime;
+ char *name, *pv;
+ char *hvname;
+ STRLEN len;
+ SV *sv;
+
+ if( profstack_ix + 5 > profstack_max ){
+ profstack_max = profstack_max * 3 / 2;
+ Renew( profstack, profstack_max, PROFANY );
+ }
+
+ realtime = times(&t);
+ pv = SvPV( Sub, len );
+
+ if( SvROK(Sub) ){
+ /* Attempt to make CODE refs identifiable by
+ * including their package name.
+ */
+ sv = (SV*)SvRV(Sub);
+ if( sv && SvTYPE(sv) == SVt_PVCV ){
+ hvname = HvNAME(CvSTASH(sv));
+ len += strlen( hvname ) + 2; /* +2 for more ::'s */
+
+ }
+ else {
+ croak( "DProf prof_mark() lost on supposed CODE ref %s.\n", pv );
+ }
+ name = (char *)safemalloc( len * sizeof(char) + 1 );
+ strcpy( name, hvname );
+ strcat( name, "::" );
+ strcat( name, pv );
+ }
+ else{
+ name = (char *)safemalloc( len * sizeof(char) + 1 );
+ strcpy( name, pv );
+ }
+
+ profstack[profstack_ix++].ptype = ptype;
+ profstack[profstack_ix++].tms_utime = t.tms_utime;
+ profstack[profstack_ix++].tms_stime = t.tms_stime;
+ profstack[profstack_ix++].realtime = realtime;
+ profstack[profstack_ix++].name = name;
+}
+
+static void
+prof_record(){
+ FILE *fp;
+ char *name;
+ int base = 0;
+ opcode ptype;
+ clock_t tms_utime;
+ clock_t tms_stime;
+ clock_t realtime;
+
+ if( (fp = fopen( Tmon, "w" )) == NULL ){
+ warn("DProf: unable to write %s, errno = %d\n", Tmon, errno );
+ return;
+ }
+
+ fprintf(fp, "#fOrTyTwO\n" );
+ fprintf(fp, "$hz=%d;\n", HZ );
+ fprintf(fp, "# All values are given in HZ\n" );
+ fprintf(fp, "$rrun_utime=%ld; $rrun_stime=%ld; $rrun_rtime=%ld\n",
+ prof_end.tms_utime - prof_start.tms_utime,
+ prof_end.tms_stime - prof_start.tms_stime,
+ rprof_end - rprof_start );
+ fprintf(fp, "PART2\n" );
+
+ while( base < profstack_ix ){
+ ptype = profstack[base++].ptype;
+ tms_utime = profstack[base++].tms_utime;
+ tms_stime = profstack[base++].tms_stime;
+ realtime = profstack[base++].realtime;
+ name = profstack[base++].name;
+
+ switch( ptype ){
+ case OP_LEAVESUB:
+ fprintf(fp,"- %ld %ld %ld %s\n",
+ tms_utime, tms_stime, realtime, name );
+ break;
+ case OP_ENTERSUB:
+ fprintf(fp,"+ %ld %ld %ld %s\n",
+ tms_utime, tms_stime, realtime, name );
+ break;
+ default:
+ fprintf(fp,"Profiler unknown prof code %d\n", ptype);
+ }
+ }
+ fclose( fp );
+}
+
+#define for_real
+#ifdef for_real
+
+XS(XS_DB_sub)
+{
+ dXSARGS;
+ dORIGMARK;
+ SP -= items;
+
+ DBG_SUB_NOTIFY( "XS DBsub(%s)\n", SvPV(Sub, na) );
+
+ sv_setiv( DBsingle, 0 ); /* disable DB single-stepping */
+
+ prof_mark( OP_ENTERSUB );
+ PUSHMARK( ORIGMARK );
+
+ perl_call_sv( Sub, GIMME );
+
+ prof_mark( OP_LEAVESUB );
+ SPAGAIN;
+ PUTBACK;
+ return;
+}
+
+#endif /* for_real */
+
+#ifdef testing
+
+ MODULE = Devel::DProf PACKAGE = DB
+
+ void
+ sub(...)
+ PPCODE:
+
+ dORIGMARK;
+ /* SP -= items; added by xsubpp */
+ DBG_SUB_NOTIFY( "XS DBsub(%s)\n", SvPV(Sub, na) );
+
+ sv_setiv( DBsingle, 0 ); /* disable DB single-stepping */
+
+ prof_mark( OP_ENTERSUB );
+ PUSHMARK( ORIGMARK );
+
+ perl_call_sv( Sub, GIMME );
+
+ prof_mark( OP_LEAVESUB );
+ SPAGAIN;
+ /* PUTBACK; added by xsubpp */
+
+#endif /* testing */
+
+
+MODULE = Devel::DProf PACKAGE = Devel::DProf
+
+void
+END()
+ PPCODE:
+ rprof_end = times(&prof_end);
+ DBG_TIMER_NOTIFY("Profiler timer is off.\n");
+ prof_record();
+
+BOOT:
+ newXS("DB::sub", XS_DB_sub, file);
+ Sub = GvSV(DBsub); /* name of current sub */
+ sv_setiv( DBsingle, 0 ); /* disable DB single-stepping */
+ { /* obtain name of tmon.out file */
+ SV *sv;
+ sv = perl_get_sv( "DB::tmon", FALSE );
+ Tmon = (char *)safemalloc( SvCUR(sv) * sizeof(char) );
+ strcpy( Tmon, SvPVX(sv) );
+ }
+ New( 0, profstack, profstack_max, PROFANY );
+ DBG_TIMER_NOTIFY("Profiler timer is on.\n");
+ rprof_start = times(&prof_start);
--- /dev/null
+use ExtUtils::MakeMaker;
+WriteMakefile(
+ 'NAME' => 'Devel::DProf',
+ 'VERSION' => 'Apr5,1995',
+ 'clean' => {'FILES' => "tmon.out"},
+ 'EXE_FILES' => ['dprofpp'],
+
+);
--- /dev/null
+Please consult the pod in DProf.pm.
+
+Dean Roehrich
--- /dev/null
+#!/usr/local/bin/perl
+
+require 5.000;
+
+
+# dprofpp - display perl profile data
+# 5apr95
+# Dean Roehrich
+#
+# changes/bugs fixed since 10feb95 version:
+# - summary info is printed by default, opt_c is gone.
+# - fixed some doc bugs
+# - changed name to dprofpp
+# changes/bugs fixed since 03feb95 version:
+# - fixed division by zero.
+# - replace many local()s with my().
+# - now prints user+system times by default
+# now -u prints user time, -U prints unsorted.
+# - fixed documentation
+# - fixed output, to clarify that times are given in seconds.
+# - can now fake exit timestamps if the profile is garbled.
+# changes/bugs fixed since 17jun94 version:
+# - podified.
+# - correct old documentation flaws.
+# - added Andy's patches.
+#
+
+
+=head1 NAME
+
+dprofpp - display perl profile data
+
+=head1 SYNOPSIS
+
+dprofpp [B<-a|-t|-l|-v|-U|-T>] [B<-s|-r|-u>] [B<-q>] [B<-F>] [B<-O cnt>] [profile]
+
+=head1 DESCRIPTION
+
+The I<dprofpp> command interprets a profile file produced by the Devel::DProf
+profiler. By default dprofpp will read the file I<tmon.out> and will display
+the 15 subroutines which are using the most time.
+
+=head1 OPTIONS
+
+=over 5
+
+=item B<-a>
+
+Sort alphabetically by subroutine names.
+
+=item B<-t>
+
+(default) Sort by amount of user+system time used. The first few lines
+should show you which subroutines are using the most time.
+
+=item B<-l>
+
+Sort by number of calls to the subroutines. This may help identify
+candidates for inlining.
+
+=item B<-v>
+
+Sort by average time spent in subroutines during each call. This may help
+identify candidates for inlining.
+
+=item B<-U>
+
+Do not sort. Display in the order found in the raw profile.
+
+=item B<-F>
+
+Force the generation of fake exit timestamps if dprofpp reports that the
+profile is garbled. This is only useful if dprofpp determines that the
+profile is garbled due to missing exit timestamps. You're on your own if
+you do this. Consult the BUGS section.
+
+=item B<-T>
+
+Display subroutine call tree to stdout. Subroutine statistics are
+not displayed.
+
+=item B<-q>
+
+Do not display column headers. Does nothing if B<-T> is used.
+
+=item B<-O cnt>
+
+Show only I<cnt> subroutines. The default is 15. Does nothing if B<-T>
+is used.
+
+=item B<-r>
+
+Display elapsed real times rather than user+system times.
+
+=item B<-s>
+
+Display system times rather than user+system times.
+
+=item B<-u>
+
+Display user times rather than user+system times.
+
+=back
+
+=head1 BUGS
+
+Applications which call I<die> from within an eval for exception handling
+(catch/throw) or for setjmp/longjmp may not generate a readable profile.
+
+Applications which call I<exit> from within a subroutine will leave an
+incomplete profile.
+
+=head1 FILES
+
+ dprofpp - profile processor
+ tmon.out - raw profile
+
+=head1 SEE ALSO
+
+L<perl>, L<Devel::DProf>, times(2)
+
+=cut
+
+use Getopt::Std 'getopts';
+
+Setup: {
+ getopts('O:ltavuTqrsUF');
+
+# -O cnt Specifies maximum number of subroutines to display.
+# -a Sort by alphabetic name of subroutines.
+# -t Sort by user+system time spent in subroutines. (default)
+# -l Sort by number of calls to subroutines.
+# -v Sort by average amount of time spent in subroutines.
+# -T Show call tree.
+# -q Do not print column headers.
+# -u Use user time rather than user+system time.
+# -s Use system time rather than user+system time.
+# -r Use real elapsed time rather than user+system time.
+# -U Do not sort subroutines.
+
+ $cnt = $opt_O || 15;
+ $sort = 'by_time';
+ $sort = 'by_calls' if defined $opt_l;
+ $sort = 'by_alpha' if defined $opt_a;
+ $sort = 'by_avgcpu' if defined $opt_v;
+ $whichtime = "User+System";
+ $whichtime = "System" if defined $opt_s;
+ $whichtime = "Real" if defined $opt_r;
+ $whichtime = "User" if defined $opt_u;
+}
+
+Main: {
+ my $monout = shift || "tmon.out";
+ my $fh = "main::fh";
+ local $names = {};
+ local $times = {}; # times in hz
+ local $calls = {};
+ local $persecs = {}; # times in seconds
+ local $idkeys = [];
+ local $runtime; # runtime in seconds
+ my @a = ();
+ my $a;
+ local $rrun_utime = 0; # user time in hz
+ local $rrun_stime = 0; # system time in hz
+ local $rrun_rtime = 0; # elapsed run time in hz
+ local $rrun_ustime = 0; # user+system time in hz
+ local $hz = 0;
+
+ open( $fh, "<$monout" ) || die "Unable to open $monout\n";
+
+ header($fh);
+
+ $rrun_ustime = $rrun_utime + $rrun_stime;
+
+ settime( \$runtime, $hz );
+
+ $~ = 'STAT';
+ if( ! $opt_q ){
+ $^ = 'CSTAT_top';
+ }
+
+ parsestack( $fh, $names, $calls, $times, $idkeys );
+
+ exit(0) if $opt_T;
+
+ if( $opt_v ){
+ percalc( $calls, $times, $persecs, $idkeys );
+ }
+ if( ! $opt_U ){
+ @a = sort $sort @$idkeys;
+ $a = \@a;
+ }
+ else {
+ $a = $idkeys;
+ }
+ display( $runtime, $hz, $names, $calls, $times, $cnt, $a );
+}
+
+
+# Sets $runtime to user, system, real, or user+system time. The
+# result is given in seconds.
+#
+sub settime {
+ my( $runtime, $hz ) = @_;
+
+ if( $opt_r ){
+ $$runtime = $rrun_rtime/$hz;
+ }
+ elsif( $opt_s ){
+ $$runtime = $rrun_stime/$hz;
+ }
+ elsif( $opt_u ){
+ $$runtime = $rrun_utime/$hz;
+ }
+ else{
+ $$runtime = $rrun_ustime/$hz;
+ }
+}
+
+
+# Report the times in seconds.
+sub display {
+ my( $runtime, $hz, $names, $calls , $times, $cnt, $idkeys ) = @_;
+ my( $x, $key, $s );
+ #format: $ncalls, $name, $secs, $percall, $pcnt
+
+ for( $x = 0; $x < @$idkeys; ++$x ){
+ $key = $idkeys->[$x];
+ $ncalls = $calls->{$key};
+ $name = $names->{$key};
+ $s = $times->{$key}/$hz;
+ $secs = sprintf("%.3f", $s );
+ $percall = sprintf("%.4f", $s/$ncalls );
+ $pcnt = sprintf("%.2f",
+ $runtime ?
+ (($secs / $runtime) * 100.0) :
+ 0 );
+ write;
+ $pcnt = $secs = $ncalls = $percall = "";
+ write while( length $name );
+ last unless --$cnt;
+ }
+}
+
+
+sub parsestack {
+ my( $fh, $names, $calls, $times, $idkeys ) = @_;
+ my( $dir, $name );
+ my( $t, $syst, $realt, $usert );
+ my( $x, $z, $c );
+ my @stack = ();
+ my @tstack = ();
+ my $tab = 3;
+ my $in = 0;
+
+ while(<$fh>){
+ next if /^#/o;
+ last if /^PART/o;
+ chop;
+ ($dir, $usert, $syst, $realt, $name) = split;
+
+ if ( $opt_u ) { $t = $usert }
+ elsif( $opt_s ) { $t = $syst }
+ elsif( $opt_r ) { $t = $realt }
+ else { $t = $usert + $syst }
+
+ if( $dir eq '+' ){
+ if( $opt_T ){
+ print " " x $in, "$name\n";
+ $in += $tab;
+ }
+ if(! defined $names->{$name} ){
+ $names->{$name} = $name;
+ $times->{$name} = 0;
+ push( @$idkeys, $name );
+ }
+ $calls->{$name}++;
+ $x = [ $name, $t ];
+ push( @stack, $x );
+
+ # my children will put their time here
+ push( @tstack, 0 );
+
+ next;
+ }
+ if( $dir eq '-' ){
+ exitstamp( \@stack, \@tstack, $t, $times,
+ $name, \$in, $tab );
+ next;
+ }
+ die "Bad profile: $_";
+ }
+ if( @stack ){
+ my @astack;
+
+ warn "Garbled profile is missing some exit time stamps:\n";
+ foreach (@stack) {
+ printf "${$_}[0]\n";
+ push( @astack, @stack );
+ }
+ if( ! $opt_F ){
+ die "Garbled profile";
+ }
+ else{
+ warn( "Faking " . scalar( @astack ) . " exit timestamp(s) . . .\n");
+
+ foreach $x ( @astack ){
+ $name = $x->[0];
+ exitstamp( \@stack, \@tstack, $t, $times,
+ $name, \$in, $tab );
+ }
+ }
+ }
+}
+
+sub exitstamp {
+ my( $stack, $tstack, $t, $times, $name, $in, $tab ) = @_;
+
+ my( $x, $c, $z );
+
+ $x = pop( @$stack );
+ if( ! defined $x ){
+ die "Garbled profile, missing an enter time stamp";
+ }
+ if( $x->[0] ne $name ){
+ die "Garbled profile, unexpected exit time stamp";
+ }
+ if( $opt_T ){
+ $$in -= $tab;
+ }
+ # collect childtime
+ $c = pop( @$tstack );
+ # total time this func has been active
+ $z = $t - $x->[1];
+ # less time spent in child funcs.
+ # prepare to accept that the children may account
+ # for all my time.
+ $times->{$name} += ($z > $c)? $z - $c: $c - $z;
+
+ # pass my time to my parent
+ if( @$tstack ){
+ $c = pop( @$tstack );
+ push( @$tstack, $c + $z );
+ }
+}
+
+
+sub header {
+ my $fh = shift;
+ chop($_ = <$fh>);
+ if( ! /^#fOrTyTwO$/ ){
+ die "Not a perl profile";
+ }
+ while(<$fh>){
+ next if /^#/o;
+ last if /^PART/o;
+ eval;
+ }
+}
+
+
+# Report avg time-per-function in seconds
+sub percalc {
+ my( $calls, $times, $persecs, $idkeys ) = @_;
+ my( $x, $t, $n, $key );
+
+ for( $x = 0; $x < @$idkeys; ++$x ){
+ $key = $idkeys->[$x];
+ $n = $calls->{$key};
+ $t = $times->{$key} / $hz;
+ $persecs->{$key} = $t ? $t / $n : 0;
+ }
+}
+
+
+sub by_time { $times->{$b} <=> $times->{$a} }
+sub by_calls { $calls->{$b} <=> $calls->{$a} }
+sub by_alpha { $names->{$a} cmp $names->{$b} }
+sub by_avgcpu { $persecs->{$b} <=> $persecs->{$a} }
+
+
+format CSTAT_top =
+Total Elapsed Time = @>>>>>> Seconds
+($rrun_rtime / $hz)
+ @>>>>>>>>>> Time = @>>>>>> Seconds
+$whichtime, $runtime
+%Time Seconds #Calls sec/call Name
+.
+
+format STAT =
+ ^>>> ^>>>> ^>>>>>>>>> ^>>>>> ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+$pcnt, $secs, $ncalls, $percall, $name
+.
+
--- /dev/null
+#!./perl
+
+sub foo {
+ print "in sub foo\n";
+ bar();
+}
+
+sub bar {
+ print "in sub bar\n";
+}
+
+sub baz {
+ print "in sub baz\n";
+ bar();
+ foo();
+}
+
+bar();
+baz();
+foo();
package DynaLoader;
+# And Gandalf said: 'Many folk like to know beforehand what is to
+# be set on the table; but those who have laboured to prepare the
+# feast like to keep their secret; for wonder makes the words of
+# praise louder.'
+
+# (Quote from Tolkien sugested by Anno Siegel.)
+#
+# See pod text at end of file for documentation.
+# See also ext/DynaLoader/README in source tree for other information.
+#
+# Tim.Bunce@ig.co.uk, August 1994
+
+require Carp;
+require Config;
+require AutoLoader;
+
+@ISA=qw(AutoLoader);
+
+
+sub import { } # override import inherited from AutoLoader
+
+# enable debug/trace messages from DynaLoader perl code
+$dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
+
+($dl_dlext, $dlsrc, $osname)
+ = @Config::Config{'dlext', 'dlsrc', 'osname'};
+
+# Some systems need special handling to expand file specifications
+# (VMS support by Charles Bailey <bailey@HMIVAX.HUMGEN.UPENN.EDU>)
+# See dl_expandspec() for more details. Should be harmless but
+# inefficient to define on systems that don't need it.
+$do_expand = ($osname eq 'VMS');
+
+@dl_require_symbols = (); # names of symbols we need
+@dl_resolve_using = (); # names of files to link with
+@dl_library_path = (); # path to look for files
+
+# This is a fix to support DLD's unfortunate desire to relink -lc
+@dl_resolve_using = dl_findfile('-lc') if $dlsrc eq "dl_dld.xs";
+
+# Initialise @dl_library_path with the 'standard' library path
+# for this platform as determined by Configure
+push(@dl_library_path, split(' ',$Config::Config{'libpth'}));
+
+# Add to @dl_library_path any extra directories we can gather from
+# environment variables. So far LD_LIBRARY_PATH is the only known
+# variable used for this purpose. Others may be added later.
+push(@dl_library_path, split(/:/, $ENV{LD_LIBRARY_PATH}))
+ if $ENV{LD_LIBRARY_PATH};
+
+
+# No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
+boot_DynaLoader() if defined(&boot_DynaLoader);
+
+
+if ($dl_debug) {
+ print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n";
+ print STDERR "DynaLoader not linked into this perl\n"
+ unless defined(&boot_DynaLoader);
+}
+
+1; # End of main code
+
+
+# The bootstrap function cannot be autoloaded (without complications)
+# so we define it here:
+
+sub bootstrap {
+ # use local vars to enable $module.bs script to edit values
+ local(@args) = @_;
+ local($module) = $args[0];
+ local(@dirs, $file);
+
+ Carp::confess "Usage: DynaLoader::bootstrap(module)" unless $module;
+
+ # A common error on platforms which don't support dynamic loading.
+ # Since it's fatal and potentially confusing we give a detailed message.
+ Carp::croak("Can't load module $module, dynamic loading not available in this perl.\n".
+ " (You may need to build a new perl executable which either supports\n".
+ " dynamic loading or has the $module module statically linked into it.)\n")
+ unless defined(&dl_load_file);
+
+ my @modparts = split(/::/,$module);
+ my $modfname = $modparts[-1];
+
+ # Some systems have restrictions on files names for DLL's etc.
+ # mod2fname returns appropriate file base name (typically truncated)
+ # It may also edit @modparts if required.
+ $modfname = &mod2fname(\@modparts) if defined &mod2fname;
+
+ my $modpname = join('/',@modparts);
+
+ print STDERR "DynaLoader::bootstrap for $module ",
+ "(auto/$modpname/$modfname.$dl_dlext)\n" if $dl_debug;
+
+ foreach (@INC) {
+ my $dir = "$_/auto/$modpname";
+ next unless -d $dir; # skip over uninteresting directories
+
+ # check for common cases to avoid autoload of dl_findfile
+ last if ($file=_check_file("$dir/$modfname.$dl_dlext"));
+
+ # no luck here, save dir for possible later dl_findfile search
+ push(@dirs, "-L$dir");
+ }
+ # last resort, let dl_findfile have a go in all known locations
+ $file = dl_findfile(@dirs, map("-L$_",@INC), $modfname) unless $file;
+
+ Carp::croak "Can't find loadable object for module $module in \@INC (@INC)"
+ unless $file;
+
+ my $bootname = "boot_$module";
+ $bootname =~ s/\W/_/g;
+ @dl_require_symbols = ($bootname);
+
+ # Execute optional '.bootstrap' perl script for this module.
+ # The .bs file can be used to configure @dl_resolve_using etc to
+ # match the needs of the individual module on this architecture.
+ my $bs = $file;
+ $bs =~ s/(\.\w+)?$/\.bs/; # look for .bs 'beside' the library
+ if (-s $bs) { # only read file if it's not empty
+ print STDERR "BS: $bs ($osname, $dlsrc)\n" if $dl_debug;
+ eval { do $bs; };
+ warn "$bs: $@\n" if $@;
+ }
+
+ # Many dynamic extension loading problems will appear to come from
+ # this section of code: XYZ failed at line 123 of DynaLoader.pm.
+ # Often these errors are actually occurring in the initialisation
+ # C code of the extension XS file. Perl reports the error as being
+ # in this perl code simply because this was the last perl code
+ # it executed.
+
+ my $libref = dl_load_file($file) or
+ Carp::croak "Can't load '$file' for module $module: ".dl_error()."\n";
+
+ my @unresolved = dl_undef_symbols();
+ Carp::carp "Undefined symbols present after loading $file: @unresolved\n"
+ if @unresolved;
+
+ my $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
+ Carp::croak "Can't find '$bootname' symbol in $file\n";
+
+ my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
+
+ # See comment block above
+ &$xs(@args);
+}
+
+
+sub _check_file { # private utility to handle dl_expandspec vs -f tests
+ my($file) = @_;
+ return $file if (!$do_expand && -f $file); # the common case
+ return $file if ( $do_expand && ($file=dl_expandspec($file)));
+ return undef;
+}
+
+
+# Let autosplit and the autoloader deal with these functions:
+__END__
+
+
+sub dl_findfile {
+ # Read ext/DynaLoader/DynaLoader.doc for detailed information.
+ # This function does not automatically consider the architecture
+ # or the perl library auto directories.
+ my (@args) = @_;
+ my (@dirs, $dir); # which directories to search
+ my (@found); # full paths to real files we have found
+ my $vms = ($osname eq 'VMS');
+ my $dl_so = $Config::Config{'so'}; # suffix for shared libraries
+
+ print STDERR "dl_findfile(@args)\n" if $dl_debug;
+
+ # accumulate directories but process files as they appear
+ arg: foreach(@args) {
+ # Special fast case: full filepath requires no search
+ if (m:/: && -f $_ && !$do_expand) {
+ push(@found,$_);
+ last arg unless wantarray;
+ next;
+ }
+
+ # Deal with directories first:
+ # Using a -L prefix is the preferred option (faster and more robust)
+ if (m:^-L:) { s/^-L//; push(@dirs, $_); next; }
+
+ # Otherwise we try to try to spot directories by a heuristic
+ # (this is a more complicated issue than it first appears)
+ if (m:/: && -d $_) { push(@dirs, $_); next; }
+
+ # VMS: we may be using native VMS directry syntax instead of
+ # Unix emulation, so check this as well
+ if ($vms && /[:>\]]/ && -d $_) { push(@dirs, $_); next; }
+
+ # Only files should get this far...
+ my(@names, $name); # what filenames to look for
+ if (m:-l: ) { # convert -lname to appropriate library name
+ s/-l//;
+ push(@names,"lib$_.$dl_so");
+ push(@names,"lib$_.a");
+ } else { # Umm, a bare name. Try various alternatives:
+ # these should be ordered with the most likely first
+ push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
+ push(@names,"lib$_.$dl_so") unless m:/:;
+ push(@names,"$_.o") unless m/\.(o|$dl_so)$/o;
+ push(@names,"$_.a") if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
+ push(@names, $_);
+ }
+ foreach $dir (@dirs, @dl_library_path) {
+ next unless -d $dir;
+ foreach $name (@names) {
+ my($file) = "$dir/$name";
+ print STDERR " checking in $dir for $name\n" if $dl_debug;
+ $file = _check_file($file);
+ if ($file) {
+ push(@found, $file);
+ next arg; # no need to look any further
+ }
+ }
+ }
+ }
+ if ($dl_debug) {
+ foreach(@dirs) {
+ print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
+ }
+ print STDERR "dl_findfile found: @found\n";
+ }
+ return $found[0] unless wantarray;
+ @found;
+}
+
+
+sub dl_expandspec {
+ my($spec) = @_;
+ # Optional function invoked if DynaLoader.pm sets $do_expand.
+ # Most systems do not require or use this function.
+ # Some systems may implement it in the dl_*.xs file in which case
+ # this autoload version will not be called but is harmless.
+
+ # This function is designed to deal with systems which treat some
+ # 'filenames' in a special way. For example VMS 'Logical Names'
+ # (something like unix environment variables - but different).
+ # This function should recognise such names and expand them into
+ # full file paths.
+ # Must return undef if $spec is invalid or file does not exist.
+
+ my $file = $spec; # default output to input
+
+ if ($osname eq 'VMS') { # dl_expandspec should be defined in dl_vms.xs
+ Carp::croak "dl_expandspec: should be defined in XS file!\n";
+ } else {
+ return undef unless -f $file;
+ }
+ print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug;
+ $file;
+}
+
+
=head1 NAME
DynaLoader - Dynamically load C libraries into Perl code
=head1 SYNOPSIS
+ package YourPackage;
require DynaLoader;
@ISA = qw(... DynaLoader ...);
+ bootstrap YourPackage;
=head1 DESCRIPTION
=item *
-calls &{"${module}::bootstrap"} to bootstrap the module
+calls &{"${module}::bootstrap"} to bootstrap the module (actually
+it uses the function reference returned by dl_install_xsub for speed)
=back
implemented the first Perl 5 dynamic loader using it.
=cut
-
-#
-# And Gandalf said: 'Many folk like to know beforehand what is to
-# be set on the table; but those who have laboured to prepare the
-# feast like to keep their secret; for wonder makes the words of
-# praise louder.'
-#
-
-# Quote from Tolkien sugested by Anno Siegel.
-#
-# Read ext/DynaLoader/README for detailed information.
-#
-# Tim.Bunce@ig.co.uk, August 1994
-
-use Config;
-use Carp;
-use AutoLoader;
-
-@ISA=qw(AutoLoader);
-
-
-# enable messages from DynaLoader perl code
-$dl_debug = 0 unless $dl_debug;
-$dl_debug = $ENV{'PERL_DL_DEBUG'} if $ENV{'PERL_DL_DEBUG'};
-
-$dl_so = $dl_dlext = ""; # avoid typo warnings
-$dl_so = $Config{'so'}; # suffix for shared libraries
-$dl_dlext = $Config{'dlext'}; # suffix for dynamic modules
-
-# Some systems need special handling to expand file specifications
-# (VMS support by Charles Bailey <bailey@HMIVAX.HUMGEN.UPENN.EDU>)
-# See dl_expandspec() for more details. Should be harmless but
-# inefficient to define on systems that don't need it.
-$do_expand = ($Config{'osname'} eq 'VMS');
-
-@dl_require_symbols = (); # names of symbols we need
-@dl_resolve_using = (); # names of files to link with
-@dl_library_path = (); # path to look for files
-
-# This is a fix to support DLD's unfortunate desire to relink -lc
-@dl_resolve_using = dl_findfile('-lc') if $Config{'dlsrc'} eq "dl_dld.xs";
-
-# Initialise @dl_library_path with the 'standard' library path
-# for this platform as determined by Configure
-push(@dl_library_path, split(' ',$Config{'libpth'}));
-
-# Add to @dl_library_path any extra directories we can gather from
-# environment variables. So far LD_LIBRARY_PATH is the only known
-# variable used for this purpose. Others may be added later.
-push(@dl_library_path, split(/:/, $ENV{'LD_LIBRARY_PATH'}))
- if $ENV{'LD_LIBRARY_PATH'};
-
-
-# No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
-boot_DynaLoader() if defined(&boot_DynaLoader);
-
-
-if ($dl_debug){
- print STDERR "DynaLoader.pm loaded (@dl_library_path)\n";
- print STDERR "DynaLoader not linked into this perl\n"
- unless defined(&boot_DynaLoader);
-}
-
-1; # End of main code
-
-
-# The bootstrap function cannot be autoloaded (without complications)
-# so we define it here:
-
-sub bootstrap {
- # use local vars to enable $module.bs script to edit values
- local(@args) = @_;
- local($module) = $args[0];
- local(@dirs, $file);
-
- confess "Usage: DynaLoader::bootstrap(module)" unless $module;
-
- # A common error on platforms which don't support dynamic loading.
- # Since it's fatal and potentially confusing we give a detailed message.
- croak("Can't load module $module, dynamic loading not available in this perl.\n".
- " (You may need to build a new perl executable which either supports\n".
- " dynamic loading or has the $module module statically linked into it.)\n")
- unless defined(&dl_load_file);
-
- print STDERR "DynaLoader::bootstrap($module)\n" if $dl_debug;
-
- my(@modparts) = split(/::/,$module);
- my($modfname) = $modparts[-1];
- my($modpname) = join('/',@modparts);
- foreach (@INC) {
- my $dir = "$_/auto/$modpname";
- next unless -d $dir; # skip over uninteresting directories
-
- # check for common cases to avoid autoload of dl_findfile
- last if ($file=_check_file("$dir/$modfname.$dl_dlext"));
-
- # no luck here, save dir for possible later dl_findfile search
- push(@dirs, "-L$dir");
- }
- # last resort, let dl_findfile have a go in all known locations
- $file = dl_findfile(@dirs, map("-L$_",@INC), $modfname) unless $file;
-
- croak "Can't find loadable object for module $module in \@INC"
- unless $file;
-
- my($bootname) = "boot_$module";
- $bootname =~ s/\W/_/g;
- @dl_require_symbols = ($bootname);
-
- # Execute optional '.bootstrap' perl script for this module.
- # The .bs file can be used to configure @dl_resolve_using etc to
- # match the needs of the individual module on this architecture.
- my $bs = $file;
- $bs =~ s/(\.\w+)?$/\.bs/; # look for .bs 'beside' the library
- if (-s $bs) { # only read file if it's not empty
- local($osname, $dlsrc) = @Config{'osname','dlsrc'};
- print STDERR "BS: $bs ($osname, $dlsrc)\n" if $dl_debug;
- eval { do $bs; };
- warn "$bs: $@\n" if $@;
- }
-
- # Many dynamic extension loading problems will appear to come from
- # this section of code: XYZ failed at line 123 of DynaLoader.pm.
- # Often these errors are actually occurring in the initialisation
- # C code of the extension XS file. Perl reports the error as being
- # in this perl code simply because this was the last perl code
- # it executed.
-
- my $libref = dl_load_file($file) or
- croak "Can't load '$file' for module $module: ".dl_error()."\n";
-
- my(@unresolved) = dl_undef_symbols();
- carp "Undefined symbols present after loading $file: @unresolved\n"
- if (@unresolved);
-
- my $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
- croak "Can't find '$bootname' symbol in $file\n";
-
- dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
-
- # See comment block above
- &{"${module}::bootstrap"}(@args);
-}
-
-
-sub _check_file{ # private utility to handle dl_expandspec vs -f tests
- my($file) = @_;
- return $file if (!$do_expand && -f $file); # the common case
- return $file if ( $do_expand && ($file=dl_expandspec($file)));
- return undef;
-}
-
-
-# Let autosplit and the autoloader deal with these functions:
-__END__
-
-
-sub dl_findfile {
- # Read ext/DynaLoader/DynaLoader.doc for detailed information.
- # This function does not automatically consider the architecture
- # or the perl library auto directories.
- my (@args) = @_;
- my (@dirs, $dir); # which directories to search
- my (@found); # full paths to real files we have found
- my ($vms) = ($Config{'osname'} eq 'VMS');
-
- print STDERR "dl_findfile(@args)\n" if $dl_debug;
-
- # accumulate directories but process files as they appear
- arg: foreach(@args) {
- # Special fast case: full filepath requires no search
- if (m:/: && -f $_ && !$do_expand){
- push(@found,$_);
- last arg unless wantarray;
- next;
- }
-
- # Deal with directories first:
- # Using a -L prefix is the preferred option (faster and more robust)
- if (m:^-L:){ s/^-L//; push(@dirs, $_); next; }
-
- # Otherwise we try to try to spot directories by a heuristic
- # (this is a more complicated issue than it first appears)
- if (m:/: && -d $_){ push(@dirs, $_); next; }
-
- # VMS: we may be using native VMS directry syntax instead of
- # Unix emulation, so check this as well
- if ($vms && /[:>\]]/ && -d $_){ push(@dirs, $_); next; }
-
- # Only files should get this far...
- my(@names, $name); # what filenames to look for
- if (m:-l: ){ # convert -lname to appropriate library name
- s/-l//;
- push(@names,"lib$_.$dl_so");
- push(@names,"lib$_.a");
- }else{ # Umm, a bare name. Try various alternatives:
- # these should be ordered with the most likely first
- push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
- push(@names,"lib$_.$dl_so") unless m:/:;
- push(@names,"$_.o") unless m/\.(o|$dl_so)$/o;
- push(@names,"$_.a") unless m/\.a$/;
- push(@names, $_);
- }
- foreach $dir (@dirs, @dl_library_path) {
- next unless -d $dir;
- foreach $name (@names) {
- my($file) = "$dir/$name";
- print STDERR " checking in $dir for $name\n" if $dl_debug;
- $file = _check_file($file);
- if ($file){
- push(@found, $file);
- next arg; # no need to look any further
- }
- }
- }
- }
- if ($dl_debug) {
- foreach(@dirs) {
- print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
- }
- print STDERR "dl_findfile found: @found\n";
- }
- return $found[0] unless wantarray;
- @found;
-}
-
-
-sub dl_expandspec{
- my($spec) = @_;
- # Optional function invoked if DynaLoader.pm sets $do_expand.
- # Most systems do not require or use this function.
- # Some systems may implement it in the dl_*.xs file in which case
- # this autoload version will not be called but is harmless.
-
- # This function is designed to deal with systems which treat some
- # 'filenames' in a special way. For example VMS 'Logical Names'
- # (something like unix environment variables - but different).
- # This function should recognise such names and expand them into
- # full file paths.
- # Must return undef if $spec is invalid or file does not exist.
-
- my($file) = $spec; # default output to input
- my($osname) = $Config{'osname'};
-
- if ($osname eq 'VMS'){ # dl_expandspec should be defined in dl_vms.xs
- croak "dl_expandspec: should be defined in XS file!\n";
- }else{
- return undef unless -f $file;
- }
- print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug;
- $file;
-}
#include "dlutils.c" /* for SaveError() etc */
+static AV *dl_resolve_using = Nullav;
+static AV *dl_require_symbols = Nullav;
+
static void
dl_private_init()
{
int dlderr;
dl_generic_private_init();
+ dl_resolve_using = perl_get_av("DynaLoader::dl_resolve_using", 0x4);
+ dl_require_symbols = perl_get_av("DynaLoader::dl_require_symbols", 0x4);
#ifdef __linux__
dlderr = dld_init("/proc/self/exe");
if (dlderr) {
CODE:
int dlderr,x,max;
GV *gv;
- AV *av;
RETVAL = filename;
DLDEBUG(1,fprintf(stderr,"dl_load_file(%s)\n", filename));
- gv = gv_fetchpv("DynaLoader::dl_require_symbols", FALSE, SVt_PVAV);
- if (gv) {
- av = GvAV(gv);
- max = AvFILL(av);
- for (x = 0; x <= max; x++) {
- char *sym = SvPVX(*av_fetch(av, x, 0));
- DLDEBUG(1,fprintf(stderr, "dld_create_ref(%s)\n", sym));
- if (dlderr = dld_create_reference(sym)) {
- SaveError("dld_create_reference(%s): %s", sym,
- dld_strerror(dlderr));
- goto haverror;
- }
+
+ max = AvFILL(dl_require_symbols);
+ for (x = 0; x <= max; x++) {
+ char *sym = SvPVX(*av_fetch(dl_require_symbols, x, 0));
+ DLDEBUG(1,fprintf(stderr, "dld_create_ref(%s)\n", sym));
+ if (dlderr = dld_create_reference(sym)) {
+ SaveError("dld_create_reference(%s): %s", sym,
+ dld_strerror(dlderr));
+ goto haverror;
}
}
+
DLDEBUG(1,fprintf(stderr, "dld_link(%s)\n", filename));
if (dlderr = dld_link(filename)) {
SaveError("dld_link(%s): %s", filename, dld_strerror(dlderr));
goto haverror;
}
- gv = gv_fetchpv("DynaLoader::dl_resolve_using", FALSE, SVt_PVAV);
- if (gv) {
- av = GvAV(gv);
- max = AvFILL(av);
- for (x = 0; x <= max; x++) {
- char *sym = SvPVX(*av_fetch(av, x, 0));
- DLDEBUG(1,fprintf(stderr, "dld_link(%s)\n", sym));
- if (dlderr = dld_link(sym)) {
- SaveError("dld_link(%s): %s", sym, dld_strerror(dlderr));
- goto haverror;
- }
+
+ max = AvFILL(dl_resolve_using);
+ for (x = 0; x <= max; x++) {
+ char *sym = SvPVX(*av_fetch(dl_resolve_using, x, 0));
+ DLDEBUG(1,fprintf(stderr, "dld_link(%s)\n", sym));
+ if (dlderr = dld_link(sym)) {
+ SaveError("dld_link(%s): %s", sym, dld_strerror(dlderr));
+ goto haverror;
}
}
DLDEBUG(2,fprintf(stderr,"libref=%s\n", RETVAL));
error.
The mode parameter must be set to 1 for Solaris 1 and to
- RTLD_LAZY on Solaris 2.
+ RTLD_LAZY (==2) on Solaris 2.
dlsym
#include <link.h>
#endif
+#ifndef RTLD_LAZY
+# define RTLD_LAZY 1 /* Solaris 1 */
+#endif
+
#ifndef HAS_DLERROR
# ifdef __NetBSD__
# define dlerror() strerror(errno)
dl_load_file(filename)
char * filename
CODE:
- int mode = 1; /* Solaris 1 */
-#ifdef RTLD_LAZY
- mode = RTLD_LAZY; /* Solaris 2 */
+ int mode = RTLD_LAZY;
+#ifdef RTLD_NOW
+ if (dl_nonlazy)
+ mode = RTLD_NOW;
#endif
DLDEBUG(1,fprintf(stderr,"dl_load_file(%s):\n", filename));
RETVAL = dlopen(filename, mode) ;
#include "dlutils.c" /* for SaveError() etc */
+static AV *dl_resolve_using = Nullav;
+
static void
dl_private_init()
{
(void)dl_generic_private_init();
+ dl_resolve_using = perl_get_av("DynaLoader::dl_resolve_using", 0x4);
}
MODULE = DynaLoader PACKAGE = DynaLoader
char * filename
CODE:
shl_t obj = NULL;
- int i, max;
- GV *gv;
- AV *av;
-
- gv = gv_fetchpv("DynaLoader::dl_resolve_using", FALSE, SVt_PVAV);
- if (gv) {
- av = GvAV(gv);
- max = AvFILL(av);
- for (i = 0; i <= max; i++) {
- char *sym = SvPVX(*av_fetch(av, i, 0));
- DLDEBUG(1,fprintf(stderr, "dl_load_file(%s) (dependent)\n", sym));
- obj = shl_load(sym,
- BIND_IMMEDIATE | BIND_NONFATAL | BIND_NOSTART | BIND_VERBOSE,
- 0L);
- if (obj == NULL) {
- goto end;
- }
+ int i, max, bind_type;
+
+ if (dl_nonlazy)
+ bind_type = BIND_IMMEDIATE;
+ else
+ bind_type = BIND_DEFERRED;
+
+ max = AvFILL(dl_resolve_using);
+ for (i = 0; i <= max; i++) {
+ char *sym = SvPVX(*av_fetch(dl_resolve_using, i, 0));
+ DLDEBUG(1,fprintf(stderr, "dl_load_file(%s) (dependent)\n", sym));
+ obj = shl_load(sym, bind_type | BIND_NOSTART, 0L);
+ if (obj == NULL) {
+ goto end;
}
}
DLDEBUG(1,fprintf(stderr,"dl_load_file(%s): ", filename));
- obj = shl_load(filename,
- BIND_IMMEDIATE | BIND_NONFATAL | BIND_NOSTART | BIND_VERBOSE, 0L);
+ obj = shl_load(filename, bind_type | BIND_NOSTART, 0L);
DLDEBUG(2,fprintf(stderr," libref=%x\n", obj));
end:
#endif
DLDEBUG(2,fprintf(stderr,"dl_find_symbol(handle=%x, symbol=%s)\n",
libhandle, symbolname));
+ ST(0) = sv_newmortal() ;
+ errno = 0;
+
status = shl_findsym(&obj, symbolname, TYPE_PROCEDURE, &symaddr);
DLDEBUG(2,fprintf(stderr," symbolref(PROCEDURE) = %x\n", symaddr));
- ST(0) = sv_newmortal() ;
+
+ if (status == -1 && errno == 0) { /* try TYPE_DATA instead */
+ status = shl_findsym(&obj, symbolname, TYPE_DATA, &symaddr);
+ DLDEBUG(2,fprintf(stderr," symbolref(DATA) = %x\n", symaddr));
+ }
+
if (status == -1) {
- if (errno == 0) {
- status = shl_findsym(&obj, symbolname, TYPE_DATA, &symaddr);
- DLDEBUG(2,fprintf(stderr," symbolref(DATA) = %x\n", symaddr));
- if (status == -1) {
- SaveError("%s",(errno) ? Strerror(errno) : "Symbol not found") ;
- } else {
- sv_setiv( ST(0), (IV)symaddr);
- }
- } else {
- SaveError("%s", Strerror(errno));
- }
+ SaveError("%s",(errno) ? Strerror(errno) : "Symbol not found") ;
} else {
sv_setiv( ST(0), (IV)symaddr);
}
-int
+void
dl_undef_symbols()
PPCODE:
*/
+/* include these before perl headers */
+#include <mach-o/rld.h>
+#include <streams/streams.h>
+
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
-#include "dlutils.c" /* SaveError() etc */
+#define DL_LOADONCEONLY
+#include "dlutils.c" /* SaveError() etc */
-#include <mach-o/rld.h>
-#include <streams/streams.h>
static char * dl_last_error = (char *) 0;
+static AV *dl_resolve_using = Nullav;
NXStream *
OpenError()
int mode; /* mode is ignored */
{
int rld_success;
- NXStream *nxerr = OpenError();
- AV * av_resolve;
+ NXStream *nxerr;
I32 i, psize;
char *result;
char **p;
+
+ /* Do not load what is already loaded into this process */
+ if (hv_fetch(dl_loaded_files, path, strlen(path), 0))
+ return path;
- av_resolve = GvAVn(gv_fetchpv(
- "DynaLoader::dl_resolve_using", FALSE, SVt_PVAV));
- psize = AvFILL(av_resolve) + 3;
+ nxerr = OpenError();
+ psize = AvFILL(dl_resolve_using) + 3;
p = (char **) safemalloc(psize * sizeof(char*));
p[0] = path;
for(i=1; i<psize-1; i++) {
- p[i] = SvPVx(*av_fetch(av_resolve, i-1, TRUE), na);
+ p[i] = SvPVx(*av_fetch(dl_resolve_using, i-1, TRUE), na);
}
p[psize-1] = 0;
rld_success = rld_load(nxerr, (struct mach_header **)0, p,
safefree((char*) p);
if (rld_success) {
result = path;
+ /* prevent multiple loads of same file into same process */
+ hv_store(dl_loaded_files, path, strlen(path), &sv_yes, 0);
} else {
TransferError(nxerr);
result = (char*) 0;
dl_private_init()
{
(void)dl_generic_private_init();
+ dl_resolve_using = perl_get_av("DynaLoader::dl_resolve_using", 0x4);
}
MODULE = DynaLoader PACKAGE = DynaLoader
#include "XSUB.h"
#include "dlutils.c" /* dl_debug, LastError; SaveError not used */
+
+static AV *dl_require_symbols = Nullav;
+
/* N.B.:
* dl_debug and LastError are static vars; you'll need to deal
* with them appropriately if you need context independence
dl_private_init()
{
dl_generic_private_init();
+ dl_require_symbols = perl_get_av("DynaLoader::dl_require_symbols", 0x4);
/* Set up the static control blocks for dl_expand_filespec() */
dlfab = cc$rms_fab;
dlnam = cc$rms_nam;
char * filespec
CODE:
char vmsspec[NAM$C_MAXRSS];
- AV *reqAV;
SV *reqSV, **reqSVhndl;
STRLEN deflen;
struct dsc$descriptor_s
dlptr->name.dsc$a_pointer,
dlptr->defspec.dsc$w_length,
dlptr->defspec.dsc$a_pointer));
- if (!(reqAV = GvAV(gv_fetchpv("DynaLoader::dl_require_symbols",
- FALSE,SVt_PVAV)))
- || !(reqSVhndl = av_fetch(reqAV,0,FALSE)) || !(reqSV = *reqSVhndl)) {
+ if (!(reqSVhndl = av_fetch(dl_require_symbols,0,FALSE)) || !(reqSV = *reqSVhndl)) {
DLDEBUG(2,fprintf(stderr,"\t@dl_require_symbols empty, returning untested libref\n"));
}
else {
/* pointer to allocated memory for last error message */
static char *LastError = (char*)NULL;
+/* flag for immediate rather than lazy linking (spots unresolved symbol) */
+static int dl_nonlazy = 0;
+
+#ifdef DL_LOADONCEONLY
+static HV *dl_loaded_files = Nullhv; /* only needed on a few systems */
+#endif
#ifdef DEBUGGING
-/* currently not connected to $DynaLoader::dl_error but should be */
-static int dl_debug = 0;
-#define DLDEBUG(level,code) if(dl_debug>=level){ code; }
+static int dl_debug = 0; /* value copied from $DynaLoader::dl_error */
+#define DLDEBUG(level,code) if (dl_debug>=level) { code; }
#else
#define DLDEBUG(level,code)
#endif
static void
dl_generic_private_init() /* called by dl_*.xs dl_private_init() */
{
+ char *perl_dl_nonlazy;
#ifdef DEBUGGING
- char *perl_dl_debug = getenv("PERL_DL_DEBUG");
- if (perl_dl_debug)
- dl_debug = atoi(perl_dl_debug);
+ dl_debug = SvIV( perl_get_sv("DynaLoader::dl_debug", 0x04) );
+#endif
+ if ( (perl_dl_nonlazy = getenv("PERL_DL_NONLAZY")) != NULL )
+ dl_nonlazy = atoi(perl_dl_nonlazy);
+ if (dl_nonlazy)
+ DLDEBUG(1,fprintf(stderr,"DynaLoader bind mode is 'non-lazy'\n"));
+#ifdef DL_LOADONCEONLY
+ if (!dl_loaded_files)
+ dl_loaded_files = newHV(); /* provide cache for dl_*.xs if needed */
#endif
}
char *message;
int len;
- /* This code is based on croak/warn but I'm not sure where mess() */
- /* gets its buffer space from! */
+ /* This code is based on croak/warn, see mess() in util.c */
#ifdef I_STDARG
va_start(args, pat);
#include <fcntl.h>
+/* This comment is a kludge to get metaconfig to see the symbols
+ VAL_O_NONBLOCK
+ VAL_EAGAIN
+ RD_NODATA
+ EOF_NONBLOCK
+ and include the appropriate metaconfig unit
+ so that Configure will test how to turn on non-blocking I/O
+ for a file descriptor. See config.h for how to use these
+ in your extension.
+
+ While I'm at it, I'll have metaconfig look for HAS_POLL too.
+ --AD October 16, 1995
+*/
+
static int
not_here(s)
char *s;
#ifdef NULL
#undef NULL
#endif
-#include <dbm.h>
+#ifdef I_DBM
+# include <dbm.h>
+#else
+# ifdef I_RPCSVC_DBM
+# include <rpcsvc/dbm.h>
+# endif
+#endif
#include <fcntl.h>
POSIX__SigSet sigset;
SV** svp;
SV** sigsvp = hv_fetch(GvHVn(siggv),
- sig_name[sig],
- strlen(sig_name[sig]),
+ whichsigname(sig),
+ strlen(whichsigname(sig)),
TRUE);
/* Remember old handler name if desired. */
=head1 NAME
-Socket - load the C socket.h defines
+Socket - load the C socket.h defines and structure manipulators
=head1 SYNOPSIS
use Socket;
$proto = (getprotobyname('udp'))[2];
- socket(Socket_Handle, PF_INET, SOCK_DGRAM, $proto);
+ socket(Socket_Handle, PF_INET, SOCK_DGRAM, $proto);
+ $sockaddr_in = pack_sockaddr_in(AF_INET,7,inet_aton("localhost"));
+ $sockaddr_in = pack_sockaddr_in(AF_INET,7,INADDR_LOOPBACK);
+ connect(Socket_Handle,$sockaddr_in);
+ $peer = inet_ntoa((unpack_sockaddr_in(getpeername(Socket_Handle)))[2]);
+
=head1 DESCRIPTION
and your native C compiler. This means that it has a
far more likely chance of getting the numbers right.
-=head1 NOTE
+In addition, some structure manipulation functions are available:
+
+=item inet_aton HOSTNAME
+
+Takes a string giving the name of a host, and translates that
+to the 4-byte string (structure). Takes arguments of both
+the 'rtfm.mit.edu' type and '18.181.0.24'. If the host name
+cannot be resolved, returns undef.
+
+=item inet_ntoa IP_ADDRESS
+
+Takes a four byte ip address (as returned by inet_aton())
+and translates it into a string of the form 'd.d.d.d'
+where the 'd's are numbers less than 256 (the normal
+readable four dotted number notation for internet addresses).
+
+=item INADDR_ANY
+
+Note - does not return a number.
+
+Returns the 4-byte wildcard ip address which specifies any
+of the hosts ip addresses. (A particular machine can have
+more than one ip address, each address corresponding to
+a particular network interface. This wildcard address
+allows you to bind to all of them simultaneously.)
+Normally equivalent to inet_aton('0.0.0.0').
+
+=item INADDR_LOOPBACK
+
+Note - does not return a number.
+
+Returns the 4-byte loopback address. Normally equivalent
+to inet_aton('localhost').
-Only C<#define> symbols get translated; you must still correctly
-pack up your own arguments to pass to bind(), etc.
+=item INADDR_NONE
+
+Note - does not return a number.
+
+Returns the 4-byte invalid ip address. Normally equivalent
+to inet_aton('255.255.255.255').
+
+=item pack_sockaddr_in FAMILY, PORT, IP_ADDRESS
+
+Takes three arguments, an address family (normally AF_INET),
+a port number, and a 4 byte IP_ADDRESS (as returned by
+inet_aton()). Returns the sockaddr_in structure with those
+arguments packed in. For internet domain sockets, this structure
+is normally what you need for the arguments in bind(), connect(),
+and send(), and is also returned by getpeername(), getsockname()
+and recv().
+
+=item unpack_sockaddr_in SOCKADDR_IN
+
+Takes a sockaddr_in structure (as returned by pack_sockaddr_in())
+and returns an array of three elements: the address family,
+the port, and the 4-byte ip-address.
=cut
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
+ inet_aton inet_ntoa pack_sockaddr_in unpack_sockaddr_in
+ INADDR_ANY INADDR_LOOPBACK INADDR_NONE
AF_802
AF_APPLETALK
AF_CCITT
goto &$AUTOLOAD;
}
-
-# pack a sockaddr_in structure for use in bind() calls.
-# (here to hide the 'S n C4 x8' magic from applications)
-sub sockaddr_in{
- my($af, $port, @quad) = @_;
- my $pack = 'S n C4 x8'; # lookup $pack from hash using $af?
- pack($pack, $af, $port, @quad);
-}
-
-
bootstrap Socket;
# Preloaded methods go here. Autoload methods go after __END__, and are
#include "perl.h"
#include "XSUB.h"
+#ifndef VMS
+# ifdef I_SYS_TYPES
+# include <sys/types.h>
+# endif
#include <sys/socket.h>
+# ifdef I_NETINET_IN
+# include <netinet/in.h>
+# endif
+#include <netdb.h>
+#include <arpa/inet.h>
+#else
+#include "sockadapt.h"
+#endif
#ifndef AF_NBS
#undef PF_NBS
#undef PF_X25
#endif
+#ifndef INADDR_NONE
+#define INADDR_NONE 0xffffffff
+#endif /* INADDR_NONE */
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7F000001
+#endif /* INADDR_LOOPBACK */
+
+
static int
not_here(s)
char *s;
return 0;
}
+
MODULE = Socket PACKAGE = Socket
double
char * name
int arg
+
+void
+inet_aton(host)
+ char * host
+ CODE:
+ {
+ struct in_addr ip_address;
+ struct hostent * phe;
+
+ if (phe = gethostbyname(host)) {
+ Copy( phe->h_addr, &ip_address, phe->h_length, char );
+ } else {
+ ip_address.s_addr = inet_addr(host);
+ }
+
+ ST(0) = sv_newmortal();
+ if(ip_address.s_addr != INADDR_NONE) {
+ sv_setpvn( ST(0), (char *)&ip_address, sizeof ip_address );
+ }
+ }
+
+void
+inet_ntoa(ip_address_sv)
+ SV * ip_address_sv
+ CODE:
+ {
+ STRLEN addrlen;
+ struct in_addr addr;
+ char * addr_str;
+ char * ip_address = SvPV(ip_address_sv,addrlen);
+ if (addrlen != sizeof(addr)) {
+ croak("Bad arg length for %s, length is %d, should be %d",
+ "Socket::inet_ntoa",
+ addrlen, sizeof(addr));
+ }
+
+ Copy( ip_address, &addr, sizeof addr, char );
+ addr_str = inet_ntoa(addr);
+
+ ST(0) = sv_2mortal(newSVpv(addr_str, strlen(addr_str)));
+ }
+
+void
+pack_sockaddr_in(family,port,ip_address)
+ short family
+ short port
+ char * ip_address
+ CODE:
+ {
+ struct sockaddr_in sin;
+
+ Zero( &sin, sizeof sin, char );
+ sin.sin_family = family;
+ sin.sin_port = htons(port);
+ Copy( ip_address, &sin.sin_addr, sizeof sin.sin_addr, char );
+
+ ST(0) = sv_2mortal(newSVpv((char *)&sin, sizeof sin));
+ }
+
+void
+unpack_sockaddr_in(sin_sv)
+ SV * sin_sv
+ PPCODE:
+ {
+ STRLEN sockaddrlen;
+ struct sockaddr_in addr;
+ short family;
+ short port;
+ struct in_addr ip_address;
+ char * sin = SvPV(sin_sv,sockaddrlen);
+ if (sockaddrlen != sizeof(addr)) {
+ croak("Bad arg length for %s, length is %d, should be %d",
+ "Socket::unpack_sockaddr_in",
+ sockaddrlen, sizeof(addr));
+ }
+
+ Copy( sin, &addr,sizeof addr, char );
+ family = addr.sin_family;
+ port = ntohs(addr.sin_port);
+ ip_address = addr.sin_addr;
+
+ EXTEND(sp, 3);
+ PUSHs(sv_2mortal(newSViv(family)));
+ PUSHs(sv_2mortal(newSViv(port)));
+ PUSHs(sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address)));
+ }
+
+void
+INADDR_ANY()
+ CODE:
+ {
+ struct in_addr ip_address;
+ ip_address.s_addr = htonl(INADDR_ANY);
+ ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address ));
+ }
+
+void
+INADDR_LOOPBACK()
+ CODE:
+ {
+ struct in_addr ip_address;
+ ip_address.s_addr = htonl(INADDR_LOOPBACK);
+ ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address));
+ }
+
+void
+INADDR_NONE()
+ CODE:
+ {
+ struct in_addr ip_address;
+ ip_address.s_addr = htonl(INADDR_NONE);
+ ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address));
+ }
sge_amg
sgt_amg
sig_name
+sig_num
siggv
sighandler
simple
q
ref
refkids
-regcomp
+pregcomp
regdump
-regexec
-regfree
+pregexec
+pregfree
regnext
regprop
repeatcpy
warn
watch
whichsig
+whichsigname
xiv_arenaroot
xiv_root
xnv_root
$name;
};
-chdir 'ext' if -d 'ext';
+(chdir 'ext', $ext = 'ext/') if -d 'ext';
if( $module =~ /::/ ){
$nested = 1;
}
-die "Won't overwrite existing ext/$modpname\n" if -e $modpname;
+die "Won't overwrite existing $ext$modpname\n" if -e $modpname;
# quick hack, should really loop over @modparts
mkdir($modparts[0], 0777) if $nested;
mkdir($modpname, 0777);
-chdir($modpname) || die "Can't chdir ext/$modpname: $!\n";
+chdir($modpname) || die "Can't chdir $ext$modpname: $!\n";
-open(XS, ">$modfname.xs") || die "Can't create ext/$modpname/$modfname.xs: $!\n";
-open(PM, ">$modfname.pm") || die "Can't create ext/$modpname/$modfname.pm: $!\n";
+open(XS, ">$modfname.xs") || die "Can't create $ext$modpname/$modfname.xs: $!\n";
+open(PM, ">$modfname.pm") || die "Can't create $ext$modpname/$modfname.pm: $!\n";
$" = "\n\t";
-warn "Writing ext/$modpname/$modfname.pm\n";
+warn "Writing $ext$modpname/$modfname.pm\n";
print PM <<"END";
package $module;
close PM;
-warn "Writing ext/$modpname/$modfname.xs\n";
+warn "Writing $ext$modpname/$modfname.xs\n";
print XS <<"END";
#include "EXTERN.h"
close XS;
-warn "Writing ext/$modpname/Makefile.PL\n";
-open(PL, ">Makefile.PL") || die "Can't create ext/$modpname/Makefile.PL: $!\n";
+warn "Writing $ext$modpname/Makefile.PL\n";
+open(PL, ">Makefile.PL") || die "Can't create $ext$modpname/Makefile.PL: $!\n";
print PL <<'END';
use ExtUtils::MakeMaker;
d_setreuid='undef'
ccflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE'
nm_opt='-B'
- scope_cflags='optimize=" "'
;;
esac
+# The optimizer in 4.1.1 apparently generates bad code for scope.c.
+# Configure doesn't offer an easy way to propagate extra variables
+# only for certain cases, so the following contortion is required:
+scope_cflags='case "$osvers" in 4.1*) optimize=" ";; esac'
+
# Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
#
# Tell perl which symbols to export for dynamic linking.
--- /dev/null
+# hints/hpux.sh
+# Perl Configure hints file for Hewlett Packard HP/UX 9.x and 10.x
+# This file is based on
+# hints/hpux_9.sh, Perl Configure hints file for Hewlett Packard HP/UX 9.x
+# Use Configure -Dcc=gcc to use gcc.
+# From: Jeff Okamoto <okamoto@hpcc123.corp.hp.com>
+# Date: Thu, 28 Sep 95 11:06:07 PDT
+# and
+# hints/hpux_10.sh, Perl Configure hints file for Hewlett Packard HP/UX 10.x
+# From: Giles Lean <giles@nemeton.com.au>
+# Date: Tue, 27 Jun 1995 08:17:45 +1000
+
+# Use Configure -Dcc=gcc to use gcc.
+# Use Configure -Dprefix=/usr/local to install in /usr/local.
+
+# Turn on the _HPUX_SOURCE flag to get many of the HP add-ons
+ccflags="$ccflags -D_HPUX_SOURCE"
+ldflags="$ldflags"
+
+# Check if you're using the bundled C compiler. This compiler doesn't support
+# ANSI C (the -Aa flag) nor can it produce shared libraries. Thus we have
+# to turn off dynamic loading.
+case "$cc" in
+'') if cc $ccflags -Aa 2>&1 | $contains 'Unknown option "A"' >/dev/null
+ then
+ case "$usedl" in
+ '') usedl="$undef"
+ cat <<'EOM'
+
+The bundled C compiler can not produce shared libraries, so you will
+not be able to use dynamic loading.
+
+EOM
+ ;;
+ esac
+ else
+ ccflags="$ccflags -Aa" # The add-on compiler supports ANSI C
+ fi
+ optimize='-O'
+ ;;
+esac
+
+# Remove bad libraries that will cause problems
+# (This doesn't remove libraries that don't actually exist)
+# -lld is unneeded (and I can't figure out what it's used for anyway)
+# -ldbm is obsolete and should not be used
+# -lBSD contains BSD-style duplicates of SVR4 routines that cause confusion
+# -lPW is obsolete and should not be used
+# Although -lndbm should be included, it will make perl blow up if you should
+# copy the binary to a system without libndbm.sl.
+# The libraries crypt, malloc, ndir, and net are empty.
+set `echo " $libswanted " | sed -e 's@ ndbm @ @' -e 's@ ld @ @' -e 's@ dbm @ @' -e 's@ BSD @ @' -e 's@ PW @ @'`
+libswanted="$*"
+
+# If you copy the perl binaries to other systems and the dynamic loader
+# complains about missing libraries, you can either copy the shared libraries
+# or switch the comments to recompile perl to use archive libraries
+# ccdlflags="-Wl,-E -Wl,-a,archive $ccdlflags"
+ccdlflags="-Wl,-E $ccdlflags"
+
+usemymalloc='y'
+alignbytes=8
+selecttype='int *'
+
+# There are some lingering issues about whether g/setpgrp should be a part
+# of the perl core. This setting should cause perl to conform to the Principle
+# of Least Astonishment. The best thing is to use the g/setpgrp in the POSIX
+# module.
+d_bsdpgrp='define'
+
+# If your compile complains about FLT_MIN, uncomment the next line
+# POSIX_cflags='ccflags="$ccflags -DFLT_MIN=1.17549435E-38"'
+
+# Comment these out if you don't want to follow the SVR4 filesystem layout
+# that HP-UX 10.0 uses
+case "$prefix" in
+'') prefix='/opt/perl5'
+ privlib='/opt/perl5/lib'
+ archlib='/opt/perl5/lib/hpux'
+ man3dir='/opt/perl5/man/man3'
+ ;;
+esac
+
+++ /dev/null
-# hints/hpux_9.sh, Perl Configure hints file for Hewlett Packard HP/UX 9.x
-# Use Configure -Dcc=gcc to use gcc.
-ccflags="$ccflags -D_POSIX_SOURCE -D_HPUX_SOURCE"
-case "$cc" in
-'') if cc $ccflags -Aa 2>&1 | $contains 'Unknown option "A"' >/dev/null
- then # The bundled (limited) compiler doesn't
- case "$usedl" in # support -Aa for "ANSI C mode".
- '') usedl="$undef";; # Nor can it produce shared libraries.
- esac
- else
- ccflags="$ccflags -Aa" # The add-on compiler supports ANSI C
- fi
- optimize='+O1'
- ;;
-esac
-libswanted='m dld'
-# ccdlflags="-Wl,-E -Wl,-a,shared $ccdlflags" # Force all shared?
-ccdlflags="-Wl,-E $ccdlflags"
-usemymalloc='y'
-alignbytes=8
-selecttype='int *'
-POSIX_cflags='ccflags="$ccflags -DFLT_MIN=1.17549435E-38"'
-
-case "$prefix" in
-'') prefix='/opt/perl5' ;;
-esac
-case "$archname" in
-'') archname='hpux' ;;
-esac
# compilation "redefinition" warnings, but they appear harmless.
# ccflags="$ccflags -D_SYSV3"
-# Pick up dbm.h in <rpcsvc/dbm.h>
-ccflags="$ccflags -I/usr/include/rpcsvc"
ldflags="$ldflags -Xp"
;;
esac
-# Pick up dbm.h in <rpcsvc/dbm.h>
-ccflags="$ccflags -I/usr/include/rpcsvc"
# Compensate for conflicts in <net/errno.h>
doio_cflags='ccflags="$ccflags -DENOTSOCK=103"'
pp_sys_cflags='ccflags="$ccflags -DENOTSOCK=103"'
+# For SysV release 2, there are no directory functions defined. To
+# prevent compile errors, acquire the functions written by Doug Gwynn.
+# They are contained in dirent.tar.gz and can be accessed from gnu
+# repositories, as well as other places.
+#
+# The following hints have been verified to work with PERL5 (001m) on
+# SysVr2 with the following caveat(s):
+# 1. Maximum User program space (MAXSPACE) must be at least 2MB.
+# 2. The directory functions mentioned above have been installed.
+#
optimize='-O0'
-ccflags="$ccflags -W2,-Sl,2000"
+ccflags="$ccflags -W2,-Sl,1500 -W0,-Sp,350,-Ss,2500 -Wp,-Sd,30"
d_mkdir=$undef
usemymalloc='y'
+useposix='false'
+so='none'
+# hints/solaris_2.sh
+# Last modified: 27 September 1995 by
+# Andy Dougherty <doughera@lafcol.lafayette.edu>
+# Based on input from lots of folks, especially
+# Dean Roehrich <roehrich@ironwood-fddi.cray.com>
+#
+# See man vfork.
usevfork=false
+#
d_suidsafe=define
+# Avoid all libraries in /usr/ucblib.
set `echo $glibpth | sed -e 's@/usr/ucblib@@'`
glibpth="$*"
# Remove bad libraries. -lucb contains incompatible routines.
*) ;;
esac
+# See below for excerpts from the Solaris FAQ.
+
+# From roehrich@ironwood-fddi.cray.com Wed Sep 27 12:51:46 1995
+# Date: Thu, 7 Sep 1995 16:31:40 -0500
+# From: Dean Roehrich <roehrich@ironwood-fddi.cray.com>
+# To: perl5-porters@africa.nicoh.com
+# Subject: Re: On perl5/solaris/gcc
+
+# Here's another draft of the perl5/solaris/gcc sanity-checker.
+
case $PATH in
-*/usr/ucb*:/usr/bin:*) cat <<END
+*/usr/ucb*:/usr/bin:*|*/usr/ucb*:/usr/bin) cat <<END
+
NOTE: Some people have reported problems with /usr/ucb/cc.
Remove /usr/ucb from your PATH if you have difficulties.
+
+END
+;;
+esac
+
+
+# Check that /dev/fd is mounted. If it is not mounted, let the
+# user know that suid scripts may not work.
+/usr/bin/df /dev/fd 2>&1 > /dev/null
+case $? in
+0) ;;
+*)
+ cat <<END
+
+NOTE: Your system does not have /dev/fd mounted. If you want to
+be able to use set-uid scripts you must ask your system administrator
+to mount /dev/fd.
+
+END
+ ;;
+esac
+
+
+# See if libucb can be found in /usr/lib. If it is, warn the user
+# that this may cause problems while building Perl extensions.
+/usr/bin/ls /usr/lib/libucb* >/dev/null 2>&1
+case $? in
+0)
+ cat <<END
+
+NOTE: libucb has been found in /usr/lib. libucb should reside in
+/usr/ucblib. You may have trouble while building Perl extensions.
+
END
;;
esac
+
+# See if make(1) is GNU make(1).
+# If it is, make sure the setgid bit is not set.
+make -v > make.vers 2>&1
+if grep GNU make.vers > /dev/null 2>&1; then
+ tmp=`/usr/bin/which make`
+ case "`/usr/bin/ls -l $tmp`" in
+ ??????s*)
+ cat <<END
+
+NOTE: Your PATH points to GNU make, and your GNU make has the set-group-id
+bit set. You must either rearrange your PATH to put /usr/ccs/bin before the
+GNU utilities or you must ask your system administrator to disable the
+set-group-id bit on GNU make.
+
+END
+ ;;
+ esac
+fi
+rm -f make.vers
+
+# If the C compiler is gcc:
+# - check the fixed-includes
+# - check as(1) and ld(1), they should not be GNU
+# If the C compiler is not gcc:
+# - check as(1) and ld(1), they should not be GNU
+#
+# Watch out in case they have not set $cc.
+case "`${cc:-cc} -v 2>&1`" in
+*gcc*)
+ #
+ # Using gcc.
+ #
+ #echo Using gcc
+
+ # Get gcc to share its secrets.
+ echo 'main() { return 0; }' > try.c
+ verbose=`${cc:-cc} -v -o try try.c 2>&1`
+ tmp=`echo "$verbose" | grep '^Reading' |
+ awk '{print $NF}' | sed 's/specs$/include/'`
+
+ # Determine if the fixed-includes look like they'll work.
+ sed 1q $tmp/stdarg.h 2>&1 | grep 'stdarg.h for GNU' 2>&1 >/dev/null
+ case $? in
+ 0) ;;
+ *)
+ cat <<END
+
+NOTE: The fixincludes or just-fixinc script for gcc was not run
+properly. Your gcc may not be able to compile Perl. Inform your system
+administrator that ${cc:-cc} is not properly installed.
+
+END
+ ;;
+ esac
+
+ # See if as(1) is GNU as(1). GNU as(1) won't work for this job.
+ case $verbose in
+ */usr/ccs/bin/as*) ;;
+ *)
+ cat <<END
+
+NOTE: You are using GNU as(1). GNU as(1) will not build Perl.
+You must arrange to use /usr/ccs/bin/as, perhaps by setting
+GCC_EXEC_PREFIX.
+
+END
+ ;;
+ esac
+
+ # See if ld(1) is GNU ld(1). GNU ld(1) won't work for this job.
+ case $verbose in
+ */usr/ccs/bin/ld*) ;;
+ *)
+ cat <<END
+
+NOTE: You are using GNU ld(1). GNU ld(1) will not build Perl.
+You must arrange to use /usr/ccs/bin/ld, perhaps by setting
+GCC_EXEC_PREFIX.
+
+END
+ ;;
+ esac
+
+ ;; #using gcc
+*)
+ #
+ # Not using gcc.
+ #
+ #echo Not using gcc
+
+ # See if as(1) is GNU as(1). GNU as(1) won't work for this job.
+ case `as --version < /dev/null 2>&1` in
+ *GNU*)
+ cat <<END
+
+NOTE: You are using GNU as(1). GNU as(1) will not build Perl.
+You must arrange to use /usr/ccs/bin, perhaps by adding it to the
+beginning of your PATH.
+
+END
+ ;;
+ esac
+
+ # See if ld(1) is GNU ld(1). GNU ld(1) won't work for this job.
+ case `ld --version < /dev/null 2>&1` in
+ *GNU*)
+ cat <<END
+
+NOTE: You are using GNU ld(1). GNU ld(1) will not build Perl.
+You must arrange to use /usr/ccs/bin, perhaps by adding it to the
+beginning of your PATH
+
+END
+ ;;
+ esac
+
+ ;; #not using gcc
+esac
+
+# as --version or ld --version might dump core.
+rm -f core
+
+# This is just a trick to include some useful notes.
+cat > /dev/null <<'End_of_Solaris_Notes'
+
+Here are some notes kindly contributed by Dean Roehrich.
+
+-----
+Generic notes about building Perl5 on Solaris:
+- Use /usr/ccs/bin/make.
+- If you use GNU make, remove its setgid bit.
+- Remove all instances of *ucb* from your path.
+- Make sure libucb is not in /usr/lib (it should be in /usr/ucblib).
+- Do not use GNU as or GNU ld, or any of GNU binutils or GNU libc.
+- Do not use /usr/ucb/cc.
+- Do not change Configure's default answers, except for the path names.
+- Do not use -lmalloc.
+- Do not build on SunOS 4 and expect it to work properly on SunOS 5.
+- /dev/fd must be mounted if you want set-uid scripts to work.
+
+
+Here are the gcc-related questions and answers from the Solaris 2 FAQ. Note
+the themes:
+ - run fixincludes
+ - run fixincludes correctly
+ - don't use GNU as or GNU ld
+
+Question 5.7 covers the __builtin_va_alist problem people are always seeing.
+Question 6.1.3 covers the GNU as and GNU ld issues which are always biting
+people.
+Question 6.9 is for those who are still trying to compile Perl4.
+
+The latest Solaris 2 FAQ can be found in the following locations:
+ rtfm.mit.edu:/pub/usenet-by-group/comp.sys.sun.admin
+ ftp.fwi.uva.nl:/pub/solaris
+
+Perl5 comes with a script in the top-level directory called "myconfig" which
+will print a summary of the configuration in your config.sh. My summary for
+Solaris 2.4 and gcc 2.6.3 follows. I have also built with gcc 2.7.0 and the
+results are identical. This configuration was generated with Configure's -d
+option (take all defaults, don't bother prompting me). All tests pass for
+Perl5.001, patch.1m.
+
+Summary of my perl5 (patchlevel 1) configuration:
+ Platform:
+ osname=solaris, osver=2.4, archname=sun4-solaris
+ uname='sunos poplar 5.4 generic_101945-27 sun4d sparc '
+ hint=recommended
+ Compiler:
+ cc='gcc', optimize='-O', ld='gcc'
+ cppflags=''
+ ccflags =''
+ ldflags =''
+ stdchar='unsigned char', d_stdstdio=define, usevfork=false
+ voidflags=15, castflags=0, d_casti32=define, d_castneg=define
+ intsize=4, alignbytes=8, usemymalloc=y, randbits=15
+ Libraries:
+ so=so
+ libpth=/lib /usr/lib /usr/ccs/lib /usr/local/lib
+ libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
+ libc=/usr/lib/libc.so
+ Dynamic Linking:
+ dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef
+ cccdlflags='-fpic', ccdlflags=' ', lddlflags='-G'
+
+
+Dean
+roehrich@cray.com
+9/7/95
+
+-----------
+
+From: Casper.Dik@Holland.Sun.COM (Casper H.S. Dik - Network Security Engineer)
+Subject: Solaris 2 Frequently Asked Questions (FAQ) 1.48
+Date: 25 Jul 1995 12:20:18 GMT
+
+5.7) Why do I get __builtin_va_alist or __builtin_va_arg_incr undefined?
+
+ You're using gcc without properly installing the gcc fixed
+ include files. Or you ran fixincludes after installing gcc
+ w/o moving the gcc supplied varargs.h and stdarg.h files
+ out of the way and moving them back again later. This often
+ happens when people install gcc from a binary distribution.
+ If there's a tmp directory in gcc's include directory, fixincludes
+ didn't complete. You should have run "just-fixinc" instead.
+
+ Another possible cause is using ``gcc -I/usr/include.''
+
+6.1) Where is the C compiler or where can I get one?
+
+ [...]
+
+ 3) Gcc.
+
+ Gcc is available from the GNU archives in source and binary
+ form. Look in a directory called sparc-sun-solaris2 for
+ binaries. You need gcc 2.3.3 or later. You should not use
+ GNU as or GNU ld. Make sure you run just-fixinc if you use
+ a binary distribution. Better is to get a binary version and
+ use that to bootstrap gcc from source.
+
+ [...]
+
+ When you install gcc, don't make the mistake of installing
+ GNU binutils or GNU libc, they are not as capable as their
+ counterparts you get with Solaris 2.x.
+
+6.9) I can't get perl 4.036 to compile or run.
+
+ Run Configure, and use the solaris_2_0 hints, *don't* use
+ the solaris_2_1 hints and don't use the config.sh you may
+ already have. First you must make sure Configure and make
+ don't find /usr/ucb/cc. (It must use gcc or the native C
+ compiler: /opt/SUNWspro/bin/cc)
+
+ Some questions need a special answer.
+
+ Are your system (especially dbm) libraries compiled with gcc? [y] y
+
+ yes: gcc 2.3.3 or later uses the standard calling
+ conventions, same as Sun's C.
+
+ Any additional cc flags? [ -traditional -Dvolatile=__volatile__
+ -I/usr/ucbinclude] -traditional -Dvolatile=__volatile__
+ Remove /usr/ucbinclude.
+
+ Any additional libraries? [-lsocket -lnsl -ldbm -lmalloc -lm
+ -lucb] -lsocket -lnsl -lm
+
+ Don't include -ldbm, -lmalloc and -lucb.
+
+ Perl 5 compiled out of the box.
+
+End_of_Solaris_Notes
+
case "$osvers" in
*4.1*) ccflags="$ccflags -DLANGUAGE_C -Olimit 2900" ;;
*4.2*) ccflags="$ccflags -DLANGUAGE_C -Olimit 2900"
+ # Prototypes sometimes cause compilation errors in 4.2.
+ prototype=undef
case "$myuname" in
*risc*) d_volatile=undef ;;
esac
d_setregid='undef'
d_setreuid='undef'
-# Pick up dbm.h in <rpcsvc/dbm.h>
-if test -f /usr/include/rpcsvc/dbm.h; then
- ccflags="$ccflags -I/usr/include/rpcsvc"
-fi
usemymalloc='y'
-# /usr/include/rpcsvc is for finding dbm.h
-inclwanted="$inclwanted /usr/include/rpcsvc"
-
echo " "
echo "NOTE: You may have to take out makefile dependencies on the files in"
echo "/usr/include (i.e. /usr/include/ctype.h) or the make will fail. A"
}
if (!xhv->xhv_array)
- Newz(506,xhv->xhv_array, sizeof(HE*) * (xhv->xhv_max + 1), char);
+ entry = Null(HE*);
+ else
do {
if (entry)
entry = entry->hent_next;
package ExtUtils::Liblist;
-require ExtUtils::MakeMaker; # currently for MM_Unix::lsdir
# Broken out of MakeMaker from version 4.11