Skip to contentSkip to conversation

Makefile cleanups

PATCH In review Akira Yokosawa 2 participants 4 messages Oct 13, 2016 – Oct 14, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Makefile cleanups

From 3fc3583818c9103ef2d1c01516b362c4b6768604 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Thu, 13 Oct 2016 20:51:46 +0900
Subject: [PATCH 0/2] Makefile cleanups

Hi,

Here is a patch set sequel to commit 0e6e192e6ea7 ("Makefile: Use implicit rules for various layout options").

1st patch shortens some rules by using automatic variables. 2nd one gets rid of apparent dependency rules like "1c: perfbook-1c.pdf" by using secondary-expansion feature of GNU make.

Now almost all redundant rules have been removed. There is no change in the behavior of make command.

This set is a by-product of my attempt to try some alternative monospace fonts to be used among Times Roman text. To give you an easy way to compare candidates, I'm preparing patches to add a few make targets, but not sure where it goes. This cleanup set seems worthwhile on its own.

Thanks, Akira

Akira Yokosawa (2):
Makefile: Use more automatic variables
Makefile: Use seconday expansion

 .gitignore |  7 ++-----
 Makefile   | 28 ++++++++++++++--------------
 2 files changed, 16 insertions(+), 19 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 Makefile: Use more automatic variables

From 2d0765641c633f9e259339f0814259aefbae863e Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Sun, 9 Oct 2016 20:38:46 +0900
Subject: [PATCH 1/2] Makefile: Use more automatic variables

This commit simplifies some rules by using automatic variables such as "$<" and "$@".
It also simplifies the "clean" rule by using wildcards. .gitignore is modified accordingly.

---
 .gitignore |  7 ++-----
 Makefile   | 15 +++++++--------
 2 files changed, 9 insertions(+), 13 deletions(-)
.gitignore +2 -5
index 4a2dc33..965b94d 100644
@@ -18,11 +18,8 @@ perfbook_flat.tex
 qqz.tex
 contrib.tex
 origpub.tex
-perfbook.out
-perfbook-1c.tex
-perfbook-1c.out
-perfbook-hb.tex
-perfbook-hb.out
+perfbook*.out
+perfbook-*.tex
 extraction
 embedfonts
 
