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 hsmarkdown markdown2pdf
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))
38#-------------------------------------------------------------------------------
39# Variables to setup through environment
40#-------------------------------------------------------------------------------
42# Specify default values.
45# Attempt to set variables from a previous make session.
47# Fallback to defaults but allow to get the values from environment.
53#-------------------------------------------------------------------------------
55#-------------------------------------------------------------------------------
56DESTPATH := $(DESTDIR)$(PREFIX)
57BINPATH := $(DESTPATH)/bin
58DATAPATH := $(DESTPATH)/share
59MANPATH := $(DATAPATH)/man
60PKGDATAPATH := $(DATAPATH)/$(DATADIR)
61PKGDOCPATH := $(DATAPATH)/$(DOCDIR)
63#-------------------------------------------------------------------------------
64# Generic Makefile variables
65#-------------------------------------------------------------------------------
67INSTALL_PROGRAM := $(INSTALL) -m 755
68INSTALL_DATA := $(INSTALL) -m 644
71GHC_VERSION := $(shell $(GHC) --version | sed -e 's/[^0-9]*//')
73#-------------------------------------------------------------------------------
75#-------------------------------------------------------------------------------
81# Document process rules.
83 ./$(MAIN) -s -S --toc $< >$@ || rm -f $@
85 ./$(MAIN) -s -w latex $< >$@ || rm -f $@
87 ./$(MAIN) -s -w rtf $< >$@ || rm -f $@
88%.pdf: % $(MAIN) markdown2pdf
89 sh ./markdown2pdf $< || rm -f $@
91 perl -p -e 's/\n/\r\n/' $< > $@ || rm -f $@ # convert to DOS line endings
94cleanup_files+=Setup.hi Setup.o $(BUILDCMD) $(BUILDVARS)
96 hc_pkg = --with-hc-pkg=$(GHC_PKG)
100templates=$(wildcard templates/*.* templates/headers/*.* templates/ui/default/*.*)
101configure: $(BUILDCONF)
103 $(GHC) -package Cabal Setup.hs -o $(BUILDCMD)
104$(BUILDCONF): $(CABAL) $(CABAL_BACKUP) $(BUILDCMD) $(templates)
105 $(BUILDCMD) configure --prefix=$(PREFIX) --with-compiler=$(GHC) $(hc_pkg) $(CABALOPTS)
106 @# Make configuration time settings persistent (definitely a hack).
107 @echo "PREFIX?=$(PREFIX)" >$(BUILDVARS)
108 @echo "DESTDIR?=$(DESTDIR)" >>$(BUILDVARS)
116cleanup_files+=$(EXECS)
119 find $(BUILDDIR) -type f -name "$$f" -perm +a=x \
120 -exec ln -s -f {} . \; ; \
124cleanup_files+=README.html $(MANPAGES)
125build-doc: $(DOCS) $(MANPAGES)
128build-program: build-exec build-doc
130.PHONY: build-lib-doc haddock
132haddock: build-lib-doc
136 $(BUILDCMD) haddock && cp -r $(BUILDDIR)/doc/html .
139build-all: build-program build-lib-doc
141# User documents installation.
142.PHONY: install-doc uninstall-doc
143man_all:=$(patsubst $(MANDIR)/%,%,$(MANPAGES))
144install-doc: build-doc
145 $(INSTALL) -d $(PKGDOCPATH) && $(INSTALL_DATA) $(DOCS) $(PKGDOCPATH)/
146 for f in $(man_all); do \
147 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
148 $(INSTALL_DATA) $(MANDIR)/$$f $(MANPATH)/$$f; \
151 -for f in $(DOCS); do rm -f $(PKGDOCPATH)/$$f; done
152 -for f in $(man_all); do rm -f $(MANPATH)/$$f; done
153 rmdir $(PKGDOCPATH) 2>/dev/null ||:
155# Program only installation.
156.PHONY: install-exec uninstall-exec
157install-exec: build-exec
159 $(INSTALL) -d $(BINPATH); \
160 for f in $(PROGS); do \
161 if [ -L $$f ]; then \
162 f=$$(readlink $$f); \
164 $(INSTALL_PROGRAM) $$f $(BINPATH)/; \
167 -for f in $(notdir $(PROGS)); do rm -f $(BINPATH)/$$f; done
169# Program + user documents installation.
170.PHONY: install-program uninstall-program
171install-program: install-exec install-doc
172uninstall-program: uninstall-exec uninstall-doc
174.PHONY: install-all uninstall-all
175# Full installation through Cabal: main + wrappers + user docs + lib + lib docs
176install-all: build-all install-program
177 destdir=$(DESTDIR); \
178 # Older Cabal versions have no '--destdir' option.
179 if $(BUILDCMD) copy --help | grep -q '\-\-destdir'; then \
180 opt="--destdir=$${destdir-/}"; \
182 opt="--copy-prefix=$${destdir}$(PREFIX)"; \
184 $(BUILDCMD) copy $$opt; $(BUILDCMD) register
185# Cabal lacks an 'uninstall' command. We have to remove some cruft manually.
186uninstall-all: uninstall-program configure
187 @libdir=$$($(GHC_PKG) field $(PKGID) library-dirs 2>/dev/null | \
188 sed 's/^library-dirs: *//'); \
189 htmldir=$$($(GHC_PKG) field $(PKGID) haddock-html 2>/dev/null | \
190 sed 's/^haddock-html: *//'); \
191 if [ -d $$libdir ]; then \
192 $(BUILDCMD) unregister ||:; \
194 echo >&2 "*** Couldn't locate library for pkgid: $(PKGID). ***"; \
196 for d in $$libdir $$htmldir; do \
198 rm -rf $$d; rmdir $$(dirname $$d) 2>/dev/null ||:; \
201 rmdir $(PKGDOCPATH) $(PKGDATAPATH) 2>/dev/null ||:
203# Default installation recipe for a common deployment scenario.
204.PHONY: install uninstall
205install: install-program
206uninstall: uninstall-program
211freebsd_makefile:=$(freebsd_dest)/Makefile
212freebsd_template:=$(freebsd_makefile).in
213cleanup_files+=$(freebsd_makefile)
214freebsd : $(freebsd_makefile)
215$(freebsd_makefile) : $(freebsd_template)
216 sed -e 's/@VERSION@/$(VERSION)/' $< > $@
220macport_dest:=macports
221portfile:=$(macport_dest)/Portfile
222portfile_template:=$(portfile).in
223cleanup_files+=$(portfile)
225$(portfile) : $(portfile_template) tarball
226 sed -e 's/@VERSION@/$(VERSION)/' $(portfile_template) | \
227 sed -e 's/@TARBALLMD5SUM@/$(word 2, $(shell openssl md5 $(tarball)))/' > \
231win_pkg_name:=$(PKGID).zip
232win_docs:=COPYING.txt COPYRIGHT.txt BUGS.txt README.txt README.html
233cleanup_files+=$(win_pkg_name) $(win_docs)
234win-pkg: $(win_pkg_name)
235$(win_pkg_name): $(PKG).exe $(win_docs)
236 zip -r $(win_pkg_name) $(PKG).exe $(win_docs)
238.PHONY: test test-markdown
241compat:=$(PWD)/hsmarkdown
242markdown_test_dirs:=$(wildcard $(TESTDIR)/MarkdownTest_*)
243test-markdown: $(MAIN) $(compat)
244 @for suite in $(markdown_test_dirs); do \
246 suite_version=$$(echo $$suite | sed -e 's/.*_//');\
247 echo >&2 "-----------------------------------------";\
248 echo >&2 "Running Markdown test suite version $${suite_version}.";\
249 PATH=$(PWD):$$PATH; export PATH; cd $$suite && \
250 perl MarkdownTest.pl -s $(compat) -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
262tarball:=$(PKGID).tar.gz
263cleanup_files+=$(tarball)
267 cp $(BUILDDIR)/$(tarball) .
271web_dest:=pandoc-website
272make_page:=./$(MAIN) -s -S -B $(web_src)/header.html \
273 -A $(web_src)/footer.html \
275cleanup_files+=$(web_dest)
276$(web_dest) : html $(wildcard $(web_src)/*) changelog \
277 INSTALL $(MANPAGES) $(MANDIR)/man1/pandoc.1.md README
278 rm -rf $(web_dest) && { \
280 cp -r html $(web_dest)/doc; \
281 cp $(web_src)/* $(web_dest)/; \
282 sed -e 's#@VERSION@#$(VERSION)#g' $(web_src)/index.txt.in > \
283 $(web_dest)/index.txt; \
284 cp changelog $(web_dest)/changelog.txt ; \
285 cp README $(web_dest)/ ; \
286 cp INSTALL $(web_dest)/ ; \
287 cp $(MANDIR)/man1/pandoc.1.md $(web_dest)/ ; \
288 cp $(MANPAGES) $(web_dest)/ ; \
289 } || { rm -rf $(web_dest); exit 1; }
290website: $(MAIN) $(web_dest)
291 PANDOC_PATH=$(shell pwd) make -C $(web_dest)
293.PHONY: distclean clean
295 if [ -d debian ]; then \
296 chmod +x debian/rules; fakeroot debian/rules clean; \
300 -if [ -f $(BUILDCONF) ]; then $(BUILDCMD) clean; fi
301 -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