Below is the file 'debian/rules' from this revision. You can also download the file.

#!/usr/bin/make -f

# Copyright (c) 2009 Stephen Leake <stephen_leake@stephe-leake.org>
# Copyright (c) 2003-2006 Ludovic Brenta <lbrenta@debian.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 2 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., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
#
# To run this makefile in a chroot:
# cd ..; sudo schroot --chroot=unstable -- dpkg-buildpackage -uc -us -i

.SUFFIXES=

include /usr/share/quilt/quilt.make

# We use gnatmake, not make, for parallel builds.
.NOTPARALLEL:

# soversions change when the library API changes
common_soversion  := 1
odbc_soversion 	  := 2
sqlite3_soversion := 2

# aliversions change when any ali file changes
common_aliversion  := 1
odbc_aliversion    := 1
sqlite3_aliversion := 1

CPUS := $(shell getconf _NPROCESSORS_ONLN)

# Targets mandated by the Debian Policy

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

build: patch build-arch
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) -f debian/rules check
endif

libs := common odbc sqlite3

build-arch: $(addprefix debian/libgnade,$(addsuffix -stamp,$(libs)))

build-indep:

all_packages += $(foreach l,$(libs), libgnade$(l)-so libgnade$(l)-dev)

binary: binary-arch

# we ignore the warnings about "dependency on libgnadecommon.so.1
# could be avoided" for libgnadeodbc; see gnade_odbc_build.gpr for
# more info.
binary-arch: build-arch testroot $(all_packages)
	dh_shlibdeps -a
	dh_installdocs -a
	dh_installdeb -a
	dh_installchangelogs -a
	dh_compress -a
	dh_fixperms -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary-indep:

clean: unpatch
	dh_clean
