#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

PACKAGE=gabedit
INSTALL=/usr/bin/install

GTKLIB        = `pkg-config --libs gtk+-2.0 gtkglext-1.0 pangox`
GTKCFLAGS     = `pkg-config --cflags gtk+-2.0 gtkglext-1.0 pangox`
OGLLIB        = -lGL -lGLU
OGLCFLAGS     = -I/usr/include
LIBPTHREAD    = -lpthread
OMPLIB        = -lgomp
OMPCFLAGS     = -DENABLE_OMP -fopenmp
DRAWGEOMGL    = -DDRAWGEOMGL

CC           ?= gcc -g
COMMONCFLAGS ?= $(shell dpkg-buildflags --get CFLAGS)
COMMONCFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
COMMONCFLAGS += -DENABLE_DEPRECATED
LDFLAGS      ?= $(shell dpkg-buildflags --get LDFLAGS)
LDFLAGS      += -Wl,--as-needed

%:
	dh $@ --parallel

override_dh_auto_build:
	dh_auto_build -- \
		external_gl2ps=1 \
		GTKLIB="$(GTKLIB)" \
		GTKCFLAGS="$(GTKCFLAGS)" \
		OGLLIB="$(OGLLIB)" \
		OGLCFLAGS="$(OGLCFLAGS)" \
		LIBPTHREAD="$(LIBPTHREAD)" \
		OMPLIB="$(OMPLIB)" \
		OMPCFLAGS="$(OMPCFLAGS)" \
		DRAWGEOMGL="$(DRAWGEOMGL)" \
		COMMONCFLAGS="$(COMMONCFLAGS) $(OMPCFLAGS) $(DRAWGEOMGL)" \
		LDFLAGS="$(LDFLAGS)" \
		CC="$(CC)"

override_dh_install:
	dh_install
	for size in 16 24 32 48 ; do \
		$(INSTALL) -D -m 644 icons/Gabedit$${size}.png \
		    $(CURDIR)/debian/$(PACKAGE)/usr/share/icons/hicolor/$${size}x$${size}/apps/gabedit.png ; \
	done

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog

override_dh_installexamples:
	dh_installexamples
	chmod 644 $(CURDIR)/debian/$(PACKAGE)/usr/share/doc/$(PACKAGE)/examples/*
	
override_dh_compress:
	dh_compress $(CURDIR)/debian/$(PACKAGE)/usr/share/doc/$(PACKAGE)/examples/exampleGeoConv.gab
