#!/usr/bin/make -f
#
# Debian Makefile for ada-reference-manual
# Copyright (c) 2010, 2012 Stephen Leake <stephen_leake@stephe-leake.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# To setup for building this package from a new upstream release:
# cd /home/Projects/arm_info/org.adaic.arm_form/build/
# make debian-free
# or
# make debian-update
#
# To build this package in a chroot:
# schroot -d `cd ..; pwd` --chroot=unstable -- dpkg-buildpackage -uc -us
#
# To run lintian:
# schroot -d `cd ..; pwd` --chroot=unstable -- make -f debian/rules lint
#
# To test a single target:
# schroot -d `cd ..; pwd` --chroot=unstable -- make -f debian/rules <target>

.SUFFIXES=

# Targets mandated by the Debian Policy

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

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

build-stamp: debian/tmp/arm2005-html
build-stamp: debian/tmp/aarm2005-html
build-stamp: debian/tmp/arm2005.info
build-stamp: debian/tmp/aarm2005.info
build-stamp: debian/tmp/arm2005.pdf
build-stamp: debian/tmp/aarm2005.pdf
build-stamp: debian/tmp/arm2005.text
build-stamp: debian/tmp/aarm2005.text
build-stamp: debian/tmp/arm2012-html
build-stamp: debian/tmp/aarm2012-html
build-stamp: debian/tmp/arm2012.info
build-stamp: debian/tmp/aarm2012.info
build-stamp: debian/tmp/arm2012.pdf
build-stamp: debian/tmp/aarm2012.pdf
build-stamp: debian/tmp/arm2012.text
build-stamp: debian/tmp/aarm2012.text
	touch build-stamp

debian/tmp/arm2005-html : debian/tmp/arm_form.exe | source_2005/Output
	cd source_2005; ../debian/tmp/arm_form.exe RM HTML New-Only 2
	rm -rf $@
	mv source_2005/Output $@
	mkdir source_2005/Output

debian/tmp/aarm2005-html : debian/tmp/arm_form.exe | source_2005/Output
	cd source_2005; ../debian/tmp/arm_form.exe AARM HTML New-Only 2
	rm -rf $@
	mv source_2005/Output $@
	mkdir source_2005/Output

debian/tmp/arm2012-html : debian/tmp/arm_form.exe | source/Output
	cd source; ../debian/tmp/arm_form.exe RM HTML New-Only 3
	rm -rf $@
	mv source/Output $@
	mkdir source/Output

debian/tmp/aarm2012-html : debian/tmp/arm_form.exe | source/Output
	cd source; ../debian/tmp/arm_form.exe AARM HTML New-Only 3
	rm -rf $@
	mv source/Output $@
	mkdir source/Output

debian/tmp/%.info : debian/tmp/%.texinfo | debian/tmp
	makeinfo --no-validate --no-split --no-number-sections $< -o $@

debian/tmp/%.pdf : debian/tmp/%.ps
	ps2pdf $< $@

debian/tmp/arm2005.text : debian/tmp/arm_form.exe | source_2005/Output
	cd source_2005; ../debian/tmp/arm_form.exe RM Text New-Only 2
	rm -rf $@
	mv source_2005/Output $@
	mkdir source_2005/Output

debian/tmp/aarm2005.text : debian/tmp/arm_form.exe | source_2005/Output
	cd source_2005; ../debian/tmp/arm_form.exe AARM Text New-Only 2
	rm -rf $@
	mv source_2005/Output $@
	mkdir source_2005/Output

debian/tmp/arm2012.text : debian/tmp/arm_form.exe | source/Output
	cd source; ../debian/tmp/arm_form.exe RM Text New-Only 3
	rm -rf $@
	mv source/Output $@
	mkdir source/Output

debian/tmp/aarm2012.text : debian/tmp/arm_form.exe | source/Output
	cd source; ../debian/tmp/arm_form.exe AARM Text New-Only 3
	rm -rf $@
	mv source/Output $@
	mkdir source/Output

debian/tmp/arm2005.texinfo : debian/tmp/arm_form.exe
	cd source_2005; ../debian/tmp/arm_form.exe RM info New-Only 2
	mv source_2005/RM.texinfo $@

debian/tmp/aarm2005.texinfo : debian/tmp/arm_form.exe
	cd source_2005; ../debian/tmp/arm_form.exe AARM info New-Only 2
	mv source_2005/AA.texinfo $@

debian/tmp/arm2012.texinfo : debian/tmp/arm_form.exe
	cd source; ../debian/tmp/arm_form.exe RM info New-Only 3
	mv source/RM.texinfo $@
	sed -i 's/arm2005)\.$$/arm2012)./g' $@

debian/tmp/aarm2012.texinfo : debian/tmp/arm_form.exe
	cd source; ../debian/tmp/arm_form.exe AARM info New-Only 3
	mv source/AA.texinfo $@
	sed -i 's/arm2005)\.$$/arm2012)./g' $@

debian/tmp/arm_form.exe : force
	gnatmake -p -k -P debian/arm_info.gpr

debian/tmp source/Output source_2005/Output :
	mkdir $@

debian/tmp/%.ps : debian/tmp/%.dvi
	dvips -o $@ $<

debian/tmp/%.dvi : debian/tmp/%.texinfo | debian/tmp
	texi2dvi --quiet --tidy --build-dir=debian/tmp/$*.t2d -o $@ $<

clean:
	dh_clean
	rm -f build-stamp

binary: binary-indep binary-arch

binary-indep:
	dh_installchangelogs
	dh_installdocs
	dh_installinfo -pada-reference-manual-2005 debian/tmp/*2005.info
	dh_installinfo -pada-reference-manual-2012 debian/tmp/*2012.info
	dh_compress --exclude=.TXT
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# no architecture-dependent files
build-arch:
binary-arch:

lint:
	cd ..; lintian -i -I ada-reference-manual*.dsc

# end of file
