git.iko.soy/typeable/pandoc
on master help sign in
More sanitizations in Makefile (needs testing):

+ Remove a bogus DOCS assignment line. + Cabal recreates pandoc executable by unnecessarily linking Main.o with library (it skips compiling *.hs files though). Since pandoc's time stamp is modified, it is copied from buildir to top directory, and also README.html is regenerated, each time a target which has a 'build' prerequisite is invoked. As a solution, now PHONY 'build' target depends on BUILDDIR/. + "THIS" variable has a confusing semantics and it is abusingly used in various targets. We in fact need it to specify package sub directories created during installation. Clarify this meaning by moving it to path variables section. + Create a new variable as MAIN which holds the main executable name. Sorry for my obsession to avoid simply using a magic "pandoc" name. :-) Modify all targets which (abusingly) refers to THIS and replace THIS with MAIN. Note that MAIN is derived from EXECS which in turn collects all executable names from Executable stanzas in cabal file. + As EXECS may hold more than one executable name, update EXECS target to reflect this semantic. + Rename BINS variable as PROGS and modify it so as to hold the names of all executables required to be installed. Remove bin_all local variable as PROGS can be used for the same purpose instead. + Modify DOCS variable so as to hold the names of all documents required to be installed. Remove doc_all local variable as DOCS can be used for the same purpose instead. + Remove DOCS target. README.html is already generated when needed. + Remove build-exec redundant prerequisite from osx_dest target. Make can find its way. + Set MAIN as the prerequisite of 'test' and 'test-markdown' to make things more clear. git-svn-id: https://pandoc.googlecode.com/svn/trunk@70 788f1e2b-df1e-0410-8736-df70ead52e1b

