@@ -8,7 +8,13 @@ CABAL := Pandoc.cabal
8NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL).in)
8NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL).in)
9THIS := $(shell echo $(NAME) | tr A-Z a-z)
9THIS := $(shell echo $(NAME) | tr A-Z a-z)
10VERSION := $(shell sed -ne 's/^[Vv]ersion:[[:space:]]*//p' $(CABAL).in)
10VERSION := $(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)
13+#-------------------------------------------------------------------------------
15+#-------------------------------------------------------------------------------
13#-------------------------------------------------------------------------------
19#-------------------------------------------------------------------------------
14# Variables to setup through environment
20# Variables to setup through environment
@@ -52,8 +58,9 @@ GHC_PKG := ghc-pkg
53#-------------------------------------------------------------------------------
59#-------------------------------------------------------------------------------
55.PHONY: all
62.PHONY: all
56−all: $(BINS)
63+all: build-program
58# Document process rules.
65# Document process rules.
59%.html: % $(THIS)
66%.html: % $(THIS)
@@ -84,6 +91,21 @@ $(BUILDCONF): $(CABAL)
84build: templates configure
91build: templates configure
85 $(BUILDCMD) build
92 $(BUILDCMD) build
96+cleanup_files+=$(BINS)
98+ find $(BUILDDIR) -type f -name "$(BINS)" -perm +a=x -exec cp {} . \;
102+cleanup_files+=$(DOCS)
106+.PHONY: build-program
107+build-program: build-exec build-doc
87.PHONY: build-lib-doc haddock
109.PHONY: build-lib-doc haddock
88build-lib-doc: html
110build-lib-doc: html
89haddock: build-lib-doc
111haddock: build-lib-doc
@@ -92,12 +114,8 @@ html/: configure
92 -rm -rf html
114 -rm -rf html
93 $(BUILDCMD) haddock && mv $(BUILDDIR)/doc/html .
115 $(BUILDCMD) haddock && mv $(BUILDDIR)/doc/html .
95−cleanup_files+=$(BINS)
97− find $(BUILDDIR) -type f -name "$(BINS)" -perm +a=x -exec cp {} . \;
99.PHONY: build-all
117.PHONY: build-all
100−build-all: build $(BINS) build-lib-doc
118+build-all: all build-lib-doc
102# XXX: Note that we don't handle PREFIX correctly at the install-* stages,
120# XXX: Note that we don't handle PREFIX correctly at the install-* stages,
103# i.e. any PREFIX given at the configuration time is lost, unless it is
121# 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
106# User documents installation.
124# User documents installation.
107.PHONY: install-doc uninstall-doc
125.PHONY: install-doc uninstall-doc
108−doc_all:=README.html README BUGS TODO
109man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))
126man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))
110−cleanup_files+=README.html
127+doc_all:=$(DOCS) README BUGS TODO
111−install-doc: $(BINS) $(doc_all)
128+install-doc: build-doc
112 $(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(doc_all) $(DOCPATH)/
129 $(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(doc_all) $(DOCPATH)/
113 for f in $(man_all); do \
130 for f in $(man_all); do \
114 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
131 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
@@ -130,7 +147,7 @@ uninstall-lib-doc:
130# Program only installation.
147# Program only installation.
131.PHONY: install-exec uninstall-exec
148.PHONY: install-exec uninstall-exec
132bin_all:=$(BINS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
149bin_all:=$(BINS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
133−install-exec: $(bin_all)
150+install-exec: build-exec
134 $(INSTALL) -d $(BINPATH); \
151 $(INSTALL) -d $(BINPATH); \
135 for f in $(bin_all); do $(INSTALL_PROGRAM) $$f $(BINPATH)/; done
152 for f in $(bin_all); do $(INSTALL_PROGRAM) $$f $(BINPATH)/; done
136uninstall-exec:
153uninstall-exec:
@@ -170,7 +187,7 @@ doc_more:=README.rtf LICENSE.rtf $(osx_src)/Welcome.rtf
170osx_pkg_name:=Pandoc_$(VERSION).pkg
187osx_pkg_name:=Pandoc_$(VERSION).pkg
171cleanup_files+=$(osx_dest) $(doc_more) $(osx_pkg_name)
188cleanup_files+=$(osx_dest) $(doc_more) $(osx_pkg_name)
172osx-pkg-prep: $(osx_dest)
189osx-pkg-prep: $(osx_dest)
173−$(osx_dest)/: $(doc_more) $(BINS)
190+$(osx_dest)/: build-exec $(doc_more)
174 -rm -rf $(osx_dest)
191 -rm -rf $(osx_dest)
175 $(INSTALL) -d $(osx_dest)
192 $(INSTALL) -d $(osx_dest)
176 DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
193 DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
@@ -214,9 +231,9 @@ $(osx_dmg_name): $(osx_pkg_name)
214 mv Pandoc.udzo.dmg $(osx_dmg_name)
231 mv Pandoc.udzo.dmg $(osx_dmg_name)
216.PHONY: test test-markdown
233.PHONY: test test-markdown
217−test: $(BINS)
234+test: build-exec
218 @cd tests && perl runtests.pl -s $(PWD)/$(THIS)
235 @cd tests && perl runtests.pl -s $(PWD)/$(THIS)
219−test-markdown: $(BINS)
236+test-markdown: build-exec
220 @cd tests/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(THIS) -tidy
237 @cd tests/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(THIS) -tidy
222# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
239# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.