# HG changeset patch
# User John Donoghue
# Date 1525463967 14400
#      Fri May 04 15:59:27 2018 -0400
# Node ID b318b6dacc25e86f7a3738c6b35072e92b59da4a
# Parent  e126cad113f059dfcda9d29fbbb490905dfc39fa
update to allow compile on octave 4.2+(Bug #46521)

* src/base-lu.cc, src/base-lu.h: new files (removed from octave)

* src/configure.ac: dont include octave/config.h, check for removed
  or new octave headers and functions

* src/galois-ops.h: check for define CAST_BINOP_ARGS

* src/galois.cc: include octave/base-lu or base-lu,
  dont include octave/config.h

* src/galois.h: include octave/base-lu or base-lu,
  dont include octave/config.h

* src/gf.cc, src/op-gm-gm.cc, src/op-gm-m.cc, src/op-gm-s.cc,
  src/op-m-gm.cc, src/op-s-gm.cc
  : dont include octave/config.h

* src/ov-galois.cc: dont include octave/config.h or octave/oct-hdf5.h,
  include ls-oct-ascii.h or ls-oct-text.h, check for hdf5 type

* src/ov-galois.h: define OC_REP_TYPE if not defined

* src/m4/octave-forge.m4, src/undef-ah-octave.h: new files

* src/bootstrap: new file

* Makefile: update to call bootstrap

diff -r e126cad113f0 -r b318b6dacc25 Makefile
--- a/Makefile	Thu Apr 14 01:07:22 2016 +0100
+++ b/Makefile	Fri May 04 15:59:27 2018 -0400
@@ -39,8 +39,7 @@
 	-rm -rf $@
 	hg archive --exclude ".hg*" --exclude Makefile --type files $@
 	cd $@/doc && $(MAKE) all
-	cd $@/src && autoconf -Wall
-	-rm -rf $@/src/autom4te.cache
+	cd $@/src && ./bootstrap
 	chmod -R a+rX,u+w,go-w $@
 
 $(RELEASE_TARBALL): $(RELEASE_DIR)
@@ -74,7 +73,7 @@
 	$(OCTAVE) --silent --eval 'pkg install $(RELEASE_TARBALL);'
 
 all:
-	cd src && autoconf -Wall
+	cd src && ./bootstrap
 	cd src && ./configure
 	cd src && $(MAKE) $@
 	cd src && $(MAKE) PKG_ADD PKG_DEL
diff -r e126cad113f0 -r b318b6dacc25 src/Makefile.in
--- a/src/Makefile.in	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/Makefile.in	Fri May 04 15:59:27 2018 -0400
@@ -2,10 +2,9 @@
 OCTAVE    ?= @OCTAVE@
 SED       ?= @SED@
 
-HDF5_CPPFLAGS = @HDF5_CPPFLAGS@
-HDF5_LDFLAGS  = @HDF5_LDFLAGS@
+HDF5_CPPFLAGS = @HDF5_CFLAGS@
 HDF5_LIBS     = @HDF5_LIBS@
-PKG_CPPFLAGS  = @PKG_CPPFLAGS@
+PKG_CPPFLAGS  = -DGALOIS_DISP_PRIVATES @DEFS@
 
 OCT_FILES = \
   __errcore__.oct \
@@ -48,7 +47,7 @@
 	$(MKOCTFILE) $(PKG_CPPFLAGS) $< -o $@
 
 gf.oct: $(GF_OBJECTS)
-	$(MKOCTFILE) $(HDF5_LDFLAGS) $^ $(HDF5_LIBS) -o $@
+	$(MKOCTFILE) $^ $(HDF5_LIBS) -o $@
 
 ov-galois.o: PKG_CPPFLAGS += $(HDF5_CPPFLAGS)
 
@@ -62,9 +61,9 @@
 	-rm -f *.o *.oct PKG_*
 
 distclean: clean
-	-rm -f Makefile config.*
+	-rm -f Makefile config.h config.log config.status oct-alt-includes.h
 
 maintainer-clean: distclean
-	-rm -rf autom4te.cache configure
+	-rm -rf autom4te.cache configure config.h.in aclocal.m4
 
 .PHONY: all clean distclean maintainer-clean
diff -r e126cad113f0 -r b318b6dacc25 src/__errcore__.cc
--- a/src/__errcore__.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/__errcore__.cc	Fri May 04 15:59:27 2018 -0400
@@ -20,6 +20,10 @@
 
 #include <octave/oct.h>
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 DEFUN_DLD (__errcore__, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {@var{c} =} __errcore__ (@var{a}, @var{b})\n\
diff -r e126cad113f0 -r b318b6dacc25 src/__gfweight__.cc
--- a/src/__gfweight__.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/__gfweight__.cc	Fri May 04 15:59:27 2018 -0400
@@ -20,6 +20,10 @@
 
 #include <octave/oct.h>
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 static int
 get_weight (const Array<char>& codeword, const Matrix& gen,
             int weight, int depth, int start, int n, int k)
@@ -68,7 +72,7 @@
   if (k > 128)
     {
       octave_stdout << "__gfweight__: this is likely to take a very long time!!\n";
-      flush_octave_stdout ();
+      OCTAVE__FLUSH_STDOUT ();
     }
 
   Array<char> codeword (dim_vector (n, 1), 0);
diff -r e126cad113f0 -r b318b6dacc25 src/base-lu.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/base-lu.cc	Fri May 04 15:59:27 2018 -0400
@@ -0,0 +1,191 @@
+/*
+
+Copyright (C) 1996-2015 John W. Eaton
+Copyright (C) 2009 VZLU Prague
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "base-lu.h"
+
+template <class lu_type>
+base_lu<lu_type>::base_lu (const lu_type& l, const lu_type& u,
+                           const PermMatrix& p)
+  : a_fact (u), l_fact (l), ipvt (p.transpose ().col_perm_vec ())
+{
+  if (l.columns () != u.rows ())
+    (*current_liboctave_error_handler) ("lu: dimension mismatch");
+}
+
+template <class lu_type>
+bool
+base_lu <lu_type> :: packed (void) const
+{
+  return l_fact.dims () == dim_vector ();
+}
+
+template <class lu_type>
+void
+base_lu <lu_type> :: unpack (void)
+{
+  if (packed ())
+    {
+      l_fact = L ();
+      a_fact = U (); // FIXME: sub-optimal
+      ipvt = getp ();
+    }
+}
+
+template <class lu_type>
+lu_type
+base_lu <lu_type> :: L (void) const
+{
+  if (packed ())
+    {
+      octave_idx_type a_nr = a_fact.rows ();
+      octave_idx_type a_nc = a_fact.cols ();
+      octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc);
+
+      lu_type l (a_nr, mn, lu_elt_type (0.0));
+
+      for (octave_idx_type i = 0; i < a_nr; i++)
+        {
+          if (i < a_nc)
+            l.xelem (i, i) = 1.0;
+
+          for (octave_idx_type j = 0; j < (i < a_nc ? i : a_nc); j++)
+            l.xelem (i, j) = a_fact.xelem (i, j);
+        }
+
+      return l;
+    }
+  else
+    return l_fact;
+}
+
+template <class lu_type>
+lu_type
+base_lu <lu_type> :: U (void) const
+{
+  if (packed ())
+    {
+      octave_idx_type a_nr = a_fact.rows ();
+      octave_idx_type a_nc = a_fact.cols ();
+      octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc);
+
+      lu_type u (mn, a_nc, lu_elt_type (0.0));
+
+      for (octave_idx_type i = 0; i < mn; i++)
+        {
+          for (octave_idx_type j = i; j < a_nc; j++)
+            u.xelem (i, j) = a_fact.xelem (i, j);
+        }
+
+      return u;
+    }
+  else
+    return a_fact;
+}
+
+template <class lu_type>
+lu_type
+base_lu <lu_type> :: Y (void) const
+{
+  if (! packed ())
+    (*current_liboctave_error_handler)
+      ("lu: Y () not implemented for unpacked form");
+  return a_fact;
+}
+
+template <class lu_type>
+Array<octave_idx_type>
+base_lu <lu_type> :: getp (void) const
+{
+  if (packed ())
+    {
+      octave_idx_type a_nr = a_fact.rows ();
+
+      Array<octave_idx_type> pvt (dim_vector (a_nr, 1));
+
+      for (octave_idx_type i = 0; i < a_nr; i++)
+        pvt.xelem (i) = i;
+
+      for (octave_idx_type i = 0; i < ipvt.numel (); i++)
+        {
+          octave_idx_type k = ipvt.xelem (i);
+
+          if (k != i)
+            {
+              octave_idx_type tmp = pvt.xelem (k);
+              pvt.xelem (k) = pvt.xelem (i);
+              pvt.xelem (i) = tmp;
+            }
+        }
+
+      return pvt;
+    }
+  else
+    return ipvt;
+}
+
+template <class lu_type>
+PermMatrix
+base_lu <lu_type> :: P (void) const
+{
+  return PermMatrix (getp (), false);
+}
+
+template <class lu_type>
+ColumnVector
+base_lu <lu_type> :: P_vec (void) const
+{
+  octave_idx_type a_nr = a_fact.rows ();
+
+  ColumnVector p (a_nr);
+
+  Array<octave_idx_type> pvt = getp ();
+
+  for (octave_idx_type i = 0; i < a_nr; i++)
+    p.xelem (i) = static_cast<double> (pvt.xelem (i) + 1);
+
+  return p;
+}
+
+template <class lu_type>
+bool
+base_lu<lu_type>::regular (void) const
+{
+  bool retval = true;
+
+  octave_idx_type k = std::min (a_fact.rows (), a_fact.columns ());
+
+  for (octave_idx_type i = 0; i < k; i++)
+    {
+      if (a_fact(i, i) == lu_elt_type ())
+        {
+          retval = false;
+          break;
+        }
+    }
+
+  return retval;
+}
diff -r e126cad113f0 -r b318b6dacc25 src/base-lu.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/base-lu.h	Fri May 04 15:59:27 2018 -0400
@@ -0,0 +1,87 @@
+/*
+
+Copyright (C) 1996-2015 John W. Eaton
+Copyright (C) 2009 VZLU Prague
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if !defined (octave_base_lu_h)
+#define octave_base_lu_h 1
+
+#include "MArray.h"
+#include "dColVector.h"
+#include "PermMatrix.h"
+
+template <class lu_type>
+class
+base_lu
+{
+public:
+
+  typedef typename lu_type::element_type lu_elt_type;
+
+  base_lu (void)
+    : a_fact (), l_fact (), ipvt () { }
+
+  base_lu (const base_lu& a)
+    : a_fact (a.a_fact), l_fact (a.l_fact), ipvt (a.ipvt) { }
+
+  base_lu (const lu_type& l, const lu_type& u,
+           const PermMatrix& p);
+
+  base_lu& operator = (const base_lu& a)
+  {
+    if (this != &a)
+      {
+        a_fact = a.a_fact;
+        l_fact = a.l_fact;
+        ipvt = a.ipvt;
+      }
+    return *this;
+  }
+
+  virtual ~base_lu (void) { }
+
+  bool packed (void) const;
+
+  void unpack (void);
+
+  lu_type L (void) const;
+
+  lu_type U (void) const;
+
+  lu_type Y (void) const;
+
+  PermMatrix P (void) const;
+
+  ColumnVector P_vec (void) const;
+
+  bool regular (void) const;
+
+protected:
+
+  Array<octave_idx_type> getp (void) const;
+
+  lu_type a_fact;
+  lu_type l_fact;
+
+  Array<octave_idx_type> ipvt;
+};
+
+#endif
diff -r e126cad113f0 -r b318b6dacc25 src/bootstrap
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/bootstrap	Fri May 04 15:59:27 2018 -0400
@@ -0,0 +1,10 @@
+#!/bin/bash
+## Octave-Forge: package bootstrap script
+## Run this to generate the configure script
+
+set -e      # halt if unhandled error
+aclocal
+autoconf    # generate configure script
+autoheader -f
+rm -rf autom4te.cache
+
diff -r e126cad113f0 -r b318b6dacc25 src/configure.ac
--- a/src/configure.ac	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/configure.ac	Fri May 04 15:59:27 2018 -0400
@@ -1,5 +1,14 @@
 AC_PREREQ([2.60])
 AC_INIT([Octave-Forge communications package], [0])
+
+AC_CONFIG_HEADERS([config.h])
+
+# Avoid warnings for redefining AH-generated preprocessor symbols of
+# Octave.
+AH_TOP([#include "undef-ah-octave.h"])
+
+AC_CONFIG_MACRO_DIRS([m4])
+
 AC_ARG_VAR([MKOCTFILE], [mkoctfile compiler helper command])
 AC_ARG_VAR([OCTAVE], [Octave interpreter command])
 AC_CHECK_PROG([MKOCTFILE], mkoctfile, mkoctfile, [])
@@ -7,34 +16,142 @@
 AC_PROG_CXX
 AC_PROG_SED
 
-comm_OCT_EVAL="$OCTAVE --norc --no-history --silent --eval"
+# Checks for octave depreciated symbols
+## Simple symbol alternatives of different Octave versions.
+AC_LANG(C++)
+save_altsyms_CXX="$CXX"
+save_altsyms_CXXFLAGS="$CXXFLAGS"
+save_altsyms_CPPFLAGS="$CPPFLAGS"
+save_altsyms_LDFLAGS="$LDFLAGS"
+save_altsyms_LIBS="$LIBS"
+OCTINCLUDEDIR=${OCTINCLUDEDIR:-`$MKOCTFILE -p INCFLAGS`}
+OCTLIBDIR=${OCTLIBDIR:-`$MKOCTFILE -p OCTLIBDIR`}
+CXX=`${MKOCTFILE} -p CXX`
+CPPFLAGS="$OCTINCLUDEDIR $CPPFLAGS"
+LDFLAGS="-L$OCTLIBDIR $LDFLAGS"
+LIBS="-loctinterp $LIBS"
+
+OF_OCTAVE_LIST_ALT_SYMS([
+[dnl
+  [gripe_nonconformant],
+  [octave::err_nonconformant],
+  [[octave::err_nonconformant ("a",0,0)]],
+  [OCTAVE__ERR_NONCONFORMANT],
+  [[#include <octave/gripes.h>]],
+  [[#include <octave/errwarn.h>]]
+],
+
+[dnl
+  [gripe_wrong_type_arg],
+  [err_wrong_type_arg],
+  [[err_wrong_type_arg ("a", "b")]],
+  [OCTAVE__ERR_WRONG_TYPE_ARG],
+  [[#include <octave/gripes.h>]],
+  [[#include <octave/errwarn.h>]]
+],
+
+[dnl
+  [gripe_square_matrix_required],
+  [err_square_matrix_required],
+  [[err_square_matrix_required ("a", "b")]],
+  [DELOCTAVE__ERR_SQUARE_MATRIX_REQUIRED],
+  [[#include <octave/gripes.h>]],
+  [[#include <octave/errwarn.h>]]
+],
+
+[dnl
+  [gripe_invalid_conversion],
+  [err_invalid_conversion],
+  [[err_invalid_conversion ("a", "b")]],
+  [OCTAVE__ERR_INVALID_CONVERSION],
+  [[#include <octave/gripes.h>]],
+  [[#include <octave/errwarn.h>]]
+],
+
+[dnl
+  [gripe_implicit_conversion],
+  [warn_implicit_conversion],
+  [[warn_implicit_conversion ("a", "b", "c")]],
+  [OCTAVE__WARN_INVALID_CONVERSION],
+  [[#include <octave/gripes.h>]],
+  [[#include <octave/errwarn.h>]]
+],
 
-AC_CACHE_CHECK([for Octave HDF5 preprocessor flags],
-  [comm_cv_hdf5_cppflags],
-  [comm_cv_hdf5_cppflags=`$comm_OCT_EVAL 'disp(octave_config_info.HDF5_CPPFLAGS)' 2>/dev/null`])
-AC_CACHE_CHECK([for Octave HDF5 linker flags],
-  [comm_cv_hdf5_ldflags],
-  [comm_cv_hdf5_ldflags=`$comm_OCT_EVAL 'disp(octave_config_info.HDF5_LDFLAGS)' 2>/dev/null`])
-AC_CACHE_CHECK([for Octave HDF5 libraries],
-  [comm_cv_hdf5_libs],
-  [comm_cv_hdf5_libs=`$comm_OCT_EVAL 'disp(octave_config_info.HDF5_LIBS)' 2>/dev/null`])
-AC_SUBST([HDF5_CPPFLAGS], [$comm_cv_hdf5_cppflags])
-AC_SUBST([HDF5_LDFLAGS], [$comm_cv_hdf5_ldflags])
-AC_SUBST([HDF5_LIBS], [$comm_cv_hdf5_libs])
+[dnl
+  [flush_octave_stdout],
+  [octave::flush_stdout],
+  [[octave::flush_stdout ();]],
+  [OCTAVE__FLUSH_STDOUT],
+  [[]],
+  [[]]
+],
+
+[dnl
+  [is_complex_type],
+  [iscomplex],
+  [[octave_value ().iscomplex ();]],
+  [OV_ISCOMPLEX],
+  [],
+  []
+],
+
+[dnl
+  [is_real_type],
+  [isreal],
+  [[octave_value ().isreal ();]],
+  [OV_ISREAL],
+  [],
+  []
+],
 
-AC_SUBST([PKG_CPPFLAGS], ["-DGALOIS_DISP_PRIVATES"])
+[dnl
+  [is_empty],
+  [isempty],
+  [[octave_value ().isempty ();]],
+  [OV_ISEMPTY],
+  [],
+  []
+]
+
+],[oct-alt-includes.h])
 
+AC_CHECK_HEADERS([octave/oct.h])
+AC_CHECK_HEADERS([octave/base-lu.h])
+AC_CHECK_HEADERS([octave/lu.h])
+AC_CHECK_HEADERS([octave/gripes.h])
+AC_CHECK_HEADERS([octave/errwarn.h])
+AC_CHECK_HEADERS([octave/ovl.h])
+AC_CHECK_HEADERS([octave/oct-obj.h])
+AC_CHECK_HEADERS([octave/ls-oct-ascii.h])
+AC_CHECK_HEADERS([octave/ls-oct-text.h])
+AC_CHECK_HEADERS([octave/oct-obj.h])
+AC_CHECK_HEADERS([octave/interpreter.h])
+
+CXX=$save_altsyms_CXX
+CXXFLAGS=$save_altsyms_CXXFLAGS
+CPPFLAGS=$save_altsyms_CPPFLAGS
+LDFLAGS=$save_altsyms_LDFLAGS
+LIBS=$save_altsyms_LIBS
+
+# check for HDF5
+PKG_CHECK_MODULES([HDF5],[hdf5],
+ [],
+ [AC_MSG_ERROR([hdf5 not found])]
+)
+
+comm_OCT_EVAL="$OCTAVE --norc --no-history --silent --eval"
+ 
 comm_CXXFLAGS=`$MKOCTFILE -p ALL_CXXFLAGS`
 
 AC_CACHE_CHECK([for octave_hdf5_id type],
   [comm_cv_octave_hdf5_id_type],
   [comm_save_CPPFLAGS=$CPPFLAGS
    comm_save_CXXFLAGS=$CXXFLAGS
-   CPPFLAGS="$CPPFLAGS $HDF5_CPPFLAGS"
+   CPPFLAGS="$CPPFLAGS $HDF5_CFLAGS"
    CXXFLAGS="$CXXFLAGS $comm_CXXFLAGS"
    AC_LANG_PUSH(C++)
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-       #include <octave/config.h>
+       #include <octave/oct.h>
        #include <octave/ov-base.h>
        ]], [[
        octave_hdf5_id x;
@@ -45,18 +162,18 @@
    CPPFLAGS=$comm_save_CPPFLAGS
    CXXFLAGS=$comm_save_CXXFLAGS])
 if test $comm_cv_octave_hdf5_id_type = yes; then
-  PKG_CPPFLAGS="$PKG_CPPFLAGS -DHAVE_OCTAVE_HDF5_ID_TYPE=1"
+  AC_DEFINE([HAVE_OCTAVE_HDF5_ID_TYPE],[1],[Define if have octave_hdf5_id])
 fi
 
 AC_CACHE_CHECK([for octave_base_value::gripe_load and octave_base_value::gripe_save],
   [comm_cv_octave_base_value_gripe_load_save],
   [comm_save_CPPFLAGS=$CPPFLAGS
    comm_save_CXXFLAGS=$CXXFLAGS
-   CPPFLAGS="$CPPFLAGS $HDF5_CPPFLAGS"
+   CPPFLAGS="$CPPFLAGS $HDF5_CFLAGS"
    CXXFLAGS="$CXXFLAGS $comm_CXXFLAGS"
    AC_LANG_PUSH(C++)
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-       #include <octave/config.h>
+       #include <octave/oct.h>
        #include <octave/ov-base.h>
        class foo : public octave_base_value
        {
@@ -73,19 +190,19 @@
    CPPFLAGS=$comm_save_CPPFLAGS
    CXXFLAGS=$comm_save_CXXFLAGS])
 if test $comm_cv_octave_base_value_gripe_load_save = yes; then
-  PKG_CPPFLAGS="$PKG_CPPFLAGS -DHAVE_OCTAVE_BASE_VALUE_GRIPE_LOAD_SAVE=1"
+  AC_DEFINE([HAVE_OCTAVE_BASE_VALUE_GRIPE_LOAD_SAVE],[1],[Define if have gripe_load and gripe_save])
 fi
 
 AC_CACHE_CHECK([whether octave_base_value::print is const-qualified],
   [comm_cv_octave_base_value_print_const_qualified],
   [comm_save_CPPFLAGS=$CPPFLAGS
    comm_save_CXXFLAGS=$CXXFLAGS
-   CPPFLAGS="$CPPFLAGS $HDF5_CPPFLAGS"
+   CPPFLAGS="$CPPFLAGS $HDF5_CFLAGS"
    CXXFLAGS="$CXXFLAGS $comm_CXXFLAGS"
    AC_LANG_PUSH(C++)
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
        #include <iostream>
-       #include <octave/config.h>
+       #include <octave/oct.h>
        #include <octave/ov-base.h>
        ]], [[
        const octave_base_value x; x.print (std::cout);
@@ -96,7 +213,7 @@
    CPPFLAGS=$comm_save_CPPFLAGS
    CXXFLAGS=$comm_save_CXXFLAGS])
 if test $comm_cv_octave_base_value_print_const_qualified = yes; then
-  PKG_CPPFLAGS="$PKG_CPPFLAGS -DHAVE_OCTAVE_BASE_VALUE_PRINT_CONST=1"
+  AC_DEFINE([HAVE_OCTAVE_BASE_VALUE_PRINT_CONST],[1],[Define if octave_base_value::print is const-qualified])
 fi
 
 AC_CONFIG_FILES([Makefile])
diff -r e126cad113f0 -r b318b6dacc25 src/cyclgen.cc
--- a/src/cyclgen.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/cyclgen.cc	Fri May 04 15:59:27 2018 -0400
@@ -22,6 +22,10 @@
 
 #include <octave/oct.h>
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 // A simplified version of the filter function for specific lengths of a and b
 // in the Galois field GF(2)
 Array<int>
@@ -29,7 +33,7 @@
             const Array<int>& x, const int& n)
 {
 
-  int x_len = x.length ();
+  int x_len = x.numel ();
   Array<int> si (dim_vector (n, 1), 0);
   Array<int> y (dim_vector (x_len, 1), 0);
 
diff -r e126cad113f0 -r b318b6dacc25 src/cyclpoly.cc
--- a/src/cyclpoly.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/cyclpoly.cc	Fri May 04 15:59:27 2018 -0400
@@ -23,6 +23,10 @@
 
 #include <octave/oct.h>
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 enum cyclic_poly_type
 {
   CYCLIC_POLY_MIN=0,
@@ -38,7 +42,7 @@
             const Array<int>& x, const int& n)
 {
 
-  int x_len = x.length ();
+  int x_len = x.numel ();
   Array<int> si (dim_vector (n, 1), 0);
   Array<int> y (dim_vector (x_len, 1), 0);
 
@@ -217,8 +221,8 @@
       for (unsigned long long i = (1UL<<m)+1; i < (1UL<<(1+m)); i+=2)
         if (do_is_cyclic_polynomial (i, n, m))
           {
-            cyclic_polys.resize (cyclic_polys.length ()+1);
-            cyclic_polys(cyclic_polys.length ()-1) = (double)i;
+            cyclic_polys.resize (cyclic_polys.numel ()+1);
+            cyclic_polys(cyclic_polys.numel ()-1) = (double)i;
           }
       break;
     case CYCLIC_POLY_L:
@@ -233,8 +237,8 @@
             {
               if (do_is_cyclic_polynomial (i, n, m))
                 {
-                  cyclic_polys.resize (cyclic_polys.length ()+1);
-                  cyclic_polys(cyclic_polys.length ()-1) = (double)i;
+                  cyclic_polys.resize (cyclic_polys.numel ()+1);
+                  cyclic_polys(cyclic_polys.numel ()-1) = (double)i;
                 }
             }
         }
@@ -244,7 +248,7 @@
       break;
     }
 
-  if (cyclic_polys.length () == 0)
+  if (cyclic_polys.numel () == 0)
     {
       octave_stdout <<
         "cyclpoly: no generator polynomial statifies constraints" << std::endl;
@@ -254,8 +258,8 @@
     {
       if (polyrep)
         {
-          Matrix polys (cyclic_polys.length (), m+1, 0);
-          for (int i = 0 ; i < cyclic_polys.length (); i++)
+          Matrix polys (cyclic_polys.numel (), m+1, 0);
+          for (int i = 0 ; i < cyclic_polys.numel (); i++)
             for (int j = 0; j < m+1; j++)
               if ((unsigned long long)cyclic_polys(i) & (1<<j))
                 polys(i, j) = 1;
diff -r e126cad113f0 -r b318b6dacc25 src/galois-def.h
--- a/src/galois-def.h	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/galois-def.h	Fri May 04 15:59:27 2018 -0400
@@ -21,6 +21,10 @@
 #if !defined (octave_galois_defs_h)
 #define octave_galois_defs_h 1
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 void gripe_nonconformant_galois (const char *op, int op1_m, int op1_primpoly,
                                  int op2_m, int op2_primpoly);
 void gripe_nonconformant_galois (const char *op, int m);
@@ -137,7 +141,7 @@
                 r(i, j) = (int)m1(i, j) ^ (int)m2(0, 0); \
           } \
         else \
-          gripe_nonconformant (#OP, m1_nr, m1_nc, m2_nr, m2_nc); \
+          OCTAVE__ERR_NONCONFORMANT (#OP, m1_nr, m1_nc, m2_nr, m2_nc); \
       } \
     else \
       { \
@@ -221,7 +225,7 @@
               } \
           } \
         else \
-          gripe_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \
+          OCTAVE__ERR_NONCONFORMANT (#F, m1_nr, m1_nc, m2_nr, m2_nc); \
       } \
     else \
       if (m1_nr > 0 && m1_nc > 0) \
@@ -289,7 +293,7 @@
                 r(i, j) = C1 (m1(i, j)) OP C2 (m2(0, 0)); \
           } \
         else \
-          gripe_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \
+          OCTAVE__ERR_NONCONFORMANT (#F, m1_nr, m1_nc, m2_nr, m2_nc); \
       } \
  \
     return r; \
@@ -350,7 +354,7 @@
                   OP (m2(0, 0) != ZERO); \
           } \
         else if ((m1_nr != 0 || m1_nc != 0) && (m2_nr != 0 || m2_nc != 0)) \
-          gripe_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \
+          OCTAVE__ERR_NONCONFORMANT (#F, m1_nr, m1_nc, m2_nr, m2_nc); \
       } \
  \
     return r; \
diff -r e126cad113f0 -r b318b6dacc25 src/galois-ops.h
--- a/src/galois-ops.h	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/galois-ops.h	Fri May 04 15:59:27 2018 -0400
@@ -21,6 +21,32 @@
 #if !defined (galois_octave_ops_h)
 #define galois_octave_ops_h 1
 
+#if ! defined (CAST_BINOP_ARGS)
+#  define CAST_BINOP_ARGS(t1, t2)               \
+  t1 v1 = dynamic_cast<t1> (a1);                \
+  t2 v2 = dynamic_cast<t2> (a2)
+#endif
+
+#if ! defined (CAST_UNOP_ARG)
+#  define CAST_UNOP_ARG(t)                      \
+  t v = dynamic_cast<t> (a)
+#endif
+
+#if ! defined (BINOPDECL)
+#  define BINOPDECL(name, a1, a2)                               \
+  static octave_value                                           \
+  CONCAT2(oct_binop_, name) (const octave_base_value& a1,       \
+                             const octave_base_value& a2)
+#endif
+
+#if ! defined (CATOPDECL)
+#  define CATOPDECL(name, a1, a2)                                       \
+  static octave_value                                                   \
+  CONCAT2(oct_catop_, name) (octave_base_value& a1,                     \
+                             const octave_base_value& a2,               \
+                             const Array<octave_idx_type>& ra_idx)
+#endif
+
 // Override the operator and function definition defines from Octave
 
 #define DEFBINOP_OP_G(name, t1, t2, op) \
diff -r e126cad113f0 -r b318b6dacc25 src/galois.cc
--- a/src/galois.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/galois.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,16 +18,28 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
-#include <octave/config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <octave/oct.h>
 #include <octave/error.h>
+#ifdef HAVE_OCTAVE_GRIPES_H
 #include <octave/gripes.h>
+#endif
+#ifdef HAVE_OCTAVE_ERRWARN_H
+#include <octave/errwarn.h>
+#endif
 #include <octave/mx-op-defs.h>
 
 #include "galois.h"
 #include "galoisfield.h"
 #include "galois-def.h"
 
-#include <octave/base-lu.cc>
+#ifdef  HAVE_OCTAVE_BASE_LU_H
+# include <octave/base-lu.cc>
+#else
+# include "base-lu.cc"
+#endif
 
 galois_field_list stored_galois_fields;
 
@@ -216,7 +228,7 @@
 
   if (nr != a_nr || nc != a_nc)
     {
-      gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc);
+      OCTAVE__ERR_NONCONFORMANT ("operator +=", nr, nc, a_nr, a_nc);
       return *this;
     }
 
@@ -252,7 +264,7 @@
 
   if (nr != a_nr || nc != a_nc)
     {
-      gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc);
+      OCTAVE__ERR_NONCONFORMANT ("operator -=", nr, nc, a_nr, a_nc);
       return *this;
     }
 
@@ -518,7 +530,7 @@
     {
       if (a_nr != b_nr || a_nc != b_nc)
         {
-          gripe_nonconformant ("operator .^", a_nr, a_nc, a_nr, a_nc);
+          OCTAVE__ERR_NONCONFORMANT ("operator .^", a_nr, a_nc, a_nr, a_nc);
           return galois ();
         }
 
@@ -549,7 +561,7 @@
 
   if (a_nr != b_nr || a_nc != b_nc)
     {
-      gripe_nonconformant ("operator .^", a_nr, a_nc, b_nr, b_nc);
+      OCTAVE__ERR_NONCONFORMANT ("operator .^", a_nr, a_nc, b_nr, b_nc);
       return galois ();
     }
 
@@ -758,7 +770,7 @@
     return product (a, b);
   else if (a_nc != b_nr)
     {
-      gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc);
+      OCTAVE__ERR_NONCONFORMANT ("operator *", a_nr, a_nc, b_nr, b_nc);
       return galois ();
     }
   else
@@ -1303,7 +1315,7 @@
 
           // Apply row interchanges to the right hand sides.
           //for (int j = 0; j < IP.length (); j++)
-          for (int j = IP.length ()-1; j >= 0; j--)
+          for (int j = IP.numel ()-1; j >= 0; j--)
             {
               int piv = IP(j);
               for (int i = 0; i < b_nc; i++)
@@ -1335,7 +1347,7 @@
           Array<int> IP (fact.ipvt);
 
           // Apply row interchanges to the right hand sides.
-          for (int j = 0; j < IP.length (); j++)
+          for (int j = 0; j < IP.numel (); j++)
             {
               int piv = IP(j);
               for (int i = 0; i < b_nc; i++)
@@ -1420,7 +1432,7 @@
       int a_nr = a.rows ();
       int b_nr = b.rows ();
 
-      gripe_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc);
+      OCTAVE__ERR_NONCONFORMANT ("operator /", a_nr, a_nc, b_nr, b_nc);
       return galois ();
     }
 
@@ -1464,7 +1476,7 @@
       int a_nc = a.cols ();
       int b_nc = b.cols ();
 
-      gripe_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc);
+      OCTAVE__ERR_NONCONFORMANT ("operator \\", a_nr, a_nc, b_nr, b_nc);
       return galois ();
     }
 
diff -r e126cad113f0 -r b318b6dacc25 src/galois.h
--- a/src/galois.h	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/galois.h	Fri May 04 15:59:27 2018 -0400
@@ -21,10 +21,18 @@
 #if !defined (octave_galois_int_h)
 #define octave_galois_int_h 1
 
-#include <octave/config.h>
-#include <octave/base-lu.h>
+#include <octave/oct.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <octave/mx-base.h>
 
+#ifdef HAVE_OCTAVE_BASE_LU_H
+# include <octave/base-lu.h>
+#else
+# include "base-lu.h"
+#endif
+
 #include "galoisfield.h"
 
 typedef void (*solve_singularity_handler) (double rcond);
diff -r e126cad113f0 -r b318b6dacc25 src/galoisfield.cc
--- a/src/galoisfield.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/galoisfield.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,6 +18,10 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "galois.h"
 #include "galoisfield.h"
 #include "galois-def.h"
diff -r e126cad113f0 -r b318b6dacc25 src/genqamdemod.cc
--- a/src/genqamdemod.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/genqamdemod.cc	Fri May 04 15:59:27 2018 -0400
@@ -14,7 +14,12 @@
 // along with this program; if not, see
 // <http://www.gnu.org/licenses/>.
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <octave/oct.h>
+#include <octave/utils.h>
 
 DEFUN_DLD (genqamdemod, args, ,
  "-*- texinfo -*-\n\
@@ -36,7 +41,7 @@
 
   int nr1 (args(0).rows ());
   int nc1 (args(0).columns ());
-  int arg_is_empty1 = empty_arg ("genqamdemod", nr1, nc1);
+  int arg_is_empty1 = args(0).OV_ISEMPTY();
   Matrix y (nr1,nc1);
 
   int nr2 (args(1).rows ());
@@ -48,7 +53,7 @@
   if (arg_is_empty1 > 0)
     return octave_value (Matrix ());
 
-  if (args(0).is_real_type () && args(1).is_real_type ())
+  if (args(0).OV_ISREAL () && args(1).OV_ISREAL ())
     { // Real-valued signal & constellation
       Matrix x (args(0).matrix_value ());
       ColumnVector constellation (args(1).vector_value ());
@@ -70,7 +75,7 @@
             }
         }
     }
-  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+  else if (args(0).OV_ISCOMPLEX () || args(1).OV_ISCOMPLEX ())
     { // Complex-valued input & constellation
       ComplexMatrix x (args(0).complex_matrix_value ());
       ComplexColumnVector constellation (args(1).complex_vector_value ());
diff -r e126cad113f0 -r b318b6dacc25 src/gf.cc
--- a/src/gf.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/gf.cc	Fri May 04 15:59:27 2018 -0400
@@ -28,10 +28,25 @@
 the website http://www.eccpage.com for more details. Permission has been granted
 for a GPL release of his code
 */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
-#include <octave/config.h>
+#include <octave/oct.h>
+
+#ifdef HAVE_OCTAVE_INTERPRETER_H
+#include <octave/interpreter.h>
+#endif
 #include <octave/defun-dld.h>
+#ifdef HAVE_OCTAVE_GRIPES_H
 #include <octave/gripes.h>
+#define OCTAVE__ERR_SQUARE_MATRIX_REQUIRED(a) gripe_square_matrix_required(a)
+#endif
+#ifdef HAVE_OCTAVE_ERRWARN_H
+#include <octave/errwarn.h>
+#define OCTAVE__ERR_SQUARE_MATRIX_REQUIRED(a) err_square_matrix_required(a, "")
+#endif
+
 #include <octave/oct-locbuf.h>
 #include <octave/ov.h>
 #include <octave/utils.h>
@@ -73,7 +88,11 @@
 // functions, this can't be done at the point. So if more default primitive
 // polynomials are added to galoisfield.cc, need to update the "16" here
 // as well!!
+#ifdef DEFMETHOD_DLD
+DEFMETHOD_DLD (gf, interp, args, nargout,
+#else
 DEFUN_DLD (gf, args, nargout,
+#endif
   "-*- texinfo -*-\n\
 @deftypefn  {Loadable Function} {@var{y} =} gf (@var{x})\n\
 @deftypefnx {Loadable Function} {@var{y} =} gf (@var{x}, @var{m})\n\
@@ -122,7 +141,11 @@
       install_s_gm_ops ();
       install_gm_s_ops ();
       galois_type_loaded = true;
+#ifdef DEFMETHOD_DLD
+      interp.mlock ();
+#else
       mlock ();
+#endif
     }
 
   retval = new octave_galois (data, m, primpoly);
@@ -142,7 +165,7 @@
 
   if ((!galois_type_loaded) || (a.type_id () !=
                                 octave_galois::static_type_id ()))
-    gripe_wrong_type_arg ("gdiag", a);
+    OCTAVE__ERR_WRONG_TYPE_ARG ("gdiag", a);
   else
     {
       galois m = ((const octave_galois&) a.get_rep ()).galois_value ();
@@ -191,12 +214,12 @@
           else
             {
               galois r = m.diag (k);
-              if (r.capacity () > 0)
+              if (r.numel () > 0)
                 retval = new octave_galois (r);
             }
         }
       else
-        gripe_wrong_type_arg ("gdiag", a);
+        OCTAVE__ERR_WRONG_TYPE_ARG ("gdiag", a);
     }
   return retval;
 }
@@ -302,7 +325,7 @@
       if ((!galois_type_loaded) || (args(0).type_id () !=
                                     octave_galois::static_type_id ()))
         {
-          gripe_wrong_type_arg ("greshape", args(0));
+          OCTAVE__ERR_WRONG_TYPE_ARG ("greshape", args(0));
           return retval;
         }
       galois a = ((const octave_galois&) args(0).get_rep ()).galois_value ();
@@ -372,7 +395,7 @@
                 } \
               else \
                 { \
-                  gripe_wrong_type_arg (#FCN, arg); \
+                  OCTAVE__ERR_WRONG_TYPE_ARG (#FCN, arg); \
                   return retval; \
                 } \
             } \
@@ -469,7 +492,7 @@
   if (!galois_type_loaded || (args(0).type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("gsqrt", args(0));
+      OCTAVE__ERR_WRONG_TYPE_ARG ("gsqrt", args(0));
       return retval;
     }
 
@@ -508,7 +531,7 @@
   if (!galois_type_loaded || (args(0).type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("glog", args(0));
+      OCTAVE__ERR_WRONG_TYPE_ARG ("glog", args(0));
       return retval;
     }
 
@@ -547,7 +570,7 @@
   if (!galois_type_loaded || (args(0).type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("gexp", args(0));
+      OCTAVE__ERR_WRONG_TYPE_ARG ("gexp", args(0));
       return retval;
     }
 
@@ -578,9 +601,9 @@
 galois
 filter (galois& b, galois& a, galois& x, galois& si)
 {
-  int ab_len = (a.length () > b.length () ? a.length () : b.length ());
+  int ab_len = (a.numel () > b.numel () ? a.numel () : b.numel ());
   b.resize (dim_vector (ab_len, 1), 0);
-  galois retval (x.length (), 1, 0, b.m (), b.primpoly ());
+  galois retval (x.numel (), 1, 0, b.m (), b.primpoly ());
   int norm = a(0, 0);
 
   if (norm == 0)
@@ -588,7 +611,7 @@
       error ("gfilter: the first element of a must be non-zero");
       return galois ();
     }
-  if (si.length () != ab_len - 1)
+  if (si.numel () != ab_len - 1)
     {
       error ("gfilter: si must be a vector of length max(length(a), length(b)) - 1");
       return galois ();
@@ -596,35 +619,35 @@
   if (norm != 1)
     {
       int idx_norm = b.index_of (norm);
-      for (int i = 0; i < b.length (); i++)
+      for (int i = 0; i < b.numel (); i++)
         {
           if (b(i, 0) != 0)
             b(i, 0) = b.alpha_to (modn (b.index_of (b(i, 0))-idx_norm+b.n (),
                                         b.m (), b.n ()));
         }
     }
-  if (a.length () > 1)
+  if (a.numel () > 1)
     {
       a.resize (dim_vector (ab_len, 1), 0);
 
       if (norm != 1)
         {
           int idx_norm = a.index_of (norm);
-          for (int i = 0; i < a.length (); i++)
+          for (int i = 0; i < a.numel (); i++)
             if (a(i, 0) != 0)
               a(i, 0) = a.alpha_to (modn (a.index_of (a(i, 0))-idx_norm+a.n (),
                                           a.m (), a.n ()));
         }
 
-      for (int i = 0; i < x.length (); i++)
+      for (int i = 0; i < x.numel (); i++)
         {
           retval(i, 0) = si(0, 0);
           if ((b(0, 0) != 0) && (x(i, 0) != 0))
             retval(i, 0) ^= b.alpha_to (modn (b.index_of (b(0, 0)) +
                                               b.index_of (x(i, 0)), b.m (), b.n ()));
-          if (si.length () > 1)
+          if (si.numel () > 1)
             {
-              for (int j = 0; j < si.length () - 1; j++)
+              for (int j = 0; j < si.numel () - 1; j++)
                 {
                   si(j, 0) = si(j+1, 0);
                   if ((a(j+1, 0) != 0) && (retval(i, 0) != 0))
@@ -634,13 +657,14 @@
                     si(j, 0) ^= b.alpha_to (modn (b.index_of (b(j+1, 0)) +
                                                   b.index_of (x(i, 0)), b.m (), b.n ()));
                 }
-              si(si.length ()-1, 0) = 0;
-              if ((a(si.length (), 0) != 0) && (retval(i, 0) != 0))
-                si(si.length ()-1, 0) ^= a.alpha_to (modn (a.index_of (a(si.length (), 0))
+              si(si.numel ()-1, 0) = 0;
+              if ((a(si.numel (), 0) != 0) && (retval(i, 0) != 0))
+                si(si.numel ()-1, 0) ^= a.alpha_to (modn (a.index_of (a(si.numel (), 0))
                                                            + a.index_of (retval(i, 0)),
                                                            a.m (), a.n ()));
-              if ((b(si.length (), 0) != 0) && (x(i, 0) != 0))
-                si(si.length ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.length (), 0))
+
+              if ((b(si.numel (), 0) != 0) && (x(i, 0) != 0))
+                si(si.numel ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.numel (), 0))
                                                            + b.index_of (x(i, 0)),
                                                            b.m (), b.n ()));
             }
@@ -656,26 +680,27 @@
             }
         }
     }
-  else if (si.length () > 0)
+  else if (si.numel () > 0)
     {
-      for (int i = 0; i < x.length (); i++)
+      for (int i = 0; i < x.numel (); i++)
         {
           retval(i, 0) = si(0, 0);
           if ((b(0, 0) != 0) && (x(i, 0) != 0))
             retval(i, 0) ^= b.alpha_to (modn (b.index_of (b(0, 0)) +
                                               b.index_of (x(i, 0)), b.m (), b.n ()));
-          if (si.length () > 1)
+          if (si.numel () > 1)
             {
-              for (int j = 0; j < si.length () - 1; j++)
+              for (int j = 0; j < si.numel () - 1; j++)
                 {
                   si(j, 0) = si(j+1, 0);
                   if ((b(j+1, 0) != 0) && (x(i, 0) != 0))
                     si(j, 0) ^= b.alpha_to (modn (b.index_of (b(j+1, 0)) +
                                                   b.index_of (x(i, 0)), b.m (), b.n ()));
                 }
-              si(si.length ()-1, 0) = 0;
-              if ((b(si.length (), 0) != 0) && (x(i, 0) != 0))
-                si(si.length ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.length (), 0))
+
+              si(si.numel ()-1, 0) = 0;
+              if ((b(si.numel (), 0) != 0) && (x(i, 0) != 0))
+                si(si.numel ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.numel (), 0))
                                                            + b.index_of (x(i, 0)),
                                                            b.m (), b.n ()));
             }
