#!/usr/bin/make -f
# debian/rules for alex
# This file is public domain software, originally written by Joey Hess.
# Adapted for alex by Ian Lynagh.
# Largely rewritten for cdbs and hlibrary.mk by Joachim Breitner in 2009.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_BUILD_DEPENDENCIES = build-arch

DEB_ENABLE_TESTS = yes

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/hlibrary.mk

ifneq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
DEB_SETUP_GHC_CONFIGURE_ARGS := --with-alex=/bin/true
endif

clean::
	rm -f debian/alex.1

configure/alex::
	# used in build to stick version into man page
	ghc --make debian/get_version.hs -o debian/get_version

build/alex:: build-ghc-stamp
	sed -e "s#@LIBDIR@#/usr/lib/alex-`debian/get_version`#g" \
	    -e "s#@DOCDIR@#/usr/share/doc/alex#g" \
	    -e "s#@VERSION@#`debian/get_version`#g" \
	  debian/alex.1.in > debian/alex.1

install/alex:: debian/tmp-inst-ghc

# Set the path for the alex binary, used by
# tests/Makefile to run tests.
check-ghc-stamp: export ALEX = ../dist-ghc/build/alex/alex
