#!/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! SETUP = runhaskell $(wildcard Setup.*hs) CABAL_ORIGINAL = $(shell sed 's/\r$$//' *.cabal | perl -ne 'if (/^name:\s*(.*)\s*$$/i) {$$_ = $$1; print; exit 0;}') CABAL_PACKAGE = $(shell sed 's/\r$$//' *.cabal | perl -ne 'if (/^name:\s*(.*)\s*$$/i) {$$_ = $$1; tr/A-Z/a-z/; print; exit 0;}') CABAL_VERSION = $(shell sed 's/\r$$//' *.cabal | sed -n 's/^[Vv]ersion:[ \t]*\([0-9.]*\)\s*/\1/p') PROFILE_FLAG=$(shell grep -q '^Package:.*-prof$$' debian/control && echo "--enable-library-profiling" || true) CABAL_EXECS = $(shell sed 's/\r$$//' *.cabal | sed -n 's/^[Ee]xecutable[ \t:][ \t:]*\(.*\)\s*/\1/p') clean:: $(SETUP) clean rm -rf dist dist-ghc6 dist-hugs .*config* dist-ghc6: $(SETUP) configure --ghc --prefix=/usr/lib/haskell-packages/ghc6 $(PROFILE_FLAG) -v2 mv dist dist-ghc6 build/libghc6-$(CABAL_PACKAGE)-dev:: dist-ghc6 mv dist-ghc6 dist $(SETUP) build mv dist dist-ghc6 build/libghc6-$(CABAL_PACKAGE)-prof:: dist-ghc6 mv dist-ghc6 dist $(SETUP) build mv dist dist-ghc6 build/libghc6-$(CABAL_PACKAGE)-doc:: dist-ghc6 mv dist-ghc6 dist $(SETUP) haddock mv dist dist-ghc6 common-build-arch:: dist-ghc6 mv dist-ghc6 dist $(SETUP) build mv dist dist-ghc6 dist-hugs: $(SETUP) configure --hugs --prefix=/usr -v2 mv dist dist-hugs build/libhugs-$(CABAL_PACKAGE):: dist-hugs mv dist-hugs dist $(SETUP) build mv dist dist-hugs binary-install/libghc6-$(CABAL_PACKAGE)-dev:: mv dist-ghc6 dist $(SETUP) copy --destdir=debian/libghc6-$(CABAL_PACKAGE)-dev dh_haskell_prep -plibghc6-$(CABAL_PACKAGE)-dev [ ! -x /usr/bin/cabal-debian ] || cabal-debian --substvar 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 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 '{}' ';' common-binary-fixup-arch:: # Move The executables into their respective packages. If # there is a library deb, the packages will be part of the dev # package, and we can just create a link. Otherwise we need # to do the install here. set -xv; \ for EXEC in $(CABAL_EXECS); do \ DEBNAME=`echo $${EXEC} | tr 'A-Z' 'a-z'`; \ mkdir -p debian/$${DEBNAME}/usr/bin; \ if [ -d debian/libghc6-$(CABAL_PACKAGE)-dev ]; then \ cp -ax dist-ghc6/build/$${EXEC}/$${EXEC} debian/$${DEBNAME}/usr/bin/$${EXEC}; \ else \ install -m 755 dist-ghc6/build/$${EXEC}/$${EXEC} debian/$${DEBNAME}/usr/bin/$${EXEC}; \ fi; \ done binary-install/libghc6-$(CABAL_PACKAGE)-prof:: mv dist-ghc6 dist $(SETUP) 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 [ ! -x /usr/bin/cabal-debian ] || cabal-debian --substvar Prof 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 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 '{}' ';' # Remove the profiling executables from the profiling library for EXEC in $(CABAL_EXECS); do rm debian/libghc6-$(CABAL_PACKAGE)-prof/usr/lib/haskell-packages/ghc6/bin/$${EXEC}; done binary-install/libghc6-$(CABAL_PACKAGE)-doc:: mv dist-ghc6 dist DDIR=debian/libghc6-$(CABAL_PACKAGE)-doc; \ GDIR=$${DDIR}/usr/share/doc/ghc6-doc/libraries; \ LDIR=$${DDIR}/usr/share/doc/libghc6-$(CABAL_PACKAGE)-doc/html; \ HDIR=$${DDIR}/usr/lib/haskell-packages/ghc6/share/doc/$(CABAL_ORIGINAL)-$(CABAL_VERSION); \ mkdir -p $${LDIR}; cp -r dist/doc/html/*/* $${LDIR}/; \ mkdir -p $${GDIR}; ln -sf ../../libghc6-$(CABAL_PACKAGE)-doc/html $${GDIR}/$(CABAL_ORIGINAL); \ mkdir -p $${HDIR}; ln -sf ../../../../../../share/doc/libghc6-$(CABAL_PACKAGE)-doc/html $${HDIR}/html; \ dh_haskell_prep -plibghc6-$(CABAL_PACKAGE)-doc [ ! -x /usr/bin/cabal-debian ] || cabal-debian --substvar Doc mv dist dist-ghc6 binary-install/libhugs-$(CABAL_PACKAGE):: mv dist-hugs dist $(SETUP) 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 DEB_COMPRESS_EXCLUDE=.haddock include /usr/share/cdbs/1/rules/debhelper.mk