commit2066ec5d0274cae6d86e8c18896ba162d8a53be6 authorroktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 2 Nov 2006, 14:32 (20 years ago) parent2d2914f
1 file changed+31−31
Makefile+31−31
Makefile+31−31
@@ -6,15 +6,15 @@ CABAL := Pandoc.cabal
66# Cabal constants
77#-------------------------------------------------------------------------------
88NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL).in)
9−THIS := $(shell echo $(NAME) | tr A-Z a-z)
109VERSION := $(shell sed -ne 's/^[Vv]ersion:[[:space:]]*//p' $(CABAL).in)
1110EXECS := $(shell sed -ne 's/^[Ee]xecutable:[[:space:]]*//p' $(CABAL).in)
11+MAIN := $(word 1, $(EXECS)) # first entry in stanza is the main executable
1212
1313#-------------------------------------------------------------------------------
14−# Build targets
14+# Install targets
1515#-------------------------------------------------------------------------------
16−BINS := $(EXECS)
17−DOCS := README.html
16+PROGS := $(EXECS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
17+DOCS := README.html README BUGS TODO
1818
1919#-------------------------------------------------------------------------------
2020# Variables to setup through environment
@@ -35,6 +35,7 @@ CONFIGURE := configure
3535#-------------------------------------------------------------------------------
3636# Installation paths
3737#-------------------------------------------------------------------------------
38+THIS := $(shell echo $(NAME) | tr A-Z a-z) # package name
3839DESTPATH := $(DESTDIR)$(PREFIX)
3940BINPATH := $(DESTPATH)/bin
4041DATAPATH := $(DESTPATH)/share
@@ -63,13 +64,13 @@ GHC_PKG := ghc-pkg
6364all: build-program
6465
6566# Document process rules.
66−%.html: % $(THIS)
67− ./$(THIS) -s $< >$@ || rm -f $@
68−%.tex: % $(THIS)
69− ./$(THIS) -s -w latex $< >$@ || rm -f $@
70−%.rtf: % $(THIS)
71− ./$(THIS) -s -w rtf $< >$@ || rm -f $@
72−%.pdf: % $(THIS)
67+%.html: % $(MAIN)
68+ ./$(MAIN) -s $< >$@ || rm -f $@
69+%.tex: % $(MAIN)
70+ ./$(MAIN) -s -w latex $< >$@ || rm -f $@
71+%.rtf: % $(MAIN)
72+ ./$(MAIN) -s -w rtf $< >$@ || rm -f $@
73+%.pdf: % $(MAIN)
7374 sh ./markdown2pdf $< || rm -f $@
7475
7576.PHONY: templates
@@ -88,20 +89,21 @@ $(BUILDCONF): $(CABAL)
8889 $(BUILDCMD) configure --prefix=$(PREFIX)
8990
9091.PHONY: build
91−build: templates configure
92+build: $(BUILDDIR)
93+$(BUILDDIR)/: templates configure
9294 $(BUILDCMD) build
9395
9496.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 {} . \;
97+build-exec: $(EXECS)
98+cleanup_files+=$(EXECS)
99+$(EXECS): $(BUILDDIR)
100+ for f in $@; do \
101+ find $(BUILDDIR) -type f -name "$$f" -perm +a=x -exec cp {} . \; ; \
102+ done
99103
100104.PHONY: build-doc
101−DOCS:=README.html
102−cleanup_files+=$(DOCS)
105+cleanup_files+=README.html
103106build-doc: $(DOCS)
104−$(DOCS): build-exec
105107
106108.PHONY: build-program
107109build-program: build-exec build-doc
@@ -124,15 +126,14 @@ build-all: all build-lib-doc
124126# User documents installation.
125127.PHONY: install-doc uninstall-doc
126128man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))
127−doc_all:=$(DOCS) README BUGS TODO
128129install-doc: build-doc
129− $(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(doc_all) $(DOCPATH)/
130+ $(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(DOCS) $(DOCPATH)/
130131 for f in $(man_all); do \
131132 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
132133 $(INSTALL_DATA) $(MANDIR)/$$f $(MANPATH)/$$f; \
133134 done
134135uninstall-doc:
135− -for f in $(doc_all); do rm -f $(DOCPATH)/$$f; done
136+ -for f in $(DOCS); do rm -f $(DOCPATH)/$$f; done
136137 -for f in $(man_all); do rm -f $(MANPATH)/$$f; done
137138 -rmdir $(DOCPATH)
138139
@@ -146,12 +147,11 @@ uninstall-lib-doc:
146147
147148# Program only installation.
148149.PHONY: install-exec uninstall-exec
149−bin_all:=$(BINS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
150150install-exec: build-exec
151151 $(INSTALL) -d $(BINPATH); \
152− for f in $(bin_all); do $(INSTALL_PROGRAM) $$f $(BINPATH)/; done
152+ for f in $(PROGS); do $(INSTALL_PROGRAM) $$f $(BINPATH)/; done
153153uninstall-exec:
154− -for f in $(bin_all); do rm -f $(BINPATH)/$$f; done
154+ -for f in $(PROGS); do rm -f $(BINPATH)/$$f; done
155155
156156# Program + user documents installation.
157157.PHONY: install-program uninstall-program
@@ -187,13 +187,13 @@ doc_more:=README.rtf LICENSE.rtf $(osx_src)/Welcome.rtf
187187osx_pkg_name:=Pandoc_$(VERSION).pkg
188188cleanup_files+=$(osx_dest) $(doc_more) $(osx_pkg_name)
189189osx-pkg-prep: $(osx_dest)
190−$(osx_dest)/: build-exec $(doc_more)
190+$(osx_dest)/: $(doc_more)
191191 -rm -rf $(osx_dest)
192192 $(INSTALL) -d $(osx_dest)
193193 DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
194194 cp $(osx_src)/uninstall-pandoc $(osx_dest)/Package_root/usr/local/bin/
195195 find $(osx_dest) -type f -regex ".*bin/.*" | xargs chmod +x
196− find $(osx_dest) -type f -regex ".*bin/$(THIS)" | xargs $(STRIP)
196+ find $(osx_dest) -type f -regex ".*bin/$(MAIN)" | xargs $(STRIP)
197197 $(INSTALL) -d $(osx_dest)/Resources
198198 cp README.rtf $(osx_dest)/Resources/ReadMe.rtf
199199 cp LICENSE.rtf $(osx_dest)/Resources/License.rtf
@@ -231,10 +231,10 @@ $(osx_dmg_name): $(osx_pkg_name)
231231 mv Pandoc.udzo.dmg $(osx_dmg_name)
232232
233233.PHONY: test test-markdown
234−test: build-exec
235− @cd tests && perl runtests.pl -s $(PWD)/$(THIS)
236−test-markdown: build-exec
237− @cd tests/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(THIS) -tidy
234+test: $(MAIN)
235+ @cd tests && perl runtests.pl -s $(PWD)/$(MAIN)
236+test-markdown: $(MAIN)
237+ @cd tests/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(MAIN) -tidy
238238
239239# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
240240src_all:=$(shell find $(SRCDIR) -type f -name '*hs' | egrep -v '^\./(_darcs|lib|test)/')