Ilya Zakharevich on Sun, 30 Nov 1997 01:54:49 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Os/2 portablity patch for pari2.0-alpha


Karim Belabas writes:
>    while preparing the 2.0.1.alpha update, I finally had a look at your OS/2
> patch (msg 19).
> 
> 1) I think your diff was not complete: it can't possibly work the way it is
> now. Presumably, modifications to Configure are missing (we need to set
> osname=os2 somewhere. As well, your introduce variables make_sh, shell_q,
> ln_s, exe_suff which are not defined anywhere).

Ouch!  My edited ./Configure disappeared, this is why `diff' could not
find it!  Fortunately, I saved a copy in ./config/, see below.

> 2) your change of doc/Makefile to make_doc.SH is problematic. We don't want
> to extract this file, since I want it to be usable even if Configure fails
> completely. That's the reason why there's the ugly target "force" which
> substitutes @version@ (we don't want to expand this particular @version@).

This is simple.  Ship both doc/Makefile and config/doc_make.SH.  Then
there is a fallback version if Configure fails (which works on most
platforms), which is substituted by a portable version if Configure
succeeds.

In the patch below I also added some other configure/ ===> config/
changes.  Apply them _after_ the previous patch, since there may be a
conflict for TOPmakefile.SH.

Enjoy,
Ilya

--- ./Configure~	Fri Nov 14 05:55:44 1997
+++ ./Configure	Sat Nov 22 00:27:30 1997
@@ -12,7 +12,7 @@ TOP=`pwd`
 dflt_conf_file=dft.Config.in
 
 # Directories
-config_dir=configure
+config_dir=config
 src_dir=src
 perl_dir=perl
 emacs_dir=emacs
@@ -96,6 +96,8 @@ the questions end, edit the file "$dflt_
 ==========================================================================
 EOT
 
+if test -z "$OS2_SHELL"; then dir_sep=':' ; else dir_sep=';' ; fi
+
 #
 # Proper PATH setting
 #
@@ -132,19 +134,19 @@ pth='               \
 
 for p in $pth
 do
-  case ":$PATH:" in
-  *:$p:*) ;;
-  *) test -d $p && PATH=$PATH:$p ;;
+  case "$dir_sep$PATH$dir_sep" in
+  *$dir_sep$p$dir_sep*) ;;
+  *) test -d $p && PATH=$PATH$dir_sep$p ;;
   esac
 done
-PATH=.:$PATH; export PATH
+PATH=.$dir_sep$PATH; export PATH
 
 #
 #  We might need the following :
 #
 echo Looking for some tools first ...
-list='as ld cc acc gcc g++ zcat gunzip ranlib perl etags emacs'
-pth=`echo $PATH | sed -e 's/:/ /g'`
+list='as ld cc acc gcc g++ zcat gunzip gzip ranlib perl etags emacs'
+pth=`echo $PATH | sed -e "s/$dir_sep/ /g" | sed -e 's/\\\\/\//g'`
 for file in $list; do
   x=`./locate $file '' $pth`
   case "$file" in
@@ -153,10 +155,15 @@ for file in $list; do
   esac
   case $x in
    /*) echo ..."$file is $x";;
+   ?:/*) echo ..."$file is $x";;
    *)  echo ..."I could not find $file." >&2;;
   esac
 done
 
+if test -z "$zcat" -a -n "$gzip" ; then zcat="$gzip -dc" ; fi
+if test -z "$gunzip" -a -n "$gzip" ; then gunzip="$gzip -d" ; fi
+if test -z "$gplusplus" -a -n "$gcc" ; then gplusplus="$gcc -x c++" ; fi
+
 echo "Checking echo to see how to suppress newlines..."
 (echo "hi there\c" ; echo " ") > echotmp
 if grep c echotmp >/dev/null 2>&1 ; then
@@ -176,7 +183,7 @@ rm -f echotmp
 # ask user.
 #
 arch=none; osname=unknown
-myuname=`( (uname -a) 2>/dev/null || arch) 2>&1`
+myuname=`(uname -a) 2>/dev/null || arch 2>&1`
 if test -d /NextApps; then myuname=nextstep; fi
 if test -n "$myuname"; then
   myuname=`echo $myuname | sed -e 's/^[^=]*=//' -e 's/\///g' | \
@@ -186,7 +193,7 @@ if test -n "$myuname"; then
   case "$osname" in
   fx2800)   arch=fx2800; osname=concentrix;;
   hp*)      arch=hppa; osname=hpux;;
-  freebsd)  arch=i386;;
+  freebsd|os2)  arch=i386;;
   ultrix)   arch=mips;;
   nextstep) arch=`file /bin/sh | sed 's/.*(for architecture \(.*\))/\1/'`;;
   osf1)     case "$5" in
@@ -300,7 +307,7 @@ ASMFILE=''; create_asmfile=''; depend_as
 kbuildcc='${CC} -c ${CFLAGS} ${CPPFLAGS}'
 kbuildas='${AS} ${ASFLAGS}'
 case "$osname-$asmarch" in
