2006-10-17 16:22:29 +02:00
|
|
|
# Makefile for Pandoc.
|
|
|
|
|
2006-11-11 11:35:10 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Constant names and commands in source tree
|
|
|
|
#-------------------------------------------------------------------------------
|
2007-07-07 07:25:44 +02:00
|
|
|
CABAL := pandoc.cabal
|
2006-11-11 11:35:10 +01:00
|
|
|
SRCDIR := src
|
|
|
|
MANDIR := man
|
2006-12-12 08:04:09 +01:00
|
|
|
TESTDIR := tests
|
2006-11-11 11:35:10 +01:00
|
|
|
BUILDDIR := dist
|
|
|
|
BUILDCONF := .setup-config
|
|
|
|
BUILDCMD := runhaskell Setup.hs
|
|
|
|
BUILDVARS := vars
|
|
|
|
CONFIGURE := configure
|
2006-10-28 17:13:18 +02:00
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Cabal constants
|
|
|
|
#-------------------------------------------------------------------------------
|
2007-06-17 18:20:50 +02:00
|
|
|
NAME := $(shell sed -ne 's/^[Nn]ame:[[:space:]]*//p' $(CABAL))
|
2006-12-24 03:32:01 +01:00
|
|
|
THIS := $(shell echo $(NAME) | tr A-Z a-z)
|
2006-12-12 16:41:55 +01:00
|
|
|
VERSION := $(shell sed -ne 's/^version[[:space:]]*=[[:space:]]*"\([^"]*\)"/\1/p' $(SRCDIR)/Main.hs)
|
2006-12-24 03:32:01 +01:00
|
|
|
RELNAME := $(THIS)-$(VERSION)
|
2007-06-17 18:20:50 +02:00
|
|
|
EXECSBASE := $(shell sed -ne 's/^[Ee]xecutable:[[:space:]]*//p' $(CABAL))
|
2006-11-02 07:45:03 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2006-11-02 15:32:57 +01:00
|
|
|
# Install targets
|
2006-11-02 07:45:03 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
2007-01-02 03:58:54 +01:00
|
|
|
WRAPPERS := html2markdown markdown2pdf hsmarkdown
|
2006-12-16 20:11:49 +01:00
|
|
|
# Add .exe extensions if we're running Windows/Cygwin.
|
|
|
|
EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
|
|
|
|
sed -ne 's/^cygwin.*$$/\.exe/p')
|
|
|
|
EXECS := $(addsuffix $(EXTENSION),$(EXECSBASE))
|
2006-12-23 13:37:31 +01:00
|
|
|
PROGS := $(EXECS) $(WRAPPERS)
|
2006-12-16 20:11:49 +01:00
|
|
|
MAIN := $(firstword $(EXECS))
|
2006-12-21 21:21:40 +01:00
|
|
|
DOCS := README.html README BUGS
|
2007-07-02 01:26:20 +02:00
|
|
|
MANPAGES := $(patsubst %.md,%,$(wildcard $(MANDIR)/man?/*.?.md))
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-11-03 12:26:53 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Variables to setup through environment
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Specify default values.
|
|
|
|
prefix := /usr/local
|
|
|
|
destdir :=
|
|
|
|
# Attempt to set variables from a previous make session.
|
|
|
|
-include $(BUILDVARS)
|
|
|
|
# Fallback to defaults but allow to get the values from environment.
|
|
|
|
PREFIX ?= $(prefix)
|
|
|
|
DESTDIR ?= $(destdir)
|
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Installation paths
|
|
|
|
#-------------------------------------------------------------------------------
|
2006-10-29 13:54:08 +01:00
|
|
|
DESTPATH := $(DESTDIR)$(PREFIX)
|
|
|
|
BINPATH := $(DESTPATH)/bin
|
|
|
|
DATAPATH := $(DESTPATH)/share
|
|
|
|
LIBPATH := $(DESTPATH)/$(NAME)-$(VERSION)
|
2006-10-17 16:22:29 +02:00
|
|
|
DOCPATH := $(DATAPATH)/doc/$(THIS)
|
|
|
|
LIBDOCPATH := $(DATAPATH)/doc/$(THIS)-doc
|
|
|
|
MANPATH := $(DATAPATH)/man
|
|
|
|
PKGPATH := $(DATAPATH)/$(THIS)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Generic Makefile variables
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
INSTALL := install -c
|
2006-10-31 19:40:47 +01:00
|
|
|
INSTALL_PROGRAM := $(INSTALL) -m 755
|
2006-10-17 16:22:29 +02:00
|
|
|
INSTALL_DATA := $(INSTALL) -m 644
|
2006-10-30 07:41:26 +01:00
|
|
|
STRIP := strip
|
2006-10-28 17:13:18 +02:00
|
|
|
GHC := ghc
|
2006-10-29 13:54:08 +01:00
|
|
|
GHC_PKG := ghc-pkg
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Recipes
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2006-11-02 07:45:03 +01:00
|
|
|
# Default target.
|
2006-10-17 16:22:29 +02:00
|
|
|
.PHONY: all
|
2006-11-02 07:45:03 +01:00
|
|
|
all: build-program
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-10-30 09:04:30 +01:00
|
|
|
# Document process rules.
|
2006-11-02 15:32:57 +01:00
|
|
|
%.html: % $(MAIN)
|
2007-07-11 09:28:12 +02:00
|
|
|
./$(MAIN) -s -S --toc $< >$@ || rm -f $@
|
2006-11-02 15:32:57 +01:00
|
|
|
%.tex: % $(MAIN)
|
|
|
|
./$(MAIN) -s -w latex $< >$@ || rm -f $@
|
|
|
|
%.rtf: % $(MAIN)
|
|
|
|
./$(MAIN) -s -w rtf $< >$@ || rm -f $@
|
2006-11-07 11:37:18 +01:00
|
|
|
%.pdf: % $(MAIN) markdown2pdf
|
2006-10-30 09:04:30 +01:00
|
|
|
sh ./markdown2pdf $< || rm -f $@
|
2006-12-24 03:32:01 +01:00
|
|
|
%.txt: %
|
|
|
|
perl -p -e 's/\n/\r\n/' $< > $@ || rm -f $@ # convert to DOS line endings
|
2007-07-02 01:26:20 +02:00
|
|
|
%.1: %.1.md $(MAIN)
|
2007-07-08 05:22:00 +02:00
|
|
|
./$(MAIN) -s -S -w man $< >$@ || rm -f $@
|
2006-10-30 09:04:30 +01:00
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
.PHONY: templates
|
|
|
|
templates: $(SRCDIR)/templates
|
|
|
|
$(MAKE) -C $(SRCDIR)/templates
|
|
|
|
|
2006-12-12 08:04:09 +01:00
|
|
|
define generate-shell-script
|
|
|
|
echo "Generating $@..."; \
|
|
|
|
awk ' \
|
|
|
|
/^[ \t]*###+ / { \
|
|
|
|
lead = $$0; sub(/[^ \t].*$$/, "", lead); \
|
|
|
|
t = "$(dir $<)/"$$2; \
|
|
|
|
while (getline line < t > 0) \
|
|
|
|
print lead line; \
|
|
|
|
next; \
|
|
|
|
} \
|
|
|
|
{ print } \
|
|
|
|
' <$< >$@
|
2006-12-29 22:41:09 +01:00
|
|
|
chmod +x $@
|
2006-12-12 08:04:09 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
.PHONY: wrappers
|
|
|
|
wrappers: $(WRAPPERS)
|
|
|
|
cleanup_files+=$(WRAPPERS)
|
2007-01-03 18:22:55 +01:00
|
|
|
$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh
|
2006-12-12 08:04:09 +01:00
|
|
|
@$(generate-shell-script)
|
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
.PHONY: configure
|
2006-11-03 12:26:53 +01:00
|
|
|
cleanup_files+=$(BUILDDIR) $(BUILDCONF) $(BUILDVARS)
|
2006-12-19 23:00:41 +01:00
|
|
|
configure: $(BUILDCONF) templates
|
2006-10-28 17:13:18 +02:00
|
|
|
$(BUILDCONF): $(CABAL)
|
2006-10-17 16:22:29 +02:00
|
|
|
$(BUILDCMD) configure --prefix=$(PREFIX)
|
2006-11-03 12:26:53 +01:00
|
|
|
# Make configuration time settings persistent (definitely a hack).
|
|
|
|
@echo "PREFIX?=$(PREFIX)" >$(BUILDVARS)
|
|
|
|
@echo "DESTDIR?=$(DESTDIR)" >>$(BUILDVARS)
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
.PHONY: build
|
2006-12-19 23:00:41 +01:00
|
|
|
build: configure
|
2006-10-17 16:22:29 +02:00
|
|
|
$(BUILDCMD) build
|
|
|
|
|
2006-11-02 07:45:03 +01:00
|
|
|
.PHONY: build-exec
|
2006-12-28 03:20:09 +01:00
|
|
|
build-exec: $(PROGS)
|
2006-11-02 15:32:57 +01:00
|
|
|
cleanup_files+=$(EXECS)
|
2006-11-10 11:55:18 +01:00
|
|
|
$(EXECS): build
|
2006-11-16 03:37:25 +01:00
|
|
|
for f in $@; do \
|
2007-07-28 05:56:27 +02:00
|
|
|
find $(BUILDDIR) -type f -name "$$f" \
|
|
|
|
-perm +a=x -exec ln -s -f {} . \; ; \
|
2007-06-17 18:20:50 +02:00
|
|
|
done
|
2006-11-02 07:45:03 +01:00
|
|
|
|
|
|
|
.PHONY: build-doc
|
2007-07-02 01:26:20 +02:00
|
|
|
cleanup_files+=README.html $(MANPAGES)
|
|
|
|
build-doc: $(DOCS) $(MANPAGES)
|
2006-11-02 07:45:03 +01:00
|
|
|
|
|
|
|
.PHONY: build-program
|
|
|
|
build-program: build-exec build-doc
|
|
|
|
|
2006-10-28 17:13:18 +02:00
|
|
|
.PHONY: build-lib-doc haddock
|
2006-10-17 16:22:29 +02:00
|
|
|
build-lib-doc: html
|
2006-10-28 17:13:18 +02:00
|
|
|
haddock: build-lib-doc
|
2006-10-17 16:22:29 +02:00
|
|
|
cleanup_files+=html
|
2006-10-28 17:13:18 +02:00
|
|
|
html/: configure
|
|
|
|
-rm -rf html
|
2006-10-17 16:22:29 +02:00
|
|
|
$(BUILDCMD) haddock && mv $(BUILDDIR)/doc/html .
|
|
|
|
|
2006-10-29 13:54:08 +01:00
|
|
|
.PHONY: build-all
|
2006-11-07 11:37:18 +01:00
|
|
|
build-all: build-program build-lib-doc
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-10-29 13:54:08 +01:00
|
|
|
# User documents installation.
|
2006-10-17 16:22:29 +02:00
|
|
|
.PHONY: install-doc uninstall-doc
|
2007-07-02 01:26:20 +02:00
|
|
|
man_all:=$(patsubst $(MANDIR)/%,%,$(MANPAGES))
|
2006-11-02 07:45:03 +01:00
|
|
|
install-doc: build-doc
|
2006-11-02 15:32:57 +01:00
|
|
|
$(INSTALL) -d $(DOCPATH) && $(INSTALL_DATA) $(DOCS) $(DOCPATH)/
|
2006-10-28 17:13:18 +02:00
|
|
|
for f in $(man_all); do \
|
|
|
|
$(INSTALL) -d $(MANPATH)/$$(dirname $$f); \
|
|
|
|
$(INSTALL_DATA) $(MANDIR)/$$f $(MANPATH)/$$f; \
|
|
|
|
done
|
2006-10-17 16:22:29 +02:00
|
|
|
uninstall-doc:
|
2006-11-02 15:32:57 +01:00
|
|
|
-for f in $(DOCS); do rm -f $(DOCPATH)/$$f; done
|
2006-10-20 19:27:57 +02:00
|
|
|
-for f in $(man_all); do rm -f $(MANPATH)/$$f; done
|
2006-10-29 08:11:37 +01:00
|
|
|
-rmdir $(DOCPATH)
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-10-29 13:54:08 +01:00
|
|
|
# Library documents installation.
|
|
|
|
.PHONY: install-lib-doc uninstall-lib-doc
|
2006-10-17 16:22:29 +02:00
|
|
|
install-lib-doc: build-lib-doc
|
2007-02-23 18:31:46 +01:00
|
|
|
$(INSTALL) -d $(LIBDOCPATH) && cp -R html $(LIBDOCPATH)/
|
2006-10-29 13:54:08 +01:00
|
|
|
uninstall-lib-doc:
|
|
|
|
-rm -rf $(LIBDOCPATH)/html
|
|
|
|
-rmdir $(LIBDOCPATH)
|
|
|
|
|
2007-01-05 11:16:15 +01:00
|
|
|
# Helper to install the given files $(1) into the path $(2).
|
|
|
|
# It also has the ability to follow symlinks.
|
|
|
|
install-executable-files = \
|
|
|
|
$(INSTALL) -d $(2); \
|
|
|
|
for f in $(1); do \
|
2006-11-16 03:37:25 +01:00
|
|
|
if [ -L $$f ]; then \
|
|
|
|
f=$$(readlink $$f); \
|
|
|
|
fi; \
|
2007-01-05 11:16:15 +01:00
|
|
|
$(INSTALL_PROGRAM) $$f $(2)/; \
|
2006-11-16 03:37:25 +01:00
|
|
|
done
|
2007-01-05 11:16:15 +01:00
|
|
|
|
|
|
|
# Program only installation.
|
|
|
|
.PHONY: install-exec uninstall-exec
|
|
|
|
install-exec: build-exec
|
2007-02-27 08:16:20 +01:00
|
|
|
$(STRIP) $(EXECS)
|
2007-01-05 11:16:15 +01:00
|
|
|
$(call install-executable-files,$(PROGS),$(BINPATH))
|
2006-10-29 13:54:08 +01:00
|
|
|
uninstall-exec:
|
2006-12-28 03:20:09 +01:00
|
|
|
-for f in $(notdir $(PROGS)); do rm -f $(BINPATH)/$$f; done ;
|
2006-10-29 13:54:08 +01:00
|
|
|
|
|
|
|
# Program + user documents installation.
|
|
|
|
.PHONY: install-program uninstall-program
|
|
|
|
install-program: install-exec install-doc
|
|
|
|
uninstall-program: uninstall-exec uninstall-doc
|
|
|
|
|
|
|
|
# Install everything.
|
|
|
|
.PHONY: install-all uninstall-all
|
2007-01-05 11:16:15 +01:00
|
|
|
install-all: build-exec install-doc install-lib-doc
|
|
|
|
# Install the library (+ main executable) and register it.
|
2006-11-03 07:15:13 +01:00
|
|
|
destdir=$(DESTDIR); \
|
2006-11-03 06:44:22 +01:00
|
|
|
# Older Cabal versions have no '--destdir' option.
|
|
|
|
if $(BUILDCMD) copy --help | grep -q '\-\-destdir'; then \
|
2006-11-03 07:15:13 +01:00
|
|
|
opt="--destdir=$${destdir-/}"; \
|
2006-11-03 06:44:22 +01:00
|
|
|
else \
|
|
|
|
opt="--copy-prefix=$${destdir}$(PREFIX)"; \
|
|
|
|
fi; \
|
|
|
|
$(BUILDCMD) copy $$opt; \
|
2006-10-29 13:54:08 +01:00
|
|
|
$(BUILDCMD) register
|
2007-01-05 11:16:15 +01:00
|
|
|
# Note that, we are in the position of having to install the wrappers
|
|
|
|
# separately, as Cabal installs the main exec along with the library.
|
|
|
|
$(call install-executable-files,$(WRAPPERS),$(BINPATH))
|
2006-10-30 06:40:41 +01:00
|
|
|
uninstall-all: uninstall-exec uninstall-doc uninstall-lib-doc
|
2006-10-29 13:54:08 +01:00
|
|
|
-pkg_id="$(NAME)-$(VERSION)"; \
|
|
|
|
libdir=$$($(GHC_PKG) field $$pkg_id library-dirs 2>/dev/null | \
|
|
|
|
sed 's/^library-dirs: *//'); \
|
|
|
|
if [ -d "$$libdir" ]; then \
|
|
|
|
$(BUILDCMD) unregister; \
|
|
|
|
rm -rf $$libdir; \
|
|
|
|
rmdir $$(dirname $$libdir); \
|
|
|
|
else \
|
|
|
|
echo "*** Couldn't locate library files for pkgid: $$pkg_id. ***"; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Default installation recipe for a common deployment scenario.
|
|
|
|
.PHONY: install uninstall
|
|
|
|
install: install-program
|
|
|
|
uninstall: uninstall-program
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-12-24 03:32:01 +01:00
|
|
|
# OSX packages: make osx-pkg-prep, then (as root) make osx-pkg
|
|
|
|
.PHONY: osx-pkg osx-pkg-prep
|
2006-11-01 08:49:18 +01:00
|
|
|
osx_dest:=osx-pkg-tmp
|
2006-11-01 08:16:58 +01:00
|
|
|
osx_src:=osx
|
2007-07-24 01:13:43 +02:00
|
|
|
doc_more:=COPYRIGHT.rtf $(osx_src)/Welcome.rtf
|
2006-12-24 03:32:01 +01:00
|
|
|
osx_pkg_name:=$(RELNAME).pkg
|
2006-11-01 08:16:58 +01:00
|
|
|
cleanup_files+=$(osx_dest) $(doc_more) $(osx_pkg_name)
|
2006-12-24 03:32:01 +01:00
|
|
|
osx-pkg-prep: $(osx_dest)
|
|
|
|
$(osx_dest)/: build-program $(doc_more)
|
2006-10-30 07:41:26 +01:00
|
|
|
-rm -rf $(osx_dest)
|
|
|
|
$(INSTALL) -d $(osx_dest)
|
2006-10-30 17:07:01 +01:00
|
|
|
DESTDIR=$(osx_dest)/Package_root $(MAKE) install-program
|
2006-11-01 09:29:13 +01:00
|
|
|
cp $(osx_src)/uninstall-pandoc $(osx_dest)/Package_root/usr/local/bin/
|
2006-10-30 07:41:26 +01:00
|
|
|
find $(osx_dest) -type f -regex ".*bin/.*" | xargs chmod +x
|
2006-11-11 11:35:10 +01:00
|
|
|
find $(osx_dest) -type f -regex ".*bin/$(notdir $(MAIN))" | xargs $(STRIP)
|
2006-10-30 07:41:26 +01:00
|
|
|
$(INSTALL) -d $(osx_dest)/Resources
|
2007-07-27 18:09:18 +02:00
|
|
|
./$(MAIN) -s -S README -o $(osx_dest)/Resources/ReadMe.html
|
2006-12-22 21:27:32 +01:00
|
|
|
cp COPYRIGHT.rtf $(osx_dest)/Resources/License.rtf
|
2006-11-01 08:16:58 +01:00
|
|
|
sed -e 's#@PREFIX@#$(PREFIX)#g' $(osx_src)/Welcome.rtf > $(osx_dest)/Resources/Welcome.rtf
|
|
|
|
sed -e 's/@VERSION@/$(VERSION)/g' $(osx_src)/Info.plist > $(osx_dest)/Info.plist
|
|
|
|
cp $(osx_src)/Description.plist $(osx_dest)/
|
2006-12-24 03:32:01 +01:00
|
|
|
osx-pkg: $(osx_pkg_name)
|
2007-01-01 22:34:50 +01:00
|
|
|
$(osx_pkg_name)/: $(osx_dest)
|
2006-11-01 08:49:18 +01:00
|
|
|
if [ "`id -u`" != 0 ]; then \
|
|
|
|
echo "Root permissions needed to create OSX package!"; \
|
2006-11-01 11:28:22 +01:00
|
|
|
exit 1; \
|
2006-11-01 08:49:18 +01:00
|
|
|
fi
|
2006-11-02 04:30:47 +01:00
|
|
|
find $(osx_dest) | xargs chown root:wheel
|
2006-11-01 08:16:58 +01:00
|
|
|
PackageMaker -build -p $(osx_pkg_name) \
|
2006-11-01 11:28:22 +01:00
|
|
|
-f $(osx_dest)/Package_root \
|
|
|
|
-r $(osx_dest)/Resources \
|
|
|
|
-i $(osx_dest)/Info.plist \
|
|
|
|
-d $(osx_dest)/Description.plist
|
2006-11-02 04:30:47 +01:00
|
|
|
chgrp admin $(osx_pkg_name)
|
2006-11-01 11:28:22 +01:00
|
|
|
-rm -rf $(osx_dest)
|
2006-11-01 08:16:58 +01:00
|
|
|
|
2006-11-02 04:30:47 +01:00
|
|
|
.PHONY: osx-dmg
|
2006-12-24 03:32:01 +01:00
|
|
|
osx_dmg_name:=$(RELNAME).dmg
|
|
|
|
cleanup_files+=$(osx_dmg_name)
|
|
|
|
osx_udzo_name:=$(RELNAME).udzo.dmg
|
2006-11-12 01:24:50 +01:00
|
|
|
osx_dmg_volume:="$(NAME) $(VERSION)"
|
2006-12-24 03:32:01 +01:00
|
|
|
osx-dmg: $(osx_dmg_name)
|
|
|
|
$(osx_dmg_name): $(osx_pkg_name)
|
2006-11-01 08:16:58 +01:00
|
|
|
-rm -f $(osx_dmg_name)
|
|
|
|
hdiutil create $(osx_dmg_name) -size 05m -fs HFS+ -volname $(osx_dmg_volume)
|
2006-11-01 11:28:22 +01:00
|
|
|
dev_handle=`hdid $(osx_dmg_name) | grep Apple_HFS | \
|
|
|
|
perl -e '\$$_=<>; /^\\/dev\\/(disk.)/; print \$$1'`; \
|
|
|
|
ditto $(osx_pkg_name) /Volumes/$(osx_dmg_volume)/$(osx_pkg_name); \
|
2006-11-01 08:16:58 +01:00
|
|
|
hdiutil detach $$dev_handle
|
2006-11-12 01:24:50 +01:00
|
|
|
hdiutil convert $(osx_dmg_name) -format UDZO -o $(osx_udzo_name)
|
2006-11-01 11:28:22 +01:00
|
|
|
-rm -f $(osx_dmg_name)
|
2006-12-24 03:32:01 +01:00
|
|
|
mv $(osx_udzo_name) $(osx_dmg_name)
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: win-pkg
|
|
|
|
win_pkg_name:=$(RELNAME).zip
|
2006-12-28 03:20:09 +01:00
|
|
|
win_docs:=COPYING.txt COPYRIGHT.txt BUGS.txt README.txt README.html
|
2006-12-24 03:32:01 +01:00
|
|
|
cleanup_files+=$(win_pkg_name) $(win_docs)
|
|
|
|
win-pkg: $(win_pkg_name)
|
|
|
|
$(win_pkg_name): $(THIS).exe $(win_docs)
|
|
|
|
zip -r $(win_pkg_name) $(THIS).exe $(win_docs)
|
2006-10-30 07:41:26 +01:00
|
|
|
|
2006-12-22 21:16:03 +01:00
|
|
|
.PHONY: test test-markdown
|
2006-11-02 15:32:57 +01:00
|
|
|
test: $(MAIN)
|
2006-12-12 08:04:09 +01:00
|
|
|
@cd $(TESTDIR) && perl runtests.pl -s $(PWD)/$(MAIN)
|
2007-01-02 22:30:07 +01:00
|
|
|
compat:=$(PWD)/hsmarkdown
|
2007-01-04 18:23:30 +01:00
|
|
|
markdown_test_dirs:=$(wildcard $(TESTDIR)/MarkdownTest_*)
|
2007-01-02 22:30:07 +01:00
|
|
|
test-markdown: $(MAIN) $(compat)
|
2007-01-04 18:23:30 +01:00
|
|
|
@for suite in $(markdown_test_dirs); do \
|
|
|
|
( \
|
|
|
|
suite_version=$$(echo $$suite | sed -e 's/.*_//');\
|
2007-01-05 02:20:18 +01:00
|
|
|
echo "-----------------------------------------";\
|
|
|
|
echo "Running Markdown test suite version $${suite_version}.";\
|
2007-01-04 18:23:30 +01:00
|
|
|
PATH=$(PWD):$$PATH; export PATH; cd $$suite && \
|
|
|
|
perl MarkdownTest.pl -s $(compat) -tidy ; \
|
|
|
|
) \
|
|
|
|
done
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
|
|
|
|
src_all:=$(shell find $(SRCDIR) -type f -name '*hs' | egrep -v '^\./(_darcs|lib|test)/')
|
|
|
|
cleanup_files+=$(patsubst %,$(SRCDIR)/%,tags tags.sorted)
|
|
|
|
tags: $(src_all)
|
|
|
|
cd $(SRCDIR) && hasktags -c $(src_all:$(SRCDIR)/%=%); \
|
|
|
|
LC_ALL=C sort tags >tags.sorted; mv tags.sorted tags
|
|
|
|
|
2006-11-08 08:19:59 +01:00
|
|
|
.PHONY: tarball
|
2006-12-24 03:32:01 +01:00
|
|
|
tarball_name:=$(RELNAME).tar.gz
|
2006-11-08 08:19:59 +01:00
|
|
|
cleanup_files+=$(tarball_name)
|
|
|
|
tarball: $(tarball_name)
|
|
|
|
$(tarball_name):
|
2006-12-24 03:32:01 +01:00
|
|
|
svn export . $(RELNAME)
|
2007-06-17 18:20:50 +02:00
|
|
|
$(MAKE) -C $(RELNAME) templates
|
|
|
|
$(MAKE) -C $(RELNAME) wrappers
|
2006-12-24 03:32:01 +01:00
|
|
|
tar cvzf $(tarball_name) $(RELNAME)
|
2007-08-15 19:49:10 +02:00
|
|
|
-rm -rf $(RELNAME)
|
2006-11-08 08:19:59 +01:00
|
|
|
|
2006-11-08 11:32:53 +01:00
|
|
|
.PHONY: deb
|
|
|
|
deb_name:=$(shell grep ^Package debian/control | cut -d' ' -f2 | head -n 1)
|
|
|
|
deb_version:=$(shell head -n 1 debian/changelog | cut -f2 -d' ' | tr -d '()')
|
|
|
|
deb_arch:=i386
|
|
|
|
deb_main:=$(deb_name)_$(deb_version)_$(deb_arch).deb
|
|
|
|
deb: debian
|
|
|
|
@[ -x /usr/bin/fakeroot ] || { \
|
|
|
|
echo "*** Please install fakeroot package. ***"; \
|
|
|
|
exit 1; \
|
|
|
|
}
|
|
|
|
@[ -x /usr/bin/dpkg-buildpackage ] || { \
|
|
|
|
echo "*** Please install dpkg-dev package. ***"; \
|
|
|
|
exit 1; \
|
|
|
|
}
|
2007-07-16 10:24:39 +02:00
|
|
|
-mv $(BUILDVARS) $(BUILDVARS).old # backup settings
|
2006-11-08 11:32:53 +01:00
|
|
|
if [ -x /usr/bin/debuild ]; then \
|
|
|
|
debuild -uc -us -i.svn -I.svn -i_darcs -I_darcs --lintian-opts -i; \
|
|
|
|
else \
|
|
|
|
echo "*** Please install devscripts package. ***"; \
|
|
|
|
echo "*** Using dpkg-buildpackage for package building. ***"; \
|
|
|
|
dpkg-buildpackage -rfakeroot -uc -us -i.svn -I.svn -i_darcs -I_darcs; \
|
|
|
|
fi
|
2007-07-16 10:24:39 +02:00
|
|
|
-mv $(BUILDVARS).old $(BUILDVARS) # restore
|
2006-11-08 11:32:53 +01:00
|
|
|
|
2006-11-08 08:19:59 +01:00
|
|
|
.PHONY: website
|
|
|
|
web_src:=web
|
|
|
|
web_dest:=web/pandoc
|
2007-01-09 03:07:20 +01:00
|
|
|
make_page:=./$(MAIN) -s -S -B $(web_src)/header.html \
|
2006-11-08 11:32:53 +01:00
|
|
|
-A $(web_src)/footer.html \
|
|
|
|
-H $(web_src)/css
|
2006-11-08 08:19:59 +01:00
|
|
|
cleanup_files+=$(web_dest)
|
2007-01-09 03:07:20 +01:00
|
|
|
website: $(MAIN) html
|
2006-11-08 08:19:59 +01:00
|
|
|
-rm -rf $(web_dest)
|
2006-11-08 11:56:05 +01:00
|
|
|
( \
|
|
|
|
mkdir $(web_dest); \
|
|
|
|
cp -r html $(web_dest)/doc; \
|
2007-07-14 08:28:09 +02:00
|
|
|
cp $(web_src)/* $(web_dest)/; \
|
2007-01-09 19:55:50 +01:00
|
|
|
sed -e 's#@PREFIX@#$(PREFIX)#g' $(osx_src)/Welcome > \
|
|
|
|
$(web_dest)/osx-notes.txt; \
|
2007-07-14 08:28:09 +02:00
|
|
|
cp changelog $(web_dest)/ ; \
|
2007-01-09 19:55:50 +01:00
|
|
|
cp README $(web_dest)/ ; \
|
|
|
|
cp INSTALL $(web_dest)/ ; \
|
2007-07-03 06:11:57 +02:00
|
|
|
cp $(MANDIR)/man1/pandoc.1.md $(web_dest)/ ; \
|
2007-07-14 08:28:09 +02:00
|
|
|
cp $(MANDIR)/man1/*.1 $(web_dest)/ ; \
|
2007-01-09 19:55:50 +01:00
|
|
|
PANDOC_PATH=$(shell pwd) make -C $(web_dest) ; \
|
2006-11-08 11:56:05 +01:00
|
|
|
) || { rm -rf $(web_dest); exit 1; }
|
2006-11-08 08:19:59 +01:00
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
.PHONY: distclean clean
|
2006-10-28 17:13:18 +02:00
|
|
|
distclean: clean
|
2006-10-30 13:15:02 +01:00
|
|
|
if [ -d debian ]; then \
|
|
|
|
chmod +x debian/rules; fakeroot debian/rules clean; \
|
|
|
|
fi
|
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
clean:
|
2006-12-19 23:20:58 +01:00
|
|
|
make -C $(SRCDIR)/templates clean
|
2006-10-17 16:22:29 +02:00
|
|
|
-if [ -f $(BUILDCONF) ]; then $(BUILDCMD) clean; fi
|
|
|
|
-rm -rf $(cleanup_files)
|