#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-undefined -Wl,--as-needed \
#				   -Wl,-rpath,/usr/lib/gworkspace

include /usr/share/GNUstep/debian/config.mk

%:
	dh $@ --parallel --with autotools-dev

override_dh_auto_configure:
	dh_auto_configure -- \
	  --enable-gwmetadata \
	  --with-unzip=unzip

override_dh_auto_build:
	$(MAKE) $(optim) \
	  messages=yes \
	  $(shell dpkg-buildflags --export=cmdline)
# Generate icons with imagemagick
	convert GWorkspace/Resources/Icons/FileManager.tiff \
	  -resize 32x32 GWorkspace.xpm
	convert GWMetadata/MDFinder/Resources/Images/MDFinder.tiff \
	  -resize 32x32 MDFinder.xpm

override_dh_auto_install:
	$(MAKE) install \
	  DESTDIR=$(CURDIR)/debian/tmp

override_dh_installman:
	dh_installman
# Create symlinks for the manpages.  Deliberately do not derive the
# programs' list from /usr/bin -- if a tool is added upstream; the
# manpage has to be updated.
	for p in ddbd fswatcher lsfupdater resizer searchtool wopen \
	    Recycler; do \
	  dh_link usr/share/man/man1/GWorkspace.1 usr/share/man/man1/$$p.1; \
	done
	for p in gmds mdextractor; do \
	  dh_link -pmdfinder.app usr/share/man/man1/MDFinder.1 \
	    usr/share/man/man1/$$p.1; \
	done

override_dh_fixperms:
	dh_fixperms
# Fix .tiff files permissions
	find debian -name "*.tiff" -perm 0755 -exec chmod -v 0644 {} \;
# Fix .desktop files permissions
	find debian -name "*.desktop" -perm 0755 -exec chmod -v 0644 {} \;

override_dh_strip:
	dh_strip --dbg-package=gworkspace-dbg
