#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

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

# This has to be exported to make some magic below work.
export DH_OPTIONS



CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.
	./debian/peer sun-j2re1.3 /usr/share/j2re1.3-sun
	./debian/peer sun-j2sdk1.3 /usr/share/j2sdk1.3-sun
	./debian/peer sun-j2re1.4 /usr/share/j2re1.4-sun
	./debian/peer sun-j2sdk1.4 /usr/share/j2sdk1.4-sun
	./debian/peer sun-j2re1.5 /usr/share/j2re1.5-sun
	./debian/peer sun-j2sdk1.5 /usr/share/j2sdk1.5-sun
	./debian/peer blackdown-j2re1.3 /usr/share/j2re1.3-blackdown
	./debian/peer blackdown-j2sdk1.3 /usr/share/j2sdk1.3-blackdown
	./debian/peer blackdown-j2re1.4 /usr/share/j2re1.4-blackdown
	./debian/peer blackdown-j2sdk1.4 /usr/share/j2sdk1.4-blackdown

	touch configure-stamp


build: build-indep

build-indep: build-indep-stamp
build-indep-stamp: configure-stamp 

	# Add here commands to compile the indep part of the package.
	$(MAKE)
	touch build-indep-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-indep-stamp configure-stamp
	rm -f debian/sun-j2re1.3debian.postinst debian/sun-j2re1.3debian.prerm 
	rm -f debian/sun-j2sdk1.3debian.postinst debian/sun-j2sdk1.3debian.prerm 
	rm -f debian/sun-j2re1.4debian.postinst debian/sun-j2re1.4debian.prerm 
	rm -f debian/sun-j2sdk1.4debian.postinst debian/sun-j2sdk1.4debian.prerm 
	rm -f debian/sun-j2re1.5debian.postinst debian/sun-j2re1.5debian.prerm 
	rm -f debian/sun-j2sdk1.5debian.postinst debian/sun-j2sdk1.5debian.prerm 
	rm -f debian/blackdown-j2re1.3debian.postinst debian/blackdown-j2re1.3debian.prerm 
	rm -f debian/blackdown-j2sdk1.3debian.postinst debian/blackdown-j2sdk1.3debian.prerm 
	rm -f debian/blackdown-j2re1.4debian.postinst debian/blackdown-j2re1.4debian.prerm 
	rm -f debian/blackdown-j2sdk1.4debian.postinst debian/blackdown-j2sdk1.4debian.prerm 

	# Add here commands to clean up after the build process.
	-$(MAKE) clean

	dh_clean 

install: install-indep
install-indep:
	dh_testdir
	dh_testroot
	dh_clean -k -i 
	dh_installdirs -i

	$(MAKE) install DESTDIR=$(CURDIR)/debian/java-package
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/sun-j2re1.3debian \
		J2SE_PACKAGE=sun-j2re1.3 J2SE_BASE=/usr/share/j2re1.3-sun
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/sun-j2sdk1.3debian \
		J2SE_PACKAGE=sun-j2sdk1.3 J2SE_BASE=/usr/share/j2sdk1.3-sun
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/sun-j2re1.4debian \
		J2SE_PACKAGE=sun-j2re1.4 J2SE_BASE=/usr/share/j2re1.4-sun
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/sun-j2sdk1.4debian \
		J2SE_PACKAGE=sun-j2sdk1.4 J2SE_BASE=/usr/share/j2sdk1.4-sun
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/sun-j2re1.5debian \
		J2SE_PACKAGE=sun-j2re1.5 J2SE_BASE=/usr/share/j2re1.5-sun
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/sun-j2sdk1.5debian \
		J2SE_PACKAGE=sun-j2sdk1.5 J2SE_BASE=/usr/share/j2sdk1.5-sun
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/blackdown-j2re1.3debian \
		J2SE_PACKAGE=blackdown-j2re1.3 J2SE_BASE=/usr/share/j2re1.3-blackdown
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/blackdown-j2sdk1.3debian \
		J2SE_PACKAGE=blackdown-j2sdk1.3 J2SE_BASE=/usr/share/j2sdk1.3-blackdown
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/blackdown-j2re1.4debian \
		J2SE_PACKAGE=blackdown-j2re1.4 J2SE_BASE=/usr/share/j2re1.4-blackdown
	$(MAKE) install-peer DESTDIR=$(CURDIR)/debian/blackdown-j2sdk1.4debian \
		J2SE_PACKAGE=blackdown-j2sdk1.4 J2SE_BASE=/usr/share/j2sdk1.4-blackdown

	dh_install -i

# Must not depend on anything. This is to be called by
# binary-arch/binary-indep
# in another 'make' thread.
binary-common:
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	dh_installexamples
#	dh_installmenu
#	dh_installdebconf	
#	dh_installlogrotate	
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress 
	dh_fixperms
#	dh_perl
#	dh_python
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb
# Build architecture independant packages using the common target.
binary-indep: build-indep install-indep
	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common

binary: binary-indep
.PHONY: build clean binary-indep binary install install-indep configure
