Heavy modification of debian/rules to allow easy building of
[yaz-moved-to-github.git] / debian / rules
1 #!/usr/bin/make -f
2
3 # Script for building YAZ from source to .deb-packages.
4 #
5 # Created by Morten Hendriksen <mgh@dbc.dk> based on sample
6 # debhelper script from Joey Hess. GPL copyright 1997 to 1999 by Joey Hess.
7
8 # Uncomment this to turn on verbose mode.
9 #export DH_VERBOSE=1
10
11 # This is the debhelper compatability version to use.
12 export DH_COMPAT=2
13
14 YAZ_WITH_SSL?=0
15 CONFIG_FLAGS=--enable-static --enable-shared --enable-tcpd --prefix=/usr
16
17 # Enable parallel builds if CONCURRENCY_LEVEL is set
18 ifdef CONCURRENCY_LEVEL
19 MCFLAGS=-j$(CONCURRENCY_LEVEL)
20 else
21 MCFLAGS=
22 endif
23
24 ifeq ($(YAZ_WITH_SSL),1)
25 export BUILD_SSL=1
26 SSL_FLAGS=--with-openssl
27 else
28 SSL_FLAGS=
29 endif
30
31 YAZ_VERSION=1.8.6
32 YAZSRCDIR?=$(shell pwd)
33 # If this is not IndexData's release, then it is a cvs-checkout. Go cheat!
34 #   YAZ_VERSION:=$(YAZ_VERSION)-$(shell date -r$(YAZSRCDIR)/CVS +"CVS%Y%m%d")
35 export YAZ_VERSION
36
37 # Local library path for linking with right dependencies
38 LOCAL_LINK=-ldebian/yaz-runtime/usr/lib/
39
40 $(YAZSRCDIR)/configure: $(YAZSRCDIR)/configure.in
41         cd $(YAZSRCDIR); sh buildconf.sh
42
43 configure: stamp-configure
44 stamp-configure: $(YAZSRCDIR)/configure
45         dh_testdir
46
47         -rm -rf build
48         mkdir build
49         cd build; $(YAZSRCDIR)/configure $(CONFIG_FLAGS) $(SSL_FLAGS)
50         touch stamp-configure
51
52 build: stamp-build
53 stamp-build: stamp-configure
54         dh_testdir
55
56         # Add here commands to compile the package.
57         $(MAKE) -C build $(MCFLAGS)
58
59         touch stamp-build
60
61 clean:
62         dh_testdir
63         #dh_testroot
64         -rm -f stamp-*
65         -rm -rf build
66
67         dh_clean
68         -rm -rf debian/yaz-runtime debian/yaz-runtime-ssl debian/yaz-devel \
69                 debian/with-ssl debian/*.debhelper debian/substvars debian/shlibs.yaz-*
70
71 install: stamp-install
72 stamp-install: stamp-build
73         dh_testdir
74         dh_testroot
75         dh_clean -k -a
76         dh_installdirs -a
77
78         # Add here commands to install the package into debian/tmp.
79         -mkdirhier debian/tmp/usr
80         $(MAKE) -C build install prefix=`pwd`/debian/tmp/usr
81
82         touch stamp-install
83
84 # Build architecture-independent files here.
85 binary-indep: build install
86         dh_testdir
87         dh_testroot
88         dh_installdocs -p yaz-doc doc/
89         dh_installchangelogs -p yaz-doc
90         dh_link -p yaz-doc
91         dh_strip -p yaz-doc
92         dh_compress -p yaz-doc
93         dh_fixperms -p yaz-doc
94         dh_gencontrol -p yaz-doc
95         dh_md5sums -p yaz-doc
96
97         dh_builddeb -p yaz-doc
98
99 # Build architecture-dependent files here.
100 binary-arch: build install
101         dh_testdir
102         dh_testroot
103         dh_movefiles -p yaz-devel  usr/share/aclocal usr/lib/*.a usr/include usr/bin
104         dh_movefiles -p yaz-runtime usr/lib usr/share/yaz
105         dh_installexamples -p yaz-devel
106
107         dh_installdocs --all README TODO LICENSE CHANGELOG debian/copyright
108         mv debian/yaz-runtime/usr/share/doc/yaz-runtime/CHANGELOG debian/yaz-runtime/usr/share/doc/yaz-runtime/changelog
109         mv debian/yaz-devel/usr/share/doc/yaz-devel/CHANGELOG debian/yaz-devel/usr/share/doc/yaz-devel/changelog
110
111         dh_installchangelogs
112         dh_link
113         dh_strip
114         dh_compress -a
115         dh_fixperms -a
116
117         dh_installdeb -p yaz-runtime
118         dh_installdeb -p yaz-devel
119
120         dh_shlibdeps -p yaz-runtime $(LOCAL_LINK) -- debian/yaz-runtime/usr/lib/*.so
121         dh_shlibdeps -p yaz-devel $(LOCAL_LINK) -- debian/yaz-devel/usr/bin/*
122
123         dh_undocumented -p yaz-devel yaz-client.1 yaz-comp.1 yaz-config.1 yaz-ztest.1 zoomsh.1
124 ifeq ($(YAZ_WITH_SSL),1)
125         dh_undocumented -p yaz-devel yaz-client-ssl.1 yaz-ztest-ssl.1
126         echo "libyaz 1 yaz-runtime-ssl" > debian/yaz-runtime/DEBIAN/shlibs
127         echo "libyazthread 1 yaz-runtime-ssl" >> debian/yaz-runtime/DEBIAN/shlibs
128         echo "libyazmalloc 1 yaz-runtime-ssl" >> debian/yaz-runtime/DEBIAN/shlibs
129         echo "libyazssl 1 yaz-runtime-ssl" >> debian/yaz-runtime/DEBIAN/shlibs
130         # Move doc dir
131         mv debian/yaz-runtime/usr/share/doc/yaz-runtime debian/yaz-runtime/usr/share/doc/yaz-runtime-ssl
132         mv debian/yaz-devel/usr/share/doc/yaz-devel debian/yaz-devel/usr/share/doc/yaz-devel-ssl
133 else
134         echo "libyaz 1 yaz-runtime" > debian/yaz-runtime/DEBIAN/shlibs
135         echo "libyazthread 1 yaz-runtime" >> debian/yaz-runtime/DEBIAN/shlibs
136         echo "libyazmalloc 1 yaz-runtime" >> debian/yaz-runtime/DEBIAN/shlibs
137 endif
138         chmod 644 debian/yaz-runtime/DEBIAN/shlibs
139
140         # Ugh Ugly hack
141         cat debian/postinst >> debian/yaz-runtime/DEBIAN/postinst
142
143         dh_md5sums -p yaz-runtime
144         dh_md5sums -p yaz-devel
145 ifeq ($(YAZ_WITH_SSL),1)
146         dh_gencontrol -p yaz-runtime -- -DPackage=yaz-runtime-ssl -DConflicts=yaz-runtime -DReplaces=yaz-runtime -DProvides=yaz-runtime
147         dh_gencontrol -p yaz-devel -- -DPackage=yaz-devel-ssl -DConflicts=yaz-devel -DReplaces=yaz-devel
148 else
149         dh_gencontrol -p yaz-runtime
150         dh_gencontrol -p yaz-devel
151 endif
152
153         # Go kill those CVS-dirs before build
154         -find debian/tmp -type d -name CVS | xargs rm -rf
155         # For some reason it is necessary to remove empty-dirs in yaz-doc
156         -rm -rf debian/tmp/usr/include debian/tmp/usr/share/aclocal debian/tmp/usr/lib debian/tmp/usr/bin \
157                 debian/tmp/usr/share/yaz
158
159         dh_builddeb -p yaz-runtime
160         dh_builddeb -p yaz-devel
161
162
163 binary: binary-indep binary-arch
164 .PHONY: build clean binary-indep binary-arch binary install install-stamp configure
165
166 yazrelease:
167         # Conveniency target for building both SSL and non-ssl versions
168         dh_testdir
169         # Non-ssl version and source
170         dpkg-buildpackage $(EXTRA_OPTS) -rfakeroot
171         # SSL version
172         -YAZ_WITH_SSL=1 dpkg-buildpackage $(EXTRA_OPTS) -rfakeroot -B