# despite the man page, dh_clean does not do this
	rm -f debian/*-stamp

# Helper targets

.PHONY: testroot

testroot:
	dh_testdir
	dh_testroot

##############################################################################
# Targets that build.

odbc_gpb_files := $(wildcard dbi/odbc/*.gpb)
odbc_preprocessed_files := $(patsubst %.gpb,debian/tmp/odbc-prep/%.adb,$(notdir $(odbc_gpb_files)))

.PRECIOUS: debian/tmp/odbc-prep

GNATPREP_FLAGS=-r -DDEBUG=False -DUNICODE=True -DCALLCONVENTION=C -DLINKOPT=\"-lodbc\"

debian/tmp/odbc-prep/%.adb: dbi/odbc/%.gpb | debian/tmp/odbc-prep
	gnatprep $(GNATPREP_FLAGS) $< $@

# Make the libraries for a package.
debian/libgnade%-stamp:
	gnatmake -p -j$(CPUS) -Pdebian/gnade_$*_build -XLIBTYPE=static  -Xsoversion=$($*_soversion)
	gnatmake -p -j$(CPUS) -Pdebian/gnade_$*_build -XLIBTYPE=dynamic -Xsoversion=$($*_soversion)
	touch $@

debian/libgnadeodbc-stamp: $(odbc_preprocessed_files)

debian/libgnadeodbc-stamp debian/libgnadesqlite3-stamp: debian/libgnadecommon-stamp

# Make a directory.
debian/tmp/%-prep:
	-mkdir -p $@

##############################################################################
# Targets that move files into the proper packages

# Install a shared object library package
libgnadecommon-so:  package := libgnadecommon$(common_soversion)
libgnadeodbc-so:    package := libgnadeodbc$(odbc_soversion)
libgnadesqlite3-so: package := libgnadesqlite3-$(sqlite3_soversion)
libgnade%-so: debian/libgnade%-stamp
	dh_installdirs -p$(package) usr/lib
	dh_install -p$(package) debian/tmp/libgnade$*.so.$($*_soversion) usr/lib
	dh_strip -p$(package) --dbg-package=libgnade$*-dbg
	dh_makeshlibs -p$(package)

# Install a -dev and -dbg package. All -dev packages add files to
# adalib/gnade and adainclude/gnade, and there is only one project
# file provided by libgnadecommon-dev. All other -dev packages depend
# on it.
libgnadeodbc-dev:    package := libgnadeodbc$(odbc_aliversion)-dev
libgnadesqlite3-dev: package := libgnadesqlite3-$(sqlite3_aliversion)-dev
libgnade%-dev: debian/libgnade%-stamp
	dh_installdirs -p$(package) \
	   usr/share/ada/adainclude/gnade \
	   usr/lib/ada/adalib/gnade
	dh_install -p$(package) debian/tmp/$*-dynamic/*.ali usr/lib/ada/adalib/gnade
	dh_install -p$(package) dbi/$*/*.ad[bs] usr/share/ada/adainclude/gnade
	if [ -d debian/tmp/$*-prep ]; then dh_install -p$(package) debian/tmp/$*-prep/*.ad[bs] usr/share/ada/adainclude/gnade; fi
	dh_install -p$(package) debian/tmp/libgnade$*.a /usr/lib
	dh_link -p$@ /usr/lib/libgnade$*.so.$($*_soversion) \
	   /usr/lib/libgnade$*.so

# Install libgnadecommon-dev; this overrides the pattern target above.
libgnadecommon-dev: package := libgnadecommon$(common_aliversion)-dev
libgnadecommon-dev: debian/libgnadecommon-stamp
	dh_installdirs -p$(package) \
	   usr/share/ada/adainclude/gnade \
	   usr/lib/ada/adalib/gnade
	dh_install -p$(package) debian/tmp/common-dynamic/*.ali usr/lib/ada/adalib/gnade
	dh_install -p$(package) support/*.ad[bs] usr/share/ada/adainclude/gnade
	dh_install -p$(package) debian/gnade.gpr usr/share/ada/adainclude
	dh_install -p$(package) debian/tmp/libgnadecommon.a /usr/lib
	dh_link -p$(package) /usr/lib/libgnadecommon.so.$(common_soversion) \
	   /usr/lib/libgnadecommon.so

# check the build by running some examples running the odbc example
# requires root privs to set it up, so we can't run it as part of the
# package build process. We keep the target here so we can easily run
# it while developing the next release.
check: patch debian/check-sqlite3-stamp

# create 'gnade' mysql account, 'gnade' mysql database
# install 'MySQL' odbc driver, 'gnade_mysql' odbc source
# assumes mysql root account has no password
# assumes mysqld has been started; use '/etc/init.d/mysql start'
# assumes gnade db and user have not already been created
debian/odbc-source-stamp:
	mysqladmin -uroot create gnade
	echo "create user gnade identified by 'gnade'" | mysql -uroot
	echo "grant all on gnade.* to gnade" | mysql -uroot
	mysql -ugnade -pgnade < samples/sample_db/gnade.mysql.sql
	odbcinst -i -d -f debian/odbc_mysql_driver.ini
	odbcinst -i -s -l -f debian/odbc_mysql_source.ini
	touch $@

debian/check-odbc-stamp: debian/libgnadeodbc-stamp debian/odbc-source-stamp debian/tmp/odbc-example-prep/demo.adb
	gnatmake -p -Pdebian/gnade_odbc_example_build -XLIBTYPE=dynamic
	export LD_LIBRARY_PATH=`pwd`/debian/tmp; debian/tmp/odbc-example-obj/demo
	touch $@

debian/tmp/odbc-example-prep/%.adb: samples/odbc/%.gpb | debian/tmp/odbc-example-prep
	gnatprep -r -DDBSOURCE=\"gnade_mysql\" -DDBUSER=\"gnade\" -DDBPASSWD=\"gnade\" $< $@

debian/check-sqlite3-stamp: debian/libgnadesqlite3-stamp
	gnatmake -p -Pdebian/gnade_sqlite3_example_build -XLIBTYPE=dynamic
	export LD_LIBRARY_PATH=`pwd`/debian/tmp; debian/tmp/sqlite3-example-obj/demo debian/tmp/demo.db
	touch $@

lint: regexp := ^Version: \([0-9.]\+-.\+\)$$
lint: version := $(shell dpkg-parsechangelog | grep ^Version | sed 's/$(regexp)/\1/')
lint:
	cd ..; lintian --lab ../../lint/gnade-$(version) -i gnade*.changes

# end of file