#!/usr/bin/make -f

LIBDIR = usr/lib

p = debian/mozilla-acroread
acrodir = $(LIBDIR)/Adobe/Reader9
rel_acrodir ?= Adobe/Reader9

%:
	dh $@ -Xnppdf.so

override_dh_install:
	cp debian/INSTALL_Debian .
	chmod a+x INSTALL_Debian

	dh_installdirs -pacroread-data usr/share/applications \
	usr/share/pixmaps usr/share/icons/hicolor

	mkdir -p debian/tmp/usr/lib

	bash ./INSTALL_Debian

#	exit 1

# Files Not needed
	rm debian/tmp/$(acrodir)/Reader/intellinux/bin/xdg*
	rm debian/tmp/$(acrodir)/Browser/install_browser_plugin
	rm debian/tmp/$(acrodir)/bin/UNINSTALL
	rm debian/tmp/$(acrodir)/Reader/GlobalPrefs/.config
	rm debian/tmp/$(acrodir)/Browser/HowTo/ENU/Browser_Plugin_HowTo.txt
	rm debian/tmp/$(acrodir)/Resource/Shell/acroread.1.gz
	rm debian/tmp/$(acrodir)/bin/acroread

# Already in bash
	rm debian/tmp/$(acrodir)/Resource/Shell/acroread_tab

# Sould never be removed otherwise doesn't start (Unable to display the licence file).
#	debian/tmp/$(acrodir)/Reader/Legal/en_US/License.txt

	chrpath -d debian/tmp/$(acrodir)/Reader/intellinux/lib/libsccore.so
	chrpath -d debian/tmp/$(acrodir)/Reader/intellinux/lib/libextendscript.so

	cp -r ia32-libs-*/* debian/tmp/usr/lib/Adobe/Reader9/Reader/intellinux/lib/

	dh_install

# Install icon in the right place
	@for icon_size in 16 20 22 24 32 36 48 64 96 128 192; do \
	dh_install -pacroread-data debian/acroread-data/$(LIBDIR)/Adobe/Reader9/Resource/Icons/$$icon_size'x'$$icon_size/* \
	usr/share/icons/hicolor/$$icon_size'x'$$icon_size/apps; \
	done
	-rm -rf debian/acroread-data/$(LIBDIR)/Adobe/Reader9/Resource/Icons

# Empty directory
	-rmdir debian/acroread-data/usr/share/pixmaps

# Install our desktop file in the right place.
	-rm  debian/acroread-data/$(acrodir)/Resource/Support/AdobeReader.desktop
	-cp debian/AdobeReader.desktop debian/acroread-data/usr/share/applications

# Prune empty directories
	find debian -type d -print0 | xargs -0 rmdir -p --ignore-fail-on-non-empty

override_dh_clean:
	dh_clean INSTALL_Debian

override_dh_shlibdeps:
	dh_shlibdeps -l$(acrodir)/Reader/intellinux/lib

override_dh_dwz override_dh_strip override_dh_installmenu:
