#!/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.
# Also some stuff taken from debmake scripts, by Christoph Lameter.

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

# This is the debhelper compatibility version to use.
export DH_COMPAT=1

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

SHELL = /bin/bash

LANGABRV := ko
LANGUAGE := korean

TAR := netscape-korean-kit
NS_VER := $(VERS)
NS_VER_KO := 476
VER := 20001031

DESTDIR = `pwd`/debian/tmp
prefix = $(DESTDIR)/usr
base_dir = usr/lib/netscape/$(NS_VER)/netscape
base_DESTDIR = $(DESTDIR)/usr/lib/netscape/$(NS_VER)/netscape
$(LANGABRV)_dir = $(base_dir)/$(LANGABRV)
$(LANGABRV)_DESTDIR = $(base_DESTDIR)/$(LANGABRV)

build: build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
#	$(MAKE)
	
	-mkdir lib
	(cd lib; \
	 tar xvzf ../$(TAR)-v$(NS_VER_KO).$(VER).tar.gz \
	     $(TAR)-v$(NS_VER_KO).$(VER)/{Netscape.ad-ko,about,mail.msg,plugins,splash}; \
	 mv $(TAR)-v$(NS_VER_KO).$(VER)/* .; \
	 rm -r $(TAR)-v$(NS_VER_KO).$(VER); \
	 mv Netscape.ad-ko Netscape; \
	 patch -p0 < ../debian/lang-and-appdir.patch \
	)

	-mkdir doc
	(cd doc; \
	 tar xvzf ../$(TAR)-v$(NS_VER_KO).$(VER).tar.gz \
	     $(TAR)-v$(NS_VER_KO).$(VER)/{Linux/README,ChangeLog,README}; \
	 mv $(TAR)-v$(NS_VER_KO).$(VER)/* .; \
	 rm -r $(TAR)-v$(NS_VER_KO).$(VER); \
	 mv Linux/README README.Linux; \
	 rm -r Linux; \
	)
	
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

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

	dh_clean

install: DH_OPTIONS=-P$(DESTDIR)
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs $(ko_dir)

	# Add here commands to install the package into debian/tmp.
#	$(MAKE) install DESTDIR=`pwd`/debian/tmp

# nethelp
#	(cd `pwd`/debian/tmp/usr/lib/netscape/$(NS_VER)/communicator-ja && \
#	 ln -s ../communicator/nethelp .)
#	(cd `pwd`/debian/tmp/usr/lib/netscape/$(NS_VER)/navigator-ja && \
#	 ln -s ../navigator/nethelp .)
# resource
#	cp debian/Netscape.ad.Debian.normal `pwd`/debian/tmp/usr/lib/netscape/$(NS_VER)/netscape/ja/Netscape.normal
#	cp debian/Netscape.ad.Debian.small `pwd`/debian/tmp/usr/lib/netscape/$(NS_VER)/netscape/ja/Netscape.small
#	(cd `pwd`/debian/tmp/usr/lib/netscape/$(NS_VER)/netscape/ja;\
#	 ln -s Netscape.normal Netscape;\
#	)
# base
	cp -a lib/* $(ko_DESTDIR)
	cd $(DESTDIR)/usr/lib/netscape/$(NS_VER)/netscape && ln -s $(LANGABRV) $(LANGUAGE)


# Build architecture-independent files here.
binary-indep: build install
#	dh_testversion
	dh_testdir -i
	dh_testroot -i
	dh_installdocs -i
	dh_installexamples -i
	dh_installmenu -i
#	dh_installemacsen -i
#	dh_installinit -i
	dh_installcron -i
#	dh_installmanpages -i
#	dh_undocumented
	dh_installchangelogs -i doc/ChangeLog
	dh_link -i
	dh_compress -i
	dh_fixperms -i
	# You may want to make some executables suid here
	dh_suidregister -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
#	dh_testversion
	dh_testdir -a
	dh_testroot -a
	dh_installdocs -a
	dh_installexamples -a
	dh_installmenu -a
#	dh_installemacsen -a
#	dh_installinit -a
	dh_installcron -a
	dh_installmanpages -a
#	dh_undocumented
	dh_installchangelogs -a 
	dh_strip -a
	dh_link -a
	dh_compress -a
	dh_fixperms -a
	# You may want to make some executables suid here
	dh_suidregister -a
	dh_installdeb -a
#	dh_makeshlibs -a
	dh_gencontrol -a
	dh_shlibdeps -a
	dh_md5sums -a
	dh_builddeb -a

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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