source: trunk/essentials/dev-lang/perl/hints/os2.sh

Last change on this file was 3220, checked in by bird, 18 years ago

Build a.out and link omf. Drop -Zexe.

  • Property svn:eol-style set to native
File size: 10.5 KB
Line 
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
14path_sep=\;
15
16if test -f $sh.exe; then sh=$sh.exe; fi
17
18startsh="#!$sh"
19cc='gcc'
20
21# Make denser object files and DLL
22case "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 ;;
27esac
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
47usrinc="`./UU/loc stdlib.h $usrinc`"
48usrinc="`dirname $usrinc | tr '\\\' '/'`"
49libemx="`dirname $libemx | tr '\\\' '/'`"
50
51if test -d $tryman/man1; then
52 sysman="$tryman/man1"
53else
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`"
55fi
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`"
62emxpath="`./UU/loc gcc.exe /@unixroot/usr/bin $trypath`"
63emxpath="`dirname $emxpath`"
64emxpath="`dirname $emxpath`"
65if test ! -d "$emxpath"; then
66 emxpath="$UNIXROOT/usr"
67fi
68
69if test ! -d "$libemx"; then
70 libemx="$emxpath/lib"
71fi
72if 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
78fi
79
80if 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
90fi
91
92#rsx="`./UU/loc rsx.exe undef $pth`"
93
94if test "$libemx" = "X"; then echo "Cannot find C library!" >&2; fi
95
96# Acute backslashitis:
97libpth="`echo \"$LIBRARY_PATH\" | tr ';\\\' ' /'`"
98libpth="$libpth $libemx"
99
100so='dll'
101
102# Additional definitions:
103
104firstmakefile='GNUmakefile'
105exe_ext='.exe'
106
107# We provide it
108i_dlfcn='define'
109
110# The default one uses exponential notation between 0.0001 and 0.1
111d_Gconvert='gcvt_os2((x),(n),(b))'
112
113cat > 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.
117case "$uselongdouble:$d_longdbl:$d_sqrtl:$d_modfl" in
118"$define:$define:$define:$define") d_Gconvert='' ;;
119esac
120EOCBU
121
122# -Zomf build has a problem with _exit() *flushing*, so the test
123# gets confused:
124fflushNULL="define"
125
126# Not listed in dynamic_ext, but needed for static_ext nevertheless
127extra_static_ext="OS2::DLL"
128
129d_shrplib='define'
130useshrplib='true'
131obj_ext='.o'
132lib_ext='.a'
133ar='ar'
134plibext='.a'
135d_fork='define'
136lddlflags="-Zdll -Zomf "
137# Recursive regmatch may eat 2.5M of stack alone.
138ldflags='-Zomf -Zhigh-mem -Zstack 32000 '
139ccflags="-DDOSISH -DOS2=2 -DEMBED -I."
140use_clib='libc_dll'
141usedl='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.
149plibext="$plibext"
150# plibext is not needed anymore. Just directly set $libperl.
151libperl="libperl${plibext}"
152
153
154libc="$libemx/$use_clib$lib_ext"
155
156if test -r "$libemx/libc_alias$lib_ext"; then
157 libnames="$libemx/libc_alias$lib_ext"
158fi
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()
164libs='-lsocket'
165randbits=31
166archobjs="os2$obj_ext dl_os2$obj_ext"
167
168# Run files without extension with sh:
169EXECSHELL=sh
170
171cccdlflags='-Zdll'
172dlsrc='dl_dlopen.xs'
173ld='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
180stdstdunder=`echo "#include <stdio.h>" | cpp | egrep -c "char +\* +_ptr"`
181d_stdstdio='define'
182d_stdiobase='define'
183d_stdio_ptr_lval='define'
184d_stdio_cnt_lval='define'
185
186if 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'
193else
194 stdio_ptr='((fp)->_ptr)'
195 stdio_cnt='((fp)->_rcount)'
196 stdio_base='((fp)->_buffer)'
197 stdio_bufsiz='((fp)->_rcount + (fp)->_ptr - (fp)->_buffer)'
198fi
199
200# to put into config.sh
201myttyname="$myttyname"
202
203# To have manpages installed
204nroff='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.
209ln='cp'
210# Will be rewritten otherwise, indented to not put in config.sh
211 _ln='cp'
212lns='cp'
213
214nm_opt='-pa'
215
216####### We define these functions ourselves
217
218d_strtoll='define'
219d_strtoull='define'
220d_getprior='define'
221d_setprior='define'
222d_usleep='define'
223d_usleepproto='define'
224
225d_link='undef'
226dont_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:
237gnupatch='patch'
238if (gnupatch -v || gnupatch --version) 2>&1 >/dev/null; then
239 gnupatch=gnupatch
240else
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
249fi
250
251for 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
255done
256if test -z "$pager"; then
257 pager='cmd /c more'
258fi
259
260# Apply patches if needed
261case "$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!!!
268EOC
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!!!
300EOC
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
322EOC
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!!!
338EOC
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!!!
347EOC
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
370esac
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.
374cat > UU/usethreads.cbu <<'EOCBU'
375case "$usethreads" in
376$define|true|[yY]*)
377 ccflags="$ccflags -DUSE_THREADS"
378 cppflags="$cppflags -DUSE_THREADS" # Do we really need to set this?
379 ;;
380esac
381EOCBU
382
383if 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
393fi
394if test -n "$cryptlib"; then
395 libs="$libs $cryptlib"
396 # d_crypt=define
397fi
398
399# Now install the external modules. We are in the ./hints directory.
400
401cd ./os2/OS2
402
403if ! test -d ../../ext/OS2 ; then
404 mkdir ../../ext/OS2
405fi
406
407cp -rfu * ../../ext/OS2/
408
409# Install tests:
410
411cp -uf ../*.t ../../t/lib
412for 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
426done
427
428case "$ldlibpthname" in
429'') ldlibpthname=none ;;
430esac
431
432# Now go back
433cd ../..
434cp os2/*.t t/lib
Note: See TracBrowser for help on using the repository browser.