3 # This script should be executed to configure the Tcl source directory 
   4 # for a particular system.  It probes the system for various header 
   5 # files and library object files.  Where things needed by Tcl are missing, 
   6 # substitute versions are included from the "compat" subdirectory. 
   8 # $Header: /user6/ouster/tcl/RCS/config,v 1.30 92/05/13 09:27:18 ouster Exp $ SPRITE (Berkeley) 
  10 # Copyright 1991, 1992 Regents of the University of California 
  11 # Permission to use, copy, modify, and distribute this 
  12 # software and its documentation for any purpose and without 
  13 # fee is hereby granted, provided that this copyright 
  14 # notice appears in all copies.  The University of California 
  15 # makes no representations about the suitability of this 
  16 # software for any purpose.  It is provided "as is" without 
  17 # express or implied warranty. 
  19 #-------------------------------------------------------------- 
  20 # The variable definitions below configure this script:  they 
  21 # tell where system-defined things are kept (so this program 
  22 # can tell whether the system contains certain features needed 
  23 # by Tcl), and they indicate which Tcl files to modify to 
  24 # reflect the configuration. 
  26 # Directory containing system include files: 
  28 set includeDir
="/usr/include" 
  30 # Archive file containing object code for standard C library: 
  32 set libc
="/usr/lib/libc.a" 
  36 set makefile
="makefile" 
  38 # Header file to modify to hold #defines about system configuration: 
  40 set config
="tclunix.h" 
  41 #-------------------------------------------------------------- 
  46 # First make sure that the configuration variables have been 
  47 # set in a reasonable fashion. 
  49 if ( ! -r $includeDir/stdio.h 
) then 
  50     echo "- ERROR\!\! $includeDir doesn't seem to contain standard system" 
  51     echo "  include files.  Please edit config to set the includeDir" 
  55 if ( ! -r $libc ) then 
  56     echo "- ERROR\!\! C library $libc doesn\'t exist.  Please edit config" 
  57     echo "  to set the libc variable." 
  60 nm 
-p $libc > tmp.libc
 
  61 if ( $status != 0 ) then 
  62     echo "- ERROR\!\!  Nm failed to extract names of system-supplied library" 
  63     echo "  procedures from $libc.  You'll have to modify config by hand to" 
  64     echo "  fix the problem (whatever it is)." 
  68 # Since nm produces different output on different machines, the code 
  69 # below attempts to guess what pattern to grep for in the nm output. 
  72 set x
=`grep printf tmp.libc | grep -c CODE` 
  76 set x
=`grep printf tmp.libc | grep -c extern` 
  78     set pattern
="|extern|" 
  81 # Check in the C library for particular library procedures and 
  82 # variables needed by Tcl. 
  84 set gettod
=`grep gettimeofday tmp.libc | grep -c "$pattern"` 
  85 if ( $gettod > 1 ) set gettod
=1 
  86 set getwd
=`grep getwd tmp.libc | grep -c "$pattern"` 
  87 if ( $getwd > 1 ) set getwd
=1 
  88 set opendir
=`grep opendir tmp.libc | grep -c "$pattern"` 
  89 if ( $opendir > 1 ) set opendir
=1 
  90 set strerror
=`grep strerror tmp.libc | grep -c "$pattern"` 
  91 if ( $strerror > 1 ) set strerror
=1 
  92 set strstr
=`grep strstr tmp.libc | grep -c "$pattern"` 
  93 if ( $strstr > 1 ) set strstr
=1 
  94 set strtod
=`grep strtod tmp.libc | grep -c "$pattern"` 
  95 if ( $strtod > 1 ) set strtod
=1 
  96 set strtol
=`grep strtol tmp.libc | grep -c "$pattern"` 
  97 if ( $strtol > 1 ) set strtol
=1 
  98 set strtoul
=`grep strtoul tmp.libc | grep -c "$pattern"` 
  99 if ( $strtoul > 1 ) set strtoul
=1 
 100 set sys_errlist
=`grep sys_errlist tmp.libc | grep -c "$pattern"` 
 101 if ( $sys_errlist > 1 ) set sys_errlist
=1 
 104 # Next, install header files that aren't present in /usr/include. 
 107 foreach i 
(dirent.h limits.h
) 
 109     if ( ! -r $includeDir/$i ) then 
 111         set extraHdrs
="$extraHdrs $i" 
 116 if ( -r $includeDir/stdlib.h 
) then 
 117     # The check below is needed because SunOS has a stdlib that 
 118     # doesn't declare strtod and other procedures, so we have to 
 121     set chk1
=`grep -c strtol $includeDir/stdlib.h` 
 122     set chk2
=`grep -c strtoul $includeDir/stdlib.h` 
 123     set chk3
=`grep -c strtod $includeDir/stdlib.h` 
 124     if ( $chk1 > 0 && $chk2 > 0 && $chk3 > 0 ) then 
 128 # XXX: Un-Kludge around sun acc, which doesn't need this... 
 130 if ( ! $stdlibOK ) then 
 132     set extraHdrs
="$extraHdrs stdlib.h" 
 135 # Even if string.h exists it's not complete on all systems.  If 
 136 # some of the procedures we need are missing from the library, then 
 137 # also install a Tcl-specific string.h. 
 140 if ( ! $strstr || ! $strtoul || ! -r $includeDir/string.h 
) then 
 142     set extraHdrs
="$extraHdrs string.h" 
 144 if ( "$extraHdrs" != "" ) then 
 145     echo "- Substitutes will be used for the following header files," 
 146     echo "  which aren't in ${includeDir} or aren't complete:" 
 151 # Even if strtoul exists, it is bogus on some AIX systems.  Detect 
 152 # this and pretend the system version doesn't exist if it's bogus. 
 155     cp compat
