#! /usr/bin/make -f

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

PACKAGE=flim
ELDIR=$(CURDIR)/debian/$(PACKAGE)/usr/share/$(PACKAGE)

get-orig-source:
	wget -O upstream.tar.gz https://github.com/wanderlust/flim/tarball/flim-1_14-wl
	mv -f upstream.tar.gz `LC_ALL=C tar ztvf upstream.tar.gz --utc | perl -ne 'if (/ (\d\d\d\d)-(\d\d)-(\d\d) /) {print "flim_1.14.9+0.$$1$$2$$3.orig.tar.gz\n"; exit}'`

build-indep: build-indep-stamp
build-indep-stamp:
	dh_testdir
	makeinfo mime-en.texi
	makeinfo mime-ja.texi
	touch $@

build-arch:

build: build-indep build-arch

clean:
	dh_testdir
	dh_testroot
	rm -f *build*-stamp
	rm -f *.info .\#* debian/.\#*

	dh_clean

install: build-indep
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	cp Makefile FLIM-* *.el $(ELDIR)/
	rm -f $(ELDIR)/FLIM-API*

# Do not install obsolete files
	for f in mailcap.el smtpmail.el; do \
	  if [ -f $(ELDIR)/$$f ]; then rm -f $(ELDIR)/$$f; fi; \
	done

binary-indep: install
	dh_testdir
	dh_testroot
#	dh_installdebconf
	dh_installdocs
#	dh_installexamples
	dh_installemacsen --priority 50
	dh_installinfo
	dh_installchangelogs
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch:

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