3#-------------------------------------------------------------------------------
4# Constant names and commands in source tree
5#-------------------------------------------------------------------------------
11BUILDCONF := $(BUILDDIR)/setup-config
14ODTSTYLES := odt-styles
16#-------------------------------------------------------------------------------
18#-------------------------------------------------------------------------------
19PKG := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL) | tr A-Z a-z)
20VERSION := $(shell sed -ne 's/^[Vv]ersion:[[:space:]]*//p' $(CABAL))
21PKGID := $(PKG)-$(VERSION)
22EXECSBASE := $(shell sed -ne 's/^[Ee]xecutable:\{0,1\}[[:space:]]*//p' $(CABAL))
24#-------------------------------------------------------------------------------
26#-------------------------------------------------------------------------------
27WRAPPERS := html2markdown markdown2pdf hsmarkdown
28# Add .exe extensions if we're running Windows/Cygwin.
29EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
30 sed -ne 's/^cygwin.*$$/\.exe/p')
31BUILDCMD := $(addsuffix $(EXTENSION), ./setup)
32EXECS := $(addsuffix $(EXTENSION),$(EXECSBASE))
33PROGS := $(EXECS) $(WRAPPERS)
34MAIN := $(firstword $(EXECS))
35DOCS := README.html README BUGS
36MANPAGES := $(patsubst %.md,%,$(wildcard $(MANDIR)/man?/*.?.md))
37ODTREF := $(ODTSTYLES)/reference.odt
39#-------------------------------------------------------------------------------
40# Variables to setup through environment
41#-------------------------------------------------------------------------------
43# Specify default values.
46# Attempt to set variables from a previous make session.
48# Fallback to defaults but allow to get the values from environment.
54#-------------------------------------------------------------------------------
56#-------------------------------------------------------------------------------
57DESTPATH := $(DESTDIR)$(PREFIX)
58BINPATH := $(DESTPATH)/bin
59DATAPATH := $(DESTPATH)/share
60MANPATH := $(DATAPATH)/man
61PKGDATAPATH := $(DATAPATH)/$(DATADIR)
62PKGDOCPATH := $(DATAPATH)/$(DOCDIR)
64#-------------------------------------------------------------------------------
65# Generic Makefile variables
66#-------------------------------------------------------------------------------
68INSTALL_PROGRAM := $(INSTALL) -m 755
69INSTALL_DATA := $(INSTALL) -m 644
72GHC_VERSION := $(shell $(GHC) --version | sed -e 's/[^0-9]*//')
74#-------------------------------------------------------------------------------
76#-------------------------------------------------------------------------------
82# Document process rules.
84 ./$(MAIN) -s -S --toc $< >$@ || rm -f $@
86 ./$(MAIN) -s -w latex $< >$@ || rm -f $@
88 ./$(MAIN) -s -w rtf $< >$@ || rm -f $@
89%.pdf: % $(MAIN) markdown2pdf
90 sh ./markdown2pdf $< || rm -f $@
92 perl -p -e 's/\n/\r\n/' $< > $@ || rm -f $@ # convert to DOS line endings
95cleanup_files+=Setup.hi Setup.o $(BUILDCMD) $(BUILDVARS)
97 hc_pkg = --with-hc-pkg=$(GHC_PKG)
101templates=$(wildcard templates/*.* templates/headers/*.* templates/ui/default/*.*)
102configure: $(BUILDCONF)
104 $(GHC) -package Cabal Setup.hs -o $(BUILDCMD)
105$(BUILDCONF): $(CABAL) $(CABAL_BACKUP) $(BUILDCMD) $(templates) $(ODTREF)
106 $(BUILDCMD) configure --prefix=$(PREFIX) --with-compiler=$(GHC) $(hc_pkg) $(CABALOPTS)
107 @# Make configuration time settings persistent (definitely a hack).
108 @echo "PREFIX?=$(PREFIX)" >$(BUILDVARS)
109 @echo "DESTDIR?=$(DESTDIR)" >>$(BUILDVARS)
117cleanup_files+=$(EXECS)
120 find $(BUILDDIR) -type f -name "$$f" -perm +a=x \
121 -exec ln -s -f {} . \; ; \
125cleanup_files+=README.html $(MANPAGES)
126build-doc: $(DOCS) $(MANPAGES)
129build-program: build-exec build-doc
131.PHONY: build-lib-doc haddock
133haddock: build-lib-doc
137 $(BUILDCMD) haddock && cp -r $(BUILDDIR)/doc/html .
140build-all: build-program build-lib-doc
142# User documents installation.
143.PHONY: install-doc uninstall-doc
144man_all:=$(patsubst $(MANDIR)/%,%,$(MANPAGES))
145install-doc: build-doc
146 $(INSTALL) -d $(PKGDOCPATH) && $(INSTALL_DATA) $(DOCS) $(PKGDOCPATH)/
147 for f in $(man_all); do \
148 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
149 $(INSTALL_DATA) $(MANDIR)/$$f $(MANPATH)/$$f; \
152 -for f in $(DOCS); do rm -f $(PKGDOCPATH)/$$f; done
153 -for f in $(man_all); do rm -f $(MANPATH)/$$f; done
154 rmdir $(PKGDOCPATH) 2>/dev/null ||:
156# Program only installation.
157.PHONY: install-exec uninstall-exec
158install-exec: build-exec
160 $(INSTALL) -d $(BINPATH); \
161 for f in $(PROGS); do \
162 if [ -L $$f ]; then \
163 f=$$(readlink $$f); \
165 $(INSTALL_PROGRAM) $$f $(BINPATH)/; \
168 -for f in $(notdir $(PROGS)); do rm -f $(BINPATH)/$$f; done
170# Program + user documents installation.
171.PHONY: install-program uninstall-program
172install-program: install-exec install-doc
173uninstall-program: uninstall-exec uninstall-doc
175.PHONY: install-all uninstall-all
176# Full installation through Cabal: main + wrappers + user docs + lib + lib docs
177install-all: build-all install-program
178 destdir=$(DESTDIR); \
179 # Older Cabal versions have no '--destdir' option.
180 if $(BUILDCMD) copy --help | grep -q '\-\-destdir'; then \
181 opt="--destdir=$${destdir-/}"; \
183 opt="--copy-prefix=$${destdir}$(PREFIX)"; \
185 $(BUILDCMD) copy $$opt; $(BUILDCMD) register
186# Cabal lacks an 'uninstall' command. We have to remove some cruft manually.
187uninstall-all: uninstall-program
188 @libdir=$$($(GHC_PKG) field $(PKGID) library-dirs 2>/dev/null | \
189 sed 's/^library-dirs: *//'); \
190 htmldir=$$($(GHC_PKG) field $(PKGID) haddock-html 2>/dev/null | \
191 sed 's/^haddock-html: *//'); \
192 if [ -d $$libdir ]; then \
193 $(BUILDCMD) unregister ||:; \
195 echo >&2 "*** Couldn't locate library for pkgid: $(PKGID). ***"; \
197 for d in $$libdir $$htmldir; do \
199 rm -rf $$d; rmdir $$(dirname $$d) 2>/dev/null ||:; \
202 rmdir $(PKGDOCPATH) $(PKGDATAPATH) 2>/dev/null ||:
204# Default installation recipe for a common deployment scenario.
205.PHONY: install uninstall
206install: install-program
207uninstall: uninstall-program
212freebsd_makefile:=$(freebsd_dest)/Makefile
213freebsd_template:=$(freebsd_makefile).in
214cleanup_files+=$(freebsd_makefile)
215freebsd : $(freebsd_makefile)
216$(freebsd_makefile) : $(freebsd_template)
217 sed -e 's/@VERSION@/$(VERSION)/' $< > $@
221macport_dest:=macports
222portfile:=$(macport_dest)/Portfile
223portfile_template:=$(portfile).in
224cleanup_files+=$(portfile)
226$(portfile) : $(portfile_template) tarball
227 sed -e 's/@VERSION@/$(VERSION)/' $(portfile_template) | \
228 sed -e 's/@TARBALLMD5SUM@/$(word 2, $(shell openssl md5 $(tarball)))/' > \
232win_pkg_name:=$(PKGID).zip
233win_docs:=COPYING.txt COPYRIGHT.txt BUGS.txt README.txt README.html
234cleanup_files+=$(win_pkg_name) $(win_docs)
235win-pkg: $(win_pkg_name)
236$(win_pkg_name): $(PKG).exe $(win_docs)
237 zip -r $(win_pkg_name) $(PKG).exe $(win_docs)
239.PHONY: test test-markdown
242compat:=$(PWD)/hsmarkdown
243markdown_test_dirs:=$(wildcard $(TESTDIR)/MarkdownTest_*)
244test-markdown: $(MAIN) $(compat)
245 @for suite in $(markdown_test_dirs); do \
247 suite_version=$$(echo $$suite | sed -e 's/.*_//');\
248 echo >&2 "-----------------------------------------";\
249 echo >&2 "Running Markdown test suite version $${suite_version}.";\
250 PATH=$(PWD):$$PATH; export PATH; cd $$suite && \
251 perl MarkdownTest.pl -s $(compat) -tidy ; \
255# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
256src_all:=$(shell find $(SRCDIR) -type f -name '*hs' | egrep -v '^\./(_darcs|lib|test)/')
257cleanup_files+=$(patsubst %,$(SRCDIR)/%,tags tags.sorted)
259 cd $(SRCDIR) && hasktags -c $(src_all:$(SRCDIR)/%=%); \
260 LC_ALL=C sort tags >tags.sorted; mv tags.sorted tags
263tarball:=$(PKGID).tar.gz
264cleanup_files+=$(tarball)
268 cp $(BUILDDIR)/$(tarball) .
271deb_name:=$(shell grep ^Package debian/control | cut -d' ' -f2 | head -n 1)
272deb_version:=$(shell head -n 1 debian/changelog | cut -f2 -d' ' | tr -d '()')
274deb_main:=$(deb_name)_$(deb_version)_$(deb_arch).deb
276 @[ -x /usr/bin/fakeroot ] || { \
277 echo >&2 "*** Please install fakeroot package. ***"; \
280 @[ -x /usr/bin/dpkg-buildpackage ] || { \
281 echo >&2 "*** Please install dpkg-dev package. ***"; \
284 mv $(BUILDVARS) $(BUILDVARS).old 2>/dev/null ||: # backup settings
285 if [ -x /usr/bin/debuild ]; then \
286 debuild -uc -us -i.svn -I.svn -i_darcs -I_darcs --lintian-opts -i; \
288 echo >&2 "*** Please install devscripts package. ***"; \
289 echo >&2 "*** Using dpkg-buildpackage for package building. ***"; \
290 dpkg-buildpackage -rfakeroot -uc -us -i.svn -I.svn -i_darcs -I_darcs; \
292 mv $(BUILDVARS).old $(BUILDVARS) 2>/dev/null ||: # restore
296web_dest:=pandoc-website
297make_page:=./$(MAIN) -s -S -B $(web_src)/header.html \
298 -A $(web_src)/footer.html \
300cleanup_files+=$(web_dest)
301$(web_dest) : html $(wildcard $(web_src)/*) debian/changelog \
302 INSTALL $(MANPAGES) $(MANDIR)/man1/pandoc.1.md README
303 rm -rf $(web_dest) && { \
305 cp -r html $(web_dest)/doc; \
306 cp $(web_src)/* $(web_dest)/; \
307 sed -e 's#@VERSION@#$(VERSION)#g' $(web_src)/index.txt.in > \
308 $(web_dest)/index.txt; \
309 cp debian/changelog $(web_dest)/changelog.txt ; \
310 cp README $(web_dest)/ ; \
311 cp INSTALL $(web_dest)/ ; \
312 cp $(MANDIR)/man1/pandoc.1.md $(web_dest)/ ; \
313 cp $(MANPAGES) $(web_dest)/ ; \
314 } || { rm -rf $(web_dest); exit 1; }
315website: $(MAIN) $(web_dest)
316 PANDOC_PATH=$(shell pwd) make -C $(web_dest)
318.PHONY: distclean clean
320 if [ -d debian ]; then \
321 chmod +x debian/rules; fakeroot debian/rules clean; \
325 -if [ -f $(BUILDCONF) ]; then $(BUILDCMD) clean; fi
326 -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