1 | #! /bin/sh
|
---|
2 | # hints/os2.sh
|
---|
3 | # This file reflects the tireless work of
|
---|
4 | # Ilya Zakharevich <ilya@math.ohio-state.edu>
|
---|
5 | #
|
---|
6 | # Trimmed and comments added by
|
---|
7 | # Andy Dougherty <doughera@lafayette.edu>
|
---|
8 | # Exactly what is required beyond a standard OS/2 installation?
|
---|
9 | # (see in README.os2)
|
---|
10 |
|
---|
11 | # Note that symbol extraction code gives wrong answers (sometimes?) on
|
---|
12 | # gethostent and setsid.
|
---|
13 |
|
---|
14 | path_sep=\;
|
---|
15 |
|
---|
16 | if test -f $sh.exe; then sh=$sh.exe; fi
|
---|
17 |
|
---|
18 | startsh="#!$sh"
|
---|
19 | cc='gcc'
|
---|
20 |
|
---|
21 | # Make denser object files and DLL
|
---|
22 | case "X$optimize" in
|
---|
23 | X)
|
---|
24 | optimize="-O2 -fomit-frame-pointer -falign-loops=2 -falign-jumps=2 -falign-functions=2 -s"
|
---|
25 | ld_dll_optimize="-s"
|
---|
26 | ;;
|
---|
27 | esac
|
---|
28 |
|
---|
29 | # Get some standard things (indented to avoid putting in config.sh):
|
---|
30 | oifs="$IFS"
|
---|
31 | IFS=" ;"
|
---|
32 | set $MANPATH
|
---|
33 | tryman="$@"
|
---|
34 | set $PATH
|
---|
35 | trypath="$@"
|
---|
36 | set `gcc -print-search-dirs | grep libraries | sed -e "s/^libraries: *=//" `
|
---|
37 | libemx="$@"
|
---|
38 | set $C_INCLUDE_PATH
|
---|
39 | usrinc="$@"
|
---|
40 | IFS="$oifs"
|
---|
41 | tryman="`./UU/loc . /man $tryman`"
|
---|
42 | tryman="`echo $tryman | tr '\\\' '/'`"
|
---|
43 |
|
---|
44 | # indented to avoid having it *two* times at start
|
---|
45 | libemx="`./UU/loc libc_alias.a $libemx`"
|
---|
46 |
|
---|
47 | usrinc="`./UU/loc stdlib.h $usrinc`"
|
---|
48 | usrinc="`dirname $usrinc | tr '\\\' '/'`"
|
---|
49 | libemx="`dirname $libemx | tr '\\\' '/'`"
|
---|
50 |
|
---|
51 | if test -d $tryman/man1; then
|
---|
52 | sysman="$tryman/man1"
|
---|
53 | else
|
---|
54 | sysman="`./UU/loc . /man/man1 $UNIXROOT/usr/share/man/man1 $UNIXROOT/usr/man/man1 c:/man/man1 c:/usr/man/man1 d:/man/man1 d:/usr/man/man1 e:/man/man1 e:/usr/man/man1 f:/man/man1 f:/usr/man/man1 g:/man/man1 g:/usr/man/man1 /usr/man/man1`"
|
---|
55 | fi
|
---|
56 |
|
---|
57 | #emxpath="`dirname $libemx`"
|
---|
58 | #if test ! -d "$emxpath"; then
|
---|
59 | # emxpath="`./UU/loc . /emx c:/emx d:/emx e:/emx f:/emx g:/emx h:/emx /emx`"
|
---|
60 | #fi
|
---|
61 | #emxpath="`which gcc.exe`"
|
---|
62 | emxpath="`./UU/loc gcc.exe /@unixroot/usr/bin $trypath`"
|
---|
63 | emxpath="`dirname $emxpath`"
|
---|
64 | emxpath="`dirname $emxpath`"
|
---|
65 | if test ! -d "$emxpath"; then
|
---|
66 | emxpath="$UNIXROOT/usr"
|
---|
67 | fi
|
---|
68 |
|
---|
69 | if test ! -d "$libemx"; then
|
---|
70 | libemx="$emxpath/lib"
|
---|
71 | fi
|
---|
72 | if test ! -d "$libemx"; then
|
---|
73 | if test -d "$LIBRARY_PATH"; then
|
---|
74 | libemx="$LIBRARY_PATH"
|
---|
75 | else
|
---|
76 | libemx="`./UU/loc . X $UNIXROOT/usr/lib $UNIXROOT/lib $UNIXROOT/usr/local/lib`"
|
---|
77 | fi
|
---|
78 | fi
|
---|
79 |
|
---|
80 | if test ! -d "$usrinc"; then
|
---|
81 | if test -d "$emxpath/include"; then
|
---|
82 | usrinc="$emxpath/include"
|
---|
83 | else
|
---|
84 | if test -d "$C_INCLUDE_PATH"; then
|
---|
85 | usrinc="$C_INCLUDE_PATH"
|
---|
86 | else
|
---|
87 | usrinc="`./UU/loc . X $UNIXROOT/usr/include $UNIXROOT/usr/local/include`"
|
---|
88 | fi
|
---|
89 | fi
|
---|
90 | fi
|
---|
91 |
|
---|
92 | #rsx="`./UU/loc rsx.exe undef $pth`"
|
---|
93 |
|
---|
94 | if test "$libemx" = "X"; then echo "Cannot find C library!" >&2; fi
|
---|
95 |
|
---|
96 | # Acute backslashitis:
|
---|
97 | libpth="`echo \"$LIBRARY_PATH\" | tr ';\\\' ' /'`"
|
---|
98 | libpth="$libpth $libemx"
|
---|
99 |
|
---|
100 | so='dll'
|
---|
101 |
|
---|
102 | # Additional definitions:
|
---|
103 |
|
---|
104 | firstmakefile='GNUmakefile'
|
---|
105 | exe_ext='.exe'
|
---|
106 |
|
---|
107 | # We provide it
|
---|
108 | i_dlfcn='define'
|
---|
109 |
|
---|
110 | # The default one uses exponential notation between 0.0001 and 0.1
|
---|
111 | d_Gconvert='gcvt_os2((x),(n),(b))'
|
---|
112 |
|
---|
113 | cat > UU/uselongdouble.cbu <<'EOCBU'
|
---|
114 | # This script UU/uselongdouble.cbu will get 'called-back' by Configure
|
---|
115 | # after it has prompted the user for whether to use long doubles.
|
---|
116 | # If we will use them, let Configure choose us a Gconvert.
|
---|
117 | case "$uselongdouble:$d_longdbl:$d_sqrtl:$d_modfl" in
|
---|
118 | "$define:$define:$define:$define") d_Gconvert='' ;;
|
---|
119 | esac
|
---|
120 | EOCBU
|
---|
121 |
|
---|
122 | # -Zomf build has a problem with _exit() *flushing*, so the test
|
---|
123 | # gets confused:
|
---|
124 | fflushNULL="define"
|
---|
125 |
|
---|
126 | # Not listed in dynamic_ext, but needed for static_ext nevertheless
|
---|
127 | extra_static_ext="OS2::DLL"
|
---|
128 |
|
---|
129 | d_shrplib='define'
|
---|
130 | useshrplib='true'
|
---|
131 | obj_ext='.o'
|
---|
132 | lib_ext='.a'
|
---|
133 | ar='ar'
|
---|
134 | plibext='.a'
|
---|
135 | d_fork='define'
|
---|
136 | lddlflags="-Zdll -Zomf "
|
---|
137 | # Recursive regmatch may eat 2.5M of stack alone.
|
---|
138 | ldflags='-Zomf -Zhigh-mem -Zstack 32000 '
|
---|
139 | ccflags="-DDOSISH -DOS2=2 -DEMBED -I."
|
---|
140 | use_clib='libc_dll'
|
---|
141 | usedl='define'
|
---|
142 |
|
---|
143 |
|
---|
144 | # indented to miss config.sh
|
---|
145 | _ar="$ar"
|
---|
146 |
|
---|
147 | # To get into config.sh (should start at the beginning of line)
|
---|
148 | # or you can put it into config.over.
|
---|
149 | plibext="$plibext"
|
---|
150 | # plibext is not needed anymore. Just directly set $libperl.
|
---|
151 | libperl="libperl${plibext}"
|
---|
152 |
|
---|
153 |
|
---|
154 | libc="$libemx/$use_clib$lib_ext"
|
---|
155 |
|
---|
156 | if test -r "$libemx/libc_alias$lib_ext"; then
|
---|
157 | libnames="$libemx/libc_alias$lib_ext"
|
---|
158 | fi
|
---|
159 | # otherwise puts -lc ???
|
---|
160 |
|
---|
161 | # [Maybe we should just remove c from $libswanted ?]
|
---|
162 |
|
---|
163 | # Test would pick up wrong rand, so we hardwire the value for random()
|
---|
164 | libs='-lsocket'
|
---|
165 | randbits=31
|
---|
166 | archobjs="os2$obj_ext dl_os2$obj_ext"
|
---|
167 |
|
---|
168 | # Run files without extension with sh:
|
---|
169 | EXECSHELL=sh
|
---|
170 |
|
---|
171 | cccdlflags='-Zdll'
|
---|
172 | dlsrc='dl_dlopen.xs'
|
---|
173 | ld='gcc'
|
---|
174 |
|
---|
175 | #cppflags='-DDOSISH -DOS2=2 -DEMBED -I.'
|
---|
176 |
|
---|
177 | # for speedup: (some patches to ungetc are also needed):
|
---|
178 | # Note that without this guy tests 8 and 10 of io/tell.t fail, with it 11 fails
|
---|
179 |
|
---|
180 | stdstdunder=`echo "#include <stdio.h>" | cpp | egrep -c "char +\* +_ptr"`
|
---|
181 | d_stdstdio='define'
|
---|
182 | d_stdiobase='define'
|
---|
183 | d_stdio_ptr_lval='define'
|
---|
184 | d_stdio_cnt_lval='define'
|
---|
185 |
|
---|
186 | if test "$stdstdunder" = 0; then
|
---|
187 | stdio_ptr='((fp)->ptr)'
|
---|
188 | stdio_cnt='((fp)->rcount)'
|
---|
189 | stdio_base='((fp)->buffer)'
|
---|
190 | stdio_bufsiz='((fp)->rcount + (fp)->ptr - (fp)->buffer)'
|
---|
191 | ccflags="$ccflags -DMYTTYNAME"
|
---|
192 | myttyname='define'
|
---|
193 | else
|
---|
194 | stdio_ptr='((fp)->_ptr)'
|
---|
195 | stdio_cnt='((fp)->_rcount)'
|
---|
196 | stdio_base='((fp)->_buffer)'
|
---|
197 | stdio_bufsiz='((fp)->_rcount + (fp)->_ptr - (fp)->_buffer)'
|
---|
198 | fi
|
---|
199 |
|
---|
200 | # to put into config.sh
|
---|
201 | myttyname="$myttyname"
|
---|
202 |
|
---|
203 | # To have manpages installed
|
---|
204 | nroff='nroff.cmd'
|
---|
205 | # above will be overwritten otherwise, indented to avoid config.sh
|
---|
206 | _nroff='nroff.cmd'
|
---|
207 |
|
---|
208 | # should be handled automatically by Configure now.
|
---|
209 | ln='cp'
|
---|
210 | # Will be rewritten otherwise, indented to not put in config.sh
|
---|
211 | _ln='cp'
|
---|
212 | lns='cp'
|
---|
213 |
|
---|
214 | nm_opt='-pa'
|
---|
215 |
|
---|
216 | ####### We define these functions ourselves
|
---|
217 |
|
---|
218 | d_strtoll='define'
|
---|
219 | d_strtoull='define'
|
---|
220 | d_getprior='define'
|
---|
221 | d_setprior='define'
|
---|
222 | d_usleep='define'
|
---|
223 | d_usleepproto='define'
|
---|
224 |
|
---|
225 | d_link='undef'
|
---|
226 | dont_use_nlink='define'
|
---|
227 | # no posix (aka hard) links for us!
|
---|
228 |
|
---|
229 | # The next two are commented. pdksh handles #!, extproc gives no path part.
|
---|
230 | # sharpbang='extproc '
|
---|
231 | # shsharp='false'
|
---|
232 |
|
---|
233 | # Commented:
|
---|
234 | #startsh='extproc ksh\\n#! sh'
|
---|
235 |
|
---|
236 | # Find patch:
|
---|
237 | gnupatch='patch'
|
---|
238 | if (gnupatch -v || gnupatch --version) 2>&1 >/dev/null; then
|
---|
239 | gnupatch=gnupatch
|
---|
240 | else
|
---|
241 | if (gpatch -v || gpatch --version) 2>&1 >/dev/null; then
|
---|
242 | gnupatch=gpatch
|
---|
243 | else
|
---|
244 | # They may have a special PATH during configuring
|
---|
245 | if (patch -v || patch --version) 2>&1 >/dev/null; then
|
---|
246 | gnupatch="`./UU/loc patch.exe undef $pth`"
|
---|
247 | fi
|
---|
248 | fi
|
---|
249 | fi
|
---|
250 |
|
---|
251 | for f in less.exe less.sh less.ksh less.cmd more.exe more.sh more.ksh more.cmd ; do
|
---|
252 | if test -z "$pager"; then
|
---|
253 | pager="`./UU/loc $f '' $pth`"
|
---|
254 | fi
|
---|
255 | done
|
---|
256 | if test -z "$pager"; then
|
---|
257 | pager='cmd /c more'
|
---|
258 | fi
|
---|
259 |
|
---|
260 | # Apply patches if needed
|
---|
261 | case "$0$running_c_cmd" in
|
---|
262 | *[/\\]Configure|*[/\\]Configure.|Configure|Configure.) # Skip Configure.cmd
|
---|
263 | if test "Xyes" = "X$configure_cmd_loop"; then
|
---|
264 | cat <<EOC >&2
|
---|
265 | !!!
|
---|
266 | !!! PANIC: Loop of self-invocations detected, aborting!
|
---|
267 | !!!
|
---|
268 | EOC
|
---|
269 | exit 20
|
---|
270 | fi
|
---|
271 | configure_cmd_loop=yes
|
---|
272 | export configure_cmd_loop
|
---|
273 |
|
---|
274 | configure_needs_patch=''
|
---|
275 | if test -s ./os2/diff.configure; then
|
---|
276 | if ! grep "^#OS2-PATCH-APPLIED" ./Configure > /dev/null; then
|
---|
277 | configure_needs_patch=yes
|
---|
278 | fi
|
---|
279 | fi
|
---|
280 | if test -n "$configure_needs_patch"; then
|
---|
281 | # Not patched!
|
---|
282 | # Restore the initial command line arguments
|
---|
283 | if test -f ./Configure.cmd ; then
|
---|
284 | cat <<EOC >&2
|
---|
285 | !!!
|
---|
286 | !!! I see that what is running is ./Configure.
|
---|
287 | !!! ./Configure is not patched, but ./Configure.cmd exists.
|
---|
288 | !!!
|
---|
289 | !!! You are supposed to run Configure.cmd, not Configure
|
---|
290 | !!! after an automagic patching.
|
---|
291 | !!!
|
---|
292 | !!! If you insist on running Configure, you may
|
---|
293 | !!! patch it manually from ./os2/diff.configure.
|
---|
294 | !!!
|
---|
295 | !!! However, I went through incredible hoolahoops, and I expect I can
|
---|
296 | !!! auto-restart Configure.cmd myself. I will start it with arguments:
|
---|
297 | !!!
|
---|
298 | !!! Configure.cmd $args_exp
|
---|
299 | !!!
|
---|
300 | EOC
|
---|
301 | rp='Do you want to auto-restart Configure.cmd?'
|
---|
302 | dflt='y'
|
---|
303 | . UU/myread
|
---|
304 | case "$ans" in
|
---|
305 | [yY]) echo >&4 "Okay, continuing." ;;
|
---|
306 | *) echo >&4 "Okay, bye."
|
---|
307 | exit 2
|
---|
308 | ;;
|
---|
309 | esac
|
---|
310 | eval "set X $args_exp";
|
---|
311 | shift;
|
---|
312 | # Restore the output
|
---|
313 | exec Configure.cmd "$@" 1>&2
|
---|
314 | exit 2
|
---|
315 | fi
|
---|
316 | cat <<EOC >&2
|
---|
317 | !!!
|
---|
318 | !!! You did not patch ./Configure!
|
---|
319 | !!! I can create Configure.cmd and patch it from ./os2/diff.configure with the command
|
---|
320 | !!!
|
---|
321 | !!! $gnupatch -b -p1 --output=Configure.cmd <./os2/diff.configure 2>&1 | tee 00_auto_patch
|
---|
322 | EOC
|
---|
323 | rp='Do you want to auto-patch Configure to Configure.cmd?'
|
---|
324 | dflt='y'
|
---|
325 | . UU/myread
|
---|
326 | case "$ans" in
|
---|
327 | [yY]) echo >&4 "Okay, continuing." ;;
|
---|
328 | *) echo >&4 "Okay, bye."
|
---|
329 | exit 2
|
---|
330 | ;;
|
---|
331 | esac
|
---|
332 | ($gnupatch -b -p1 --output=Configure.cmd <./os2/diff.configure 2>&1 | tee 00_auto_patch) >&2
|
---|
333 | cat <<EOC >&2
|
---|
334 | !!!
|
---|
335 | !!! The report of patching is copied to 00_auto_patch.
|
---|
336 | !!! Now we need to restart Configure.cmd with all the options.
|
---|
337 | !!!
|
---|
338 | EOC
|
---|
339 | echo "extproc sh" > Configure.ctm
|
---|
340 | ( cat Configure.cmd >> Configure.ctm && mv -f Configure.ctm Configure.cmd ) || (echo "!!! Failure to add extproc-line to Configure.cmd." >&2 ; exit 21)
|
---|
341 | cat <<EOC >&2
|
---|
342 | !!! I went through incredible hoolahoops, and I expect I can
|
---|
343 | !!! auto-restart Configure.cmd myself. I will start it with arguments:
|
---|
344 | !!!
|
---|
345 | !!! Configure.cmd $args_exp
|
---|
346 | !!!
|
---|
347 | EOC
|
---|
348 | rp='Do you want to auto-restart Configure.cmd?'
|
---|
349 | dflt='y'
|
---|
350 | . UU/myread
|
---|
351 | case "$ans" in
|
---|
352 | [yY]) echo >&4 "Okay, continuing." ;;
|
---|
353 | *) echo >&4 "Okay, bye."
|
---|
354 | exit 2
|
---|
355 | ;;
|
---|
356 | esac
|
---|
357 | eval "set X $args_exp";
|
---|
358 | shift;
|
---|
359 | exec Configure.cmd "$@" 1>&2
|
---|
360 | exit 2
|
---|
361 | else
|
---|
362 | if test -s ./os2/diff.configure; then
|
---|
363 | echo "!!! Apparently we are running a patched Configure." >&2
|
---|
364 | else
|
---|
365 | echo "!!! Apparently there is no need to patch Configure." >&2
|
---|
366 | fi
|
---|
367 | fi
|
---|
368 | ;;
|
---|
369 | *) echo "!!! Apparently we are running a renamed Configure: '$0'." >&2
|
---|
370 | esac
|
---|
371 |
|
---|
372 | # This script UU/usethreads.cbu will get 'called-back' by Configure
|
---|
373 | # after it has prompted the user for whether to use threads.
|
---|
374 | cat > UU/usethreads.cbu <<'EOCBU'
|
---|
375 | case "$usethreads" in
|
---|
376 | $define|true|[yY]*)
|
---|
377 | ccflags="$ccflags -DUSE_THREADS"
|
---|
378 | cppflags="$cppflags -DUSE_THREADS" # Do we really need to set this?
|
---|
379 | ;;
|
---|
380 | esac
|
---|
381 | EOCBU
|
---|
382 |
|
---|
383 | if test -z "$cryptlib"; then
|
---|
384 | cryptlib=`UU/loc crypt$lib_ext "" $libpth`
|
---|
385 | if $test -n "$cryptlib"; then
|
---|
386 | cryptlib=-lcrypt
|
---|
387 | else
|
---|
388 | cryptlib=`UU/loc ufc$lib_ext "" $libpth`
|
---|
389 | if $test -n "$cryptlib"; then
|
---|
390 | cryptlib=-lufc
|
---|
391 | fi
|
---|
392 | fi
|
---|
393 | fi
|
---|
394 | if test -n "$cryptlib"; then
|
---|
395 | libs="$libs $cryptlib"
|
---|
396 | # d_crypt=define
|
---|
397 | fi
|
---|
398 |
|
---|
399 | # Now install the external modules. We are in the ./hints directory.
|
---|
400 |
|
---|
401 | cd ./os2/OS2
|
---|
402 |
|
---|
403 | if ! test -d ../../ext/OS2 ; then
|
---|
404 | mkdir ../../ext/OS2
|
---|
405 | fi
|
---|
406 |
|
---|
407 | cp -rfu * ../../ext/OS2/
|
---|
408 |
|
---|
409 | # Install tests:
|
---|
410 |
|
---|
411 | cp -uf ../*.t ../../t/lib
|
---|
412 | for xxx in * ; do
|
---|
413 | if $test -d $xxx/t; then
|
---|
414 | cp -uf $xxx/t/*.t ../../t/lib
|
---|
415 | else
|
---|
416 | if $test -d $xxx; then
|
---|
417 | cd $xxx
|
---|
418 | for yyy in * ; do
|
---|
419 | if $test -d $yyy/t; then
|
---|
420 | cp -uf $yyy/t/*.t ../../t/lib
|
---|
421 | fi
|
---|
422 | done
|
---|
423 | cd ..
|
---|
424 | fi
|
---|
425 | fi
|
---|
426 | done
|
---|
427 |
|
---|
428 | case "$ldlibpthname" in
|
---|
429 | '') ldlibpthname=none ;;
|
---|
430 | esac
|
---|
431 |
|
---|
432 | # Now go back
|
---|
433 | cd ../..
|
---|
434 | cp os2/*.t t/lib
|
---|