-  linux-i386|freebsd-i386)
+  linux-i386|freebsd-i386|os2-i386)
                 # KERNEL is not in $asmdir but in $objdir because built by make.
                 KERNEL="ker$asmarch.s";         kbuild="$kbuildcc";
                 depend_asmfile="$asmdir/ker$asmarch.c"
@@ -373,8 +380,12 @@ if test -f $Xincroot/X11/Xos.h; then
   test -n "$extralib" && echo ..."Extra Libraries are $extralib"
   echo ..."Found X11 header files in $Xincroot/X11"; fi
 
+case "$osname" in
+    os2) pth=`echo $LIBRARY_PATH | sed 's/;/ /g' | sed 's/\\\\/\//g'` ;;
+    *) pth=$dftpth ;;
+esac
+
 # LIB : GNU Plot
-pth=$dftpth
 lib=gnuplot;  . ./locatelib
 
 # LIB : GNU ReadLine
@@ -399,24 +410,27 @@ if test -n "$readline"; then
   x=`(strings $rl_fullname | grep "\<_rl_copy\>")2>/dev/null` 
   case "$x" in
     _*) addsunview=; which_rl=1 ;;
-    *)  x=`(strings $rl_fullname | grep "LibraryVersion") 2>/dev/null`
+    *)  x=`(strings $rl_fullname | grep "LibraryVersion\|rl_library_version") 2>/dev/null`
         if test -n "$x"; then which_rl=2; else which_rl=1; fi;;
   esac
   # Readline -- Headers
-  pth=' \
-    /usr/local/include/readline       \
-    /usr/include/readline             \
-    /opt/gnu/include/readline         \
-    /usr/unsupported/include/readline \
-    /usr/local/include                \
-    /usr/include                      \
-    /opt/gnu/include                  \
-    /a/lix/share/lix/sys/share/include \
-  ';
+  case "$osname" in
+    os2) pth=`echo $C_INCLUDE_PATH | sed 's/\([^;]\)$/\1;/g' | sed 's/;/\/readline /g' | sed 's/\\\\/\//g'` ;;
+    *) pth=' \
+	/usr/local/include/readline       \
+	/usr/include/readline             \
+	/opt/gnu/include/readline         \
+	/usr/unsupported/include/readline \
+	/usr/local/include                \
+	/usr/include                      \
+	/opt/gnu/include                  \
+	/a/lix/share/lix/sys/share/include \
+      ';;
+  esac
   x=`./locate 'readline.h' '' $pth`
   CPPF_defined=''
   case $x in
