# HG changeset patch
# User John Donoghue
# Date 1547041560 18000
#      Wed Jan 09 08:46:00 2019 -0500
# Node ID f04d493754ccf69fb345bf2ce935e6bb98f60521
# Parent  db1ee7036df04061b20c51dc10545993ecf4a183
Add configure scripts

* src/Makefile.in, src/bootstrap, src/configure.ac,
   src/m4/octave-forge.m4, src/undef-ah-octave.h: new files

* src/pcregexp.cc: use OCTAVE_WRONG_TYPE_ARG instead of gripe_wrong_type_arg

* src/Makefile: deleted

diff -r db1ee7036df0 -r f04d493754cc src/Makefile
--- a/src/Makefile	Tue Jul 07 22:46:46 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-OCTAVE ?= octave
-MKOCTFILE ?= mkoctfile -Wall
-
-PCRE_SWITCHES := $(shell $(OCTAVE) \
-	--no-gui --no-init-file --no-site-file --silent --no-history \
-	--eval 'disp (octave_config_info ("PCRE_LIBS"));' \
-	--eval 'disp (octave_config_info ("PCRE_CPPFLAGS"));' \
-	)
-
-pcregexp.oct: %.oct: %.cc
-	$(MKOCTFILE) $(PCRE_SWITCHES) -o $@ $<
diff -r db1ee7036df0 -r f04d493754cc src/Makefile.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Makefile.in	Wed Jan 09 08:46:00 2019 -0500
@@ -0,0 +1,42 @@
+# Makefile for strings package for Octave
+#
+# Copyright (C) 2019 John Donoghue 
+#
+# 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/>.
+
+
+# before cross building, pre-build at least $(TEXIFILE) natively,
+# e.g. with targets 'doc', 'html', or 'prebuild'
+
+PCRE_CXXFLAGS ?= @PCRE_CFLAGS@
+PCRE_LIBS ?= @PCRE_LIBS@
+
+MKOCTFILE ?= @MKOCTFILE@
+
+.PHONY: all clean distclean maintainer-clean
+
+all: pcregexp.oct
+
+%.oct: %.cc
+	$(MKOCTFILE) -o $@ $< $(PCRE_CXXFLAGS) $(PCRE_LIBS)
+
+clean:
+	$(RM) *.o octave-core *.oct *~
+
+distclean: clean
+	$(RM) config.h config.log config.status Makefile oct-alt-includes.h
+	$(RM) -r autom4te.cache
+
+maintainer-clean: distclean
+	$(RM) configure config.h.in aclocal.m4
diff -r db1ee7036df0 -r f04d493754cc src/bootstrap
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/bootstrap	Wed Jan 09 08:46:00 2019 -0500
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+aclocal
+
+autoconf
+
+autoheader -f
diff -r db1ee7036df0 -r f04d493754cc src/configure.ac
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/configure.ac	Wed Jan 09 08:46:00 2019 -0500
@@ -0,0 +1,102 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+#
+### Copyright (C) 2015-2018 Olaf Till <i7tiol@t-online.de>
+### Copyright (C) 2019 John Donoghue <john.donoghue@ieee.org>
+###
+### 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/>.
+
+AC_PREREQ([2.67])
+AC_INIT([strings], [1.2.0])
+AC_CONFIG_SRCDIR([pcregexp.cc])
+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])
+
+# Checks for programs.
+AC_CHECK_PROG(MKOCTFILE, mkoctfile, mkoctfile)
+if test -z "$MKOCTFILE"; then
+AC_MSG_ERROR([mkoctfile not found], 1);
+fi
+AC_CHECK_PROG(OCTAVE_CONFIG, octave-config, octave-config)
+if test -z "$OCTAVE_CONFIG"; then
+AC_MSG_ERROR([octave-config not found], 1);
+fi
+
+#AC_CHECK_TOOL(PKG_CONFIG, pkg-config, [])
+#if test -z "$PKG_CONFIG"; then
+#    AC_MSG_ERROR([pkg-config not found], 1);
+#fi
+
+
+# The same value of CXX as Octave was compiled with is supposed to be used.
+CXX=${CXX:-`${MKOCTFILE} -p CXX`}
+AC_PROG_CXX
+  
+AC_PROG_CXXCPP
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+PKG_CHECK_MODULES([PCRE],[libpcre],
+ [],
+ [AC_MSG_ERROR([libpcre not found])]
+)
+
+
+# Start of checks for Octave features, preparations for checks.
+OCTLIBDIR=${OCTLIBDIR:-`$OCTAVE_CONFIG -p OCTLIBDIR`}
+## We need Octaves include path both with and without '/octave'
+## appended. The path without '/octave' is needed to selectively test
+## for Octave headers, like octave/....h. The path with '/octave' is
+## needed since some Octave headers contain include directives for
+## other Octave headers with <> instead of "".
+OCTINCLUDEDIR=${OCTINCLUDEDIR:-`$MKOCTFILE -p INCFLAGS`}
+AC_LANG_PUSH([C++])
+TCXXFLAGS=$CXXFLAGS
+TLDFLAGS=$LDFLAGS
+TLIBS=$LIBS
+TCPPFLAGS=$CPPFLAGS
+LDFLAGS="-L$OCTLIBDIR $LDFLAGS"
+LIBS="-loctinterp $LIBS"
+# CXXFLAGS=
+CPPFLAGS="$OCTINCLUDEDIR $CPPFLAGS"
+
+## Simple symbol alternatives of different Octave versions.
+OF_OCTAVE_LIST_ALT_SYMS([
+[dnl
+  [gripe_wrong_type_arg],
+  [err_wrong_type_arg],
+  [[err_wrong_type_arg("test");]],
+  [OCTAVE__WRONG_TYPE_ARG],
+  [],
+  []
+]
+],
+   [oct-alt-includes.h])
+
+LIBS=$TLIBS
+LDFLAGS=$TLDFLAGS
+CXXFLAGS=$TCXXFLAGS
+CPPFLAGS=$TCPPFLAGS
+AC_LANG_POP([C++])
+# End of checks for Octave features.
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff -r db1ee7036df0 -r f04d493754cc src/m4/octave-forge.m4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/m4/octave-forge.m4	Wed Jan 09 08:46:00 2019 -0500
@@ -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 db1ee7036df0 -r f04d493754cc src/pcregexp.cc
--- a/src/pcregexp.cc	Tue Jul 07 22:46:46 2015 +0200
+++ b/src/pcregexp.cc	Wed Jan 09 08:46:00 2019 -0500
@@ -1,4 +1,5 @@
 // Copyright (C) 2004 Stefan van der Walt <stefan@sun.ac.za>
+// Copyright (C) 2019 John Donoghue <john.donoghue@ieee.org>
 // All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
@@ -26,6 +27,8 @@
 #include <iostream>
 #include <vector>
 
+#include "config.h"
+
 //FIXME This function needs some documentation
 DEFUN_DLD(pcregexp, args, nargout, "\
 -*- texinfo -*-\n\
@@ -49,7 +52,7 @@
     std::string pattern = args(0).string_value();
     std::string input = args(1).string_value();
     if (error_state) {
-        gripe_wrong_type_arg("pcregexp", args(0));
+        OCTAVE__WRONG_TYPE_ARG("pcregexp", args(0));
         return retval;
     }
 
diff -r db1ee7036df0 -r f04d493754cc src/undef-ah-octave.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/undef-ah-octave.h	Wed Jan 09 08:46:00 2019 -0500
@@ -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
