5#-------------------------------------------------------------------------------
7#-------------------------------------------------------------------------------
8NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL).in)
9VERSION := $(shell sed -ne 's/^[Vv]ersion:[[:space:]]*//p' $(CABAL).in)
10EXECS := $(shell sed -ne 's/^[Ee]xecutable:[[:space:]]*//p' $(CABAL).in)
12# First entry in Cabal's executable stanza is the main executable.
13MAIN := $(word 1, $(EXECS))
15#-------------------------------------------------------------------------------
17#-------------------------------------------------------------------------------
18PROGS := $(EXECS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
19DOCS := README.html README BUGS TODO
21#-------------------------------------------------------------------------------
22# Constant names and commands in source tree
23#-------------------------------------------------------------------------------
27BUILDCONF := .setup-config
28BUILDCMD := runhaskell Setup.hs
32#-------------------------------------------------------------------------------
33# Variables to setup through environment
34#-------------------------------------------------------------------------------
36# Specify default values.
39# Attempt to set variables from a previous make session.
41# Fallback to defaults but allow to get the values from environment.
45#-------------------------------------------------------------------------------
47#-------------------------------------------------------------------------------
48THIS := $(shell echo $(NAME) | tr A-Z a-z)
49DESTPATH := $(DESTDIR)$(PREFIX)
50BINPATH := $(DESTPATH)/bin
51DATAPATH := $(DESTPATH)/share
52LIBPATH := $(DESTPATH)/$(NAME)-$(VERSION)
53DOCPATH := $(DATAPATH)/doc/$(THIS)
54LIBDOCPATH := $(DATAPATH)/doc/$(THIS)-doc
55MANPATH := $(DATAPATH)/man
56PKGPATH := $(DATAPATH)/$(THIS)
58#-------------------------------------------------------------------------------
59# Generic Makefile variables
60#-------------------------------------------------------------------------------
62INSTALL_PROGRAM := $(INSTALL) -m 755
63INSTALL_DATA := $(INSTALL) -m 644
68#-------------------------------------------------------------------------------
70#-------------------------------------------------------------------------------
76# Document process rules.
78 ./$(MAIN) -s $< >$@ || rm -f $@
80 ./$(MAIN) -s -w latex $< >$@ || rm -f $@
82 ./$(MAIN) -s -w rtf $< >$@ || rm -f $@
83%.pdf: % $(MAIN) markdown2pdf
84 sh ./markdown2pdf $< || rm -f $@
87templates: $(SRCDIR)/templates
89 $(MAKE) -C $(SRCDIR)/templates
91cleanup_files+=$(CABAL)
92$(CABAL): cabalize $(CABAL).in
93 ./cabalize <$(CABAL).in >$(CABAL)
96cleanup_files+=$(BUILDDIR) $(BUILDCONF) $(BUILDVARS)
97configure: $(BUILDCONF)
99 $(BUILDCMD) configure --prefix=$(PREFIX)
100 # Make configuration time settings persistent (definitely a hack).
101 @echo "PREFIX?=$(PREFIX)" >$(BUILDVARS)
102 @echo "DESTDIR?=$(DESTDIR)" >>$(BUILDVARS)
106$(BUILDDIR)/: templates configure
111cleanup_files+=$(EXECS)
114 find $(BUILDDIR) -type f -name "$$f" -perm +a=x -exec cp {} . \; ; \
118cleanup_files+=README.html
122build-program: build-exec build-doc
124.PHONY: build-lib-doc haddock
126haddock: build-lib-doc
130 $(BUILDCMD) haddock && mv $(BUILDDIR)/doc/html .
133build-all: build-program build-lib-doc
135# User documents installation.
136.PHONY: install-doc uninstall-doc
137man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))
138install-doc: build-doc
139 $(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(DOCS) $(DOCPATH)/
140 for f in $(man_all); do \
141 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
142 $(INSTALL_DATA) $(MANDIR)/$$f $(MANPATH)/$$f; \
145 -for f in $(DOCS); do rm -f $(DOCPATH)/$$f; done
146 -for f in $(man_all); do rm -f $(MANPATH)/$$f; done
149# Library documents installation.
150.PHONY: install-lib-doc uninstall-lib-doc
151install-lib-doc: build-lib-doc
152 $(INSTALL) -d $(LIBDOCPATH) && cp -a html $(LIBDOCPATH)/
154 -rm -rf $(LIBDOCPATH)/html
157# Program only installation.
158.PHONY: install-exec uninstall-exec
159install-exec: build-exec
160 $(INSTALL) -d $(BINPATH); \
161 for f in $(PROGS); do $(INSTALL_PROGRAM) $$f $(BINPATH)/; done
163 -for f in $(PROGS); do rm -f $(BINPATH)/$$f; done
165# Program + user documents installation.
166.PHONY: install-program uninstall-program
167install-program: install-exec install-doc
168uninstall-program: uninstall-exec uninstall-doc
171.PHONY: install-all uninstall-all
172install-all: install-doc install-lib-doc
173 destdir=$(DESTDIR); \
174 # Older Cabal versions have no '--destdir' option.
175 if $(BUILDCMD) copy --help | grep -q '\-\-destdir'; then \
176 opt="--destdir=$${destdir-/}"; \
178 opt="--copy-prefix=$${destdir}$(PREFIX)"; \
180 $(BUILDCMD) copy $$opt; \
182uninstall-all: uninstall-exec uninstall-doc uninstall-lib-doc
183 -pkg_id="$(NAME)-$(VERSION)"; \
184 libdir=$$($(GHC_PKG) field $$pkg_id library-dirs 2>/dev/null | \
185 sed 's/^library-dirs: *//'); \
186 if [ -d "$$libdir" ]; then \
187 $(BUILDCMD) unregister; \
189 rmdir $$(dirname $$libdir); \
191 echo "*** Couldn't locate library files for pkgid: $$pkg_id. ***"; \
194# Default installation recipe for a common deployment scenario.
195.PHONY: install uninstall
196install: install-program
197uninstall: uninstall-program
201doc_more:=README.rtf LICENSE.rtf $(osx_src)/Welcome.rtf
202osx_pkg_name:=Pandoc_$(VERSION).pkg
203cleanup_files+=$(osx_dest) $(doc_more) $(osx_pkg_name)
204osx-pkg-prep: build-program $(osx_dest)
205$(osx_dest)/: $(doc_more)
207 $(INSTALL) -d $(osx_dest)
208 DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
209 cp $(osx_src)/uninstall-pandoc $(osx_dest)/Package_root/usr/local/bin/
210 find $(osx_dest) -type f -regex ".*bin/.*" | xargs chmod +x
211 find $(osx_dest) -type f -regex ".*bin/$(MAIN)" | xargs $(STRIP)
212 $(INSTALL) -d $(osx_dest)/Resources
213 cp README.rtf $(osx_dest)/Resources/ReadMe.rtf
214 cp LICENSE.rtf $(osx_dest)/Resources/License.rtf
215 sed -e 's#@PREFIX@#$(PREFIX)#g' $(osx_src)/Welcome.rtf > $(osx_dest)/Resources/Welcome.rtf
216 sed -e 's/@VERSION@/$(VERSION)/g' $(osx_src)/Info.plist > $(osx_dest)/Info.plist
217 cp $(osx_src)/Description.plist $(osx_dest)/
219 if [ "`id -u`" != 0 ]; then \
220 echo "Root permissions needed to create OSX package!"; \
223 find $(osx_dest) | xargs chown root:wheel
224 PackageMaker -build -p $(osx_pkg_name) \
225 -f $(osx_dest)/Package_root \
226 -r $(osx_dest)/Resources \
227 -i $(osx_dest)/Info.plist \
228 -d $(osx_dest)/Description.plist
229 chgrp admin $(osx_pkg_name)
233osx_dmg_name:=Pandoc.dmg
234osx_dmg_volume:="Pandoc $(VERSION)"
235cleanup_files+=$(osx_dmg_name)
236osx-dmg: $(osx_dmg_name)
237$(osx_dmg_name): $(osx_pkg_name)
238 -rm -f $(osx_dmg_name)
239 hdiutil create $(osx_dmg_name) -size 05m -fs HFS+ -volname $(osx_dmg_volume)
240 dev_handle=`hdid $(osx_dmg_name) | grep Apple_HFS | \
241 perl -e '\$$_=<>; /^\\/dev\\/(disk.)/; print \$$1'`; \
242 ditto $(osx_pkg_name) /Volumes/$(osx_dmg_volume)/$(osx_pkg_name); \
243 hdiutil detach $$dev_handle
244 hdiutil convert $(osx_dmg_name) -format UDZO -o Pandoc.udzo.dmg
245 -rm -f $(osx_dmg_name)
246 mv Pandoc.udzo.dmg $(osx_dmg_name)
248.PHONY: test test-markdown
250 @cd tests && perl runtests.pl -s $(PWD)/$(MAIN)
251test-markdown: $(MAIN)
252 @cd tests/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(MAIN) -tidy
254# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
255src_all:=$(shell find $(SRCDIR) -type f -name '*hs' | egrep -v '^\./(_darcs|lib|test)/')
256cleanup_files+=$(patsubst %,$(SRCDIR)/%,tags tags.sorted)
258 cd $(SRCDIR) && hasktags -c $(src_all:$(SRCDIR)/%=%); \
259 LC_ALL=C sort tags >tags.sorted; mv tags.sorted tags
262 [ -x /usr/bin/fakeroot ] || { \
263 echo "*** Please install fakeroot package. ***"; \
266 [ -x /usr/bin/dpkg-buildpackage ] || { \
267 echo "*** Please install dpkg-dev package. ***"; \
270 if [ -x /usr/bin/debuild ]; then \
271 debuild -uc -us -i.svn -I.svn -i_darcs -I_darcs --lintian-opts -i; \
273 echo "*** Please install devscripts package. ***"; \
274 echo "*** Using dpkg-buildpackage for package building. ***"; \
275 dpkg-buildpackage -rfakeroot -uc -us -i.svn -I.svn -i_darcs -I_darcs; \
278.PHONY: distclean clean
280 if [ -d debian ]; then \
281 chmod +x debian/rules; fakeroot debian/rules clean; \
285 -if [ -f $(BUILDCONF) ]; then $(BUILDCMD) clean; fi
286 -rm -rf $(cleanup_files)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list