#!/usr/bin/make -f
# -*- makefile -*-
# Simple debian/rules that uses debhelper.
# Created by Bernd Paysan, in the public domain

GFORTH_VER = `sed -e 's/.*gforth (>= \([^)]\+\).*/\1/; 6q' debian/control | tr '-' '_' | tail -n1`
NET2O_VER = `cut -f2 -d\" version.fs | sed -e 's/ //g'`
D = $(CURDIR)/debian/net2o
DL = $(CURDIR)/debian/net2o-libcc
DT = $(CURDIR)/debian/net2o-tests
DG = $(CURDIR)/debian/net2o-gui
SHELL	 = /bin/bash

%:
	dh $@ 

override_dh_auto_test:
override_dh_shlibdeps:
override_dh_auto_build:
	make libcc
override_dh_auto_install:
	rm -rf $(D) $(DL) $(DT) $(DG)
	dh_auto_install -- DESTDIR=$(DL)
	mkdir -p $(D)/usr/share/doc/
	mkdir -p $(DT)/usr/share/gforth/$(GFORTH_VER)/net2o-$(NET2O_VER)/
	mkdir -p $(DG)/usr/share/gforth/$(GFORTH_VER)/net2o-$(NET2O_VER)/
	mv $(DL)/usr/share/gforth/$(GFORTH_VER)/net2o-$(NET2O_VER)/tests $(DT)/usr/share/gforth/$(GFORTH_VER)/net2o-$(NET2O_VER)/
	mv $(DL)/usr/share/gforth $(D)/usr/share/
	mv $(D)/usr/share/gforth/$(GFORTH_VER)/net2o-$(NET2O_VER)/{gui*.fs,qrscan.fs,doc} $(DG)/usr/share/gforth/$(GFORTH_VER)/net2o-$(NET2O_VER)/
	mv $(DL)/usr/share/icons $(DG)/usr/share
	mv $(DL)/usr/share/applications $(DG)/usr/share
	mv $(DL)/usr/bin $(D)/usr/

override_dh_installchangelogs:
	fossil timeline --verbose --limit 200  | gzip >$(D)/usr/share/doc/net2o/changelog.gz
	rm -rf $(DL)/usr/share/doc
	rm -rf $(DT)/usr/share/doc
