File: hlibrary.mk

package info (click to toggle)
haskell-devscripts 0.16.34
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 272 kB
  • sloc: perl: 1,199; haskell: 30; sh: 19; makefile: 17
file content (263 lines) | stat: -rw-r--r-- 9,866 bytes parent folder | download | duplicates (2)
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# -*- mode: makefile -*-
#
# Copyright 2022 Felix Lechner <felix.lechner@lease-up.com>
# Copyright 2008 Kari Pahula <kaol@debian.org>
# Description: A class for Haskell library packages
#
# 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 2, 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.

export GREP_OPTIONS :=

# DH_haskell.sh uses shell features
export SHELL = /bin/bash

# Set a dummy HOME variable upon build. Some build daemons do not set HOME, but
# cabal expects it to be available.
export HOME = /homedoesnotexistatbuildtime

# If we can't figure out which compiler to use from the library
# package names, and DEB_DEFAULT_COMPILER isn't set in debian/rules,
# we can safely assume the desired compiler is ghc.
DEB_DEFAULT_COMPILER ?= ghc

DEB_GHC_DATABASE = debian/tmp-db

DEB_CABAL_PACKAGE ?= $(shell cat *.cabal |\
 perl -ne \
 'if (/^name\s*:\s*(.*?)\s*$$/i) {$$_ = $$1; tr/A-Z/a-z/; print; exit 0;}')
CABAL_PACKAGE=$(DEB_CABAL_PACKAGE)
CABAL_VERSION=$(shell runhaskell /usr/share/haskell-devscripts/GetCabalVersion.hs *.cabal || true)

DEB_ENABLE_TESTS ?= no
DEB_ENABLE_HOOGLE ?= yes

DEB_DH_GENCONTROL_ARGS_libghc-$(CABAL_PACKAGE)-dev += -- '-DGHC-Package=$${haskell:ghc-package}'

ifneq (,$(filter libghc-$(CABAL_PACKAGE)-prof,$(DEB_PACKAGES)))
ENABLE_PROFILING = --enable-library-profiling
endif

ifeq (0,$(shell ghc --info | grep -q 'Have interpreter.*YES' ; echo $$?))
GHC_HAS_INTERPRETER = yes
else
GHC_HAS_INTERPRETER = no
endif

ifeq (0,$(shell ghc --info | grep -q 'Support SMP.*YES' ; echo $$?))
GHC_HAS_SMP = yes
else
GHC_HAS_SMP = no
endif


NO_GHCI_FLAG = $(shell test -e /usr/bin/ghci || echo --ghc-option=-DDEBIAN_NO_GHCI; exit 0)

DEB_COMPRESS_EXCLUDE += .haddock .hs .txt

# (because we do not (yet) have shlibs files for libHS libraries)
DEB_DH_SHLIBDEPS_ARGS_ALL += -- --ignore-missing-info
DEB_DH_MAKESHLIBS_ARGS_ALL += -XlibHS

# Starting from debhelper v9.20151219, dh_strip automatically generats debug
# symbol packages. GHC cannot produce debugging symbols so the dbgsym
# package ends up being empty. Disable dbgsym generation.
DEB_DH_STRIP_ARGS += --no-automatic-dbgsym

# TODO:
# - some of this would probably be useful for generic Haskell programs,
#   not just libraries
# - provide more hooks
# - get this included in the cdbs package once this gets mature enough (maybe?)

DEB_SETUP_BIN_NAME ?= debian/hlibrary.setup

# most likely you don't need to touch this one
GHC6_VERSION = $(shell ghc --numeric-version)
GHC_VERSION = $(shell ghc --numeric-version)

DEB_HADDOCK_OPTS += --html --hoogle \
	--haddock-options="--mathjax=file:///usr/share/javascript/mathjax/MathJax.js"
ifndef DEB_NO_IMPLICIT_HADDOCK_HYPERLINK
DEB_HADDOCK_OPTS += --hyperlink-source
endif

MAKEFILE := debian/hlibrary.Makefile

#ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
#    NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
#    MAKEFLAGS := -j$(NUMJOBS)
#    BUILD_GHC := $(DEB_SETUP_BIN_NAME) makefile -f $(MAKEFILE) && $(MAKE) $(MAKEFLAGS) -f $(MAKEFILE) && $(BUILD_GHC)
#endif

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
   OPTIMIZATION = --disable-optimization
endif

ifeq ($(DEB_ENABLE_TESTS),yes)
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
   TESTS = --enable-tests
endif
endif

# We call the shell for most things, so make our variables available to it
export DEB_SETUP_BIN_NAME
export CABAL_PACKAGE
export CABAL_VERSION
export ENABLE_PROFILING
export NO_GHCI_FLAG
export DEB_SETUP_GHC6_CONFIGURE_ARGS
export DEB_SETUP_GHC_CONFIGURE_ARGS
export OPTIMIZATION
export TESTS
export DEB_DEFAULT_COMPILER
export DEB_GHC_DATABASE
export DEB_PACKAGES
export DEB_HADDOCK_OPTS
export HASKELL_HIDE_PACKAGES
export DEB_GHC_EXTRA_PACKAGES
export DEB_ENABLE_HOOGLE
export DEB_ENABLE_TESTS
export MAKEFILE
export GHC_HAS_SMP 

clean::
	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ \
		-E 'clean_recipe'
	rm -f configure-ghc-stamp
	rm -f build-ghc-stamp build-hugs-stamp build-haddock-stamp
	rm -f check-ghc-stamp
	rm -f debian/tmp
	rm -rf debian/tmp-inst-ghc debian/tmp-inst-ghcjs
	rm -rf $(DEB_GHC_DATABASE)
	rm -f $(MAKEFILE)


$(DEB_SETUP_BIN_NAME):
	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ \
		-E 'make_setup_recipe'

configure-ghc-stamp: $(DEB_SETUP_BIN_NAME)
	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ \
		-E 'configure_recipe'
	touch $@

build-ghc-stamp: configure-ghc-stamp
	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ \
		-E 'build_recipe'
	touch $@

check-ghc-stamp: build-ghc-stamp
	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ \
		-E 'check_recipe'
	touch $@

build/%-dev build/%-prof:: check-ghc-stamp

build-haddock-stamp: configure-ghc-stamp
	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ \
		-E 'haddock_recipe'
	touch $@

build/%-doc:: build-haddock-stamp

install-%-base::
	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ \
		-E 'install_recipe($$ARGV[0])' "$(patsubst install-%-base,debian/tmp-inst-%,$@)"
	ln --symbolic --force "$(patsubst install-%-base,debian/tmp-inst-%,$@)" debian/tmp

install-%-arch: $(DEB_SETUP_BIN_NAME) check-ghc-stamp install-%-base
	:

# FIXME: the install_recipe doesn't work for indep-only builds, so our
# indep target depends on the arch target for now.
install-%-indep: $(DEB_SETUP_BIN_NAME) check-ghc-stamp build-haddock-stamp install-%-base
	:

debian/tmp-inst-%: $(DEB_SETUP_BIN_NAME) check-ghc-stamp build-haddock-stamp install-%-base
	:

dist-hugs: $(DEB_SETUP_BIN_NAME)
	$(DEB_SETUP_BIN_NAME) configure --hugs --prefix=/usr -v2 \
		--builddir=dist-hugs $(DEB_SETUP_HUGS_CONFIGURE_ARGS)

build/libhugs-$(CABAL_PACKAGE):: dist-hugs
	$(DEB_SETUP_BIN_NAME) build --builddir=dist-hugs

install/libghc-$(CABAL_PACKAGE)-dev:: install-ghc-arch
	dh_haskell_install_ghc_registration --package=$(notdir $@)
	dh_haskell_install_development_libs --package=$(notdir $@) --source-dir="debian/tmp-inst-ghc"
	dh_haskell_provides_ghc --package=$(notdir $@)
	dh_haskell_depends_cabal --package=$(notdir $@)
	dh_haskell_extra_depends_ghc --package=$(notdir $@) --type=dev
	dh_haskell_shlibdeps --package=$(notdir $@)
	dh_haskell_blurbs --package=$(notdir $@) --type=dev

