From 74ec250d3d89d0125c409b3340aca50a00b067ad Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <michael@orlitzky.com>
Date: Sun, 30 May 2021 08:28:41 -0400
Subject: [PATCH 3/3] autotools: support docdir and htmldir.

Instead of hard-coding the "doc" and "html" subdirectories,
allow them to be ./configured.
---
 Makefile.am             | 8 ++++----
 configure.ac            | 5 +++++
 resources/configure.ac  | 4 ++++
 resources/feResource.cc | 2 +-
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index fbea51d..c5d78a7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,10 +16,10 @@ bin_SCRIPTS = libsingular-config
 
 install-data-local:
 	if test -e $(srcdir)/doc/doc.tbz2; then\
-	  (cat ${top_srcdir}/doc/doc.tbz2| (cd $(DESTDIR)$(datadir)/singular; tar -jx --no-same-owner -f -));\
-	   mkdir $(DESTDIR)$(datadir)/info;\
-	   mkdir $(DESTDIR)$(datadir)/doc;\
-	   mv  $(DESTDIR)$(datadir)/singular/singular.hlp  $(DESTDIR)$(datadir)/info/.;\
+	   mkdir -p $(DESTDIR)$(docdir);\
+	   (cat ${top_srcdir}/doc/doc.tbz2| (cd $(DESTDIR)$(docdir); tar -jx --no-same-owner -f -));\
+	   mv  $(DESTDIR)$(docdir)/singular.hlp  $(DESTDIR)$(datadir)/info/.;\
+	   @INSTALL_DATA@ doc/singular.idx  $(DESTDIR)$(datadir)/singular/.;\
 	fi
 
 uninstall-local:
diff --git a/configure.ac b/configure.ac
index 490a45f..997db6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,6 +228,11 @@ AX_NORMALIZE_PATH([config_datadir],['/'])
 AC_DEFINE_UNQUOTED([DATA_DIR],"$config_datadir",[datadir])
 AC_SUBST(DATA_DIR, "$config_datadir")
 
+AX_RECURSIVE_EVAL([[$]docdir], [config_docdir])
+AX_NORMALIZE_PATH([config_docdir],['/'])
+AC_DEFINE_UNQUOTED([DOC_DIR],"$config_docdir",[docdir])
+AC_SUBST(DOC_DIR, "$config_docdir")
+
 SING_SHOW_FLAGS([Compiler/linker flags: ])
 
 
diff --git a/resources/configure.ac b/resources/configure.ac
index 0dc468f..da68144 100644
--- a/resources/configure.ac
+++ b/resources/configure.ac
@@ -72,5 +72,9 @@ AX_RECURSIVE_EVAL([[$]datadir], [config_datadir])
 AX_NORMALIZE_PATH([config_datadir],['/'])
 AC_DEFINE_UNQUOTED([DATA_DIR],"$config_datadir",[datadir])
 
+AX_RECURSIVE_EVAL([[$]htmldir], [config_htmldir])
+AX_NORMALIZE_PATH([config_htmldir],['/'])
+AC_DEFINE_UNQUOTED([HTML_DIR],"$config_datadir",[htmldir])
+
 AC_CONFIG_FILES([singular_resources.pc Makefile])
 AC_OUTPUT
diff --git a/resources/feResource.cc b/resources/feResource.cc
index 3d75bc9..7e4fc8c 100644
--- a/resources/feResource.cc
+++ b/resources/feResource.cc
@@ -85,7 +85,7 @@ VAR feResourceConfig_s feResourceConfigs[] =
   {"DefaultDir",'d',    feResDir,   "SINGULAR_DEFAULT_DIR",  SINGULAR_DEFAULT_DIR,  (char *)""},
   {"InfoFile",  'i',    feResFile,  "SINGULAR_INFO_FILE",   "%D/info/singular.hlp", (char *)""},
   {"IdxFile",   'x',    feResFile,  "SINGULAR_IDX_FILE",    "%D/singular/singular.idx",  (char *)""},
-  {"HtmlDir",   'h',    feResDir,   "SINGULAR_HTML_DIR",    "%D/singular/html",              (char *)""},
+  {"HtmlDir",   'h',    feResDir,   "SINGULAR_HTML_DIR",    HTML_DIR,              (char *)""},
   {"ManualUrl", 'u',    feResUrl,   "SINGULAR_URL",         "https://www.singular.uni-kl.de/Manual/",    (char *)""},
   {"ExDir",     'm',    feResDir,   "SINGULAR_EXAMPLES_DIR","%r/examples",          (char *)""},
   {"Path",      'p',    feResPath,  NULL,                   "%b;%P;$PATH",             (char *)""},
-- 
2.31.1

