<newsletter:master> Improve Makefile

Colomban Wendling git-noreply at xxxxx
Thu Mar 31 18:33:01 UTC 2011


Updating branch refs/heads/master
         to 0dfe45cd12377d739fd153c600f74382e3ebfac7 (commit)
       from 42765e910663717448cde7b9f8b65fe21a84dbdb (commit)

commit 0dfe45cd12377d739fd153c600f74382e3ebfac7
Author: Colomban Wendling <ban at herbesfolles.org>
Date:   Thu Mar 31 20:21:02 2011 +0200

    Improve Makefile
    
     * Less duplicated stuff;
     * Targets now depend on their sources;
     * Make the current volume the default, rather than having no default;
     * Should still support BSD and GNU make (at least).

 Makefile |   52 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index a72ae62..5ecb159 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,44 @@
-all: html pdf latex odt
+#!/usr/bin/make -f
 
-html:
-	rst2html --stylesheet=style.css \
-		vol_$(VOL)/newsletter_$(VOL).rst > vol_$(VOL)/newsletter_$(VOL).html
+# build the current volume if none provided
+VOL			?= 2
 
-pdf:
-	rst2pdf vol_$(VOL)/newsletter_$(VOL).rst -o vol_$(VOL)/newsletter_$(VOL).pdf
+NAME		=	vol_$(VOL)/newsletter_$(VOL)
+OUTPUT_HTML	=	$(NAME).html
+OUTPUT_PDF	=	$(NAME).pdf
+OUTPUT_ODT	=	$(NAME).odt
+OUTPUT_TEX	=	$(NAME).tex
+OUTPUTS		=	$(OUTPUT_HTML) \
+				$(OUTPUT_PDF) \
+				$(OUTPUT_ODT) \
+				$(OUTPUT_TEX)
 
-latex:
-	rst2latex vol_$(VOL)/newsletter_$(VOL).rst > vol_$(VOL)/newsletter_$(VOL).tex
+.PHONY: all clean html pdf odt tex
 
-odt:
-	rst2odt vol_$(VOL)/newsletter_$(VOL).rst > vol_$(VOL)/newsletter_$(VOL).odt
+.SUFFIXES: .rst .html .pdf .tex .odt
+
+all: $(OUTPUTS)
+
+# convenience aliases
+html:	$(OUTPUT_HTML)
+pdf:	$(OUTPUT_PDF)
+odt:	$(OUTPUT_ODT)
+tex:	$(OUTPUT_TEX)
 
 clean:
-	rm -f vol_$(VOL)/newsletter_$(VOL).html
-	rm -f vol_$(VOL)/newsletter_$(VOL).pdf
-	rm -f vol_$(VOL)/newsletter_$(VOL).odt
-	rm -f vol_$(VOL)/newsletter_$(VOL).tex
+	rm -f $(OUTPUTS)
+
+.rst.html:
+	rst2html --stylesheet=style.css $< > $@
+
+.rst.pdf:
+	rst2pdf $< -o $@
+
+.rst.tex:
+	rst2latex $< > $@
+
+.rst.odt:
+	rst2odt $< > $@
+
+# extra dependencies we cannot add to suffix rules
+$(OUTPUT_HTML): style.css



More information about the Newsletter-Commits mailing list