650080fa9c20ab211eb1116b6cabb719e1498005
[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?=1
15 CONFIG_FLAGS=--with-xml2=/usr --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 YAZSRCDIR?=$(shell pwd)
32
33 # Local library path for linking with right dependencies
34 LOCAL_LINK=-ldebian/yaz-runtime/usr/lib:debian/yaz-ssl/usr/lib
35
36 $(YAZSRCDIR)/configure: $(YAZSRCDIR)/configure.in
37         cd $(YAZSRCDIR); sh buildconf.sh
38
39 stamp-configure: $(YAZSRCDIR)/configure
40         dh_testdir
41
42         -rm -rf build
43         mkdir build
44         cd build; $(YAZSRCDIR)/configure $(CONFIG_FLAGS) $(SSL_FLAGS)
45         touch stamp-configure
46
47 build: stamp-build
48 stamp-build: stamp-configure
49         dh_testdir
50
51         # Add here commands to compile the package.
52         $(MAKE) -C build $(MCFLAGS)
53
54         touch stamp-build
55
56 clean:
57         dh_testdir
58         #dh_testroot
59         -rm -f stamp-*
60         -rm -rf build
61
62         dh_clean
63         -rm -rf debian/yaz-runtime debian/yaz-ssl debian/yaz-devel \
64                 debian/with-ssl debian/*.debhelper debian/substvars debian/shlibs.yaz-*
65
66 install: stamp-install
67 stamp-install: stamp-build
68         dh_testdir
69         dh_testroot
70         dh_clean -k -a
71         dh_installdirs -a
72
73         # Add here commands to install the package into debian/tmp.
74         -mkdirhier debian/tmp/usr
75         $(MAKE) -C build install prefix=`pwd`/debian/tmp/usr
76
77         touch stamp-install
78
79 # Build architecture-independent files here.
80 binary-indep: build install
81         dh_testdir
82         dh_testroot
83         dh_installdocs -p yaz-doc doc/*.html doc/*.pdf doc/*.png
84         dh_installchangelogs -p yaz-doc
85         dh_link -p yaz-doc
86         dh_strip -p yaz-doc
87         dh_compress -p yaz-doc
88         dh_fixperms -p yaz-doc
89         dh_gencontrol -p yaz-doc
90         dh_md5sums -p yaz-doc
91
92         dh_builddeb -p yaz-doc
93
94 # Build architecture-dependent files here.
95 binary-arch: build install
96         dh_testdir
97         dh_testroot
98 ifeq ($(YAZ_WITH_SSL),1)
99         dh_movefiles -p yaz-ssl usr/bin/*ssl usr/lib/libyazssl* 
100 endif
101         dh_movefiles -p yaz-devel  usr/share/aclocal usr/lib/*.a usr/lib/*.la usr/lib/*.so usr/include usr/bin/yaz-config usr/bin/yaz-comp
102         dh_movefiles -p yaz-runtime usr/lib usr/share/yaz usr/bin
103         dh_installexamples -p yaz-devel
104
105         cp LICENSE debian/copyright
106         cp CHANGELOG changelog
107         dh_installdocs --all README TODO changelog debian/copyright
108
109         dh_installchangelogs
110         dh_link
111         dh_strip
112         dh_compress -a
113         dh_fixperms -a
114
115         dh_installdeb -p yaz-runtime
116         dh_installdeb -p yaz-devel
117         dh_installman -p yaz-devel doc/yaz-config.1
118         dh_undocumented -p yaz-devel yaz-comp.1
119         dh_installman -p yaz-runtime doc/yaz-client.1 doc/yaz-ztest.8 doc/yaz.7 doc/zoomsh.1
120         echo "libyaz 2 yaz-runtime (>= 1.9.3)" > debian/yaz-runtime/DEBIAN/shlibs
121         echo "libyazthread 2 yaz-runtime (>= 1.9.3)" >> debian/yaz-runtime/DEBIAN/shlibs
122         echo "libyazmalloc 2 yaz-runtime (>= 1.9.3)" >> debian/yaz-runtime/DEBIAN/shlibs
123         chmod 644 debian/yaz-runtime/DEBIAN/shlibs
124         dh_shlibdeps -p yaz-runtime $(LOCAL_LINK) 
125 ifeq ($(YAZ_WITH_SSL),1)
126         dh_installdeb -p yaz-ssl
127         dh_installman -p yaz-ssl doc/yaz-client-ssl.1 doc/yaz-ztest-ssl.8
128         echo "libyazssl 2 yaz-ssl (>= 1.9.3)" >> debian/yaz-ssl/DEBIAN/shlibs
129         chmod 644 debian/yaz-ssl/DEBIAN/shlibs
130         dh_shlibdeps -p yaz-ssl $(LOCAL_LINK)
131         cat debian/postinst >> debian/yaz-ssl/DEBIAN/postinst
132 endif
133         cat debian/postinst >> debian/yaz-runtime/DEBIAN/postinst
134
135         dh_gencontrol -p yaz-runtime
136         dh_md5sums -p yaz-runtime
137
138         dh_gencontrol -p yaz-devel
139         dh_md5sums -p yaz-devel
140
141 ifeq ($(YAZ_WITH_SSL),1)
142         dh_gencontrol -p yaz-ssl
143         dh_md5sums -p yaz-ssl
144 endif
145         # Go kill those CVS-dirs before build
146         -find debian/tmp -type d -name CVS | xargs rm -rf
147         # For some reason it is necessary to remove empty-dirs in yaz-doc
148         -rm -rf debian/tmp/usr/include debian/tmp/usr/share/aclocal debian/tmp/usr/lib debian/tmp/usr/bin \
149                 debian/tmp/usr/share/yaz
150
151         dh_builddeb -p yaz-runtime
152         dh_builddeb -p yaz-devel
153 ifeq ($(YAZ_WITH_SSL),1)
154         dh_builddeb -p yaz-ssl
155 endif
156
157
158 binary: binary-indep binary-arch
159 .PHONY: build clean binary-indep binary-arch binary install install-stamp configure
160
161 yazrelease:
162         # Conveniency target for building both SSL and non-ssl versions
163         dh_testdir
164         # Non-ssl version and source
165         dpkg-buildpackage $(EXTRA_OPTS) -rfakeroot
166         # SSL version
167         -YAZ_WITH_SSL=1 dpkg-buildpackage $(EXTRA_OPTS) -rfakeroot -B