Makefile +7 -8
index 55361c3..6e6d66b 100644
@@ -80,22 +80,22 @@ perfbook_flat.tex: perfbook.tex $(LATEXSOURCES) $(PDFTARGETS_OF_EPS) $(PDFTARGET
 	echo > qqz.tex
 	echo > contrib.tex
 	echo > origpub.tex
-	texexpand perfbook.tex > perfbook_flat.tex
+	texexpand perfbook.tex > $@
 
 qqz.tex: perfbook_flat.tex
-	sh utilities/extractqqz.sh < perfbook_flat.tex > qqz.tex
+	sh utilities/extractqqz.sh < $< > $@
 
 contrib.tex: perfbook_flat.tex qqz.tex
-	cat perfbook_flat.tex qqz.tex | sh utilities/extractcontrib.sh > contrib.tex
+	cat $^ | sh utilities/extractcontrib.sh > $@
 
 origpub.tex: perfbook_flat.tex
-	sh utilities/extractorigpub.sh < perfbook_flat.tex > origpub.tex
+	sh utilities/extractorigpub.sh < $< > $@
 
 perfbook-1c.tex: perfbook.tex
-	sed -e 's/,twocolumn//' -e 's/setboolean{twocolumn}{true}/setboolean{twocolumn}{false}/' < perfbook.tex > perfbook-1c.tex
+	sed -e 's/,twocolumn//' -e 's/setboolean{twocolumn}{true}/setboolean{twocolumn}{false}/' < $< > $@
 
 perfbook-hb.tex: perfbook.tex
-	sed -e 's/,twocolumn/&,letterpaperhb/' -e 's/setboolean{hardcover}{false}/setboolean{hardcover}{true}/' < perfbook.tex > perfbook-hb.tex
+	sed -e 's/,twocolumn/&,letterpaperhb/' -e 's/setboolean{hardcover}{false}/setboolean{hardcover}{true}/' < $< > $@
 
 # Rules related to perfbook_html are removed as of May, 2016
 
@@ -139,9 +139,8 @@ clean:
 	find . -name '*.aux' -o -name '*.blg' \
 		-o -name '*.dvi' -o -name '*.log' \
 		-o -name '*.qqz' -o -name '*.toc' -o -name '*.bbl' | xargs rm -f
-	rm -f perfbook_flat.tex perfbook.out perfbook-1c.out
+	rm -f perfbook_flat.tex perfbook*.out perfbook-*.tex
 	rm -f $(LATEXGENERATED)
-	rm -f perfbook-hb.out perfbook-1c.tex perfbook-hb.tex
 	rm -f extraction
 
 distclean: clean
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 Makefile: Use secondary expansion

In reply to Akira Yokosawa

From 3fc3583818c9103ef2d1c01516b362c4b6768604 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Mon, 10 Oct 2016 00:10:27 +0900
Subject: [PATCH 2/2] Makefile: Use secondary expansion

By using secondary expansion, abbreviated targets' dependencies can be expressed as a single rule.

---
 Makefile | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
Makefile +7 -6
index 6e6d66b..eb83af4 100644
@@ -9,7 +9,9 @@ LATEXSOURCES = \
 
 LATEXGENERATED = qqz.tex contrib.tex origpub.tex
 
-PDFTARGETS := perfbook.pdf perfbook-1c.pdf perfbook-hb.pdf
+ABBREVTARGETS := 1c hb
+
+PDFTARGETS := perfbook.pdf $(foreach v,$(ABBREVTARGETS),perfbook-$(v).pdf)
 
 EPSSOURCES_FROM_TEX := \
 	SMPdesign/DiningPhilosopher5.eps \
@@ -58,15 +60,11 @@ else
 	targ = $(default)
 endif
 
-.PHONY: all touchsvg clean distclean neatfreak 1c 2c hb ls-unused
+.PHONY: all touchsvg clean distclean neatfreak 2c ls-unused $(ABBREVTARGETS)
 all: $(targ)
 
-1c: perfbook-1c.pdf
-
 2c: perfbook.pdf
 
-hb: perfbook-hb.pdf
-
 $(PDFTARGETS): %.pdf: %.tex %.bbl
 	sh utilities/runlatex.sh $(basename $@)
 
@@ -156,3 +154,6 @@ ls-unused:
 neatfreak: distclean
 	# Don't forget to regenerate the .pdf from each .svg file
 	find . -name '*.pdf' | xargs rm -f
+
+.SECONDEXPANSION:
+$(ABBREVTARGETS): %: [email protected]
Signature · 1 line
2.7.4
#3 lore raw
In reply to Akira Yokosawa
Quoted 24 lines · Akira Yokosawa
Quoted 1 line

From 3fc3583818c9103ef2d1c01516b362c4b6768604 Mon Sep 17 00:00:00 2001

From: Akira Yokosawa <[email protected]>
Date: Thu, 13 Oct 2016 20:51:46 +0900
Subject: [PATCH 0/2] Makefile cleanups

Hi,

Here is a patch set sequel to commit 0e6e192e6ea7 ("Makefile: Use implicit rules for various layout options").

1st patch shortens some rules by using automatic variables. 2nd one gets rid of apparent dependency rules like "1c: perfbook-1c.pdf" by using secondary-expansion feature of GNU make.

Now almost all redundant rules have been removed. There is no change in the behavior of make command.

This set is a by-product of my attempt to try some alternative monospace fonts to be used among Times Roman text. To give you an easy way to compare candidates, I'm preparing patches to add a few make targets, but not sure where it goes. This cleanup set seems worthwhile on its own.

Thanks, Akira

Quoted 7 lines

Akira Yokosawa (2):
Makefile: Use more automatic variables
Makefile: Use seconday expansion

 .gitignore |  7 ++-----
 Makefile   | 28 ++++++++++++++--------------
 2 files changed, 16 insertions(+), 19 deletions(-)

Applied and pushed, thank you!

Thanx, Paul