Subject: added bootstrap support for IRIX 5
To: None <tech-pkg@netbsd.org>
From: Georg Schwarz <geos@epost.de>
List: tech-pkg
Date: 04/03/2004 20:59:27
I have added bootstrap support for IRIX 5 and maybe earlier (differs quite a bit
from the current IRIX 6.5) to the current pkgsrc. Here are the diffs with a few
remarks. I would appreciate it they could make their way into pkgsrc. Comments
would be welcome.

One problem with IRIX 5 is that it does not have libregex and libfnmatch.
Therefore one first has to manually get some GNU equivalents and install them.
Any suggestion how to improve this and how to properly ingetrage it would be
appreciated.


The main diff:

*** bootstrap/bootstrap.orig    Sat Apr  3 19:59:06 2004
--- bootstrap/bootstrap Sat Apr  3 19:55:53 2004
***************
*** 81,86 ****
--- 81,87 ----
        abi_opsys=$@
        case "$abi_opsys" in
        IRIX)
+       if [ -s /etc/compiler.defaults ]; then
                abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.
defaults`
                isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.def
aults`
                case "$abi" in
***************
*** 96,102 ****
                        abi="64"
                        ;;
                esac
! 
  
                ;;
        esac
--- 97,103 ----
                        abi="64"
                        ;;
                esac
!               fi
  
                ;;
        esac
***************
*** 127,132 ****
--- 128,135 ----
  {
        case "$opsys" in
        IRIX)
+               # no X11 support yet on IRIX 5
+               if test `uname -r` -ge 6; then
                # setting X11BASE to /usr breaks buildlink
                if [ ! -e /usr/X11R6 ]; then
                        ln -sf /usr /usr/X11R6
***************
*** 136,141 ****
--- 139,145 ----
                fi
                patch -d / --forward --quiet -E -p0 \
                        < files/irix.patch 2>/dev/null || true
+               fi # IRIX 6
                ;;
        esac
  }
***************
*** 175,181 ****
        if [ ! -d $wrkdir/$_dst ]; then
                mkdir_p $wrkdir/$_dst
        fi
