5#-------------------------------------------------------------------------------
7#-------------------------------------------------------------------------------
8NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL).in)
9THIS := $(shell echo $(NAME) | tr A-Z a-z)
10VERSION := $(shell sed -ne 's/^[Vv]ersion:[[:space:]]*//p' $(CABAL).in)
11BINS := $(shell sed -ne 's/^[Ee]xecutable:[[:space:]]*//p' $(CABAL).in)
13#-------------------------------------------------------------------------------
14# Variables to setup through environment
15#-------------------------------------------------------------------------------
19#-------------------------------------------------------------------------------
20# Constant names and commands in source tree
21#-------------------------------------------------------------------------------
25BUILDCONF := .setup-config
26BUILDCMD := runhaskell Setup.hs
29#-------------------------------------------------------------------------------
31#-------------------------------------------------------------------------------
32DESTPATH := $(DESTDIR)$(PREFIX)
33BINPATH := $(DESTPATH)/bin
34DATAPATH := $(DESTPATH)/share
35LIBPATH := $(DESTPATH)/$(NAME)-$(VERSION)
36DOCPATH := $(DATAPATH)/doc/$(THIS)
37LIBDOCPATH := $(DATAPATH)/doc/$(THIS)-doc
38MANPATH := $(DATAPATH)/man
39PKGPATH := $(DATAPATH)/$(THIS)
41#-------------------------------------------------------------------------------
42# Generic Makefile variables
43#-------------------------------------------------------------------------------
45INSTALL_PROGRAM := $(INSTALL) -m 755
46INSTALL_DATA := $(INSTALL) -m 644
51#-------------------------------------------------------------------------------
53#-------------------------------------------------------------------------------
58# Document process rules.
60 ./$(THIS) -s $< >$@ || rm -f $@
62 ./$(THIS) -s -w latex $< >$@ || rm -f $@
64 ./$(THIS) -s -w rtf $< >$@ || rm -f $@
66 sh ./markdown2pdf $< || rm -f $@
69templates: $(SRCDIR)/templates
71 $(MAKE) -C $(SRCDIR)/templates
73cleanup_files+=$(CABAL)
74$(CABAL): cabalize $(CABAL).in
75 ./cabalize <$(CABAL).in >$(CABAL)
78cleanup_files+=$(BUILDDIR) $(BUILDCONF)
79configure: $(BUILDCONF)
81 $(BUILDCMD) configure --prefix=$(PREFIX)
84build: templates configure
87.PHONY: build-lib-doc haddock
93 $(BUILDCMD) haddock && mv $(BUILDDIR)/doc/html .
97 find $(BUILDDIR) -type f -name "$(BINS)" -perm +a=x -exec cp {} . \;
100build-all: build $(BINS) build-lib-doc
102# XXX: Note that we don't handle PREFIX correctly at the install-* stages,
103# i.e. any PREFIX given at the configuration time is lost, unless it is
104# also supplied (via environment) at these stages.
106# User documents installation.
107.PHONY: install-doc uninstall-doc
108doc_all:=README.html README BUGS TODO
109man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))
110cleanup_files+=README.html
111install-doc: $(BINS) $(doc_all)
112 $(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(doc_all) $(DOCPATH)/
113 for f in $(man_all); do \
114 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
115 $(INSTALL_DATA) $(MANDIR)/$$f $(MANPATH)/$$f; \
118 -for f in $(doc_all); do rm -f $(DOCPATH)/$$f; done
119 -for f in $(man_all); do rm -f $(MANPATH)/$$f; done
122# Library documents installation.
123.PHONY: install-lib-doc uninstall-lib-doc
124install-lib-doc: build-lib-doc
125 $(INSTALL) -d $(LIBDOCPATH) && cp -a html $(LIBDOCPATH)/
127 -rm -rf $(LIBDOCPATH)/html
130# Program only installation.
131.PHONY: install-exec uninstall-exec
132bin_all:=$(BINS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
133install-exec: $(bin_all)
134 $(INSTALL) -d $(BINPATH); \
135 for f in $(bin_all); do $(INSTALL_PROGRAM) $$f $(BINPATH)/; done
137 -for f in $(bin_all); do rm -f $(BINPATH)/$$f; done
139# Program + user documents installation.
140.PHONY: install-program uninstall-program
141install-program: install-exec install-doc
142uninstall-program: uninstall-exec uninstall-doc
145.PHONY: install-all uninstall-all
146install-all: install-doc install-lib-doc
147 destdir=$(DESTDIR); destdir=$${destdir:-/}; \
148 $(BUILDCMD) copy --destdir=$$destdir; \
150uninstall-all: uninstall-exec uninstall-doc uninstall-lib-doc
151 -pkg_id="$(NAME)-$(VERSION)"; \
152 libdir=$$($(GHC_PKG) field $$pkg_id library-dirs 2>/dev/null | \
153 sed 's/^library-dirs: *//'); \
154 if [ -d "$$libdir" ]; then \
155 $(BUILDCMD) unregister; \
157 rmdir $$(dirname $$libdir); \
159 echo "*** Couldn't locate library files for pkgid: $$pkg_id. ***"; \
162# Default installation recipe for a common deployment scenario.
163.PHONY: install uninstall
164install: install-program
165uninstall: uninstall-program
169doc_more:=README.rtf LICENSE.rtf OSX-Welcome.rtf
170cleanup_files+=$(osx_dest) $(doc_more)
172$(osx_dest): $(doc_more)
174 $(INSTALL) -d $(osx_dest)
175 DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
176 find $(osx_dest) -type f -regex ".*bin/.*" | xargs chmod +x
177 find $(osx_dest) -type f -regex ".*bin/$(THIS)" | xargs $(STRIP)
178 find $(osx_dest) -type f | xargs chown root:wheel
179 $(INSTALL) -d $(osx_dest)/Resources
180 mv README.rtf $(osx_dest)/Resources/ReadMe.rtf
181 mv LICENSE.rtf $(osx_dest)/Resources/License.rtf
182 sed -e 's#@PREFIX@#$(PREFIX)#g' OSX-Welcome.rtf > $(osx_dest)/Resources/Welcome.rtf
183 sed -e 's/@VERSION@/$(VERSION)/g' Info.plist > $(osx_dest)/Info.plist
184 cp Description.plist $(osx_dest)/
185 PackageMaker -build -p Pandoc_$(VERSION).pkg \
186 -f $(osx_dest)/Package_root \
187 -r $(osx_dest)/Resources \
188 -i $(osx_dest)/Info.plist \
189 -d $(osx_dest)/Description.plist
191.PHONY: test test-markdown
193 @cd tests && perl runtests.pl -s $(PWD)/$(THIS)
194test-markdown: $(BINS)
195 @cd tests/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(THIS) -tidy
197# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
198src_all:=$(shell find $(SRCDIR) -type f -name '*hs' | egrep -v '^\./(_darcs|lib|test)/')
199cleanup_files+=$(patsubst %,$(SRCDIR)/%,tags tags.sorted)
201 cd $(SRCDIR) && hasktags -c $(src_all:$(SRCDIR)/%=%); \
202 LC_ALL=C sort tags >tags.sorted; mv tags.sorted tags
205 [ -x /usr/bin/fakeroot ] || { \
206 echo "*** Please install fakeroot package. ***"; \
209 [ -x /usr/bin/dpkg-buildpackage ] || { \
210 echo "*** Please install dpkg-dev package. ***"; \
213 if [ -x /usr/bin/debuild ]; then \
214 debuild -uc -us -i.svn -I.svn -i_darcs -I_darcs --lintian-opts -i; \
216 echo "*** Please install devscripts package. ***"; \
217 echo "*** Using dpkg-buildpackage for package building. ***"; \
218 dpkg-buildpackage -rfakeroot -uc -us -i.svn -I.svn -i_darcs -I_darcs; \
221.PHONY: distclean clean
223 if [ -d debian ]; then \
224 chmod +x debian/rules; fakeroot debian/rules clean; \
228 -if [ -f $(BUILDCONF) ]; then $(BUILDCMD) clean; fi
229 -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