#!/usr/bin/make -f
#-*- makefile -*-
# Made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Christoph Lameter.

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

TAR_DIR = Socket6-0.23
PACKAGE=$(shell dh_listpackages)

include /usr/share/dbs/dbs-build.mk
ifeq (,$(DEB_BUILD_GNU_TYPE))
	include /usr/share/dbs/dpkg-arch.mk
endif

ifndef PERL
PERL = /usr/bin/perl
endif

ifndef DESTDIR
DESTDIR=..
endif
TMP     =`pwd`/debian/$(PACKAGE)

OPTIMIZE = -O2 -Wall
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
OPTIMIZE += -g
endif

BUILD_DIR=$(SOURCE_DIR)/$(TAR_DIR)
ARCHLIB=`perl -V:archlib |sed -e 's/archlib=\(.*\);/\1/'`

configure: configure-stamp
configure-stamp: $(patched)
	dh_testdir

	cd $(BUILD_DIR) && $(PERL) Makefile.PL INSTALLDIRS=vendor
	touch configure-stamp

build: configure-stamp build-stamp
build-stamp: $(patched)
	dh_testdir

	cd $(BUILD_DIR) && $(MAKE) OPTIMIZE="$(OPTIMIZE)" LD_RUN_PATH=""

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	rm -rf $(STAMP_DIR) $(SOURCE_DIR)

	dh_clean

install: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_clean
	dh_installdirs

	cd $(BUILD_DIR) && \
		$(MAKE) install PREFIX=$(CURDIR)/debian/$(PACKAGE)/usr

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
#	dh_testversion
	dh_testdir
	dh_testroot
	dh_installdocs $(BUILD_DIR)/README
	dh_installexamples $(BUILD_DIR)/im-140.diff \
				$(BUILD_DIR)/ftpmirror-1.96.diff 
#	dh_installmenu
#	dh_installcron
	dh_installmanpages
#	dh_undocumented
	dh_installchangelogs $(BUILD_DIR)/ChangeLog
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
	dh_perl 
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb --destdir=$(DESTDIR)

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary
