#!/usr/bin/make -f
# -*- makefile -*-

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

# The code casts between unrelated pointer types (e.g. sock.c reads a
# struct in_addr out of a char buffer), so keep the aliasing relaxation that
# imake used to supply through GccAliasingArgs. This must be set before
# buildflags.mk is included, as that file evaluates it at include time.
export DEB_CFLAGS_MAINT_APPEND = -fno-strict-aliasing

include /usr/share/dpkg/buildflags.mk

KOULES_FLAGS = \
	CDEBUGFLAGS="$(CFLAGS)" \
	LOCAL_LDFLAGS="$(LDFLAGS)"

KOULES_DIRS = \
	KOULESDIR=/usr/games \
	SOUNDDIR=/usr/lib/games/koules \
	MANDIR=/usr/share/man/man6

%:
	dh $@

override_dh_auto_configure:
	xmkmf -a

override_dh_auto_build:
	if [ ! -s xkoules.man ]; then ln -sf xkoules.6 xkoules.man; fi
	dh_auto_build -- $(KOULES_FLAGS) $(KOULES_DIRS)

override_dh_auto_install:
	dh_auto_install -- $(KOULES_FLAGS) $(KOULES_DIRS)
	for file in debian/koules/usr/lib/games/koules/*.raw; do if [ -f $$file ]; then mv $$file debian/koules/usr/share/games/koules/; fi; done