!       $cpprog -Rp $_src/* $wrkdir/$_dst
  }
  
  build_start=`date`
--- 179,185 ----
        if [ ! -d $wrkdir/$_dst ]; then
                mkdir_p $wrkdir/$_dst
        fi
!       $cpprog -rp $_src/* $wrkdir/$_dst
  }
  
  build_start=`date`
***************
*** 184,189 ****
--- 188,199 ----
  
  overpath=""
  root_user=root
+ buildbmakeargs= # no additional args needed
+ buildsedargs=
+ extraincpath=
+ extralibpath=
+ libregex=
+ libglob=
  case "$opsys" in
  Darwin)
        root_group=wheel
***************
*** 228,233 ****
--- 238,270 ----
        opsys=IRIX
        need_sed=yes
        set_opsys=yes
+       if test `uname -r` -lt 6; then # IRIX 5.X or earlier
+               is_root () {
+                       if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
+                               return 0
+                       fi
+                       return 1
+                       }
+       extraincpath=-I`pwd`
+       extralibpath=-L`pwd`
+       libregex=-lregex
+       libfnmatch=-lglob
+       buildbmakeargs="SHELL=/bin/sh XDEFS=$extraincpath XLIBS='$extralibpath $
libregex' LDFLAGS=$extralibpath LDADD=$libregex"
+       buildsedargs="CPPFLAGS=$extraincpath LDFLAGS='-L../libnbcompat $extralib
path' LIBS='-lnbcompat $libregex'"
+ #   IRIX 5.x's csh seems to have problems with "'s, so we have make use
+ #   /bin/sh.
+ #   IRIX 5.X does not come with regex.h, so get GNU regex-0.12, unpack the
+ #   archive, do a ./configure, then make CFLAGS="-O2 -Olimit 2000" and
+ #   ignore the error of not finding tex.
+ #   Do ar cru libregex.a regex.o and copy libregex.a and regex.h into
+ #   the pkgsrc/bootstrap directory.
+ #   IRIX 5.3 does not come with libfnmatch. You can get it from GNU
+ #   inetutils. Untar the archive, do a configure, then cd into glob, do
+ #   make CFLAGS="-O2". Finally copy libglob.a and fnmatch.h into
+ #   pkgsrc/bootstrap.
+       buildsedflags="CPPFLAGS=$extraincpath LDFLAGS='-L../libnbcompat $extrali
bpath' LIBS='-lnbcompat $libregex'"
+ #   libnbcompat is needed to build sed to have snprintf.
+       fi # IRIX version 5 and lower
        ;;
  Linux)
        if [ -f /etc/debian_version ]; then
***************
*** 500,506 ****
  fi
  
  echo_msg "Installing bmake"
! run_cmd "(cd $wrkdir/bmake; $shprog ./configure --prefix=$prefix --with-defaul
t-sys-path=$prefix/share/mk $configargs && make -f makefile.boot bootstrap && en
v BINDIR=$prefix/bin MANDIR=$prefix/man $BSTRAP_ENV ./bmake -f Makefile install)
"
  
  # build libnbcompat
  echo_msg "Building libnbcompat"
--- 537,543 ----
  fi
  
  echo_msg "Installing bmake"
! run_cmd "(cd $wrkdir/bmake; $shprog ./configure --prefix=$prefix --with-defaul
t-sys-path=$prefix/share/mk $configargs && make -f makefile.boot bootstrap $buil
dbmakeargs && env BINDIR=$prefix/bin MANDIR=$prefix/man $BSTRAP_ENV ./bmake -f M
akefile install)"
  
  # build libnbcompat
  echo_msg "Building libnbcompat"
***************
*** 528,534 ****
  run_cmd "(cd $wrkdir/digest; env $BSTRAP_ENV $shprog ./configure -C --prefix=$
prefix && make && make install)"
  
  # create the digest package's meta files
! digestversion=digest-`$awkprog -F "'" '/^PACKAGE_VERSION=/ {print $2}' $wrkdir
/digest/configure`
  $lsprog -ld $prefix/bin/digest | $awkprog '{ print $5 }' > $wrkdir/digest/.siz
e
  env DIGESTPROG=$prefix/bin/digest PKG_DIGEST=md5 PKG_DBDIR=$pkgdbdir \
        $shprog ./pkg.sh create -d $wrkdir/digest/DESCR -O \
--- 565,571 ----
  run_cmd "(cd $wrkdir/digest; env $BSTRAP_ENV $shprog ./configure -C --prefix=$
prefix && make && make install)"
  
  # create the digest package's meta files
! digestversion=digest-`$awkprog -F"'" '/^PACKAGE_VERSION=/ {print $2}' $wrkdir/
digest/configure`
  $lsprog -ld $prefix/bin/digest | $awkprog '{ print $5 }' > $wrkdir/digest/.siz
e
  env DIGESTPROG=$prefix/bin/digest PKG_DIGEST=md5 PKG_DBDIR=$pkgdbdir \
        $shprog ./pkg.sh create -d $wrkdir/digest/DESCR -O \
***************
*** 539,545 ****
  case "$need_pax" in
  yes)  echo_msg "Installing pax"
        copy_src ../archivers/pax/files pax
!       run_cmd "(cd $wrkdir/pax; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat' LD
FLAGS='-L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure -C --prefix=$pref
ix && $prefix/bin/bmake && $prefix/bin/bmake install)"
        echo "PAX=$prefix/bin/pax" >> ${MKCONF_EXAMPLE}
        pkg_install_args="$pkg_install_args --with-pax=$prefix/bin/pax --with-ta
r=$prefix/bin/tar"
        ;;
--- 576,582 ----
  case "$need_pax" in
  yes)  echo_msg "Installing pax"
        copy_src ../archivers/pax/files pax
!       run_cmd "(cd $wrkdir/pax; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat $ex
traincpath' LDFLAGS='-L../libnbcompat $extralibpath' LIBS='-lnbcompat $libregex'
 $shprog ./configure -C --prefix=$prefix && $prefix/bin/bmake && $prefix/bin/bma
ke install)"
        echo "PAX=$prefix/bin/pax" >> ${MKCONF_EXAMPLE}
        pkg_install_args="$pkg_install_args --with-pax=$prefix/bin/pax --with-ta
r=$prefix/bin/tar"
        ;;
***************
*** 552,558 ****
  case "$need_mtree" in
  yes)  echo_msg "Installing mtree"
        copy_src ../pkgtools/mtree/files mtree
!       run_cmd "(cd $wrkdir/mtree; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat'
LDFLAGS='-L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure -C --prefix=$pr
efix && $prefix/bin/bmake && $prefix/bin/bmake install)"
        pkg_install_args="$pkg_install_args --with-mtree=$prefix/sbin/mtree"
        ;;
  *)    pkg_install_args="$pkg_install_args --with-mtree=$mtreeprog"
--- 589,595 ----
  case "$need_mtree" in
  yes)  echo_msg "Installing mtree"
        copy_src ../pkgtools/mtree/files mtree
!       run_cmd "(cd $wrkdir/mtree; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat $
extraincpath' LDFLAGS='-L../libnbcompat $extralibpath' LIBS='-lnbcompat $libfnma
tch' $shprog ./configure -C --prefix=$prefix && $prefix/bin/bmake && $prefix/bin
/bmake install)"
        pkg_install_args="$pkg_install_args --with-mtree=$prefix/sbin/mtree"
        ;;
  *)    pkg_install_args="$pkg_install_args --with-mtree=$mtreeprog"
***************
*** 563,569 ****
  case "$need_sed" in
  yes)  echo_msg "Installing sed"
        copy_src ../textproc/nbsed/files sed
!       run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV $shprog ./configure -C --prefi
x=$prefix && make && make install)"
        echo "SED=$prefix/bin/nbsed" >> ${MKCONF_EXAMPLE}
        ;;
  esac
--- 600,606 ----
  case "$need_sed" in
  yes)  echo_msg "Installing sed"
        copy_src ../textproc/nbsed/files sed
!       run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV $buildsedargs $shprog ./config
ure -C --prefix=$prefix && make && make install)"
        echo "SED=$prefix/bin/nbsed" >> ${MKCONF_EXAMPLE}
        ;;
  esac
***************
*** 575,581 ****
  if [ "$prefix" = "/usr" ]; then
        pkg_install_mandir="$prefix/share/man"
  fi
! run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat -
I../../libnbcompat' LDFLAGS='-L../libnbcompat -L../../libnbcompat' LIBS='-lnbcom
pat' $shprog ./configure -C --prefix=$prefix --with-pkgdbdir=$pkgdbdir --mandir=
$pkg_install_mandir $pkg_install_args && $prefix/bin/bmake && $prefix/bin/bmake
install)"
  
  # all's ready, install the man page
  echo_msg "Installing packages(7) man page"
--- 612,618 ----
  if [ "$prefix" = "/usr" ]; then
        pkg_install_mandir="$prefix/share/man"
  fi
! run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat -
I../../libnbcompat $extraincpath' LDFLAGS='-L../libnbcompat -L../../libnbcompat
$extralibpath' LIBS='-lnbcompat $libfnmatch $libregex' $shprog ./configure -C --
prefix=$prefix --with-pkgdbdir=$pkgdbdir --mandir=$pkg_install_mandir $pkg_insta
ll_args && $prefix/bin/bmake && $prefix/bin/bmake install)"
  
  # all's ready, install the man page
  echo_msg "Installing packages(7) man page"




This extension is necessary to add extra libs:

*** bootstrap/bmake/makefile.boot.in.orig       Fri Apr  2 20:45:56 2004
--- bootstrap/bmake/makefile.boot.in    Fri Apr  2 21:14:49 2004
***************
*** 27,33 ****
  
  bmake.boot: ${OBJ}
        (cd lst.lib; $(MAKE) -f makefile.boot CC="$(CC)" CFLAGS="-I..
-I${srcdir}/.. ${CFLAGS}" )
!       ${CC} *.o -o $@ @LIBS@
        rm -f *.[ado] */*.[ado] 
  
  bootstrap:    bmake.boot
