For illustration purposes only, I know we can't commit this as-is.
From 526abc6eed9511de263df36b806565ba1e4a5070 Mon Sep 17 00:00:00 2001
From: Hans Ulrich Niedermann
Date: Tue, 30 Oct 2007 02:11:41 +0100
Subject: [PATCH] Automatically update man page from rhd_id.c
In a normal build in src/ ("make", "make all"), ensure that the
man page (man/radeonhd.man) is consistent with rhd_id.c.
If this requires man/radeonhd.man to be changed, display error
error message and abort the build to notify the developer that he
needs to add man/radeonhd.man to his next commit.
The next build will succeed unconditionally.
---
Makefile.am | 3 ++-
man/radeonhd.man | 24 ++++++++++++++----------
src/Makefile.am | 32 ++++++++++++++++++++++++++++++++
src/rhd_id.c | 2 ++
4 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 0ef7755..54df8dd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,8 @@
# OTHER DEALINGS IN THE SOFTWARE.
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = man src utils/conntest
+# src before man: src/ may update sources in man/
+SUBDIRS = src man utils/conntest
EXTRA_DIST = RadeonHD.tmpl Imakefile git_version.sh ChangeLog
MAINTAINERCLEANFILES = ChangeLog
diff --git a/man/radeonhd.man b/man/radeonhd.man
index 4d8f2b3..e09aafb 100644
--- a/man/radeonhd.man
+++ b/man/radeonhd.man
@@ -58,12 +58,10 @@ A more up-to-date list can be found on the wiki page.
The
.B radeonhd
driver supports video cards based on the following ATI chips:
-.\" The following list was generated from "X -logverbose 7" by the following command:
-.\" sed -n '/^\t[RM][A-Z0-9]\+ * : /{ s/\.$//; s/^\t\([A-Z0-9]\+\) \+: \(.*\)/.TP 8\n.B \1\n\2/; p};' /var/log/Xorg.0.log
-.\" TODO: Note that this line doesn't deal with multi-line output correctly
-.\" The list replicates the output of RHDIdentify() in src/rhd_id.c.
.PP
.PD 0
+.\" This list is generated from the RHDIdentify() function in src/rhd_id.c.
+.\" START_DEVICE_LIST marker - do not delete
.TP 8
.B RV505
Radeon X1550, X1550 64bit
@@ -105,13 +103,14 @@ Radeon HD 2350, HD 2400 Pro/XT, HD 2400 Pro AGP; FireGL V4000
Radeon HD 3450, HD 3470
.TP 8
.B RV630
-Radeon HD 2600 LE/Pro/XT, HD 2600 Pro/XT AGP; Gemini RV630; FireGL V3600/V5600
+Radeon HD 2600 LE/Pro/XT, HD 2600 Pro/XT AGP; Gemini RV630;
+FireGL V3600/V5600
.TP 8
.B RV635
Radeon HD 3650, HD 3670
.TP 8
.B RV670
-Radeon HD 3850, HD 3870, FireGL V7700
+Radeon HD 3690, 3850, HD 3870, FireGL V7700, FireStream 9170
.TP 8
.B R680
Radeon HD 3870 X2
@@ -150,19 +149,24 @@ Mobility Radeon HD 2400; Radeon E2400
Mobility Radeon HD 2400 XT
.TP 8
.B M76
-Mobility Radeon HD 2600; (Gemini ATI) Mobility Radeon HD 2600 XT
+Mobility Radeon HD 2600;
+(Gemini ATI) Mobility Radeon HD 2600 XT
.TP 8
.B M82
Mobility Radeon HD 3400
.TP 8
-.B M86
-Mobility Radeon HD 3600
-.TP 8
.B RS600
Radeon Xpress 1200, Xpress 1250
.TP 8
.B RS690
Radeon X1200, X1250, X1270
+.TP 8
+.B RS780
+Radeon HD 3200 Series
+.TP 8
+.B RV770
+Radeon HD 4800 Series
+.\" END_DEVICE_LIST marker - do not delete
.PD
.\"
.\"
diff --git a/src/Makefile.am b/src/Makefile.am
index 3a349d1..1212486 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -108,3 +108,35 @@ libatom_la_SOURCES = \
radeonhd_drv_la_LIBADD = libatom.la
endif
+
+if MAINTAINER_MODE
+SRCMAN = $(top_srcdir)/man/radeonhd.man
+
+CLEANFILES += radeonhd.man.new
+radeonhd.man.new: rhd_id.c $(SRCMAN)
+ echo "Generating radeon.man.new..."; \
+ ( $(SED) -n '1,/^\.\\" START_DEVICE_LIST marker - do not delete/p' "$(SRCMAN)"; \
+ $(SED) -e '1,/^[ ]*\/\* START_DEVICE_LIST marker - do not delete \*\/ *$$/d' \
+ -e '/^[ ]*\/\* END_DEVICE_LIST marker - do not delete \*\/ *$$/,$$d' \
+ -e '/^[ ]\{1,\}xf86Msg(X_NONE,/d' \
+ -e '/^[ ]\{1,\}\/\*/d' \
+ -e 's/^[ ]\{1,\}"\\t\([A-Z0-9]\{1,\}\) \{1,\}: \(.*;\)\\n"$$/.TP 8\n.B \1\n\2/' \
+ -e 's/^[ ]\{1,\}"\\t\\t\(.*\)\.\\n"\();\)\{,1\}$$/\1/' \
+ -e 's/^[ ]\{1,\}"\\t\([A-Z0-9]\{1,\}\) \{1,\}: \(.*\)\.\\n"\();\)\{,1\}$$/.TP 8\n.B \1\n\2/' \
+ "$(srcdir)/rhd_id.c"; \
+ $(SED) -n '/^\.\\" END_DEVICE_LIST marker - do not delete/,$$p' "$(SRCMAN)" \
+ ) > radeonhd.man.new
+
+# Update man page from rhd_id.c RHDIdentify() output.
+# The exit(1) makes sure the update does not go unnoticed.
+all-local: radeonhd.man.new
+ @if diff -u "$(SRCMAN)" radeonhd.man.new; then \
+ echo "radeon(4) man page is current."; \
+ else \
+ echo "WARNING: New man pages differs from old one."; \
+ echo " Please check the changes to $(SRCMAN) and commit them together with your"; \
+ echo " changes to $(srcdir)/rhd_id.c."; \
+ mv -f radeonhd.man.new "$(SRCMAN)"; \
+ exit 1; \
+ fi
+endif
diff --git a/src/rhd_id.c b/src/rhd_id.c
index 301ab32..6a94653 100644
--- a/src/rhd_id.c
+++ b/src/rhd_id.c
@@ -319,6 +319,7 @@ void
RHDIdentify(int flags)
{
xf86Msg(X_INFO, "%s: X driver for the following AMD GPG (ATI) graphics devices:\n", RHD_NAME);
+ /* START_DEVICE_LIST marker - do not delete */
xf86Msg(X_NONE,
"\tRV505 : Radeon X1550, X1550 64bit.\n"
"\tRV515 : Radeon X1300, X1550, X1600; FireGL V3300, V3350.\n"
@@ -361,6 +362,7 @@ RHDIdentify(int flags)
"\tRS780 : Radeon HD 3200 Series.\n"
"\tRV770 : Radeon HD 4800 Series.\n"
/* NOT YET "\tRS740 : RS740, RS740M\n" */ );
+ /* END_DEVICE_LIST marker - do not delete */
xf86Msg(X_NONE, "\n");
xf86Msg(X_INFO, "%s: version %s, built from %s\n\n",
--
1.5.5.2