#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

%:
	dh  $@ --with python-central


override_dh_auto_configure:
	./configure --prefix=/usr/lib/alliance --enable-alc-shared --disable-static


override_dh_makeshlibs:
	dh_makeshlibs
	destdir="`pwd`/debian/alliance"; \
	ldsoconfdir="$${destdir}/etc/ld.so.conf.d"; \
	allianceldsoconf="$${ldsoconfdir}/alliance.conf"; \
	if [ ! -d "$${ldsoconfdir}" ]; then mkdir -p "$${ldsoconfdir}"; fi; \
	echo "# Alliance VLSI design system" >  $${allianceldsoconf}; \
	echo "/usr/lib/alliance/lib"         >> $${allianceldsoconf};


override_dh_auto_install:
	dh_auto_install
	destdir="`pwd`/debian/alliance"; \
	prefix="/usr/lib/alliance"; \
	sharedir="/usr/share"; \
	alliancesharedir="$${sharedir}/alliance"; \
	celldir="$${alliancesharedir}/cell"; \
	docdir="$${sharedir}/doc/alliance"; \
	mandir="$${sharedir}/man"; \
	bindir="/usr/bin"; \
	examplesdir="$${alliancesharedir}/examples"; \
	echo "destdir=$${destdir}"; \
	if [ ! -d "$${destdir}/etc/alliance" ]; then mkdir -p "$${destdir}/etc/alliance"; fi; \
	mv $${destdir}$${prefix}/etc/* $${destdir}/etc/alliance; \
	rmdir $${destdir}$${prefix}/etc; \
	if [ ! -d "$${destdir}$${alliancesharedir}" ]; then mkdir -p "$${destdir}$${alliancesharedir}"; fi; \
	mv $${destdir}$${prefix}/cells $${destdir}$${alliancesharedir}; \
	if [ ! -d "$${destdir}$${examplesdir}" ]; then mkdir -p "$${destdir}$${examplesdir}"; fi; \
	mv "$${destdir}$${prefix}/examples/alliance-examples" "$${destdir}$${examplesdir}"; \
	mv "$${destdir}$${prefix}/examples/alliance-run"      "$${destdir}$${examplesdir}"; \
	mv "$${destdir}$${prefix}/examples/regression.sh"     "$${destdir}$${examplesdir}"; \
        chmod u+x "$${destdir}$${examplesdir}/regression.sh" \
                  "$${destdir}$${examplesdir}/alliance-examples/"*.*sh \
                  "$${destdir}$${examplesdir}/alliance-examples/mipsR3000/asm/"*.*sh \
                  "$${destdir}$${examplesdir}/alliance-run/"*.*sh; \
	rmdir "$${destdir}$${prefix}/examples"; \
	if [ ! -d "$${destdir}$${docdir}" ]; then mkdir -p "$${destdir}$${docdir}"; fi; \
	mv "$${destdir}$${prefix}/tutorials" "$${destdir}$${docdir}"; \
	mv "$${destdir}$${prefix}/doc/"* "$${destdir}$${docdir}"; \
	rmdir "$${destdir}$${prefix}/doc"; \
	mv "$${destdir}$${prefix}/share/man/man3/log.3" "$${destdir}$${prefix}/share/man/man3/alc_log.3"; \
	if [ ! -d "$${destdir}$${mandir}" ]; then mkdir -p "$${destdir}$${mandir}"; fi; \
	mv "$${destdir}$${prefix}/share/man/"* "$${destdir}$${mandir}"; \
	rmdir "$${destdir}$${prefix}/share/man"; \
	if [ ! -d "$${destdir}$${bindir}" ]; then mkdir -p "$${destdir}$${bindir}"; fi; \
	mv "$${destdir}$${prefix}/bin/"* "$${destdir}$${bindir}"; \
	rmdir "$${destdir}$${prefix}/bin"; \
	find $${destdir} -name "attila*" | xargs rm;