install/libghc-$(CABAL_PACKAGE)-prof:: install-ghc-arch
	dh_haskell_install_profiling_libs --package=$(notdir $@) --source-dir="debian/tmp-inst-ghc"
	dh_haskell_provides_ghc --package=$(notdir $@) --config-shipper="libghc-$(CABAL_PACKAGE)-dev"
	dh_haskell_depends_cabal --package=$(notdir $@) --config-shipper="libghc-$(CABAL_PACKAGE)-dev"
	dh_haskell_blurbs --package=$(notdir $@) --type=prof

install/libghc-$(CABAL_PACKAGE)-doc:: install-ghc-indep
	dh_haskell_install_htmldocs --package=$(notdir $@) --source-dir="debian/tmp-inst-ghc"
	dh_haskell_install_haddock --package=$(notdir $@) --source-dir="debian/tmp-inst-ghc"
	dh_haskell_depends_haddock --package=$(notdir $@)
	dh_haskell_recommends_documentation_references --package=$(notdir $@)
	dh_haskell_suggests --package=$(notdir $@)
	dh_haskell_blurbs --package=$(notdir $@) --type=doc

install/libghcjs-$(CABAL_PACKAGE)-dev:: install-ghcjs-arch
	dh_haskell_install_ghc_registration --package=$(notdir $@)
	dh_haskell_install_development_libs --package=$(notdir $@) --source-dir="debian/tmp-inst-ghcjs"
	dh_haskell_provides_ghc --package=$(notdir $@)
	dh_haskell_depends_cabal --package=$(notdir $@)
	dh_haskell_extra_depends_ghc --package=$(notdir $@) --type=dev
	dh_haskell_shlibdeps --package=$(notdir $@)
	dh_haskell_blurbs --package=$(notdir $@) --type=dev

install/libghcjs-$(CABAL_PACKAGE)-prof:: install-ghcjs-arch
	dh_haskell_install_profiling_libs --package=$(notdir $@) --source-dir="debian/tmp-inst-ghcjs"
	dh_haskell_provides_ghc --package=$(notdir $@) --config-shipper="libghcjs-$(CABAL_PACKAGE)-dev"
	dh_haskell_depends_cabal --package=$(notdir $@) --config-shipper="libghc-$(CABAL_PACKAGE)-dev"
	dh_haskell_blurbs --package=$(notdir $@) --type=prof

install/libghcjs-$(CABAL_PACKAGE)-doc:: install-ghcjs-indep
	dh_haskell_install_htmldocs --package=$(notdir $@) --source-dir="debian/tmp-inst-ghcjs"
	dh_haskell_install_haddock --package=$(notdir $@) --source-dir="debian/tmp-inst-ghcjs"
	dh_haskell_depends_haddock --package=$(notdir $@)
	dh_haskell_recommends_documentation_references --package=$(notdir $@)
	dh_haskell_suggests --package=$(notdir $@)
	dh_haskell_blurbs --package=$(notdir $@) --type=doc

install/libhugs-$(CABAL_PACKAGE):: $(DEB_SETUP_BIN_NAME) dist-hugs
	$(DEB_SETUP_BIN_NAME) copy --builddir=dist-hugs --destdir=debian/libhugs-$(CABAL_PACKAGE)
	rm -rf debian/libhugs-$(CABAL_PACKAGE)/usr/share/doc/*
	dh_haskell_depends_hugs --package=$(notdir $@)

$(patsubst %,install/%,$(DEB_PACKAGES)) :: install/%:
	dh_haskell_description --package=$(cdbs_curpkg)
	dh_haskell_compiler --package=$(cdbs_curpkg)


# Support for installing executables
define newline


endef
$(patsubst debian/%.haskell-binaries,build/%,$(wildcard debian/*.haskell-binaries)):: check-ghc-stamp

$(patsubst debian/%.haskell-binaries,install/%,$(wildcard debian/*.haskell-binaries)):: debian/tmp-inst-ghc
	$(foreach binary,$(shell cat debian/$(cdbs_curpkg).haskell-binaries),dh_install -p$(cdbs_curpkg) dist-ghc/build/$(binary)/$(binary) usr/bin $(newline))