]> git.zerfleddert.de Git - micropolis/blame_incremental - src/tcl/config
handle spaces in path-names, too
[micropolis] / src / tcl / config
... / ...
CommitLineData
1#!/bin/csh -f
2#
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.
7#
8# $Header: /user6/ouster/tcl/RCS/config,v 1.30 92/05/13 09:27:18 ouster Exp $ SPRITE (Berkeley)
9#
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.
18
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.
25
26# Directory containing system include files:
27
28set includeDir="/usr/include"
29
30# Archive file containing object code for standard C library:
31
32set libc="/usr/lib/libc.a"
33
34# Makefile to modify:
35
36set makefile="makefile"
37
38# Header file to modify to hold #defines about system configuration:
39
40set config="tclunix.h"
41#--------------------------------------------------------------
42
43set changes=0
44unset time
45
46# First make sure that the configuration variables have been
47# set in a reasonable fashion.
48
49if ( ! -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"
52 echo " variable."
53 exit(1)
54endif
55if ( ! -r $libc ) then
56 echo "- ERROR\!\! C library $libc doesn\'t exist. Please edit config"
57 echo " to set the libc variable."
58 exit(1)
59endif
60nm -p $libc > tmp.libc
61if ( $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)."
65 exit(1)
66endif
67
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.
70
71set pattern="[ADIT]"
72set x=`grep printf tmp.libc | grep -c CODE`
73if ( $x ) then
74 set pattern=CODE
75endif
76set x=`grep printf tmp.libc | grep -c extern`
77if ( $x ) then
78 set pattern="|extern|"
79endif
80
81# Check in the C library for particular library procedures and
82# variables needed by Tcl.
83
84set gettod=`grep gettimeofday tmp.libc | grep -c "$pattern"`
85if ( $gettod > 1 ) set gettod=1
86set getwd=`grep getwd tmp.libc | grep -c "$pattern"`
87if ( $getwd > 1 ) set getwd=1
88set opendir=`grep opendir tmp.libc | grep -c "$pattern"`
89if ( $opendir > 1 ) set opendir=1
90set strerror=`grep strerror tmp.libc | grep -c "$pattern"`
91if ( $strerror > 1 ) set strerror=1
92set strstr=`grep strstr tmp.libc | grep -c "$pattern"`
93if ( $strstr > 1 ) set strstr=1
94set strtod=`grep strtod tmp.libc | grep -c "$pattern"`
95if ( $strtod > 1 ) set strtod=1
96set strtol=`grep strtol tmp.libc | grep -c "$pattern"`
97if ( $strtol > 1 ) set strtol=1
98set strtoul=`grep strtoul tmp.libc | grep -c "$pattern"`
99if ( $strtoul > 1 ) set strtoul=1
100set sys_errlist=`grep sys_errlist tmp.libc | grep -c "$pattern"`
101if ( $sys_errlist > 1 ) set sys_errlist=1
102\rm tmp.libc
103
104# Next, install header files that aren't present in /usr/include.
105
106set extraHdrs=""
107foreach i (dirent.h limits.h)
108 \rm -f $i
109 if ( ! -r $includeDir/$i ) then
110 cp compat/$i .
111 set extraHdrs="$extraHdrs $i"
112 endif
113end
114set stdlibOK=0
115\rm -f stdlib.h
116if ( -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
119 # use ours instead.
120
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
125 set stdlibOK=1
126 endif
127endif
128# XXX: Un-Kludge around sun acc, which doesn't need this...
129set stdlibOK=1
130if ( ! $stdlibOK ) then
131 cp compat/stdlib.h .
132 set extraHdrs="$extraHdrs stdlib.h"
133endif
134
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.
138
139\rm -f string.h
140if ( ! $strstr || ! $strtoul || ! -r $includeDir/string.h ) then
141 cp compat/string.h .
142 set extraHdrs="$extraHdrs string.h"
143endif
144if ( "$extraHdrs" != "" ) then
145 echo "- Substitutes will be used for the following header files,"
146 echo " which aren't in ${includeDir} or aren't complete:"
147 echo " $extraHdrs"
148 set changes=1
149endif
150
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.
153
154if ( $strtoul ) then
155 cp compat/teststrtoul.c test.c
156 make configtest >& /dev/null
157 if ( $status == 0 ) then
158 ./a.out
159 if ( $status != 0 ) then
160 set strtoul=0
161 endif
162 endif
163 \rm -f a.out test.c
164endif
165
166# Next, install C procedures for missing library functions.
167
168set extraLibs=""
169\rm -f strerror.c
170if ( ! $strerror ) then
171 set extraLibs="$extraLibs strerror"
172 cp compat/strerror.c .
173endif
174\rm -f opendir.c
175if ( ! $opendir ) then
176 set extraLibs="$extraLibs opendir"
177 cp compat/opendir.c .
178 \rm -f dirent.h
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\!"
183endif
184\rm -f strstr.c
185if ( ! $strstr ) then
186 set extraLibs="$extraLibs strstr"
187 cp compat/strstr.c .
188endif
189\rm -f strtod.c
190if ( ! $strtod ) then
191 set extraLibs="$extraLibs strtod"
192 cp compat/strtod.c .
193endif
194\rm -f strtol.c
195if ( ! $strtol ) then
196 set extraLibs="$extraLibs strtol"
197 cp compat/strtol.c .
198endif
199\rm -f strtoul.c
200if ( ! $strtoul ) then
201 set extraLibs="$extraLibs strtoul"
202 cp compat/strtoul.c .
203endif
204if ( "$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:"
207 echo " $extraLibs"
208 set changes=1
209endif
210
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
215# you run it).
216
217set ranlibOK=0
218cat > ranlibtest.c << EOF
219#include <stdio.h>
220main (argc, argv)
221 int argc;
222 char **argv;
223{
224 printf ("Hello, world.\n");
225}
226EOF
227cc -c ranlibtest.c
228ar cru ranlibtest.a ranlibtest.o
229ranlib ranlibtest.a >& /dev/null
230if ( $status == 0 ) then
231 set ranlibOK=1
232else
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."
235 set changes=1
236endif
237\rm -f ranlibtest.*
238
239# Modify the Makefile to include supplemental library sources, if needed.
240
241set compatObjs=""
242foreach i ($extraLibs)
243 set compatObjs="$compatObjs $i.o"
244end
245#if ( ! -e $makefile.bak ) mv $makefile $makefile.bak
246mv $makefile $makefile.bak
247if ( $ranlibOK ) then
248 sed -e "s/COMPAT_OBJS =/COMPAT_OBJS =$compatObjs/" $makefile.bak > $makefile
249else
250 sed -e "s/COMPAT_OBJS =/COMPAT_OBJS =$compatObjs/" \
251 -e "/ranlib/d" $makefile.bak > $makefile
252endif
253
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.)
257
258if ( ! $gettod ) then
259 echo "- There's no gettimeofday in ${libc} so Tcl will use"
260 echo ' times for the "time" command.'
261 set changes=1
262endif
263if ( ! $getwd ) then
264 echo "- There's no getwd in ${libc} so Tcl will use"
265 echo ' getcwd for the "pwd" command.'
266 set changes=1
267endif
268set errlist=1
269if ( ! $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."
272 set errlist=0
273 set changes=1
274endif
275set sysTime=0
276if ( -r $includeDir/sys/time.h ) then
277 set sysTime=1
278endif
279set sysWait=0
280set unionWait=0
281if ( -r $includeDir/sys/wait.h ) then
282 set sysWait=1
283 cp compat/testwait.c test.c
284 make configtest >& /dev/null
285 if ( $status == 0 ) then
286 set unionWait=1
287 endif
288 \rm -f a.out test.c
289endif
290set pid_t=1
291cp compat/testpid.c test.c
292make configtest >& /dev/null
293if ( $status != 0 ) then
294 set pid_t=0
295 echo "- The type pid_t isn't defined in <sys/types.h> so Tcl will"
296 echo ' use "int" instead.'
297endif
298\rm -f a.out test.c
299set uid_t=1
300cp compat/testuid.c test.c
301make configtest >& /dev/null
302if ( $status != 0 ) then
303 set uid_t=0
304 echo "- The type uid_t isn't defined in <sys/types.h> so Tcl will"
305 echo ' use "int" instead.'
306endif
307\rm -f a.out test.c
308if ( ! -e $config.bak ) mv $config $config.bak
309set x=\.\*\$
310sed -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
319
320if ( ! $changes ) then
321 echo "- No special modifications were needed for this system."
322endif
Impressum, Datenschutz