3#-------------------------------------------------------------------------------
4# Constant names and commands in source tree
5#-------------------------------------------------------------------------------
11BUILDCONF := .setup-config
12BUILDCMD := runhaskell Setup.hs
16#-------------------------------------------------------------------------------
18#-------------------------------------------------------------------------------
19NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL).in)
20THIS := $(shell echo $(NAME) | tr A-Z a-z)
21VERSION := $(shell sed -ne 's/^version[[:space:]]*=[[:space:]]*"\([^"]*\)"/\1/p' $(SRCDIR)/Main.hs)
22RELNAME := $(THIS)-$(VERSION)
23EXECSBASE := $(shell sed -ne 's/^[Ee]xecutable:[[:space:]]*//p' $(CABAL).in)
25#-------------------------------------------------------------------------------
27#-------------------------------------------------------------------------------
28WRAPPERS := html2markdown markdown2pdf hsmarkdown
29# Add .exe extensions if we're running Windows/Cygwin.
30EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
31 sed -ne 's/^cygwin.*$$/\.exe/p')
32EXECS := $(addsuffix $(EXTENSION),$(EXECSBASE))
33PROGS := $(EXECS) $(WRAPPERS)
34# First entry in Cabal's executable stanza is the main executable.
35MAIN := $(firstword $(EXECS))
36DOCS := README.html README BUGS
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.
51#-------------------------------------------------------------------------------
53#-------------------------------------------------------------------------------
54DESTPATH := $(DESTDIR)$(PREFIX)
55BINPATH := $(DESTPATH)/bin
56DATAPATH := $(DESTPATH)/share
57LIBPATH := $(DESTPATH)/$(NAME)-$(VERSION)
58DOCPATH := $(DATAPATH)/doc/$(THIS)
59LIBDOCPATH := $(DATAPATH)/doc/$(THIS)-doc
60MANPATH := $(DATAPATH)/man
61PKGPATH := $(DATAPATH)/$(THIS)
63#-------------------------------------------------------------------------------
64# Generic Makefile variables
65#-------------------------------------------------------------------------------
67INSTALL_PROGRAM := $(INSTALL) -m 755
68INSTALL_DATA := $(INSTALL) -m 644
73#-------------------------------------------------------------------------------
75#-------------------------------------------------------------------------------
81# Document process rules.
83 ./$(MAIN) -s $< >$@ || 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
94templates: $(SRCDIR)/templates
95 $(MAKE) -C $(SRCDIR)/templates
97define generate-shell-script
98echo "Generating $@..."; \
101 lead = $$0; sub(/[^ \t].*$$/, "", lead); \
102 t = "$(dir $<)/"$$2; \
103 while (getline line < t > 0) \
114cleanup_files+=$(WRAPPERS)
115$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh
116 @$(generate-shell-script)
118cleanup_files+=$(CABAL)
119$(CABAL): cabalize $(CABAL).in $(SRCDIR)/Main.hs
120 ./cabalize <$(CABAL).in >$(CABAL)
123cleanup_files+=$(BUILDDIR) $(BUILDCONF) $(BUILDVARS)
124configure: $(BUILDCONF) templates
125$(BUILDCONF): $(CABAL)
126 $(BUILDCMD) configure --prefix=$(PREFIX)
127 # Make configuration time settings persistent (definitely a hack).
128 @echo "PREFIX?=$(PREFIX)" >$(BUILDVARS)
129 @echo "DESTDIR?=$(DESTDIR)" >>$(BUILDVARS)
137cleanup_files+=$(EXECS)
141 find $(BUILDDIR) -type f -name "$$f" \
142 -perm +a=x -exec ln -s {} . \; ; \
147cleanup_files+=README.html
151build-program: build-exec build-doc
153.PHONY: build-lib-doc haddock
155haddock: build-lib-doc
159 $(BUILDCMD) haddock && mv $(BUILDDIR)/doc/html .
162build-all: build-program build-lib-doc
164# User documents installation.
165.PHONY: install-doc uninstall-doc
166man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))
167install-doc: build-doc
168 $(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(DOCS) $(DOCPATH)/
169 for f in $(man_all); do \
170 $(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
171 $(INSTALL_DATA) $(MANDIR)/$$f $(MANPATH)/$$f; \
174 -for f in $(DOCS); do rm -f $(DOCPATH)/$$f; done
175 -for f in $(man_all); do rm -f $(MANPATH)/$$f; done
178# Library documents installation.
179.PHONY: install-lib-doc uninstall-lib-doc
180install-lib-doc: build-lib-doc
181 $(INSTALL) -d $(LIBDOCPATH) && cp -a html $(LIBDOCPATH)/
183 -rm -rf $(LIBDOCPATH)/html
186# Program only installation.
187.PHONY: install-exec uninstall-exec
188install-exec: build-exec
189 $(INSTALL) -d $(BINPATH); \
190 for f in $(PROGS); do \
191 if [ -L $$f ]; then \
192 f=$$(readlink $$f); \
194 $(INSTALL_PROGRAM) $$f $(BINPATH)/; \
197 -for f in $(notdir $(PROGS)); do rm -f $(BINPATH)/$$f; done ;
199# Program + user documents installation.
200.PHONY: install-program uninstall-program
201install-program: install-exec install-doc
202uninstall-program: uninstall-exec uninstall-doc
205.PHONY: install-all uninstall-all
206install-all: install-doc install-lib-doc
207 destdir=$(DESTDIR); \
208 # Older Cabal versions have no '--destdir' option.
209 if $(BUILDCMD) copy --help | grep -q '\-\-destdir'; then \
210 opt="--destdir=$${destdir-/}"; \
212 opt="--copy-prefix=$${destdir}$(PREFIX)"; \
214 $(BUILDCMD) copy $$opt; \
216uninstall-all: uninstall-exec uninstall-doc uninstall-lib-doc
217 -pkg_id="$(NAME)-$(VERSION)"; \
218 libdir=$$($(GHC_PKG) field $$pkg_id library-dirs 2>/dev/null | \
219 sed 's/^library-dirs: *//'); \
220 if [ -d "$$libdir" ]; then \
221 $(BUILDCMD) unregister; \
223 rmdir $$(dirname $$libdir); \
225 echo "*** Couldn't locate library files for pkgid: $$pkg_id. ***"; \
228# Default installation recipe for a common deployment scenario.
229.PHONY: install uninstall
230install: install-program
231uninstall: uninstall-program
233# OSX packages: make osx-pkg-prep, then (as root) make osx-pkg
234.PHONY: osx-pkg osx-pkg-prep
237doc_more:=README.rtf COPYRIGHT.rtf $(osx_src)/Welcome.rtf
238osx_pkg_name:=$(RELNAME).pkg
239cleanup_files+=$(osx_dest) $(doc_more) $(osx_pkg_name)
240osx-pkg-prep: $(osx_dest)
241$(osx_dest)/: build-program $(doc_more)
243 $(INSTALL) -d $(osx_dest)
244 DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
245 cp $(osx_src)/uninstall-pandoc $(osx_dest)/Package_root/usr/local/bin/
246 find $(osx_dest) -type f -regex ".*bin/.*" | xargs chmod +x
247 find $(osx_dest) -type f -regex ".*bin/$(notdir $(MAIN))" | xargs $(STRIP)
248 $(INSTALL) -d $(osx_dest)/Resources
249 cp README.rtf $(osx_dest)/Resources/ReadMe.rtf
250 cp COPYRIGHT.rtf $(osx_dest)/Resources/License.rtf
251 sed -e 's#@PREFIX@#$(PREFIX)#g' $(osx_src)/Welcome.rtf > $(osx_dest)/Resources/Welcome.rtf
252 sed -e 's/@VERSION@/$(VERSION)/g' $(osx_src)/Info.plist > $(osx_dest)/Info.plist
253 cp $(osx_src)/Description.plist $(osx_dest)/
254osx-pkg: $(osx_pkg_name)
255$(osx_pkg_name)/: $(osx_dest)
256 if [ "`id -u`" != 0 ]; then \
257 echo "Root permissions needed to create OSX package!"; \
260 find $(osx_dest) | xargs chown root:wheel
261 PackageMaker -build -p $(osx_pkg_name) \
262 -f $(osx_dest)/Package_root \
263 -r $(osx_dest)/Resources \
264 -i $(osx_dest)/Info.plist \
265 -d $(osx_dest)/Description.plist
266 chgrp admin $(osx_pkg_name)
270osx_dmg_name:=$(RELNAME).dmg
271cleanup_files+=$(osx_dmg_name)
272osx_udzo_name:=$(RELNAME).udzo.dmg
273osx_dmg_volume:="$(NAME) $(VERSION)"
274osx-dmg: $(osx_dmg_name)
275$(osx_dmg_name): $(osx_pkg_name)
276 -rm -f $(osx_dmg_name)
277 hdiutil create $(osx_dmg_name) -size 05m -fs HFS+ -volname $(osx_dmg_volume)
278 dev_handle=`hdid $(osx_dmg_name) | grep Apple_HFS | \
279 perl -e '\$$_=<>; /^\\/dev\\/(disk.)/; print \$$1'`; \
280 ditto $(osx_pkg_name) /Volumes/$(osx_dmg_volume)/$(osx_pkg_name); \
281 hdiutil detach $$dev_handle
282 hdiutil convert $(osx_dmg_name) -format UDZO -o $(osx_udzo_name)
283 -rm -f $(osx_dmg_name)
284 mv $(osx_udzo_name) $(osx_dmg_name)
288win_pkg_name:=$(RELNAME).zip
289win_docs:=COPYING.txt COPYRIGHT.txt BUGS.txt README.txt README.html
290cleanup_files+=$(win_pkg_name) $(win_docs)
291win-pkg: $(win_pkg_name)
292$(win_pkg_name): $(THIS).exe $(win_docs)
293 zip -r $(win_pkg_name) $(THIS).exe $(win_docs)
295.PHONY: test test-markdown
297 @cd $(TESTDIR) && perl runtests.pl -s $(PWD)/$(MAIN)
298compat:=$(PWD)/hsmarkdown
299markdown_test_dirs:=$(wildcard $(TESTDIR)/MarkdownTest_*)
300test-markdown: $(MAIN) $(compat)
301 @for suite in $(markdown_test_dirs); do \
303 suite_version=$$(echo $$suite | sed -e 's/.*_//');\
304 echo "\nRunning Markdown test suite version $${suite_version}.";\
305 PATH=$(PWD):$$PATH; export PATH; cd $$suite && \
306 perl MarkdownTest.pl -s $(compat) -tidy ; \
310# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
311src_all:=$(shell find $(SRCDIR) -type f -name '*hs' | egrep -v '^\./(_darcs|lib|test)/')
312cleanup_files+=$(patsubst %,$(SRCDIR)/%,tags tags.sorted)
314 cd $(SRCDIR) && hasktags -c $(src_all:$(SRCDIR)/%=%); \
315 LC_ALL=C sort tags >tags.sorted; mv tags.sorted tags
318tarball_name:=$(RELNAME).tar.gz
319cleanup_files+=$(tarball_name)
320tarball: $(tarball_name)
322 svn export . $(RELNAME)
323 tar cvzf $(tarball_name) $(RELNAME)
327deb_name:=$(shell grep ^Package debian/control | cut -d' ' -f2 | head -n 1)
328deb_version:=$(shell head -n 1 debian/changelog | cut -f2 -d' ' | tr -d '()')
330deb_main:=$(deb_name)_$(deb_version)_$(deb_arch).deb
332 @[ -x /usr/bin/fakeroot ] || { \
333 echo "*** Please install fakeroot package. ***"; \
336 @[ -x /usr/bin/dpkg-buildpackage ] || { \
337 echo "*** Please install dpkg-dev package. ***"; \
340 if [ -x /usr/bin/debuild ]; then \
341 debuild -uc -us -i.svn -I.svn -i_darcs -I_darcs --lintian-opts -i; \
343 echo "*** Please install devscripts package. ***"; \
344 echo "*** Using dpkg-buildpackage for package building. ***"; \
345 dpkg-buildpackage -rfakeroot -uc -us -i.svn -I.svn -i_darcs -I_darcs; \
351make_page:=./$(MAIN) -s -B $(web_src)/header.html \
352 -A $(web_src)/footer.html \
354cleanup_files+=$(web_dest)
356$(web_dest)/: $(MAIN) html
360 cp -r html $(web_dest)/doc; \
361 cp $(web_src)/*.css $(web_dest)/; \
362 sed -e 's#@PREFIX@#$(PREFIX)#g' $(osx_src)/Welcome | \
363 $(make_page) > $(web_dest)/osx-notes.html; \
364 sed -e '/^ --.*/d' -e 's#^# #g' changelog | \
365 sed -e 's/ \(pandoc (.*\)/## \1/g' | \
366 $(make_page) -T "Pandoc changelog" > $(web_dest)/changelog.html; \
367 $(make_page) README > $(web_dest)/README.html; \
368 $(make_page) INSTALL > $(web_dest)/INSTALL.html; \
369 sed -e 's/@TARBALL_NAME@/$(tarball_name)/g' $(web_src)/index.txt | \
370 sed -e 's/@OSX_DMG_NAME@/$(osx_dmg_name)/g' | \
371 sed -e 's/@WINDOWS_PKG_NAME@/$(win_pkg_name)/g' | \
372 sed -e 's/@VERSION@/$(VERSION)/g' | \
373 $(make_page) > $(web_dest)/index.html; \
374 cp README $(web_dest)/ ; \
375 ./$(MAIN) -s -w latex README > $(web_dest)/README.tex ; \
376 cp $(web_src)/myheader.tex $(web_dest)/ ; \
377 cp $(web_src)/S5DEMO $(web_dest)/ ; \
378 cp $(web_src)/header.html $(web_dest)/ ; \
379 cp $(web_src)/footer.html $(web_dest)/ ; \
380 sh $(web_src)/mkdemos.sh $(web_dest) $(shell pwd) | \
381 $(make_page) > $(web_dest)/examples.html; \
382 ) || { rm -rf $(web_dest); exit 1; }
384.PHONY: distclean clean
386 if [ -d debian ]; then \
387 chmod +x debian/rules; fakeroot debian/rules clean; \
391 make -C $(SRCDIR)/templates clean
392 -if [ -f $(BUILDCONF) ]; then $(BUILDCMD) clean; fi
393 -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