summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 78ca854a589c0ad8bbbedceb515b790a621f1356 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/make -f

# Copyright © 2006-2010 John MacFarlane <jgm@berkeley.edu>
# Copyright © 2007-2008 Recai Oktaş <roktas@debian.org>
# Copyright © 2008-2015 Jonas Smedegaard <dr@jones.dk>
# Description: Main Debian packaging script for Pandoc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

include /usr/share/cdbs/1/rules/upstream-tarball.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/hlibrary.mk

pkg = $(DEB_SOURCE_PACKAGE)
pkg-data = $(pkg)-data

# ABI by default follows upstream version (without repackaging suffix)
abi = $(DEB_UPSTREAM_TARBALL_VERSION)

DEB_UPSTREAM_URL = https://hackage.haskell.org/package/$(DEB_UPSTREAM_PACKAGE)-$(DEB_UPSTREAM_TARBALL_VERSION)

DEB_UPSTREAM_REPACKAGE_EXCLUDES = \
 data/LaTeXMathML.js \
 tests/docx/block_quotes.docx \
 tests/docx/char_styles.docx \
 tests/docx/deep_normalize.docx \
 tests/docx/drop_cap.docx \
 tests/docx/hanging_indent.docx \
 tests/docx/headers.docx \
 tests/docx/inline_formatting.docx \
 tests/docx/inline_images.docx \
 tests/docx/links.docx \
 tests/docx/lists.docx \
 tests/docx/metadata.docx \
 tests/docx/metadata_after_normal.docx \
 tests/docx/normalize.docx \
 tests/docx/notes.docx \
 tests/docx/numbered_header.docx \
 tests/docx/tables.docx \
 tests/s5-fancy.html

# Build-depend unversioned on debhelper
#  TODO: Drop when adopted in cdbs
CDBS_BUILD_DEPENDS_rules_debhelper_v9 = debhelper

# extract metadata from images, fonts and archives before copyright check
CDBS_BUILD_DEPENDS +=, libimage-exiftool-perl, libregexp-assemble-perl
CDBS_BUILD_DEPENDS +=, libipc-system-simple-perl, lcdf-typetools
local_inspection_regex = png|jpg|jpeg|gif|ttf|otf|docx|odt|epub
DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^((.*/)?[^/]+\.($(local_inspection_regex))|debian/(changelog|copyright(|_hints|_newhints)))$$
debian/stamp-copyright-check: debian/stamp-extract-copyright
debian/stamp-extract-copyright:
	find * -type f -regextype posix-extended \
		-regex '.*\.($(local_inspection_regex))' \
		-print0 | perl -0 debian/print-metadata.pl
	touch $@
pre-build:: clean-extracted-copyright-during-build
clean-extracted-copyright-during-build: debian/stamp-copyright-check
	find -type f -name '*.metadata_dump' -delete
clean::
	find -type f -name '*.metadata_dump' -delete
	rm -f debian/stamp-extract-copyright

DEB_INSTALL_MANPAGES_$(pkg) = man/man1/*.1 man/man5/*.5 debian/hsmarkdown.1

# Use threaded RTS only when supported
DEB_SETUP_GHC_CONFIGURE_ARGS += $(if $(wildcard /usr/lib/ghc-$(GHC_VERSION)/libHSrts_thr.a),,--flags=-threaded)

# Disable timer to help build on slow arches like hppa
DEB_SETUP_GHC_CONFIGURE_ARGS += --ghc-options="+RTS -V0 -RTS"

# put aside upstream-shipped temp files during build but after copyright-check
upstreamtmpfiles = man/man1/pandoc.1 man/man5/pandoc_markdown.5
pre-build:: debian/stamp-upstreamtmpstuff
debian/stamp-upstreamtmpstuff: debian/stamp-copyright-check
	for file in $(upstreamtmpfiles); do \
		[ ! -e $$file ] || [ -e $$file.upstream ] || cp $$file $$file.upstream; \
	done
	touch $@
clean::
	for file in $(upstreamtmpfiles); do \
		[ ! -e $$file.upstream ] || mv -f $$file.upstream $$file; \
	done
	rm -f debian/stamp-upstreamtmpstuff

# install data to varying path, and add symlink when datadir versioned
# TODO: simplify after buster: unversioned since haskell-devscripts 0.8.19
datadir := $(if $(shell grep datasubdir /usr/share/cdbs/1/class/hlibrary.mk),pandoc,pandoc-$(abi))
DEB_DH_INSTALL_ARGS_$(pkg-data) = debian/tmp-inst-*/usr/share/$(datadir)/data /usr/share/$(datadir)/
DEB_DH_LINK_$(pkg-data) = $(if $(call cdbs_streq,$(datadir),pandoc),,/usr/share/$(datadir) /usr/share/pandoc)

