From 129e34bf6768596a992dbf19eff46718f3009410 Mon Sep 17 00:00:00 2001
From: "James K. Lowden" <jklowden@symas.com>
Date: Mon, 3 Feb 2025 18:36:22 -0500
Subject: [PATCH] support --enable-generated-files-in-srcdir

---
 gcc/cobol/Make-lang.in | 25 +++++++++++++++----------
 gcc/cobol/gcobol.1     |  8 +++++---
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in
index 310f968d9b2d..80dba2c1099e 100644
--- a/gcc/cobol/Make-lang.in
+++ b/gcc/cobol/Make-lang.in
@@ -49,10 +49,6 @@ BINCLUDE ?= ./gcc
 LIB_INCLUDE ?= $(srcdir)/../libgcobol
 LIB_SOURCE ?= $(srcdir)/../libgcobol
 
-EXTRA_DIST = parse.h parse.c cdf.h cdf.c	\
-		gcobol.html gcobol-io.html	\
-		gcobol.pdf gcobol-io.pdf
-
 #
 # At this point, as of 2022-10-21, CPPFLAGS is an empty string and can be
 # altered.  CFLAGS and CXXFLAGS are being established upstream, and thus
@@ -173,6 +169,9 @@ cobol/cdf.c: cobol/cdf.y
 	$(BISON) -o $@ $(YFLAGS)						\
 		--defines=cobol/cdf.h --report-file=cobol/cdf.out $<
 
+cobol.srcextra: cobol/parse.c cobol/cdf.c
+	ln -f $^ cobol/parse.h cobol/cdf.h $(srcdir)/cobol/
+
 # See "Trailing context is getting confused with trailing optional patterns"
 # in Flex manual. We suppress those messages, as a convenience.
 FLEX_WARNING = warning, dangerous trailing context
@@ -282,29 +281,34 @@ cobol.install-pdf: installdirs gcobol.pdf gcobol-io.pdf
 cobol.install-plugin:
 
 cobol.install-html: installdirs gcobol.html gcobol-io.html
-	mkdir -p $(DESTDIR)$(datadir)/gcobol/html
-	$(INSTALL_DATA) gcobol.html gcobol-io.html $(DESTDIR)$(datadir)/gcobol/html/
+	$(INSTALL_DATA) gcobol.html gcobol-io.html $(DESTDIR)$(htmldir)/
 
 cobol.info:
+cobol.srcinfo:
 
 cobol.dvi:
+cobol.srcdvi:
 
 cobol.pdf: gcobol.pdf gcobol-io.pdf
+cobol.srcpdf: gcobol.pdf gcobol-io.pdf
+	ln $^ $(srcdir)/cobol/
 
-gcobol.pdf: gcobol.1
+gcobol.pdf: $(srcdir)/cobol/gcobol.1
 	groff -mdoc -T pdf  $^ > $@~
 	@mv $@~ $@
-gcobol-io.pdf: gcobol.3
+gcobol-io.pdf: $(srcdir)/cobol/gcobol.3
 	groff -mdoc -T pdf  $^ > $@~
 	@mv $@~ $@
 
 cobol.html: gcobol.html gcobol-io.html
+cobol.srchtml: gcobol.html gcobol-io.html
+	ln $^ $(srcdir)/cobol/
 
 gcobol.html: $(srcdir)/cobol/gcobol.1
-	mandoc $^ -T html > $@
+	mandoc -T html $^ > $@~
 	@mv $@~ $@
 gcobol-io.html: $(srcdir)/cobol/gcobol.3
-	mandoc $^ -T html > $@
+	mandoc -T html $^ > $@~
 	@mv $@~ $@
 
 # "make uninstall" is not expected to work.  It's not clear how to name
@@ -317,6 +321,7 @@ cobol.uninstall:
 		$(DESTDIR)$(man3dir)/gcobol.3
 
 cobol.man:
+cobol.srcman:
 
 cobol.mostlyclean:
 
diff --git a/gcc/cobol/gcobol.1 b/gcc/cobol/gcobol.1
index 169f0a478c6d..5bd8dcfab7f7 100644
--- a/gcc/cobol/gcobol.1
+++ b/gcc/cobol/gcobol.1
@@ -21,7 +21,7 @@
 .Fl main Ns Li = Ns Ar filename
 .Fl main Ns Li = Ns Ar filename:program-id
 .Oc
-.Op Fl fcobol-exceptions Ar exception Ns Op Ns , Ns Ar exception Ns ...
+.Op Fl fcobol-exceptions Ar exception Ns Op Ns \/, Ns Ar exception Ns ...
 .Op Fl copyext Ar ext
 .Op Fl ffixed-form | Fl ffree-form
 .Op Fl findicator-column
@@ -1588,12 +1588,14 @@ foundation on which any needed extensions can be built.
 author's knowledge, free \*[lang] compilers first began to appear in 2000.
 Around that time an earlier \*[lang] for GCC project
 .br
-(https://cobolforgcc.sourceforge.net/)
+.Lk https://cobolforgcc.sourceforge.net/ cobolforgcc
 met with some success, but was never officially merged into GCC.
 .Pp
 This compiler,
 .Nm ,
-was begun by COBOLworx (www.cobolworx.com) in the fall of 2021. The
+was begun by
+.Lk https://www.cobolworx.com/ COBOLworx
+in the fall of 2021. The
 project announced a complete implementation of the core language
 features in December 2022.
 .
-- 
GitLab