-   /*) rl_include=`echo $x | sed -e 's/\/readline.h//'`
+   ?:/*|/*) rl_include=`echo $x | sed -e 's/\/readline.h//'`
        if (grep CPPFunction $x 2>&1 > /dev/null); then
 	 CPPF_defined=yes
        fi;;
@@ -626,7 +640,12 @@ int main(){return 0;}
 int main(){return 1;}
 #endif
 EOT_GNU
-$CC -o /tmp/gnu /tmp/gnu.c
+
+case "$osname-$arch" in
+    os2-*) $CC -Zexe -o /tmp/gnu /tmp/gnu.c ;;
+    *) $CC -o /tmp/gnu /tmp/gnu.c ;;
+esac
+
 if /tmp/gnu; then
   case "$ASFLAGS" in *-P*) ASFLAGS="$ASFLAGS -D__GNUC__";;esac
   case "$osname-$arch" in
@@ -691,6 +710,7 @@ case "$osname-$arch" in
 	  LDFLAGS='-std0 -call_shared /usr/lib/cmplrs/cc/crt0.o';;
       esac;;
   solaris-*) LD=$CC; LDFLAGS=$cflags; runpathprefix=-R ;;
+  os2-*)         LD=$CC; LDFLAGS="$cflags -Zexe" ;;
   *)         LD=$CC; LDFLAGS=$cflags ;;
 esac
 
@@ -766,6 +786,14 @@ echo "No Dynamic Lib"; DLLDFLAGS=no-dyna
 echo "Dynamic Lib linker is  $DLLD  $DLLDFLAGS"
 fi
 
+#
+# Which Copy, shell ?
+#
+case "$osname-$arch" in
+  os2-*)  ln_s=cp  make_sh=sh exe_suff=.exe shell_q='"';;
+  *)      ln_s="ln -s" make_sh="/bin/sh" exe_suff= shell_q="'";;
+esac
+
 if test "$fastread" != yes; then
   cat << EOT
 ==========================================================================
@@ -784,9 +812,9 @@ fi
 #
 #  Long integer ?
 #
-endian=4321; rm -f a.out
-if ($CC endian.c -o a.out 2>/dev/null); then
-  endian=`a.out`;
+endian=4321; rm -f endian
+if ($CC $LDFLAGS endian.c -o endian 2>/dev/null); then
+  endian=`endian`;
 fi
 
 case $endian in 
@@ -922,14 +950,14 @@ for variable in \
   arch asmarch osname pretty \
   AS ASFLAGS CC cflags DBGFLAGS OPTFLAGS LD LDFLAGS DLLD DLLDFLAGS EXTRADLLDFLAGS\
   runpath runpathprefix LDDYN LIBS \
-  ranlib zcat gunzip perl etags emacs \
+  ranlib zcat gunzip perl etags emacs ln_s make_sh \
   ASMFILE KERNEL kbuild create_asmfile depend_asmfile \
   readline completionfun which_rl CPPF_defined rl_include RLINCLUDE RLLIBS \
   sizeof_long endian has_exp2\
   has_getrusage has_times has_ulong has_ftime \
   has_sigrelse has_sigsetmask has_dlopen has_TIOCGWINSZ\
   gnuplot extralib X11 Xincroot which_graphic_lib \
-  TOP config_dir src_dir emacs_dir perl_dir doc_dir \
+  TOP config_dir src_dir emacs_dir perl_dir doc_dir exe_suff shell_q \
   ; do
   eval "echo $variable=\'"'$'"$variable\'" \>\> $dflt_conf_file
 done
diff -pru pari-2.0.alpha.my/config/tar_include pari-2.0.alpha.my.newer/config/tar_include
--- pari-2.0.alpha.my/config/tar_include	Tue Nov 11 14:29:54 1997
+++ pari-2.0.alpha.my.newer/config/tar_include	Sat Nov 29 16:39:46 1997
@@ -1,5 +1,5 @@
 src
-configure
+config
 emacs
 examples
 perl
diff -pru pari-2.0.alpha.my/config/TOPMakefile.SH pari-2.0.alpha.my.newer/config/TOPMakefile.SH
--- pari-2.0.alpha.my/config/TOPMakefile.SH	Fri Nov 21 18:06:20 1997
+++ pari-2.0.alpha.my.newer/config/TOPMakefile.SH	Sat Nov 29 16:40:26 1997
@@ -41,26 +41,26 @@ doc::
 
 undo::
 	@\$(RM) Configure; mv Configure.orig Configure
-	@for dir in configure src doc perl; do \$(RM) -r \$\$dir; \\
+	@for dir in config src doc perl; do \$(RM) -r \$\$dir; \\
 	   mv \$\$dir.orig \$\$dir; done
 	@\$(RM) exp
 
 exp::
-	@for dir in configure src doc perl; do if test -d \$\$dir.orig; then \\
+	@for dir in config src doc perl; do if test -d \$\$dir.orig; then \\
 	   echo "Remove \$\$dir.orig before building an experimental release";\\
 	   exit 1; fi; done
-	for dir in configure src doc perl; do \\
+	for dir in config src doc perl; do \\
 	   mv \$\$dir \$\$dir.orig; cp -pr \$\$dir.orig \$\$dir; done
 	$ln_s src exp
 	sed "s,patch_level=.*,patch_level=exp," \\
-	    < configure.orig/version > configure/version
+	    < config.orig/version > config/version
 
 patch:: pl$next_patch
 pl$next_patch:
 	@if diff -c src exp >/dev/null 2>/dev/null; then :; else \\
 	   echo "'src' should be a link to 'exp'"; exit 1; fi
 	-diff -c Configure.orig Configure > pl$next_patch
-	@for dir in configure src doc perl; do \\
+	@for dir in config src doc perl; do \\
 	   echo "diff -c \$\$dir.orig \$\$dir"; \\
 	   for i in \`find \$\$dir -type f -print\`; do \\
 	   diff -c \`echo \$\$i|sed s,\$\$dir/,\$\$dir.orig/,\` \$\$i; \\
@@ -69,7 +69,7 @@ pl$next_patch:
 update-version::
 	sed -e "s,^patch_level=.*,patch_level=$next_patch," \\
 	    -e "s,^next_patch=.*,next_patch=`expr $next_patch + 1`," \\
-	  < configure.orig/version > configure/version
+	  < config.orig/version > config/version
 
 rel: update-version pl$next_patch
 	\$(RM) exp
diff -pru pari-2.0.alpha.my/doc/usersch4.tex pari-2.0.alpha.my.newer/doc/usersch4.tex
--- pari-2.0.alpha.my/doc/usersch4.tex	Thu Nov 13 17:47:44 1997
+++ pari-2.0.alpha.my.newer/doc/usersch4.tex	Sat Nov 29 16:39:24 1997
@@ -1755,7 +1755,7 @@ in this document, e.g if you happen to w
 exemplifying some fine points that you think were unduly omitted.
 
   The second type is to expand or modify the configure routines and skeleton
-files (the {\tt Configure} script and anything in the {\tt configure/}
+files (the {\tt Configure} script and anything in the {\tt config/}
 subdirectory) so that compilation is possible (or easier, or more efficient)
 on a new system. This includes suppressing any idiosyncrasies in the code
 that would hinder its portability.