#!/usr/bin/make -f
# (C) 2003 Marcelo E. Magallon <mmagallo@debian.org>
# (C) 2006-2011 Joost Yervante Damad <andete@debian.org>
# (C) 2012 Matteo F. Vescovi <mfv.debian@gmail.com>
# (C) 2020 Alastair McKinstry <mckinstry@debian.org>

export DH_VERBOSE=1
# export DH_NO_ACT
# export DH_OPTIONS

# The magic debhelper  rule
%:
	dh $@ 

include /usr/share/dpkg/architecture.mk

DPKG_EXPORT_BUILDFLAGS = 1
DEB_CFLAGS_MAINT_APPEND = -Wall -g
include /usr/share/dpkg/buildflags.mk

# let dh_strip strip
export STRIP=true
export INSTALL=install --strip-program=true

SYSTEM:=$(firstword $(subst -, ,$(DEB_HOST_GNU_SYSTEM))) 
ifeq ($(SYSTEM),linux)
SYSTEM:= linux-egl
endif


override_dh_auto_configure:
	rm -f config/config.guess
	ln -sf /usr/share/misc/config.guess config/

override_dh_auto_build:
	dh_auto_build -- \
		GL_LDFLAGS=-lGL \
		GLU_LDFLAGS=-lGLU \
		GLUT_LDFLAGS=-lglut \
		LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
		SYSTEM=$(SYSTEM) \
		'LD=$$(CC)' \
		'OPT=$(CFLAGS)'
	dh_installdirs
	$(MAKE) install.all GLEW_DEST=$(CURDIR)/debian/tmp/usr LIBDIR=$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_clean:
	rm -f config/config.guess
	ln -sf /usr/share/misc/config.guess config/
	dh_auto_clean

override_dh_strip:
	dh_strip --dbgsym-migration="libglew-dbg (<< 2.0.0-5)"

debian/%.1: debian/%.sgml
	docbook-to-man $< > $@

