[Debian-haskell] Using cdbs and haskell-devscripts to build Haskell libraries

Kari Pahula kaol at debian.org
Tue Jan 22 19:27:36 GMT 2008


I wasn't quite happy with either haskell-utils' or haskell-devscripts'
style of Haskell library packaging.

In my eyes, haskell-utils was just too messy with all those generated
files and haskell-devscripts was too monolithic, with a magic
dh_haskell call that did all the work.  It was a step in the right
direction, but I felt that it replicated much of what was done in CDBS
and rightly belonged to its domain.

Therefore, I chose to reimplement (most of) the wheel.  I discarded
most of haskell-devscripts and just used dh_haskell_prep and made a
CDBS rule file to take care of the rest.

Here's my complete debian/rules file, using CDBS:
#!/usr/bin/make -f
include $(CURDIR)/debian/hlibrary.mk

Neat, no?  And this should work for any cabalized Haskell library.
That's the theory, at least.  The rest is mostly controlled by
debian/control.  This has been successfully tested with haskell-binary
(already in unstable) and haskell-hlist.

I know some people wouldn't touch CDBS if they can help it...
-------------- next part --------------
#!/usr/bin/make -f

# Experimental CDBS rule file for building haskell library packages v0.2
# TODO: Get this included in a package (haskell-devscripts?) and have
# it installed somewhere under /usr/share/cdbs/
# Fix any remaining issues with this.  Feedback is welcome!

CABAL_PACKAGE = $(shell cat *.cabal |\
 perl -ne 'if (/^name:\s*(.*)$$/i) {$$_ = $$1; tr/A-Z/a-z/; print; exit 0;}')

clean::
	test ! -e setup-bin || ./setup-bin clean
	rm -rf dist dist-ghc6 dist-hugs setup-bin Setup.hi Setup.ho Setup.o .*config*

setup-bin::
	if test ! -e Setup.lhs -a ! -e Setup.hs; then echo "No setup script found!"; exit 1; fi
	for setup in Setup.lhs Setup.hs; do if test -e $$setup; then ghc6 -package Cabal $$setup -o setup-bin; exit 0; fi; done

dist-ghc6: setup-bin
	./setup-bin configure --ghc --prefix=/usr/lib/haskell-packages/ghc6 --enable-library-profiling -v2
	mv dist dist-ghc6

build/libghc6-$(CABAL_PACKAGE)-dev:: dist-ghc6
	mv dist-ghc6 dist
	./setup-bin build
	mv dist dist-ghc6

build/libghc6-$(CABAL_PACKAGE)-prof:: dist-ghc6
	mv dist-ghc6 dist
	./setup-bin build
	mv dist dist-ghc6

build/libghc6-$(CABAL_PACKAGE)-doc:: dist-ghc6
	mv dist-ghc6 dist
	./setup-bin haddock
	mv dist dist-ghc6

dist-hugs: setup-bin
	./setup-bin configure --hugs --prefix=/usr -v2
	mv dist dist-hugs

build/libhugs-$(CABAL_PACKAGE):: dist-hugs
	mv dist-hugs dist
	./setup-bin build
	mv dist dist-hugs

binary-install/libghc6-$(CABAL_PACKAGE)-dev:: setup-bin
	mv dist-ghc6 dist
	./setup-bin copy --destdir=debian/libghc6-$(CABAL_PACKAGE)-dev
	dh_haskell_prep -plibghc6-$(CABAL_PACKAGE)-dev
	cp dist/installed-pkg-config debian/libghc6-$(CABAL_PACKAGE)-dev/usr/lib/haskell-packages/ghc6/lib/*/
	rm -rf debian/libghc6-$(CABAL_PACKAGE)-dev/usr/lib/haskell-packages/ghc6/share/
	mv dist dist-ghc6

binary-fixup/libghc6-$(CABAL_PACKAGE)-dev:: binary-install/libghc6-$(CABAL_PACKAGE)-dev setup-bin
	find debian/libghc6-$(CABAL_PACKAGE)-dev/usr/lib/haskell-packages/ghc6/lib/ -name "*_p.a" -exec rm '{}' ';'
	find debian/libghc6-$(CABAL_PACKAGE)-dev/usr/lib/haskell-packages/ghc6/lib/ -name "*.p_hi" -exec rm '{}' ';'

binary-install/libghc6-$(CABAL_PACKAGE)-prof:: setup-bin
	mv dist-ghc6 dist
	./setup-bin copy --destdir=debian/libghc6-$(CABAL_PACKAGE)-prof
	dh_haskell_prep -plibghc6-$(CABAL_PACKAGE)-prof
# Work around #460558
	sed -i 's/ghc6-prof-prof/ghc6-prof/' debian/libghc6-$(CABAL_PACKAGE)-prof.substvars
	cp dist/installed-pkg-config debian/libghc6-$(CABAL_PACKAGE)-dev/usr/lib/haskell-packages/ghc6/lib/*/
	rm -rf debian/libghc6-$(CABAL_PACKAGE)-prof/usr/lib/haskell-packages/ghc6/share/
	mv dist dist-ghc6

binary-fixup/libghc6-$(CABAL_PACKAGE)-prof:: binary-install/libghc6-$(CABAL_PACKAGE)-prof setup-bin
	find debian/libghc6-$(CABAL_PACKAGE)-prof/usr/lib/haskell-packages/ghc6/lib/ -name "*[^p].a" -exec rm '{}' ';'
	find debian/libghc6-$(CABAL_PACKAGE)-prof/usr/lib/haskell-packages/ghc6/lib/ -name "*.o" -exec rm '{}' ';'
	find debian/libghc6-$(CABAL_PACKAGE)-prof/usr/lib/haskell-packages/ghc6/lib/ -name "*.hi" -exec rm '{}' ';'

binary-install/libghc6-$(CABAL_PACKAGE)-doc:: setup-bin
	mv dist-ghc6 dist
	mkdir -p debian/libghc6-$(CABAL_PACKAGE)-doc/usr/share/doc/libghc6-$(CABAL_PACKAGE)-doc/html/
	cp -r dist/doc/html/*/* debian/libghc6-$(CABAL_PACKAGE)-doc/usr/share/doc/*/html/
	mv dist dist-ghc6

binary-install/libhugs-$(CABAL_PACKAGE):: setup-bin
	mv dist-hugs dist
	./setup-bin copy --destdir=debian/libhugs-$(CABAL_PACKAGE)
	rm -rf debian/libhugs-$(CABAL_PACKAGE)/usr/share/doc/
	dh_haskell_prep -plibhugs-$(CABAL_PACKAGE)
	mv dist dist-hugs

include /usr/share/cdbs/1/rules/debhelper.mk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://urchin.earth.li/pipermail/debian-haskell/attachments/20080122/fc067736/attachment.pgp 


More information about the debian-haskell mailing list