#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

include /usr/share/cdbs/1/class/mingw64.mk
include /usr/share/cdbs/1/rules/mingw64-autotools.mk

export MINGW32_SYSROOT MINGW64_SYSROOT BUILD_ROOT

CFLAGS32 := $(CFLAGS32) -I.
CFLAGS64 := $(CFLAGS64) -I.

configure: configure-stamp
configure-stamp:
	dh_testdir
	
	mkdir -p build-32
	cp *.c *.h Makefile build-32
	mkdir -p build-64
	cp *.c *.h Makefile build-64
	
	touch configure-stamp

build-stamp: configure-stamp
	
	# Build 64
	if [ -f debian/pre64_build.sh ]; then /bin/bash debian/pre64_build.sh; fi
	cd build-64 && $(MAKE) $(MAKEOPTS) $(MINGW64_ENVARS)
	if [ -f debian/post64_build.sh ]; then /bin/bash debian/post64_build.sh; fi
	
	# Build 32
	if [ -f debian/pre32_build.sh ]; then /bin/bash debian/pre32_build.sh; fi
	cd build-32 && $(MAKE) $(MAKEOPTS) $(MINGW32_ENVARS)
	if [ -f debian/post32_build.sh ]; then /bin/bash debian/post32_build.sh; fi
	
	touch build-stamp
	
install: build
	dh_testdir
	dh_testroot
	dh_installdirs
	
	mkdir -p $(BUILD_ROOT)/64
	if [ -f debian/post64_install.sh ]; then /bin/bash debian/post64_install.sh; fi
	
	mkdir -p $(BUILD_ROOT)/32
	if [ -f debian/post32_install.sh ]; then /bin/bash debian/post32_install.sh; fi
