]> git.zerfleddert.de Git - micropolis/blob - src/tcl/config
better search for matching visual
[micropolis] / src / tcl / config
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
28 set includeDir="/usr/include"
29
30 # Archive file containing object code for standard C library:
31
32 set libc="/usr/lib/libc.a"
33
34 # Makefile to modify:
35
36 set makefile="makefile"
37
38 # Header file to modify to hold #defines about system configuration:
39
40 set config="tclunix.h"
41 #--------------------------------------------------------------
42
43 set changes=0
44 unset time
45
46 # First make sure that the configuration variables have been
47 # set in a reasonable fashion.
48
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"
52 echo " variable."
53 exit(1)
54 endif
55 if ( ! -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)
59 endif
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)."
65 exit(1)
66 endif
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
71 set pattern="[ADIT]"
72 set x=`grep printf tmp.libc | grep -c CODE`
73 if ( $x ) then
74 set pattern=CODE
75 endif
76 set x=`grep printf tmp.libc | grep -c extern`
77 if ( $x ) then
78 set pattern="|extern|"
79 endif
80
81 # Check in the C library for particular library procedures and
82 # variables needed by Tcl.
83
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
102 \rm tmp.libc
103
104 # Next, install header files that aren't present in /usr/include.
105
106 set extraHdrs=""
107 foreach 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
113 end
114 set stdlibOK=0
115 \rm -f stdlib.h
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
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
127 endif
128 # XXX: Un-Kludge around sun acc, which doesn't need this...
129 set stdlibOK=1
130 if ( ! $stdlibOK ) then
131 cp compat/stdlib.h .
132 set extraHdrs="$extraHdrs stdlib.h"
133 endif
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
140 if ( ! $strstr || ! $strtoul || ! -r $includeDir/string.h ) then
141 cp compat/string.h .
142 set extraHdrs="$extraHdrs string.h"
143 endif
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:"
147 echo " $extraHdrs"
148 set changes=1
149 endif
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
154 if ( $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
164 endif
165
166 # Next, install C procedures for missing library functions.
167
168 set extraLibs=""
169 \rm -f strerror.c
170 if ( ! $strerror ) then
171 set extraLibs="$extraLibs strerror"
172 cp compat/strerror.c .
173 endif
174 \rm -f opendir.c
175 if ( ! $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\!"
183 endif
184 \rm -f strstr.c
185 if ( ! $strstr ) then
186 set extraLibs="$extraLibs strstr"
187 cp compat/strstr.c .
188 endif
189 \rm -f strtod.c
190 if ( ! $strtod ) then
191 set extraLibs="$extraLibs strtod"
192 cp compat/strtod.c .
193 endif
194 \rm -f strtol.c
195 if ( ! $strtol ) then
196 set extraLibs="$extraLibs strtol"
197 cp compat/strtol.c .
198 endif
199 \rm -f strtoul.c
200 if ( ! $strtoul ) then
201 set extraLibs="$extraLibs strtoul"
202 cp compat/strtoul.c .
203 endif
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:"
207 echo " $extraLibs"
208 set changes=1
209 endif
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
217 set ranlibOK=0
218 cat > ranlibtest.c << EOF
219 #include <stdio.h>
220 main (argc, argv)
221 int argc;
222 char **argv;
223 {
224 printf ("Hello, world.\n");
225 }
226 EOF
227 cc -c ranlibtest.c
228 ar cru ranlibtest.a ranlibtest.o
229 ranlib ranlibtest.a >& /dev/null
230 if ( $status == 0 ) then
231 set ranlibOK=1
232 else
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
236 endif
237 \rm -f ranlibtest.*
238
239 # Modify the Makefile to include supplemental library sources, if needed.
240
241 set compatObjs=""
242 foreach i ($extraLibs)
243 set compatObjs="$compatObjs $i.o"
244 end
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
249 else
250 sed -e "s/COMPAT_OBJS =/COMPAT_OBJS =$compatObjs/" \
251 -e "/ranlib/d" $makefile.bak > $makefile
252 endif
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
258 if ( ! $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
262 endif
263 if ( ! $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
267 endif
268 set errlist=1
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."
272 set errlist=0
273 set changes=1
274 endif
275 set sysTime=0
276 if ( -r $includeDir/sys/time.h ) then
277 set sysTime=1
278 endif
279 set sysWait=0
280 set unionWait=0
281 if ( -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
289 endif
290 set pid_t=1
291 cp compat/testpid.c test.c
292 make configtest >& /dev/null
293 if ( $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.'
297 endif
298 \rm -f a.out test.c
299 set uid_t=1
300 cp compat/testuid.c test.c
301 make configtest >& /dev/null
302 if ( $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.'
306 endif
307 \rm -f a.out test.c
308 if ( ! -e $config.bak ) mv $config $config.bak
309 set x=\.\*\$
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
319
320 if ( ! $changes ) then
321 echo "- No special modifications were needed for this system."
322 endif
Impressum, Datenschutz