diff rogue3/Makefile.in @ 223:0e99eade579c

Generate text documentation from the troff source files. This is done by make, in the 'docs' target, which is now part of the normal build process. Unfortunately, not all the games include troff sources. Getting decent HTML output from groff is still a difficult process which will not be attempted at this time. There are a few bugs in the 'install' and 'uninstall' rules. Not to mention that the documentation is sometimes inaccurate.
author John "Elwin" Edwards
date Sun, 21 Feb 2016 20:47:12 -0500
parents a666e4a034ed
children 4d0f53998e8a
line wrap: on
line diff
--- a/rogue3/Makefile.in	Fri Feb 12 15:12:37 2016 -0500
+++ b/rogue3/Makefile.in	Sun Feb 21 20:47:12 2016 -0500
@@ -48,9 +48,9 @@
 
 MISC_C=
 DOCSRC= rogue.6 rogue.r
-DOCS  = $(PROGRAM).doc $(PROGRAM).cat $(PROGRAM).html readme36.html
+DOCS  = $(PROGRAM).doc $(PROGRAM).cat
 MISC  =	Makefile $(MISC_C) LICENSE.TXT $(PROGRAM).sln $(PROGRAM).vcproj $(DOCS)\
-	$(DOCSRC)
+	$(DOCSRC) rogue36.html readme36.html
 
 CC    = gcc
 CPPFLAGS =@DEFS@
@@ -62,21 +62,43 @@
 LD    = $(CC)
 LDOUT = -o 
 INSTALL=@INSTALL@
+GROFF=@GROFF@
+NROFF=@NROFF@
+COLCRT=@COLCRT@
+TBL=@TBL@
 
 .SUFFIXES: .obj
 
 .c.obj:
 	$(CC) $(CFLAGS) /c $*.c
 
+all: $(PROGRAM)$(EXE) docs
+
 $(PROGRAM)$(EXE): $(HDRS) $(OBJS)
 	$(LD) $(LDFLAGS) $(OBJS) $(LIBS) $(LDOUT)$@
 
 clean:
 	$(RM) $(OBJS1)
 	$(RM) $(OBJS2)
-	$(RM) core $(PROGRAM) $(PROGRAM).exe $(DISTNAME).tar $(DISTNAME).tar.gz 
+	$(RM) core $(PROGRAM) $(PROGRAM).exe $(DOCS) $(DISTNAME).tar $(DISTNAME).tar.gz 
 	$(RM) $(DISTNAME).zip
 
+docs: $(DOCS)
+
+$(PROGRAM).doc: rogue.r
+	if test "x$(GROFF)" != "x" ; then \
+	$(GROFF) -P-c -P-b -P-u -t -ms -Tutf8 rogue.r > $(PROGRAM).doc ;\
+	elif test "x$(NROFF)" != "x" -a "x$(TBL)" != "x" -a "x$(COLCRT)" != "x" ; then \
+	$(TBL) rogue.r | $(NROFF) -ms | $(COLCRT) - > $(PROGRAM).doc ;\
+	fi
+
+$(PROGRAM).cat: rogue.6
+	if test "x$(GROFF)" != "x" ; then \
+	$(GROFF) -P-c -P-b -P-u -Tascii -man rogue.6 > $(PROGRAM).cat ;\
+	elif test "x$(NROFF)" != "x" -a "x$(COLCRT)" != "x" ; then \
+	$(NROFF) -man rogue.6 | $(COLCRT) - > $(PROGRAM).cat ;\
+	fi
+
 install: $(PROGRAM)
 	-touch test
 	-if test ! -f $(DESTDIR)$(SCOREFILE) ; \
@@ -104,12 +126,16 @@
 	    then mkdir -p $(DESTDIR)$(docdir) ; fi
 	-$(INSTALL) -m 0644 LICENSE.TXT $(DESTDIR)$(docdir)/LICENSE.TXT
 	-$(INSTALL) -m 0644 rogue.r $(DESTDIR)$(docdir)/$(PROGRAM).r
+	-$(INSTALL) -m 0644 $(PROGRAM).doc $(DESTDIR)$(docdir)/$(PROGRAM).doc
+	-$(INSTALL) -m 0644 $(PROGRAM).cat $(DESTDIR)$(docdir)/$(PROGRAM).cat
 	-$(RM) test
 
 uninstall:	
 	-$(RM) $(DESTDIR)$(bindir)/$(PROGRAM)
 	-$(RM) $(DESTDIR)$(man6dir)/$(PROGRAM).6
-	-$(RM) $(DESTDIR)$(docdir)$(PROGRAM)/$(PROGRAM).doc
+	-$(RM) $(DESTDIR)$(docdir)/$(PROGRAM).r
+	-$(RM) $(DESTDIR)$(docdir)/$(PROGRAM).doc
+	-$(RM) $(DESTDIR)$(docdir)/$(PROGRAM).cat
 	-$(RMDIR) $(DESTDIR)$(docdir)$(PROGRAM)
     
 reinstall: uninstall install