3#-------------------------------------------------------------------------------
4# Constant names and commands in source tree
5#-------------------------------------------------------------------------------
11BUILDCONF := $(BUILDDIR)/setup-config
15#-------------------------------------------------------------------------------
17#-------------------------------------------------------------------------------
18PKG := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL) | tr A-Z a-z)
19VERSION := $(shell sed -ne 's/^[Vv]ersion:[[:space:]]*//p' $(CABAL))
20PKGID := $(PKG)-$(VERSION)
23#-------------------------------------------------------------------------------
25#-------------------------------------------------------------------------------
26WRAPPERS := html2markdown hsmarkdown markdown2pdf
27# Add .exe extensions if we're running Windows/Cygwin.
28EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
29 sed -ne 's/^cygwin.*$$/\.exe/p')
30BUILDCMD := $(addsuffix $(EXTENSION), ./setup)
31EXECS := $(addsuffix $(EXTENSION),$(EXECSBASE))
32PROGS := $(EXECS) $(WRAPPERS)
33MAIN := $(firstword $(EXECS))
34DOCS := README.html README BUGS
35MANPAGES := $(patsubst %.md,%,$(wildcard $(MANDIR)/man?/*.?.md))
37#-------------------------------------------------------------------------------
38# Variables to setup through environment
39#-------------------------------------------------------------------------------
41# Specify default values.
44# Attempt to set variables from a previous make session.
46# Fallback to defaults but allow to get the values from environment.
52#-------------------------------------------------------------------------------
54#-------------------------------------------------------------------------------
55DESTPATH := $(DESTDIR)$(PREFIX)
56BINPATH := $(DESTPATH)/bin
57DATAPATH := $(DESTPATH)/share
58MANPATH := $(DATAPATH)/man
59PKGDATAPATH := $(DATAPATH)/$(DATADIR)
60PKGDOCPATH := $(DATAPATH)/$(DOCDIR)
62#-------------------------------------------------------------------------------
63# Generic Makefile variables
64#-------------------------------------------------------------------------------
66INSTALL_PROGRAM := $(INSTALL) -m 755
67INSTALL_DATA := $(INSTALL) -m 644
70GHC_VERSION := $(shell $(GHC) --version | sed -e 's/[^0-9]*//')
72#-------------------------------------------------------------------------------
74#-------------------------------------------------------------------------------
80# Document process rules.
82 ./$(MAIN) -s -S --toc $< >$@ || rm -f $@
84 ./$(MAIN) -s -w latex $< >$@ || rm -f $@
86 ./$(MAIN) -s -w rtf $< >$@ || rm -f $@
87%.pdf: % $(MAIN) markdown2pdf
88 sh ./markdown2pdf $< || rm -f $@
90 perl -p -e 's/\n/\r\n/' $< > $@ || rm -f $@ # convert to DOS line endings
93cleanup_files+=Setup.hi Setup.o $(BUILDCMD) $(BUILDVARS)
95 hc_pkg = --with-hc-pkg=$(GHC_PKG)
99templates=$(wildcard templates/*.* templates/headers/*.* templates/ui/default/*.*)
100configure: $(BUILDCONF)
102 $(GHC) -package Cabal Setup.hs -o $(BUILDCMD)
103$(BUILDCONF): $(CABAL) $(CABAL_BACKUP) $(BUILDCMD) $(templates)
104 $(BUILDCMD) configure --prefix=$(PREFIX) --with-compiler=$(GHC) $(hc_pkg) $(CABALOPTS) -f-wrappers
105 @# Make configuration time settings persistent (definitely a hack).
106 @echo "PREFIX?=$(PREFIX)" >$(BUILDVARS)
107 @echo "DESTDIR?=$(DESTDIR)" >>$(BUILDVARS)
115cleanup_files+=$(EXECS)
118 find $(BUILDDIR) -type f -name "$$f" -perm +a=x \
119 -exec ln -s -f {} . \; ; \
123cleanup_files+=README.html
127build-program: build-exec build-doc
129.PHONY: build-lib-doc haddock
131haddock: build-lib-doc
135 $(BUILDCMD) haddock && cp -r $(BUILDDIR)/doc/html .
138build-all: build-program build-lib-doc
140# User documents installation.
141.PHONY: install-doc uninstall-doc
142man_all:=$(patsubst $(MANDIR)/%,%,$(MANPAGES))
143install-doc: build-doc
144 $(INSTALL) -d $(PKGDOCPATH) && $(INSTALL_DATA) $(DOCS) $(PKGDOCPATH)/
145 for f in $(man_all); do \
146 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
147 $(INSTALL_DATA) $(MANDIR)/$$f $(MANPATH)/$$f; \
150 -for f in $(DOCS); do rm -f $(PKGDOCPATH)/$$f; done
151 -for f in $(man_all); do rm -f $(MANPATH)/$$f; done
152 rmdir $(PKGDOCPATH) 2>/dev/null ||:
154# Program only installation.
155.PHONY: install-exec uninstall-exec
156install-exec: build-exec
158 $(INSTALL) -d $(BINPATH); \
159 for f in $(PROGS); do \
160 if [ -L $$f ]; then \
161 f=$$(readlink $$f); \
163 $(INSTALL_PROGRAM) $$f $(BINPATH)/; \
166 -for f in $(notdir $(PROGS)); do rm -f $(BINPATH)/$$f; done
168# Program + user documents installation.
169.PHONY: install-program uninstall-program
170install-program: install-exec install-doc
171uninstall-program: uninstall-exec uninstall-doc
173.PHONY: install-all uninstall-all
174# Full installation through Cabal: main + wrappers + user docs + lib + lib docs
175install-all: build-all install-program
176 destdir=$(DESTDIR); \
177 # Older Cabal versions have no '--destdir' option.
178 if $(BUILDCMD) copy --help | grep -q '\-\-destdir'; then \
179 opt="--destdir=$${destdir-/}"; \
181 opt="--copy-prefix=$${destdir}$(PREFIX)"; \
183 $(BUILDCMD) copy $$opt; $(BUILDCMD) register
184# Cabal lacks an 'uninstall' command. We have to remove some cruft manually.
185uninstall-all: uninstall-program configure
186 @libdir=$$($(GHC_PKG) field $(PKGID) library-dirs 2>/dev/null | \
187 sed 's/^library-dirs: *//'); \
188 htmldir=$$($(GHC_PKG) field $(PKGID) haddock-html 2>/dev/null | \
189 sed 's/^haddock-html: *//'); \
190 if [ -d $$libdir ]; then \
191 $(BUILDCMD) unregister ||:; \
193 echo >&2 "*** Couldn't locate library for pkgid: $(PKGID). ***"; \
195 for d in $$libdir $$htmldir; do \
197 rm -rf $$d; rmdir $$(dirname $$d) 2>/dev/null ||:; \
200 rmdir $(PKGDOCPATH) $(PKGDATAPATH) 2>/dev/null ||:
202# Default installation recipe for a common deployment scenario.
203.PHONY: install uninstall
204install: install-program
205uninstall: uninstall-program
210freebsd_makefile:=$(freebsd_dest)/Makefile
211freebsd_template:=$(freebsd_makefile).in
212cleanup_files+=$(freebsd_makefile)
213freebsd : $(freebsd_makefile)
214$(freebsd_makefile) : $(freebsd_template)
215 sed -e 's/@VERSION@/$(VERSION)/' $< > $@
219macport_dest:=macports
220portfile:=$(macport_dest)/Portfile
221portfile_template:=$(portfile).in
222cleanup_files+=$(portfile)
224$(portfile) : $(portfile_template) tarball
225 sed -e 's/@VERSION@/$(VERSION)/' $(portfile_template) | \
226 sed -e 's/@TARBALLMD5SUM@/$(word 2, $(shell openssl md5 $(tarball)))/' > \
230win_pkg_name:=$(PKGID).zip
231win_docs:=COPYING.txt COPYRIGHT.txt BUGS.txt README.txt README.html
232cleanup_files+=$(win_pkg_name) $(win_docs)
233win-pkg: $(win_pkg_name)
234$(win_pkg_name): $(PKG).exe $(win_docs)
235 zip -r $(win_pkg_name) $(PKG).exe $(win_docs)
237.PHONY: test test-markdown
240compat:=$(PWD)/hsmarkdown
241markdown_test_dirs:=$(wildcard $(TESTDIR)/MarkdownTest_*)
242test-markdown: $(MAIN) $(compat)
243 @for suite in $(markdown_test_dirs); do \
245 suite_version=$$(echo $$suite | sed -e 's/.*_//');\
246 echo >&2 "-----------------------------------------";\
247 echo >&2 "Running Markdown test suite version $${suite_version}.";\
248 PATH=$(PWD):$$PATH; export PATH; cd $$suite && \
249 perl MarkdownTest.pl -s $(compat) -tidy ; \
253# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
254src_all:=$(shell find $(SRCDIR) -type f -name '*hs' | egrep -v '^\./(_darcs|lib|test)/')
255cleanup_files+=$(patsubst %,$(SRCDIR)/%,tags tags.sorted)
257 cd $(SRCDIR) && hasktags -c $(src_all:$(SRCDIR)/%=%); \
258 LC_ALL=C sort tags >tags.sorted; mv tags.sorted tags
261tarball:=$(PKGID).tar.gz
262cleanup_files+=$(tarball)
266 cp $(BUILDDIR)/$(tarball) .
270web_dest:=pandoc-website
271make_page:=./$(MAIN) -s -S -B $(web_src)/header.html \
272 -A $(web_src)/footer.html \
274cleanup_files+=$(web_dest)
275$(web_dest) : html $(wildcard $(web_src)/*) changelog \
276 INSTALL $(MANPAGES) $(MANDIR)/man1/pandoc.1.md README
277 rm -rf $(web_dest) && { \
279 cp -r html $(web_dest)/doc; \
280 cp $(web_src)/* $(web_dest)/; \
281 sed -e 's#@VERSION@#$(VERSION)#g' $(web_src)/index.txt.in > \
282 $(web_dest)/index.txt; \
283 cp changelog $(web_dest)/changelog.txt ; \
284 cp README $(web_dest)/ ; \
285 cp INSTALL $(web_dest)/ ; \
286 cp $(MANDIR)/man1/pandoc.1.md $(web_dest)/ ; \
287 cp $(MANPAGES) $(web_dest)/ ; \
288 } || { rm -rf $(web_dest); exit 1; }
289website: $(MAIN) $(web_dest)
290 PANDOC_PATH=$(shell pwd) make -C $(web_dest)
292.PHONY: distclean clean
294 if [ -d debian ]; then \
295 chmod +x debian/rules; fakeroot debian/rules clean; \
299 -if [ -f $(BUILDCONF) ]; then $(BUILDCMD) clean; fi
300 -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