@@ -689,7 +714,7 @@
         }
     }
   else
-    for (int i = 0; i < x.length (); i++)
+    for (int i = 0; i < x.numel (); i++)
       if ((b(0, 0) != 0) && (x(i, 0) != 0))
         retval(i, 0) = b.alpha_to (modn (b.index_of (b(0, 0)) +
                                          b.index_of (x(i, 0)), b.m (), b.n ()));
@@ -839,8 +864,8 @@
     }
   else
     {
-      int a_len = a.length ();
-      int b_len = b.length ();
+      int a_len = a.numel ();
+      int b_len = b.numel ();
 
       int si_len = (a_len > b_len ? a_len : b_len) - 1;
 
@@ -962,7 +987,7 @@
   if (!galois_type_loaded || (arg.type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("glu", arg);
+      OCTAVE__ERR_WRONG_TYPE_ARG ("glu", arg);
       return retval;
     }
 
@@ -971,7 +996,7 @@
   int nr = arg.rows ();
   int nc = arg.columns ();
 
-  int arg_is_empty = empty_arg ("glu", nr, nc);
+  int arg_is_empty = arg.OV_ISEMPTY();
 
   if (arg_is_empty < 0)
     return retval;
@@ -1049,13 +1074,13 @@
   if (!galois_type_loaded || (arg.type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("ginverse", arg);
+      OCTAVE__ERR_WRONG_TYPE_ARG ("ginverse", arg);
       return retval;
     }
 
   galois m = ((const octave_galois&) arg.get_rep ()).galois_value ();
 
-  int arg_is_empty = empty_arg ("ginverse", nr, nc);
+  int arg_is_empty = arg.OV_ISEMPTY ();
 
   if (arg_is_empty < 0)
     return retval;
@@ -1066,7 +1091,7 @@
     }
   if (nr != nc)
     {
-      gripe_square_matrix_required ("ginverse");
+      OCTAVE__ERR_SQUARE_MATRIX_REQUIRED ("ginverse");
       return retval;
     }
 
@@ -1143,7 +1168,7 @@
   if (!galois_type_loaded || (arg.type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("gdet", arg);
+      OCTAVE__ERR_WRONG_TYPE_ARG ("gdet", arg);
       return retval;
     }
 
@@ -1152,7 +1177,7 @@
 
   galois m = ((const octave_galois&) arg.get_rep ()).galois_value ();
 
-  int arg_is_empty = empty_arg ("gdet", nr, nc);
+  int arg_is_empty = arg.OV_ISEMPTY ();
 
   if (arg_is_empty < 0)
     return retval;
@@ -1164,7 +1189,7 @@
 
   if (nr != nc)
     {
-      gripe_square_matrix_required ("det");
+      OCTAVE__ERR_SQUARE_MATRIX_REQUIRED ("det");
       return retval;
     }
 
@@ -1203,7 +1228,7 @@
   if (!galois_type_loaded || (arg.type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("grank", arg);
+      OCTAVE__ERR_WRONG_TYPE_ARG ("grank", arg);
       return retval;
     }
 
@@ -1212,7 +1237,7 @@
 
   galois m = ((const octave_galois&) arg.get_rep ()).galois_value ();
 
-  int arg_is_empty = empty_arg ("grank", nr, nc);
+  int arg_is_empty = arg.OV_ISEMPTY ();
 
   if (arg_is_empty > 0)
     retval = 0.0;
@@ -1333,7 +1358,7 @@
   if (!galois_type_loaded || (args(0).type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("rsenc", args(0));
+      OCTAVE__ERR_WRONG_TYPE_ARG ("rsenc", args(0));
       return retval;
     }
 
@@ -1874,7 +1899,7 @@
   if (!galois_type_loaded || (args(0).type_id () !=
                               octave_galois::static_type_id ()))
     {
-      gripe_wrong_type_arg ("rsdec", args(0));
+      OCTAVE__ERR_WRONG_TYPE_ARG ("rsdec", args(0));
       return retval;
     }
 
diff -r e126cad113f0 -r b318b6dacc25 src/isprimitive.cc
--- a/src/isprimitive.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/isprimitive.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,6 +18,9 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <octave/oct.h>
 
 static bool
diff -r e126cad113f0 -r b318b6dacc25 src/m4/octave-forge.m4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/m4/octave-forge.m4	Fri May 04 15:59:27 2018 -0400
@@ -0,0 +1,93 @@
+# Copyright (C) 2017-2018 Olaf Till <i7tiol@t-online.de>
+# Modifications to print what is searching for by JohnD
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+# arguments of OF_OCTAVE_ALT_SYMS (see also description of
+# OF_OCTAVE_LIST_ALT_SYMS below):
+#
+# $1: symbol version 1
+# $2: symbol version 2
+# $3: test for symbol version 2
+# $4: macro name to access alternative symbols
+# $5: include directives for symbol version 1
+# $6: include directives for symbol version 2
+# (a list of lists of args 1--6 is $1 of OF_OCTAVE_LIST_ALT_SYMS)
+# $7: name of generated include file with alternatives of Octave headers
+# (arg7 is $2 of OF_OCTAVE_LIST_ALT_SYMS)
+AC_DEFUN([OF_OCTAVE_ALT_SYMS], [
+AC_MSG_CHECKING([$1 or $2])
+  AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM([[#include <octave/oct.h>]
+                      $6],
+                     [$3])],
+    [AC_DEFINE($4,
+               [[$2]],
+               [macro for alternative Octave symbols])
+     AC_MSG_RESULT([$2])
+     echo '$6' >> $7],
+    [AC_DEFINE($4,
+               [[$1]],
+               [macro for alternative Octave symbols])
+     AC_MSG_RESULT([$1])
+     echo '$5' >> $7]
+)
+])
+
+
+# OF_OCTAVE_LIST_ALT_SYMS is called in the following way:
+#
+# OF_OCTAVE_LIST_ALT_SYMS([
+# [dnl
+#   [old_octave_symbol],
+#   [new_octave_symbol],
+#   [[compilation test]
+#    [for new_octave_symbol]],
+#   [NAME_OF_GENERATED_MACRO____WILL_EXPAND_TO_OLD_OR_NEW_SYMBOL],
+#   [[include directives]
+#    [except #include <octave/oct.h>]
+#    [necessary to compile with old_octave_symbol]],
+#   [[include directives]
+#    [except #include <octave/oct.h>]
+#    [nessary to compile with new_octave_symbol]
+#    [and to compile the test]]
+# ],
+#
+# ... further such lists as the above
+#
+# ],
+#
+# [name-of-header-file-for-alternative-octave-iclude-directives.h])
+#
+#
+# This file should be put into src/m4/, and the line
+#
+# AC_CONFIG_MACRO_DIRS([m4])
+#
+# should be put into src/configure.ac. The package should use
+# autoheader to generate config.h.in (src/bootstrap should contain the
+# lines 'aclocal', 'autoconf', and 'autoheader -f'). Package code
+# should include config.h and use the generated macros to access the
+# alternative symbols of Octave. An example of a call to
+# OF_OCTAVE_LIST_ALT_SYMS in src/configure.ac is available together
+# with this file.
+AC_DEFUN([OF_OCTAVE_LIST_ALT_SYMS], [
+
+echo '/* generated by configure */' > $2
+
+m4_foreach([it], [$1], [m4_apply([OF_OCTAVE_ALT_SYMS], [it, $2])])
+
+AH_BOTTOM([#include "$2"])
+
+])
diff -r e126cad113f0 -r b318b6dacc25 src/op-gm-gm.cc
--- a/src/op-gm-gm.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/op-gm-gm.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,8 +18,15 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
-#include <octave/config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <octave/oct.h>
+#ifdef HAVE_OCTAVE_OVL_H
+#include <octave/ovl.h>
+#elif HAVE_OCTAVE_OCT_OBJ_H
 #include <octave/oct-obj.h>
+#endif
 #include <octave/ops.h>
 
 #include "galois.h"
diff -r e126cad113f0 -r b318b6dacc25 src/op-gm-m.cc
--- a/src/op-gm-m.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/op-gm-m.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,7 +18,10 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
-#include <octave/config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <octave/oct.h>
 #include <octave/ops.h>
 #include <octave/ov-re-mat.h>
 
diff -r e126cad113f0 -r b318b6dacc25 src/op-gm-s.cc
--- a/src/op-gm-s.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/op-gm-s.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,7 +18,10 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
-#include <octave/config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <octave/oct.h>
 #include <octave/ops.h>
 #include <octave/ov-scalar.h>
 
diff -r e126cad113f0 -r b318b6dacc25 src/op-m-gm.cc
--- a/src/op-m-gm.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/op-m-gm.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,7 +18,10 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
-#include <octave/config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <octave/oct.h>
 #include <octave/ops.h>
 #include <octave/ov-re-mat.h>
 
diff -r e126cad113f0 -r b318b6dacc25 src/op-s-gm.cc
--- a/src/op-s-gm.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/op-s-gm.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,7 +18,10 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
-#include <octave/config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <octave/oct.h>
 #include <octave/ops.h>
 #include <octave/ov-scalar.h>
 
diff -r e126cad113f0 -r b318b6dacc25 src/ov-galois.cc
--- a/src/ov-galois.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/ov-galois.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,23 +18,58 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <iostream>
 
-#include <octave/config.h>
+#include <octave/oct.h>
 #include <octave/byte-swap.h>
+#ifdef HAVE_OCTAVE_GRIPES_H
 #include <octave/gripes.h>
+#endif
+#ifdef HAVE_OCTAVE_ERRWARN_H
+#include <octave/errwarn.h>
+#endif
 #include <octave/lo-ieee.h>
-#include <octave/oct-hdf5.h>
 #include <octave/oct-locbuf.h>
+
+#ifdef HAVE_OCTAVE_OVL_H
+#include <octave/ovl.h>
+#elif HAVE_OCTAVE_OCT_OBJ_H
 #include <octave/oct-obj.h>
+#endif
 #include <octave/ov.h>
 #include <octave/pr-output.h>
 
-#include <octave/ls-oct-ascii.h>
+#if defined(HAVE_OCTAVE_LS_OCT_TEXT_H)
+#  include <octave/ls-oct-text.h>
+#else
+#  include <octave/ls-oct-ascii.h>
+#endif
 
 #include "galois.h"
 #include "ov-galois.h"
 
+#if defined (HAVE_HDF5)
+#  if defined (HAVE_HDF5_H)
+#    include <hdf5.h>
+#  endif
+#  if defined (HAVE_OCTAVE_OCT_HDF5_TYPES_H)
+#    include "oct-hdf5-types.h"
+#  endif
+#  if defined (OCTAVE_ENABLE_64)
+#    define H5T_NATIVE_IDX H5T_NATIVE_INT64
+#  else
+#    define H5T_NATIVE_IDX H5T_NATIVE_INT
+#  endif
+#endif
+
+#if ! defined (X_CAST)
+#  define X_CAST(T, E) (T) (E)
+#endif
+
 #if defined (DEFINE_OCTAVE_ALLOCATOR)
 DEFINE_OCTAVE_ALLOCATOR (octave_galois);
 #endif
@@ -313,13 +348,13 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      OCTAVE__WARN_INVALID_CONVERSION ("Octave:array-as-scalar",
                                  "real matrix", "real scalar");
 
       retval = (double) gval (0, 0);
     }
   else
-    gripe_invalid_conversion ("galois", "real scalar");
+    OCTAVE__ERR_INVALID_CONVERSION ("galois", "real scalar");
 
   return retval;
 }
@@ -333,13 +368,13 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      OCTAVE__WARN_INVALID_CONVERSION ("Octave:array-as-scalar",
                                  "real matrix", "real scalar");
 
       retval = (double) gval (0, 0);
     }
   else
-    gripe_invalid_conversion ("galois", "complex scalar");
+    OCTAVE__ERR_INVALID_CONVERSION ("galois", "complex scalar");
 
   return retval;
 }
diff -r e126cad113f0 -r b318b6dacc25 src/ov-galois.h
--- a/src/ov-galois.h	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/ov-galois.h	Fri May 04 15:59:27 2018 -0400
@@ -21,6 +21,9 @@
 #if !defined (octave_galois_h)
 #define octave_galois_h 1
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <octave/ov.h>
 #include <octave/ov-typeinfo.h>
 
@@ -44,8 +47,12 @@
 #endif
 #endif
 
-class octave_value_list;
-class tree_walker;
+#if ! defined (OV_REP_TYPE)
+#  define OV_REP_TYPE octave_base_value
+#endif
+
+//class octave_value_list;
+//class tree_walker;
 
 // Data structures.
 
diff -r e126cad113f0 -r b318b6dacc25 src/primpoly.cc
--- a/src/primpoly.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/primpoly.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,6 +18,10 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <iostream>
 #include <string>
 
@@ -216,8 +220,8 @@
       for (int i = (1<<m)+1; i < (1<<(1+m)); i+=2)
         if (do_isprimitive (i, m))
           {
-            primpolys.resize (primpolys.length ()+1);
-            primpolys(primpolys.length ()-1) = (double)i;
+            primpolys.resize (primpolys.numel ()+1);
+            primpolys(primpolys.numel ()-1) = (double)i;
           }
       break;
     case PRIMPOLY_K:
@@ -231,8 +235,8 @@
             {
               if (do_isprimitive (i, m))
                 {
-                  primpolys.resize (primpolys.length ()+1);
-                  primpolys(primpolys.length ()-1) = (double)i;
+                  primpolys.resize (primpolys.numel ()+1);
+                  primpolys(primpolys.numel ()-1) = (double)i;
                 }
             }
         }
@@ -244,12 +248,12 @@
 
   if (disp)
     {
-      if (primpolys.length () == 0)
+      if (primpolys.numel () == 0)
         warning ("primpoly: No primitive polynomial satisfies the given constraints");
       else
         {
           octave_stdout << std::endl << "Primitive polynomial(s) =" << std::endl << std::endl;
-          for (int i = 0; i < primpolys.length (); i++)
+          for (int i = 0; i < primpolys.numel (); i++)
             {
               bool first = true;
               for (int j = m; j >= 0; j--)
diff -r e126cad113f0 -r b318b6dacc25 src/syndtable.cc
--- a/src/syndtable.cc	Thu Apr 14 01:07:22 2016 +0100
+++ b/src/syndtable.cc	Fri May 04 15:59:27 2018 -0400
@@ -18,10 +18,18 @@
 // program with any Open Source program, as defined by the Open Source
 // Initiative (www.opensource.org)
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <octave/oct.h>
 
-#define COL_MAJ(N) (N / (SIZEOF_INT << 3))
-#define COL_MIN(N) (N % (SIZEOF_INT << 3))
+#ifndef SIZEOF_INT
+  #define SIZEOF_INT int(sizeof(int))
+#endif
+
+#define COL_MAJ(N) (N / (sizeof (int) << 3))
+#define COL_MIN(N) (N % (sizeof (int) << 3))
 
 Array<int>
 get_errs (const int& nmin, const int& nmax, const int &nerrs)
@@ -94,7 +102,7 @@
   if (m > (int)(sizeof (int) << 3))
     {
       error ("syndtable: codeword minus message length must be less than %d",
-             (sizeof (int) << 3));
+             (int)(sizeof (int) << 3));
       return retval;
     }
 
diff -r e126cad113f0 -r b318b6dacc25 src/undef-ah-octave.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/undef-ah-octave.h	Fri May 04 15:59:27 2018 -0400
@@ -0,0 +1,27 @@
+/* To be included at the top of config.h (by autoheader). Avoid
+   warnings for redefining AH-generated preprocessor symbols of
+   Octave. */
+
+#ifdef PACKAGE_BUGREPORT
+#undef PACKAGE_BUGREPORT
+#endif
+
+#ifdef PACKAGE_NAME
+#undef PACKAGE_NAME
+#endif
+
+#ifdef PACKAGE_STRING
+#undef PACKAGE_STRING
+#endif
+
+#ifdef PACKAGE_TARNAME
+#undef PACKAGE_TARNAME
+#endif
+
+#ifdef PACKAGE_URL
+#undef PACKAGE_URL
+#endif
+
+#ifdef PACKAGE_VERSION
+#undef PACKAGE_VERSION
+#endif
