Description: autotools: help2man
 Implement the generation of the manpages for the front-end
 programs and development tools with help2man(1);
 meant to be submitted to the upstream maintainer.
Origin: vendor, Debian
Forwarded: https://github.com/Singular/Sources/pull/695
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2021-11-20

--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,7 @@
 
 AC_CHECK_FUNCS(readlink getcwd getwd setenv putenv qsort_r poll)
 
+AC_PATH_PROG([HELP2MAN],[help2man])
 AC_CHECK_PROGS([DOXYGEN], [doxygen])
 if test -z "$DOXYGEN";
    then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
--- a/Singular/Makefile.am
+++ b/Singular/Makefile.am
@@ -149,6 +149,20 @@
 
 bin_PROGRAMS = Singular ESingular TSingular $(optional_Singular_programs)
 
+man_MANS = Singular.1 ESingular.1 TSingular.1
+
+AM_H2MFLAGS = \
+	--manual="CAS Singular" \
+	--version-option="--dump-versiontuple" \
+	--source="Singular" \
+	--libtool \
+	--no-info
+
+## short descriptions for manpages
+Singular_DESCRIPTION =  "Computer Algebra System for Polynomial Computations -- command-line interface"
+ESingular_DESCRIPTION = "Computer Algebra System for Polynomial Computations -- command-line interface within emacs"
+TSingular_DESCRIPTION = "Computer Algebra System for Polynomial Computations -- command-line interface within a new terminal"
+
 Singular_SOURCES = tesths.cc utils.cc  utils.h
 
 Singular_LDADD = libSingular.la ${OMALLOC_LIBS} ${BUILTIN_FLAGS} $(FACTORY_LIBS)
@@ -185,6 +199,15 @@
 #libparse_LDADD = ${top_builddir}/resources/libsingular_resources.la
 libparse_LDFLAGS = ${AM_LDFLAGS}
 
+%.1: %
+	$(HELP2MAN) \
+			-s 1 \
+			$(AM_H2MFLAGS) \
+			-I $(top_srcdir)/Singular/man/$*.h2m \
+			-n $(if $($(subst -,_,$*)_DESCRIPTION), $($(subst -,_,$*)_DESCRIPTION), "manual page for $*") \
+			-o $@ \
+		$(abs_top_builddir)/Singular/$<
+
 #########################################################
 # the Singular library (*.lib files)
 
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,6 +14,17 @@
 
 bin_SCRIPTS = libsingular-config
 
+man_MANS = libsingular-config.1
+
+AM_H2MFLAGS = \
+	--manual="CAS Singular" \
+	--source="Singular" \
+	--libtool \
+	--no-info
+
+## short descriptions for manpages
+libsingular_config_DESCRIPTION = "get information about installed Singular library"
+
 install-data-local:
 	if test -e $(srcdir)/doc/doc.tbz2; then\
 	   test -e $(DESTDIR)$(datadir) || mkdir -p $(DESTDIR)$(datadir);\
@@ -35,3 +46,12 @@
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = Singular.pc
+
+%.1: %
+	$(HELP2MAN) \
+			-s 1 \
+			$(AM_H2MFLAGS) \
+			-I $(top_srcdir)/man/$*.h2m \
+			-n $(if $($(subst -,_,$*)_DESCRIPTION), $($(subst -,_,$*)_DESCRIPTION), "manual page for $*") \
+			-o $@ \
+		$(abs_top_builddir)/$<
--- a/libpolys/configure.ac
+++ b/libpolys/configure.ac
@@ -37,6 +37,9 @@
 
 SING_WIN_FLAGS
 
+# Checks for programs.
+AC_PATH_PROG([HELP2MAN],[help2man])
+
 # Checks for libraries.
 # This test for -lpthread etc has to come before AX_PTHREAD,
 # because libtool tends to ignore -pthread in linking shared C++-libs
--- a/libpolys/Makefile.am
+++ b/libpolys/Makefile.am
@@ -2,6 +2,17 @@
 
 bin_SCRIPTS = libpolys-config
 
+man_MANS = libpolys-config.1
+
+AM_H2MFLAGS = \
+	--manual="CAS Singular" \
+	--source="Singular" \
+	--libtool \
+	--no-info
+
+## short descriptions for manpages
+libpolys_config_DESCRIPTION = "get information about installed Singular polynomial library"
+
 SUBDIRS=misc reporter coeffs polys tests
 
 configheaderdir = ${includedir}/singular
@@ -10,3 +21,12 @@
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libpolys.pc
+
+%.1: %
+	$(HELP2MAN) \
+			-s 1 \
+			$(AM_H2MFLAGS) \
+			-I $(top_srcdir)/man/$*.h2m \
+			-n $(if $($(subst -,_,$*)_DESCRIPTION), $($(subst -,_,$*)_DESCRIPTION), "manual page for $*") \
+			-o $@ \
+		$(abs_top_builddir)/$<