/teststrtoul.c 
test.c
 
 156     make configtest 
>& /dev
/null
 
 157     if ( $status == 0 ) then 
 159         if ( $status != 0 ) then 
 166 # Next, install C procedures for missing library functions. 
 170 if ( ! $strerror ) then 
 171     set extraLibs
="$extraLibs strerror" 
 172     cp compat
/strerror.c .
 
 175 if ( ! $opendir ) then 
 176     set extraLibs
="$extraLibs opendir" 
 177     cp compat
/opendir.c .
 
 179     cp compat
/dirent2.h dirent.h
 
 180     echo "- No opendir/readdir/closedir library exists in this system," 
 181     echo "  so substitutes will be provided.  This system better have" 
 182     echo "  V7-style directories\!" 
 185 if ( ! $strstr ) then 
 186     set extraLibs
="$extraLibs strstr" 
 190 if ( ! $strtod ) then 
 191     set extraLibs
="$extraLibs strtod" 
 195 if ( ! $strtol ) then 
 196     set extraLibs
="$extraLibs strtol" 
 200 if ( ! $strtoul ) then 
 201     set extraLibs
="$extraLibs strtoul" 
 202     cp compat
/strtoul.c .
 
 204 if ( "$extraLibs" != "" ) then 
 205     echo "- Substitutes will be used for the following library procedures," 
 206     echo "  which aren't in ${libc} or don't work correctly:" 
 211 # The following statements determine whether ranlib should be used 
 212 # in the Makefile.  On System-V systems it shouldn't.  The only way 
 213 # to figure this out is to run ranlib and see if it complains (ranlib 
 214 # actually exists on some Sys-V systems, but it returns an error if 
 218 cat > ranlibtest.c 
<< EOF 
 224     printf ("Hello, world.\n"); 
 228 ar cru ranlibtest.a ranlibtest.o
 
 229 ranlib ranlibtest.a 
>& /dev
/null
 
 230 if ( $status == 0 ) then 
 233     echo "- This system appears to be a System V one where ranlib isn't" 
 234     echo "  used.  The ranlib commands will be removed from Makefile." 
 239 # Modify the Makefile to include supplemental library sources, if needed. 
 242 foreach i 
($extraLibs) 
 243     set compatObjs
="$compatObjs $i.o" 
 245 #if ( ! -e $makefile.bak ) mv $makefile $makefile.bak 
 246 mv $makefile $makefile.bak
 
 247 if ( $ranlibOK ) then 
 248     sed -e "s/COMPAT_OBJS =/COMPAT_OBJS =$compatObjs/" $makefile.bak 
> $makefile 
 250     sed -e "s/COMPAT_OBJS =/COMPAT_OBJS =$compatObjs/" \
 
 251         -e "/ranlib/d" $makefile.bak 
> $makefile 
 254 # Set the #defines in tclUnix.h to provide various pieces of system 
 255 # configuration information at compile time (existence of header files, 
 256 # variables, type definitions, etc.) 
 258 if ( ! $gettod ) then 
 259     echo "- There's no gettimeofday in ${libc} so Tcl will use" 
 260     echo '  times for the "time" command.' 
 264     echo "- There's no getwd in ${libc} so Tcl will use" 
 265     echo '  getcwd for the "pwd" command.' 
 269 if ( ! $sys_errlist && ! $strerror ) then 
 270     echo "- Neither strerror nor sys_errlist is defined in ${libc} so" 
 271     echo "  Tcl will make a guess about errno-related messages." 
 276 if ( -r $includeDir/sys
/time.h 
) then 
 281 if ( -r $includeDir/sys
/wait.h 
) then 
 283     cp compat
/testwait.c 
test.c
 
 284     make configtest 
>& /dev
/null
 
 285     if ( $status == 0 ) then 
 291 cp compat
/testpid.c 
test.c
 
 292 make configtest 
>& /dev
/null
 
 293 if ( $status != 0 ) then 
 295     echo "- The type pid_t isn't defined in <sys/types.h> so Tcl will" 
 296     echo '  use "int" instead.' 
 300 cp compat
/testuid.c 
test.c
 
 301 make configtest 
>& /dev
/null
 
 302 if ( $status != 0 ) then 
 304     echo "- The type uid_t isn't defined in <sys/types.h> so Tcl will" 
 305     echo '  use "int" instead.' 
 308 if ( ! -e $config.bak 
) mv $config $config.bak
 
 310 sed -e "s/define TCL_GETTOD 1/define TCL_GETTOD $gettod/" \
 
 311     -e "s/define TCL_GETWD 1/define TCL_GETWD $getwd/" \
 
 312     -e "s/define TCL_SYS_ERRLIST 1/define TCL_SYS_ERRLIST $errlist/" \
 
 313     -e "s/define TCL_SYS_TIME_H 1/define TCL_SYS_TIME_H $sysTime/" \
 
 314     -e "s/define TCL_SYS_WAIT_H 1/define TCL_SYS_WAIT_H $sysWait/" \
 
 315     -e "s/define TCL_UNION_WAIT 1/define TCL_UNION_WAIT $unionWait/" \
 
 316     -e "s/define TCL_PID_T 1/define TCL_PID_T $pid_t/" \
 
 317     -e "s/define TCL_UID_T 1/define TCL_UID_T $uid_t/" \
 
 318 $config.bak 
> $config 
 320 if ( ! $changes ) then 
 321     echo "- No special modifications were needed for this system."