#!/usr/bin/make -f
#                                          -*- makefile -*-
# debian/rules file for the Debian/GNU Linux pcb package
# Copyright 1997-99 by Hartmut Koptein <koptein@debian.org>

package = pcb

CONFIGURE_OPTS=--disable-rpath --enable-dbus --disable-update-desktop-database --disable-update-mime-database --enable-dependency-tracking --enable-coord64 LDFLAGS="$(LDFLAGS) -Wl,--as-needed"

%:
	dh $@ --with=autotools_dev

override_dh_auto_configure:
	dh_auto_configure --builddirectory build_gtk -- $(CONFIGURE_OPTS) --with-gui=gtk
	dh_auto_configure --builddirectory build_lesstif -- $(CONFIGURE_OPTS) --with-gui=lesstif

override_dh_auto_build:
	dh_auto_build --builddirectory build_gtk
	dh_auto_build --builddirectory build_lesstif

override_dh_auto_test:
	dh_auto_test --builddirectory build_gtk
	dh_auto_test --builddirectory build_lesstif

override_dh_auto_install:
	dh_auto_install --builddirectory build_gtk

override_dh_auto_clean:
	dh_auto_clean --builddirectory build_gtk
	dh_auto_clean --builddirectory build_lesstif

override_dh_install:
	# Remove needlessly installed static library and header file before
	# installing common files:
	rm -rf $(CURDIR)/debian/tmp/usr/lib
	rm -rf $(CURDIR)/debian/tmp/usr/include
	dh_install -Xusr/bin -Xusr/share/pcb- -Xusr/share/doc -Xexamples -Xtutorial -Xusr/share/info

	# Install pcb-gtk binary:
	install build_gtk/src/pcb debian/$(package)-gtk/usr/bin/pcb-gtk

	# Install pcb-lesstif binary:
	install build_lesstif/src/pcb debian/$(package)-lesstif/usr/bin/pcb-lesstif

	# Set executable bit for pcb tools:
	[ ! -d debian/$(package)-common ] || chmod a+x debian/$(package)-common/usr/share/pcb/tools/MergePCBPS
	[ ! -d debian/$(package)-common ] || chmod a+x debian/$(package)-common/usr/share/pcb/tools/Merge_dimPCBPS
	[ ! -d debian/$(package)-common ] || chmod a+x debian/$(package)-common/usr/share/pcb/tools/tgo2pcb.tcl
	[ ! -d debian/$(package)-common ] || chmod a+x debian/$(package)-common/usr/share/pcb/tools/PCB2HPGL
	[ ! -d debian/$(package)-common ] || chmod a+x debian/$(package)-common/usr/share/pcb/tools/pcbdiff

	# Remove empty dirs:
	[ ! -d debian/$(package)-common ] || find debian/$(package)-common -type d -empty -delete

override_dh_fixperms:
	dh_fixperms
	# Fix permissions of a couple of example files:
	[ ! -d debian/$(package)-common ] || chmod -x debian/$(package)-common/usr/share/doc/$(package)-common/examples/LED.pcb
	[ ! -d debian/$(package)-common ] || chmod -x debian/$(package)-common/usr/share/doc/$(package)-common/examples/LED.net

override_dh_installexamples:
	dh_installexamples -XMakefile

override_dh_installchangelogs:
	dh_installchangelogs -p$(package)-common

override_dh_installdocs:
	# Only install docs in $(package)-common & link other packages' docs to
	# $(package)-common:
	dh_installdocs --link-doc=$(package)-common

override_dh_compress:
	# exclude example files from compression
	dh_compress -X.pcb -XLED
