This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Scratch #3008 and introduce $crosscompile and $multiarch
[perl5.git] / hints / os2.sh
index 9bce2a5..5365522 100644 (file)
@@ -6,14 +6,11 @@
 # Trimmed and comments added by 
 #     Andy Dougherty  <doughera@lafcol.lafayette.edu>
 #     Exactly what is required beyond a standard OS/2 installation?
-#     There are notes about "patched pdksh" I do not understand.
+#     (see in README.os2)
 
 # Note that symbol extraction code gives wrong answers (sometimes?) on
 # gethostent and setsid.
 
-# Note that during the .obj compile you need to move the perl.dll file
-# to LIBPATH :-(
-
 # Optimization (GNU make 3.74 cannot be loaded :-():
 emxload -m 30 sh.exe ls.exe tr.exe id.exe sed.exe # make.exe 
 emxload -m 30 grep.exe egrep.exe fgrep.exe cat.exe rm.exe mv.exe cp.exe
@@ -24,15 +21,77 @@ path_sep=\;
 if test -f $sh.exe; then sh=$sh.exe; fi
 
 startsh="#!$sh"
-
-sysman=`../UU/loc . /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`
 cc='gcc'
-usrinc='/emx/include'
-libemx="`../UU/loc . X c:/emx/lib d:/emx/lib e:/emx/lib f:/emx/lib g:/emx/lib h:/emx/lib /emx/lib`"
 
-if test "$libemx" = "X"; then echo "Cannot find C library!"; fi
+# Make denser object files and DLL
+case "X$optimize" in
+  X)
+       optimize="-O2 -fomit-frame-pointer -malign-loops=2 -malign-jumps=2 -malign-functions=2 -s"
+       ld_dll_optimize="-s"
+       ;;
+esac
+
+# Get some standard things (indented to avoid putting in config.sh):
+ oifs="$IFS"
+ IFS=" ;"
+ set $MANPATH
+ tryman="$@"
+ set $LIBRARY_PATH
+ libemx="$@"
+ set $C_INCLUDE_PATH
+ usrinc="$@"
+ IFS="$oifs"
+ tryman="`./UU/loc . /man $tryman`"
+ tryman="`echo $tryman | tr '\\\' '/'`"
+ # indented to avoid having it *two* times at start
+ libemx="`./UU/loc os2.a /emx/lib $libemx`"
+
+usrinc="`./UU/loc stdlib.h /emx/include $usrinc`"
+usrinc="`dirname $usrinc | tr '\\\' '/'`"
+libemx="`dirname $libemx | tr '\\\' '/'`"
+
+if test -d $tryman/man1; then
+  sysman="$tryman/man1"
+else
+  sysman="`./UU/loc . /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`"
+fi
+
+emxpath="`dirname $libemx`"
+if test ! -d "$emxpath"; then 
+  emxpath="`./UU/loc . /emx c:/emx d:/emx e:/emx f:/emx g:/emx h:/emx /emx`"
+fi
+
+if test ! -d "$libemx"; then 
+  libemx="$emxpath/lib"
+fi
+if test ! -d "$libemx"; then 
+  if test -d "$LIBRARY_PATH"; then
+    libemx="$LIBRARY_PATH"
+  else
+    libemx="`./UU/loc . X c:/emx/lib d:/emx/lib e:/emx/lib f:/emx/lib g:/emx/lib h:/emx/lib /emx/lib`"
+  fi
+fi
+
+if test ! -d "$usrinc"; then 
+  if test -d "$emxpath/include"; then 
+    usrinc="$emxpath/include"
+  else
+    if test -d "$C_INCLUDE_PATH"; then
+      usrinc="$C_INCLUDE_PATH"
+    else
+      usrinc="`./UU/loc . X c:/emx/include d:/emx/include e:/emx/include f:/emx/include g:/emx/include h:/emx/include /emx/include`"
+    fi
+  fi
+fi
+
+rsx="`./UU/loc rsx.exe undef $pth`"
 
-libpth="$libemx/mt $libemx"
+if test "$libemx" = "X"; then echo "Cannot find C library!" >&2; fi
+
+# Acute backslashitis:
+libpth="`echo \"$LIBRARY_PATH\" | tr ';\\\' ' /'`"
+libpth="$libpth $libemx/mt $libemx"
 
 set `emxrev -f emxlibcm`
 emxcrtrev=$5
@@ -53,19 +112,20 @@ aout_obj_ext='.o'
 aout_lib_ext='.a'
 aout_ar='ar'
 aout_plibext='.a'
-aout_lddlflags='-Zdll'
+aout_lddlflags="-Zdll $ld_dll_optimize"
+# Cannot have 32000K stack: get SYS0170  ?!
 if [ $emxcrtrev -ge 50 ]; then 
-    aout_ldflags='-Zexe -Zsmall-conv'
+    aout_ldflags='-Zexe -Zsmall-conv -Zstack 16000'
 else
-    aout_ldflags='-Zexe'
+    aout_ldflags='-Zexe -Zstack 16000'
 fi
 
 # To get into config.sh:
 aout_ldflags="$aout_ldflags"
 
 aout_d_fork='define'
-aout_ccflags='-DPERL_CORE -DDOSISH -DPERL_IS_AOUT -DOS2=2 -DEMBED -I. -DPACK_MALLOC -DDEBUGGING_MSTATS -DTWO_POT_OPTIMIZE -DPERL_EMERGENCY_SBRK'
-aout_cppflags='-DPERL_CORE -DDOSISH -DPERL_IS_AOUT -DOS2=2 -DEMBED -I. -DPACK_MALLOC -DDEBUGGING_MSTATS -DTWO_POT_OPTIMIZE -DPERL_EMERGENCY_SBRK'
+aout_ccflags='-DPERL_CORE -DDOSISH -DPERL_IS_AOUT -DOS2=2 -DEMBED -I.'
+aout_cppflags='-DPERL_CORE -DDOSISH -DPERL_IS_AOUT -DOS2=2 -DEMBED -I.'
 aout_use_clib='c'
 aout_usedl='undef'
 aout_archobjs="os2.o dl_os2.o"
@@ -101,18 +161,21 @@ else
     else
        d_fork='undef'
     fi
-    lddlflags='-Zdll -Zomf -Zmt -Zcrtdll'
+    lddlflags="-Zdll -Zomf -Zmt -Zcrtdll $ld_dll_optimize"
     # Recursive regmatch may eat 2.5M of stack alone.
     ldflags='-Zexe -Zomf -Zmt -Zcrtdll -Zstack 32000'
     if [ $emxcrtrev -ge 50 ]; then 
-       ccflags='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I. -DPACK_MALLOC -DDEBUGGING_MSTATS -DTWO_POT_OPTIMIZE -DPERL_EMERGENCY_SBRK'
+       ccflags='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I.'
     else
-       ccflags='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I. -DPACK_MALLOC -DDEBUGGING_MSTATS -DEMX_BAD_SBRK'
+       ccflags='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I. -DEMX_BAD_SBRK'
     fi
     use_clib='c_import'
     usedl='define'
 fi
 
+# indented to miss config.sh
+  _ar="$ar"
+
 # To get into config.sh (should start at the beginning of line)
 # or you can put it into config.over.
 plibext="$plibext"
@@ -187,9 +250,7 @@ nm_opt='-p'
 d_getprior='define'
 d_setprior='define'
 
-####### All the rest is commented
-
-# The next two are commented. pdksh handles #!
+# The next two are commented. pdksh handles #!, extproc gives no path part.
 # sharpbang='extproc '
 # shsharp='false'
 
@@ -198,11 +259,26 @@ d_setprior='define'
 
 # Copy pod:
 
-cp ../README.os2 ../pod/perlos2.pod
+cp ./README.os2 ./pod/perlos2.pod
+
+# This script UU/usethreads.cbu will get 'called-back' by Configure 
+# after it has prompted the user for whether to use threads.
+cat > UU/usethreads.cbu <<'EOCBU'
+case "$usethreads" in
+$define|true|[yY]*)
+       ccflags="-Zmt $ccflags"
+        cppflags="-Zmt $cppflags"  # Do we really need to set this?
+        aout_ccflags="-DUSE_THREADS $aout_ccflags"
+        aout_cppflags="-DUSE_THREADS $aout_cppflags"
+        aout_lddlflags="-Zmt $aout_lddlflags"
+        aout_ldflags="-Zmt $aout_ldflags"
+       ;;
+esac
+EOCBU
 
 # Now install the external modules. We are in the ./hints directory.
 
-cd ../os2/OS2
+cd ./os2/OS2
 
 if ! test -d ../../ext/OS2 ; then
    mkdir ../../ext/OS2
@@ -228,6 +304,5 @@ for xxx in * ; do
        fi
 done
 
-
 # Now go back
-cd ../../hints
+cd ../..