@@ -8,7 +8,13 @@ CABAL := Pandoc.cabal
88NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL).in)
99THIS := $(shell echo $(NAME) | tr A-Z a-z)
1010VERSION := $(shell sed -ne 's/^[Vv]ersion:[[:space:]]*//p' $(CABAL).in)
11−BINS := $(shell sed -ne 's/^[Ee]xecutable:[[:space:]]*//p' $(CABAL).in)
11+EXECS := $(shell sed -ne 's/^[Ee]xecutable:[[:space:]]*//p' $(CABAL).in)
12+
13+#-------------------------------------------------------------------------------
14+# Build targets
15+#-------------------------------------------------------------------------------
16+BINS := $(EXECS)
17+DOCS := README.html
1218
1319#-------------------------------------------------------------------------------
1420# Variables to setup through environment
@@ -52,8 +58,9 @@ GHC_PKG := ghc-pkg
5258# Recipes
5359#-------------------------------------------------------------------------------
5460
61+# Default target.
5562.PHONY: all
56−all: $(BINS)
63+all: build-program
5764
5865# Document process rules.
5966%.html: % $(THIS)
@@ -84,6 +91,21 @@ $(BUILDCONF): $(CABAL)
8491build: templates configure
8592 $(BUILDCMD) build
8693
94+.PHONY: build-exec
95+build-exec: $(BINS)
96+cleanup_files+=$(BINS)
97+$(BINS): build
98+ find $(BUILDDIR) -type f -name "$(BINS)" -perm +a=x -exec cp {} . \;
99+
100+.PHONY: build-doc
101+DOCS:=README.html
102+cleanup_files+=$(DOCS)
103+build-doc: $(DOCS)
104+$(DOCS): build-exec
105+
106+.PHONY: build-program
107+build-program: build-exec build-doc
108+
87109.PHONY: build-lib-doc haddock
88110build-lib-doc: html
89111haddock: build-lib-doc
@@ -92,12 +114,8 @@ html/: configure
92114 -rm -rf html
93115 $(BUILDCMD) haddock && mv $(BUILDDIR)/doc/html .
94116
95−cleanup_files+=$(BINS)
96−$(BINS): build
97− find $(BUILDDIR) -type f -name "$(BINS)" -perm +a=x -exec cp {} . \;
98−
99117.PHONY: build-all
100−build-all: build $(BINS) build-lib-doc
118+build-all: all build-lib-doc
101119
102120# XXX: Note that we don't handle PREFIX correctly at the install-* stages,
103121# i.e. any PREFIX given at the configuration time is lost, unless it is
@@ -105,10 +123,9 @@ build-all: build $(BINS) build-lib-doc
105123
106124# User documents installation.
107125.PHONY: install-doc uninstall-doc
108−doc_all:=README.html README BUGS TODO
109126man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))
110−cleanup_files+=README.html
111−install-doc: $(BINS) $(doc_all)
127+doc_all:=$(DOCS) README BUGS TODO
128+install-doc: build-doc
112129 $(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(doc_all) $(DOCPATH)/
113130 for f in $(man_all); do \
114131 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
@@ -130,7 +147,7 @@ uninstall-lib-doc:
130147# Program only installation.
131148.PHONY: install-exec uninstall-exec
132149bin_all:=$(BINS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
133−install-exec: $(bin_all)
150+install-exec: build-exec
134151 $(INSTALL) -d $(BINPATH); \
135152 for f in $(bin_all); do $(INSTALL_PROGRAM) $$f $(BINPATH)/; done
136153uninstall-exec:
@@ -170,7 +187,7 @@ doc_more:=README.rtf LICENSE.rtf $(osx_src)/Welcome.rtf
170187osx_pkg_name:=Pandoc_$(VERSION).pkg
171188cleanup_files+=$(osx_dest) $(doc_more) $(osx_pkg_name)
172189osx-pkg-prep: $(osx_dest)
173−$(osx_dest)/: $(doc_more) $(BINS)
190+$(osx_dest)/: build-exec $(doc_more)
174191 -rm -rf $(osx_dest)
175192 $(INSTALL) -d $(osx_dest)
176193 DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
@@ -214,9 +231,9 @@ $(osx_dmg_name): $(osx_pkg_name)
214231 mv Pandoc.udzo.dmg $(osx_dmg_name)
215232
216233.PHONY: test test-markdown
217−test: $(BINS)
234+test: build-exec
218235 @cd tests && perl runtests.pl -s $(PWD)/$(THIS)
219−test-markdown: $(BINS)
236+test-markdown: build-exec
220237 @cd tests/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(THIS) -tidy
221238
222239# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.