@@ -17,7 +17,9 @@ CONFIGURE := configure
1717# Cabal constants
1818#-------------------------------------------------------------------------------
1919NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL).in)
20+THIS := $(shell echo $(NAME) | tr A-Z a-z)
2021VERSION := $(shell sed -ne 's/^version[[:space:]]*=[[:space:]]*"\([^"]*\)"/\1/p' $(SRCDIR)/Main.hs)
22+RELNAME := $(THIS)-$(VERSION)
2123EXECSBASE := $(shell sed -ne 's/^[Ee]xecutable:[[:space:]]*//p' $(CABAL).in)
2224
2325#-------------------------------------------------------------------------------
@@ -51,7 +53,6 @@ DESTDIR ?= $(destdir)
5153#-------------------------------------------------------------------------------
5254# Installation paths
5355#-------------------------------------------------------------------------------
54−THIS := $(shell echo $(NAME) | tr A-Z a-z)
5556DESTPATH := $(DESTDIR)$(PREFIX)
5657BINPATH := $(DESTPATH)/bin
5758DATAPATH := $(DESTPATH)/share
@@ -88,6 +89,8 @@ all: build-program
8889 ./$(MAIN) -s -w rtf $< >$@ || rm -f $@
8990%.pdf: % $(MAIN) markdown2pdf
9091 sh ./markdown2pdf $< || rm -f $@
92+%.txt: %
93+ perl -p -e 's/\n/\r\n/' $< > $@ || rm -f $@ # convert to DOS line endings
9194
9295.PHONY: templates
9396templates: $(SRCDIR)/templates
@@ -236,13 +239,15 @@ uninstall-all: uninstall-exec uninstall-doc uninstall-lib-doc
236239install: install-program
237240uninstall: uninstall-program
238241
242+# OSX packages: make osx-pkg-prep, then (as root) make osx-pkg
243+.PHONY: osx-pkg osx-pkg-prep
239244osx_dest:=osx-pkg-tmp
240245osx_src:=osx
241246doc_more:=README.rtf COPYRIGHT.rtf $(osx_src)/Welcome.rtf
242−osx_pkg_name:=$(NAME)_$(VERSION).pkg
247+osx_pkg_name:=$(RELNAME).pkg
243248cleanup_files+=$(osx_dest) $(doc_more) $(osx_pkg_name)
244−osx-pkg-prep: build-program $(osx_dest)
245−$(osx_dest)/: $(doc_more)
249+osx-pkg-prep: $(osx_dest)
250+$(osx_dest)/: build-program $(doc_more)
246251 -rm -rf $(osx_dest)
247252 $(INSTALL) -d $(osx_dest)
248253 DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
@@ -255,7 +260,8 @@ $(osx_dest)/: $(doc_more)
255260 sed -e 's#@PREFIX@#$(PREFIX)#g' $(osx_src)/Welcome.rtf > $(osx_dest)/Resources/Welcome.rtf
256261 sed -e 's/@VERSION@/$(VERSION)/g' $(osx_src)/Info.plist > $(osx_dest)/Info.plist
257262 cp $(osx_src)/Description.plist $(osx_dest)/
258−osx-pkg: osx-pkg-prep
263+osx-pkg: $(osx_pkg_name)
264+$(osx_pkg_name): $(osx_dest)
259265 if [ "`id -u`" != 0 ]; then \
260266 echo "Root permissions needed to create OSX package!"; \
261267 exit 1; \
@@ -270,11 +276,12 @@ osx-pkg: osx-pkg-prep
270276 -rm -rf $(osx_dest)
271277
272278.PHONY: osx-dmg
273−osx_dmg_name:=$(NAME).dmg
274−osx_udzo_name:=$(NAME).udzo.dmg
279+osx_dmg_name:=$(RELNAME).dmg
280+cleanup_files+=$(osx_dmg_name)
281+osx_udzo_name:=$(RELNAME).udzo.dmg
275282osx_dmg_volume:="$(NAME) $(VERSION)"
276−osx-dmg: ../$(osx_dmg_name)
277−../$(osx_dmg_name): $(osx_pkg_name)
283+osx-dmg: $(osx_dmg_name)
284+$(osx_dmg_name): $(osx_pkg_name)
278285 -rm -f $(osx_dmg_name)
279286 hdiutil create $(osx_dmg_name) -size 05m -fs HFS+ -volname $(osx_dmg_volume)
280287 dev_handle=`hdid $(osx_dmg_name) | grep Apple_HFS | \
@@ -283,7 +290,20 @@ osx-dmg: ../$(osx_dmg_name)
283290 hdiutil detach $$dev_handle
284291 hdiutil convert $(osx_dmg_name) -format UDZO -o $(osx_udzo_name)
285292 -rm -f $(osx_dmg_name)
286− mv $(osx_udzo_name) ../$(osx_dmg_name)
293+ mv $(osx_udzo_name) $(osx_dmg_name)
294+
295+
296+.PHONY: win-pkg
297+win_pkg_name:=$(RELNAME).zip
298+win_docs:=COPYING.txt COPYRIGHT.txt BUGS.txt README-WINDOWS.txt
299+cleanup_files+=$(win_pkg_name) $(win_docs)
300+win-pkg: $(win_pkg_name)
301+$(win_pkg_name): $(THIS).exe $(win_docs)
302+ zip -r $(win_pkg_name) $(THIS).exe $(win_docs)
303+cleanup_files+=README-WINDOWS
304+README-WINDOWS: README
305+ sed -e '/^Requirements/,/^\[fancyvrb\]:/ d' \
306+ -e '/^Character encodings/,/mysite.com$$/ d' $< > $@
287307
288308.PHONY: test test-markdown
289309test: $(MAIN)
@@ -299,13 +319,12 @@ tags: $(src_all)
299319 LC_ALL=C sort tags >tags.sorted; mv tags.sorted tags
300320
301321.PHONY: tarball
302−fullname:=$(THIS)-$(VERSION)
303−tarball_name:=$(fullname).tar.gz
322+tarball_name:=$(RELNAME).tar.gz
304323cleanup_files+=$(tarball_name)
305324tarball: $(tarball_name)
306325$(tarball_name):
307− svn export . $(fullname)
308− tar cvzf $(tarball_name) $(fullname)
326+ svn export . $(RELNAME)
327+ tar cvzf $(tarball_name) $(RELNAME)
309328 -rm -rf $(fullname)
310329
311330.PHONY: deb
@@ -336,30 +355,13 @@ web_dest:=web/pandoc
336355make_page:=./$(MAIN) -s -B $(web_src)/header.html \
337356 -A $(web_src)/footer.html \
338357 -H $(web_src)/css
339−win_main:=$(basename $(MAIN)).exe
340358cleanup_files+=$(web_dest)
341359website: $(web_dest)
342−$(web_dest)/: $(MAIN) html $(tarball_name)
343− @[ -f ../$(osx_dmg_name) ] || { \
344− echo "*** Missing ../$(osx_dmg_name). ***"; \
345− exit 1; \
346− }
347− @[ -f ../$(deb_main) ] || { \
348− echo "*** Missing ../$(deb_main). ***"; \
349− exit 1; \
350− }
351− @[ -f $(win_main) ] || { \
352− echo "*** Missing $(win_main). ***"; \
353− exit 1; \
354− }
360+$(web_dest)/: $(MAIN) html
355361 -rm -rf $(web_dest)
356362 ( \
357363 mkdir $(web_dest); \
358364 cp -r html $(web_dest)/doc; \
359− cp ../$(osx_dmg_name) $(web_dest)/; \
360− cp ../$(deb_main) $(web_dest)/; \
361− cp $(win_main) $(web_dest)/; \
362− cp $(tarball_name) $(web_dest)/; \
363365 cp $(web_src)/*.css $(web_dest)/; \
364366 sed -e 's#@PREFIX@#$(PREFIX)#g' $(osx_src)/Welcome | \
365367 $(make_page) > $(web_dest)/osx-notes.html; \
@@ -370,9 +372,8 @@ $(web_dest)/: $(MAIN) html $(tarball_name)
370372 $(make_page) README > $(web_dest)/README.html; \
371373 $(make_page) INSTALL > $(web_dest)/INSTALL.html; \
372374 sed -e 's/@TARBALL_NAME@/$(tarball_name)/g' $(web_src)/index.txt | \
373− sed -e 's/@DEB_NAME@/$(deb_main)/g' | \
374375 sed -e 's/@OSX_DMG_NAME@/$(osx_dmg_name)/g' | \
375− sed -e 's/@WINDOWS_EXE_NAME@/$(win_main)/g' | \
376+ sed -e 's/@WINDOWS_PKG_NAME@/$(win_pkg_name)/g' | \
376377 sed -e 's/@VERSION@/$(VERSION)/g' | \
377378 $(make_page) > $(web_dest)/index.html; \
378379 ) || { rm -rf $(web_dest); exit 1; }