# Haskell dependencies for any build from pandoc.cabal
deps-ghc += unordered-containers,<<,3
deps-ghc += parsec3,<<,3.2
deps-ghc += mtl,<<,2.3
deps-ghc += network,>=,2.6
deps-ghc += network-uri,>=,2.6
deps-ghc += network-uri,<<,2.7
deps-ghc += text,<<,1.3
deps-ghc += zip-archive,>=,0.2.3.4,<<,0.3
deps-ghc += http,<<,1:4000.3
deps-ghc += texmath,>=,0.8.0.1,<<,0.9
deps-ghc += xml,<<,1.4
deps-ghc += random,<<1.2
deps-ghc += extensible-exceptions,<<,0.2
deps-ghc += pandoc-types,>=,1.12.4,<<,1.13
deps-ghc += aeson,>=,0.7.0.5,<<,0.9
deps-ghc += tagsoup,>=,0.13.1,<<,0.14
deps-ghc += base64-bytestring,<<,1.1
deps-ghc += zlib,<<,0.6
deps-ghc += highlighting-kate,>=,0.5.11.1,<<,0.6
deps-ghc += data-default,<<,0.6
deps-ghc += temporary,<<,1.3
deps-ghc += blaze-html,>=,0.5,<<,0.9
deps-ghc += blaze-markup,<<,0.8
deps-ghc += yaml,>=,0.8.8.2,<<,0.9
deps-ghc += scientific,<<,0.4
deps-ghc += hslua,<<,0.4
deps-ghc += sha,>=,1.6,<<,1.7
deps-ghc += haddock-library,<<,1.2
deps-ghc += deepseq-generics,<<,0.2
deps-ghc += juicypixels,<<,3.3
deps-ghc += http-client,<<,0.5
deps-ghc += http-client-tls,<<,0.3
deps-ghc += http-types,>=,0.8,<<,0.9
deps-ghc += syb,<<,0.5

# Haskell dependencies for testsuite from pandoc.cabal
deps-ghc-test += diff,>=,0.2,<<,0.3
deps-ghc-test += test-framework,<<,0.9
deps-ghc-test += test-framework-hunit,<<,0.4
deps-ghc-test += test-framework-quickcheck2,<<,0.4
deps-ghc-test += quickcheck2,<<,2.8
deps-ghc-test += hunit,<<,1.3
deps-ghc-test += template-haskell,<<,2.9
deps-ghc-test += ansi-terminal,<<,0.7

# Haskell dependencies (maybe) needed for documentation
# TODO: actually use these (not maintain Build-depends-indep by hand)
deps-ghc-doc += blaze-builder
deps-ghc-doc += digest
deps-ghc-doc += dlist
deps-ghc-doc += hs-bibutils
deps-ghc-doc += pcre-light
deps-ghc-doc += rts
deps-ghc-doc += transformers
deps-ghc-doc += utf8-string

expand-ghc-dep = $(comma) libghc-$2-$1 $(if $3,($3 $4)$(if $5,$(comma) libghc-$2-$1 ($5 $6)))
strip-ghc-deps = $(foreach dep,$2,$(call expand-ghc-dep,$1,$(word 1,$(subst $(comma),$(space),$(dep)))))
expand-ghc-deps = $(foreach dep,$2,$(call expand-ghc-dep,$1,$(word 1,$(subst $(comma),$(space),$(dep))),$(word 2,$(subst $(comma),$(space),$(dep))),$(word 3,$(subst $(comma),$(space),$(dep))),$(word 4,$(subst $(comma),$(space),$(dep))),$(word 5,$(subst $(comma),$(space),$(dep)))))

# Needed by upstream build process
CDBS_BUILD_DEPENDS +=, ghc, alex, happy
CDBS_BUILD_DEPENDS += $(call expand-ghc-deps,dev,$(deps-ghc))
# FIXME: enable, set DEB_ENABLE_TESTS = yes, and configure with -ftests
#CDBS_BUILD_DEPENDS += $(call expand-ghc-deps,dev,$(deps-ghc-test))
CDBS_BUILD_DEPENDS +=, ghc-prof
CDBS_BUILD_DEPENDS +=, $(call strip-ghc-deps,prof,$(deps-ghc))
CDBS_BUILD_DEPENDS_INDEP +=, ghc-doc
CDBS_BUILD_DEPENDS_INDEP +=, $(call strip-ghc-deps,doc,$(deps-ghc) $(deps-ghc-doc))

# Needed for our packaging
CDBS_BUILD_DEPENDS +=, haskell-devscripts

# Needed (always/often/seldom) at runtime
#  texlive-* needed for PDF output
#  etoolbox needed for PDF output of data with YAML metadata
# TODO: suggest slide show Javascript libraries when in Debian
CDBS_DEPENDS_$(pkg) = $(pkg-data)
CDBS_SUGGESTS_$(pkg) = texlive-latex-recommended, texlive-xetex, texlive-luatex
CDBS_SUGGESTS_$(pkg) +=, pandoc-citeproc, etoolbox