--- 27,33 ----
  
  bmake.boot: ${OBJ}
        (cd lst.lib; $(MAKE) -f makefile.boot CC="$(CC)" CFLAGS="-I..
-I${srcdir}/.. ${CFLAGS}" )
!       ${CC} *.o -o $@ ${XLIBS} @LIBS@
        rm -f *.[ado] */*.[ado] 
  
  bootstrap:    bmake.boot

IRIX support to bootstrap/pkg.sh. It is important to use nawk here.

*** bootstrap/pkg.sh.orig       Fri Apr  2 23:04:37 2004
--- bootstrap/pkg.sh    Fri Apr  2 23:25:34 2004
***************
*** 50,55 ****
--- 50,65 ----
        rmprog=/bin/rm
        sedprog=/usr/bin/sed
        ;;
+ IRIX*)
+       awkprog=/usr/bin/nawk
+       catprog=/sbin/cat
+       chmodprog=/sbin/chmod
+       cpprog=/sbin/cp
+       lnprog=/sbin/ln
+       mkdirprog=/sbin/mkdir
+       rmprog=/sbin/rm
+       sedprog=/sbin/sed
+       ;;
  Linux)
        awkprog=/usr/bin/awk
        catprog=/bin/cat



textproc/nbsed makes use of _POSIX2_LINE_MAX, which at least on IRIX 5.X is
undefined. 


*** textproc/nbsed/files/defs.h.orig    Sat Apr  3 12:25:26 2004
--- textproc/nbsed/files/defs.h Sat Apr  3 12:25:58 2004
***************
*** 146,148 ****
--- 146,152 ----
  #define       WARNING         2       /* Just print the warning */
  #define       COMPILE         3       /* Print error, count and finish script
*/
  #define       COMPILE2        3       /* Print error, count and finish script
*/
+ 
+ #ifndef _POSIX2_LINE_MAX
+ #define _POSIX2_LINE_MAX 2048
+ #endif


I do not understand what mtree/files/configure tried to do here, but at least
for me it did not work. Commenting out these lines was my only way out. 


*** pkgtools/mtree/files/configure.orig Sat Apr  3 01:52:02 2004
--- pkgtools/mtree/files/configure      Sat Apr  3 00:34:03 2004
***************
*** 4220,4232 ****
  
  done
  
! LIBOBJS="$LIBOBJS fnmatch.$ac_objext"
!           ac_config_links="$ac_config_links
$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h"
  
  
! cat >>confdefs.h <<\_ACEOF
  #define fnmatch rpl_fnmatch
! _ACEOF
  
  
  fi
--- 4220,4232 ----
  
  done
  
! #LIBOBJS="$LIBOBJS fnmatch.$ac_objext"
! #          ac_config_links="$ac_config_links
$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h"
  
  
! #cat >>confdefs.h <<\_ACEOF
  #define fnmatch rpl_fnmatch
! #_ACEOF
  
  
  fi


-- 
Georg Schwarz    http://home.pages.de/~schwarz/
 geos@epost.de     +49 177 8811442