File: rules

package info (click to toggle)
gnade 1.6.2-8
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 8,220 kB
  • ctags: 847
  • sloc: ada: 40,154; sh: 4,124; sql: 3,590; makefile: 1,372; xml: 120; awk: 29
file content (211 lines) | stat: -rwxr-xr-x 8,417 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/make -f

# Copyright (c) 2009, 2010 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 build this package:
# schroot -d `cd ..; pwd` --chroot=unstable -- dpkg-buildpackage -uc -us -i"_MTN|\\.mtn-ignore"
#
# To run lintian:
# schroot -d `cd ..; pwd` --chroot=unstable -- make -f debian/rules lint
#
# To install the packages and run the examples:
# sudo /etc/init.d/mysql stop
# schroot --chroot=unstable -- ./test_installed.sh
#
# To review changes from previous version:
# schroot -d `cd ..; pwd` --chroot=unstable -- debdiff

.SUFFIXES=

# We use gnatmake, not make, for parallel builds.
.NOTPARALLEL:
CPUS := $(shell getconf _NPROCESSORS_ONLN)

# get soversions, aliversions from debian/control
common_soversion  := $(shell sed -n -e "s/^Package: libgnadecommon\([0123456789]\+\)$$/\1/p" debian/control)
odbc_soversion 	  := $(shell sed -n -e "s/^Package: libgnadeodbc\([0123456789]\+\)$$/\1/p" debian/control)
sqlite3_soversion := $(shell sed -n -e "s/^Package: libgnadesqlite3-\([0123456789]\+\)$$/\1/p" debian/control)

common_aliversion  := $(shell sed -n -e "s/^Package: libgnadecommon\(.\+\)-dev$$/\1/p" debian/control)
odbc_aliversion    := $(shell sed -n -e "s/^Package: libgnadeodbc\(.\+\)-dev$$/\1/p" debian/control)
sqlite3_aliversion := $(shell sed -n -e "s/^Package: libgnadesqlite3-\(.\+\)-dev$$/\1/p" debian/control)

# Targets mandated by the Debian Policy

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

build: 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) libgnadeodbc-example libgnadesqlite3-example

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:
	dh_clean
	rm -f debian/*-stamp
	rm -f debian/gnadesqlite3*-dev.README.Debian
	rm -f debian/gnadeodbc*-dev.README.Debian

# 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 debian/tmp/odbc-example-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/gnadeodbc$(odbc_aliversion)-dev.README.Debian

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

debian/libgnadesqlite3-stamp: debian/gnadesqlite3$(sqlite3_aliversion)-dev.README.Debian

debian/gnade%-dev.README.Debian:
	cd debian; ln -s gnadecommon$(common_aliversion)-dev.README.Debian gnade$*-dev.README.Debian

# 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)
	dh_lintian -p$(package)

# Install a -dev and -dbg package.
libgnadecommon-dev:  package := libgnadecommon$(common_aliversion)-dev
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$*
	if [ -d dbi/$* ]; then \
	   dh_install -p$(package) dbi/$*/*.ad[bs] usr/share/ada/adainclude/gnade$* ; \
	else \
	   dh_install -p$(package) support/*.ad[bs] usr/share/ada/adainclude/gnade$* ; \
	fi
	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$(package) /usr/lib/libgnade$*.so.$($*_soversion) /usr/lib/libgnade$*.so
	dh_install -p$(package) debian/gnade$*.gpr /usr/share/ada/adainclude

# dh_installexamples compresses demo.adb. The Debian Ada Policy says
# to not compress, but any decent editor can read a compressed file.
libgnadeodbc-example: package := libgnadeodbc$(odbc_aliversion)-dev
libgnadeodbc-example: debian/tmp/odbc-example-prep/demo.adb
	dh_installexamples -p$(package) debian/tmp/odbc-example-prep/demo.adb

libgnadesqlite3-example: package := libgnadesqlite3-$(sqlite3_aliversion)-dev
libgnadesqlite3-example:
	dh_installexamples -p$(package) samples/sqlite3/demo.adb

# Check the build by running some examples.
check: 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 in main install has been stopped; use 'sudo /etc/init.d/mysql stop'
# assumes mysqld in main chroot has been started; use 'sudo schroot -- /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 $@

# 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 odbc
# target here so we can easily run it while developing the next
# release.
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: version := $(shell dpkg-parsechangelog | grep "Version: " | sed "s/Version: //")
lint: arch := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
lint:
	cd ..; lintian -i gnade_$(version)_$(arch).changes

# end of file