rules revision 55e00a250398a2446e9872302579d49a5da76c22
1#! /usr/bin/make -f
2# -*- makefile -*-
3#
4# Invoke each target with `./debian/rules <target>'.  All targets should be
5# invoked with the package root as the current directory.
6#
7# The `binary' target must be run as root, as it needs to install files with
8# specific ownerships.
9
10# be paranoid
11export LC_ALL=C
12
13# Allow distro-specific behaviour
14DISTRO :=$(shell sed -ne '/DISTRIB_ID/s/.*=//p' /etc/lsb-release 2>/dev/null || echo Debian)
15SYS_BLKID_VER := $(shell dpkg-query -W libblkid1 | cut -f 2 | cut -b 1)
16ifeq ($(SYS_BLKID_VER),2)
17UTIL_LINUX_NG ?= yes
18endif
19
20# These are used for cross-compiling and for saving the configure script
21# from having to guess our platform (since we know it already)
22DEB_HOST_ARCH   ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
23DEB_BUILD_ARCH   ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
24DEB_HOST_OS   ?= $(shell dpkg-architecture -qDEB_HOST_OS)
25DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
26DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
27DEB_HOST_MULTIARCH  ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)
28
29# find the version for the main package, from changelog file
30MAIN_VERSION = $(shell head -n 1 debian/changelog | cut '-d ' -f 2 | sed 's/[()]//g')
31# find versions for libraries going into their own packages, from their Makefile.in's,
32# and sonames for all libs
33COMERR_VERSION = $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
34COMERR_SOVERSION = $(shell grep ELF_SO_VERSION lib/et/Makefile.in | cut '-d ' -f3)
35SS_VERSION = $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
36SS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
37
38ifneq ($(UTIL_LINUX_NG),yes)
39UUID_VERSION = $(shell grep ELF_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
40UUID_SOVERSION = $(shell grep ELF_SO_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
41
42BLKID_VERSION = $(shell grep ELF_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
43BLKID_SOVERSION = $(shell grep ELF_SO_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
44endif
45
46EXT2FS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ext2fs/Makefile.in | cut '-d ' -f3)
47E2P_SOVERSION = $(shell grep ELF_SO_VERSION lib/e2p/Makefile.in | cut '-d ' -f3)
48
49package=e2fsprogs
50
51topdir=$(shell pwd)
52debdir=${topdir}/debian
53tmpdir=${debdir}/tmp
54udebdir=${debdir}/e2fsprogs-udeb
55ifneq ($(UTIL_LINUX_NG),yes)
56blkidudebdir=${debdir}/libblkid1-udeb
57uuidudebdir=${debdir}/libuuid1-udeb
58endif
59libcomerrdir=${debdir}/libcomerr${COMERR_SOVERSION}
60comerrdevdir=${debdir}/comerr-dev
61libcomerrdbgdir=${debdir}/libcomerr2-dbg
62libssdir=${debdir}/libss${SS_SOVERSION}
63ssdevdir=${debdir}/ss-dev
64libssdbgdir=${debdir}/libss2-dbg
65ifneq ($(UTIL_LINUX_NG),yes)
66libblkiddir=${debdir}/libblkid${BLKID_SOVERSION}
67libblkiddevdir=${debdir}/libblkid-dev
68libblkiddbgdir=${debdir}/libblkid1-dbg
69libuuiddir=${debdir}/libuuid${UUID_SOVERSION}
70uuiddevdir=${debdir}/uuid-dev
71libuuiddbgdir=${debdir}/libuuid1-dbg
72uuidruntimedir=${debdir}/uuid-runtime
73uuidruntimedbgdir=${debdir}/uuid-runtime-dbg
74endif
75libext2dir=${debdir}/e2fslibs
76libext2devdir=${debdir}/e2fslibs-dev
77libext2dbgdir=${debdir}/e2fslibs-dbg
78maindir=${debdir}/e2fsprogs
79e2fsckstaticdir=${debdir}/e2fsck-static
80debugdir=${debdir}/e2fsprogs-dbg
81stdbuilddir=${debdir}/BUILD-STD
82bfbuilddir=${debdir}/BUILD-BF
83staticbuilddir=${debdir}/BUILD-STATIC
84mipsbuilddir=${debdir}/BUILD-MIPS
85mipsbuilddir64=${debdir}/BUILD-MIPS-64
86# docdir=${maindir}/usr/share/doc/${package}
87MANDIR=/usr/share/man
88mandir=${tmpdir}${MANDIR}
89
90UDEB_NAME = $(package)-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
91UDEB_PRIORITY = $(shell grep '^Package: e2fsprogs-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
92
93ifneq ($(UTIL_LINUX_NG),yes)
94BLKID_UDEB_NAME = libblkid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
95BLKID_UDEB_PRIORITY = $(shell grep '^Package: libblkid1-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
96
97UUID_UDEB_NAME = libuuid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
98UUID_UDEB_PRIORITY = $(shell grep '^Package: libuuid1-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
99endif
100
101STAMPSDIR=debian/stampdir
102CFGSTDSTAMP=${STAMPSDIR}/configure-std-stamp
103CFGBFSTAMP=${STAMPSDIR}/configure-bf-stamp
104CFGSTATICSTAMP=${STAMPSDIR}/configure-static-stamp
105BUILDSTDSTAMP=${STAMPSDIR}/build-std-stamp
106BUILDBFSTAMP=${STAMPSDIR}/build-bf-stamp
107BUILDSTATICSTAMP=${STAMPSDIR}/build-static-stamp
108
109INSTALL = install
110INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 0755
111
112#ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
113#INSTALL_PROGRAM += -s
114#endif
115
116ifeq (${DEB_HOST_ARCH},alpha)
117CFLAGS += -DHAVE_NETINET_IN_H
118else
119CFLAGS += -D__NO_STRING_INLINES
120endif
121
122ifeq (${DEB_HOST_ARCH_OS},linux)
123BUILD_STATIC = build-static
124E2FSCK_STATIC = ${staticbuilddir}/e2fsck/e2fsck.static
125else
126E2FSCK_STATIC = ${stdbuilddir}/e2fsck/e2fsck.static
127endif
128
129BF_CFLAGS = -Os -fomit-frame-pointer
130
131COMMON_CONF_FLAGS = --disable-e2initrd-helper --enable-elf-shlibs \
132	--infodir=/usr/share/info
133ifeq ($(UTIL_LINUX_NG),yes)
134COMMON_CONF_FLAGS += --disable-fsck --disable-libblkid \
135			--disable-libuuid --disable-uuidd
136else
137COMMON_CONF_FLAGS += --enable-fsck
138endif
139
140ifneq ($(strip $(DEB_HOST_MULTIARCH)),)
141MULTIARCH_CONF = --with-multiarch=$(DEB_HOST_MULTIARCH)
142# This doesn't work yet because gdb and lintian don't expect and/or
143# don't work with /usr/lib/<triplet>/debug
144#USRLIB = /usr/lib/$(DEB_HOST_MULTIARCH)
145USRLIB = /usr/lib
146else
147USRLIB = /usr/lib
148endif
149
150STD_CONF_FLAGS = --enable-symlink-install $(MULTIARCH_CONF)
151
152BF_CONF_FLAGS = --disable-nls --disable-imager --disable-testio-debug \
153	--disable-uuidd --disable-tls --disable-debugfs
154
155STATIC_CONF_FLAGS = --disable-nls --disable-imager \
156	--disable-uuidd --disable-tls
157
158MIPS_NOPIC_CONF_FLAGS = --disable-nls --disable-imager \
159	--disable-uuidd --disable-tls \
160        --disable-resizer # --disable-debugfs
161
162# we can't use those flags at configure time
163MIPS_CFLAGS= -G 0 -fno-pic -mno-abicalls
164MIPS_CFLAGS_64= -mabi=64 -G 0 -fno-pic -mno-abicalls
165
166ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
167ifneq (,$(findstring $(DEB_BUILD_ARCH),mips mipsel))
168ismips=ismips
169endif
170endif
171
172M4_ARGS=
173ifeq ($(UTIL_LINUX_NG),yes)
174M4_ARGS+=-DUTIL_LINUX_NG
175else
176M4_ARGS+=-UUTIL_LINUX_NG
177endif
178
179ifneq ($(strip $(DEB_HOST_MULTIARCH)),)
180M4_ARGS+=-DDO_MULTIARCH
181else
182M4_ARGS+=-UDO_MULTIARCH
183endif
184
185FILES_FIXUP= libcomerr2.files comerr-dev.files libss2.files ss-dev.files \
186	libuuid1.files uuid-dev.files libblkid1.files libblkid-dev.files \
187	e2fslibs.files e2fslibs-dev.files
188
189debian-files: debian/control debian/e2fsprogs.shlibs.local
190ifeq ($(strip $(DEB_HOST_MULTIARCH)),)
191	for i in $(FILES_FIXUP); do \
192		sed -e 's;lib/\*/;lib/;' debian/$$i.in > debian/$$i; \
193	done
194else
195	for i in $(FILES_FIXUP); do cp debian/$$i.in debian/$$i; done
196endif
197
198mrproper: clean
199	rm debian/control debian/e2fsprogs.shlibs.local
200
201debian/control: debian/control.in debian/rules
202	m4 $(M4_ARGS) < debian/control.in | grep -v ^REMOVE_ME$$ > $@
203
204debian/e2fsprogs.shlibs.local: debian/e2fsprogs.shlibs.local.in
205	m4 $(M4_ARGS) < debian/e2fsprogs.shlibs.local.in > $@
206
207${CFGSTDSTAMP}:
208	dh_testdir
209
210	# Make sure we don't try to rebuild the configure scripts
211	find . -name configure | xargs touch
212
213	mkdir -p ${stdbuilddir}
214ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
215	cd ${stdbuilddir} && AWK=/usr/bin/awk \
216		${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \
217		CFLAGS="${CFLAGS}"
218else
219	cd ${stdbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \
220		${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \
221		--build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
222		CFLAGS="${CFLAGS}"
223endif
224
225  # specially-built MIPS libs
226ifneq ($(ismips),)
227	mkdir -p ${mipsbuilddir} ${mipsbuilddir64}
228	cd ${mipsbuilddir} && AWK=/usr/bin/awk \
229		${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS} CFLAGS="${CFLAGS}"
230	cd ${mipsbuilddir64} && AWK=/usr/bin/awk \
231		${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS} CFLAGS="${CFLAGS}"
232endif
233
234	mkdir -p ${STAMPSDIR}
235	touch ${CFGSTDSTAMP}
236
237${CFGBFSTAMP}:
238	dh_testdir
239	rm -f config.cache
240
241	mkdir -p ${bfbuilddir}
242ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
243	cd ${bfbuilddir} && AWK=/usr/bin/awk \
244		${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \
245		CFLAGS="${CFLAGS} ${BF_CFLAGS}"
246else
247	cd ${bfbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \
248		${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \
249		--build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
250		CFLAGS="${CFLAGS}"
251endif
252	mkdir -p ${STAMPSDIR}
253	touch ${CFGBFSTAMP}
254
255${CFGSTATICSTAMP}:
256	dh_testdir
257	rm -f config.cache
258
259	mkdir -p ${staticbuilddir}
260ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
261	if type diet > /dev/null  2>&1 ; then \
262		cd ${staticbuilddir} && AWK=/usr/bin/awk \
263		${topdir}/configure ${STATIC_CONF_FLAGS} \
264		--with-diet-libc CFLAGS="${CFLAGS}"; \
265	else \
266		cd ${staticbuilddir} && AWK=/usr/bin/awk \
267			${topdir}/configure ${STATIC_CONF_FLAGS} \
268			CFLAGS="${CFLAGS}"; \
269	fi
270else
271	cd ${staticbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \
272		${topdir}/configure ${COMMON_CONF_FLAGS} ${STATIC_CONF_FLAGS} \
273		--build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
274		CFLAGS="${CFLAGS}"
275endif
276	mkdir -p ${STAMPSDIR}
277	touch ${CFGSTATICSTAMP}
278
279build-arch: build
280build-indep: build
281build: build-std build-bf $(BUILD_STATIC)
282
283build-std: ${BUILDSTDSTAMP}
284${BUILDSTDSTAMP}: ${CFGSTDSTAMP}
285	dh_testdir
286	$(MAKE) -C ${stdbuilddir} all
287	$(MAKE) -C ${stdbuilddir}/e2fsck e2fsck.static
288
289	( cd ${stdbuilddir}/doc && $(MAKE) libext2fs_abt.html )
290	( cd ${stdbuilddir}/lib/et && $(MAKE) com_err.info com_err_abt.html )
291
292  # specially-built MIPS libs
293ifneq ($(ismips),)
294	$(MAKE) -C ${mipsbuilddir}/util
295	$(MAKE) -C ${mipsbuilddir} \
296		CFLAGS="${CFLAGS} ${MIPS_CFLAGS}" \
297		LIB_SUBDIRS="lib/et lib/ext2fs" libs
298	$(MAKE) -C ${mipsbuilddir64}/util
299	$(MAKE) -C ${mipsbuilddir64} \
300		CFLAGS="${CFLAGS} ${MIPS_CFLAGS_64}" \
301		LIB_SUBDIRS="lib/et lib/ext2fs" libs
302endif
303
304	touch ${BUILDSTDSTAMP}
305
306build-bf: ${BUILDBFSTAMP}
307${BUILDBFSTAMP}: ${CFGBFSTAMP}
308	dh_testdir
309	$(MAKE) -C ${bfbuilddir} libs
310	$(MAKE) -C ${bfbuilddir}/e2fsck all
311	$(MAKE) -C ${bfbuilddir}/misc all
312	touch ${BUILDBFSTAMP}
313
314build-static: ${BUILDSTATICSTAMP}
315${BUILDSTATICSTAMP}: ${CFGSTATICSTAMP}
316	dh_testdir
317	$(MAKE) -C ${staticbuilddir} libs
318	$(MAKE) -C ${staticbuilddir}/e2fsck all e2fsck.static
319	touch ${BUILDSTATICSTAMP}
320
321clean:
322	dh_testdir
323	rm -rf ${STAMPSDIR}
324	[ ! -f ${stdbuilddir}/Makefile ] || $(MAKE) -C ${stdbuilddir} distclean
325	[ ! -f ${bfbuilddir}/Makefile ] || $(MAKE) -C ${bfbuilddir} distclean
326	[ ! -f ${staticbuilddir}/Makefile ] || $(MAKE) -C ${staticbuilddir} distclean
327	rm -rf ${stdbuilddir} ${bfbuilddir} ${staticbuilddir} ${mipsbuilddir} ${mipsbuilddir64}
328	rm -f debian/*.substvars
329	dh_clean
330
331install: cleanup install-std
332
333# This rule allows to factorize the dh_clean between the 2 install rules
334# This must be launched before install-* (if launching them by hand, for
335# exemple) or results are unpredictable
336cleanup:
337	dh_testdir
338	dh_testroot
339	dh_prep
340
341install-std: DH_OPTIONS=
342install-std: build
343	dh_testdir
344	dh_testroot
345	dh_installdirs
346
347	mkdir -p ${tmpdir}/sbin
348	$(MAKE) -C ${stdbuilddir} install DESTDIR=${tmpdir} \
349		INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
350  # static libs and .h files
351	$(MAKE) -C ${stdbuilddir} install-libs DESTDIR=${tmpdir} LDCONFIG=true
352
353  # statically-linked fsck
354	${INSTALL_PROGRAM} $(E2FSCK_STATIC) ${tmpdir}/sbin
355	cp ${mandir}/man8/e2fsck.8 ${mandir}/man8/e2fsck.static.8
356
357	dh_movefiles
358	test -z "`find ${tmpdir} -type f`"
359
360  # specially-built MIPS libs
361ifneq ($(ismips),)
362	$(INSTALL) -p -m 0644 ${mipsbuilddir}/lib/libext2fs.a \
363		${debdir}/e2fslibs-dev/usr/lib/libext2fs-nopic.a
364	$(INSTALL) -p -m 0644 ${mipsbuilddir64}/lib/libext2fs.a \
365		${debdir}/e2fslibs-dev/usr/lib/lib64ext2fs-nopic.a
366endif
367
368install-udeb: DH_OPTIONS=
369install-udeb: build
370	dh_testdir
371	dh_testroot
372
373	$(MAKE) -C ${bfbuilddir} install-shlibs-libs-recursive DESTDIR=${udebdir} \
374		INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
375	$(MAKE) -C ${bfbuilddir}/e2fsck install DESTDIR=${udebdir} \
376		INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
377	$(MAKE) -C ${bfbuilddir}/misc install DESTDIR=${udebdir} \
378		INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
379	$(MAKE) -C ${bfbuilddir}/resize install DESTDIR=${udebdir} \
380		INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
381
382	rm -rf ${udebdir}/usr
383	find ${udebdir}/sbin -type f -a ! -name e2fsck \
384		-a ! -name mke2fs -a ! -name tune2fs \
385		-a ! -name resize2fs -a ! -name badblocks -print | xargs rm
386
387	(cd ${udebdir}/sbin; ln -s e2fsck fsck.ext2 ; \
388		ln -s e2fsck fsck.ext3 ; ln -s e2fsck fsck.ext4 ; \
389		ln -s mke2fs mkfs.ext2 ; ln -s mke2fs mkfs.ext3 ; \
390		ln -s mke2fs mkfs.ext4)
391
392ifneq ($(UTIL_LINUX_NG),yes)
393	mkdir -p ${blkidudebdir}/lib
394	mv ${udebdir}/lib/libblkid.* ${blkidudebdir}/lib
395
396	mkdir -p ${uuidudebdir}/lib
397	mv ${udebdir}/lib/libuuid.* ${uuidudebdir}/lib
398endif
399
400binary-indep: 
401  # no arch-independant debs.
402
403binary-arch: DH_OPTIONS= -a
404binary-arch: install install-udeb
405	dh_testdir
406	dh_testroot
407
408  # lintian overrides
409	for i in $$(cd debian && echo *.lintian-overrides); do \
410		pkg=$${i%.lintian-overrides} ;\
411		$(INSTALL) -m 0644 -D -p debian/$$i ${debdir}/$${pkg}/usr/share/lintian/overrides/$${pkg} ;\
412	done
413
414  # symlinks to prepare dh_installdocs run
415
416ifneq ($(UTIL_LINUX_NG),yes)
417	mkdir -p ${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION}
418	mkdir -p ${debdir}/libblkid-dev/usr/share/doc
419	ln -sf libblkid${BLKID_SOVERSION} ${debdir}/libblkid-dev/usr/share/doc/libblkid-dev
420endif
421
422	mkdir -p ${debdir}/libss${SS_SOVERSION}/usr/share/doc/libss${SS_SOVERSION}
423	mkdir -p ${debdir}/ss-dev/usr/share/doc
424	ln -sf libss${SS_SOVERSION} ${debdir}/ss-dev/usr/share/doc/ss-dev
425
426	mkdir -p ${debdir}/libcomerr${COMERR_SOVERSION}/usr/share/doc/libcomerr${COMERR_SOVERSION}
427	mkdir -p ${debdir}/comerr-dev/usr/share/doc
428	ln -sf libcomerr${COMERR_SOVERSION} ${debdir}/comerr-dev/usr/share/doc/comerr-dev
429
430ifneq ($(UTIL_LINUX_NG),yes)
431	mkdir -p ${debdir}/libuuid${UUID_SOVERSION}/usr/share/doc/libuuid${UUID_SOVERSION}
432	mkdir -p ${debdir}/uuid-dev/usr/share/doc
433#	ln -sf libuuid${UUID_SOVERSION} ${debdir}/uuid-dev/usr/share/doc/uuid-dev
434endif
435
436	mkdir -p ${debdir}/e2fslibs/usr/share/doc/e2fslibs
437	mkdir -p ${debdir}/e2fslibs-dev/usr/share/doc
438	ln -sf e2fslibs ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev
439
440ifneq ($(UTIL_LINUX_NG),yes)
441	$(INSTALL) -p -m 0644 debian/libblkid.copyright \
442		${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION}/copyright
443endif
444
445	dh_installdocs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
446
447  # HTML docs
448	$(INSTALL) -d ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/html-info/
449	$(INSTALL) -p -m 0644 ${stdbuilddir}/doc/*.html \
450	   ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/html-info/
451	$(INSTALL) -d ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/html-info/
452	$(INSTALL) -p -m 0644 ${stdbuilddir}/lib/et/*.html \
453	   ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/html-info/
454
455  # texinfo docs
456	mkdir -p ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}
457	$(INSTALL) -p -m 0644 ${topdir}/doc/libext2fs.texinfo \
458	   ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/libext2fs.texi
459	$(INSTALL) -p -m 0644 ${topdir}/lib/et/com_err.texinfo \
460	   ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/com_err.texi
461
462	$(INSTALL) -d ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/examples
463	$(INSTALL) -p -m 0644 lib/ss/ss_err.et \
464		${stdbuilddir}/lib/ext2fs/ext2_err.et \
465		${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/examples
466	$(INSTALL) -d ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION}/examples
467	$(INSTALL) -p -m 0644 debugfs/debug_cmds.ct \
468		${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION}/examples
469
470	dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info
471	dh_installinfo -pe2fslibs-dev ${stdbuilddir}/doc/libext2fs.info
472
473	DH_OPTIONS= dh_installchangelogs -pe2fsprogs \
474		-plibcomerr${COMERR_SOVERSION} \
475		-plibss${SS_SOVERSION} \
476		-pe2fslibs -pe2fsck-static \
477		-pe2fsprogs-dbg -pe2fslibs-dbg \
478		-plibcomerr2-dbg -plibss2-dbg
479ifneq ($(UTIL_LINUX_NG),yes)
480	DH_OPTIONS= dh_installchangelogs -plibuuid${UUID_SOVERSION} \
481		-puuid-dev -puuid-runtime -puuid-runtime-dbg -plibuuid1-dbg \
482		-plibblkid${BLKID_SOVERSION} -plibblkid1-dbg
483endif
484
485	dh_fixperms
486ifneq ($(ismips),)
487	dh_strip -k -Xlib64ext2fs-nopic.a
488else
489	dh_strip -k
490endif
491
492	# debug package stuff
493	rm -rf ${udebdir}/usr
494ifneq ($(UTIL_LINUX_NG),yes)
495	rm -rf ${blkidudebdir}/usr
496	rm -rf ${uuidudebdir}/usr
497endif
498
499	mkdir -p ${debugdir}/$(USRLIB)
500	mv ${maindir}/usr/lib/debug ${debugdir}/$(USRLIB)
501	rm -rf ${maindir}/usr/lib/debug
502	mv ${e2fsckstaticdir}/usr/lib/debug/sbin/* \
503		${debugdir}/$(USRLIB)/debug
504	rm -rf ${e2fsckstaticdir}/usr/lib
505
506ifneq ($(UTIL_LINUX_NG),yes)
507	mkdir -p ${uuidruntimedbgdir}/$(USRLIB)
508	mv ${uuidruntimedir}/usr/lib/debug ${uuidruntimedbgdir}/$(USRLIB)
509	rmdir ${uuidruntimedir}/usr/lib
510endif
511
512	mkdir -p ${libext2dbgdir}/$(USRLIB)
513	mv ${libext2dir}/usr/lib/debug ${libext2dbgdir}/$(USRLIB)
514	rmdir ${libext2dir}/usr/lib
515
516	mkdir -p ${libcomerrdbgdir}/$(USRLIB)
517	mv ${libcomerrdir}/usr/lib/debug ${libcomerrdbgdir}/$(USRLIB)
518	rmdir ${libcomerrdir}/usr/lib
519
520	mkdir -p ${libssdbgdir}/$(USRLIB)
521	mv ${libssdir}/usr/lib/debug ${libssdbgdir}/$(USRLIB)
522	rmdir ${libssdir}/usr/lib
523
524ifneq ($(UTIL_LINUX_NG),yes)
525	mkdir -p ${libuuiddbgdir}/$(USRLIB)
526	mv ${libuuiddir}/usr/lib/debug ${libuuiddbgdir}/$(USRLIB)
527	rmdir ${libuuiddir}/usr/lib
528
529	mkdir -p ${libblkiddbgdir}/$(USRLIB)
530	mv ${libblkiddir}/usr/lib/debug ${libblkiddbgdir}/$(USRLIB)
531	rmdir ${libblkiddir}/usr/lib
532endif
533
534	# dpkg symbol handling
535ifneq (,$(findstring update-symbols,$(DEB_BUILD_OPTIONS)))
536SYMBOL_LIBS := e2fslibs libcomerr2 libss2
537ifneq ($(UTIL_LINUX_NG),yes)
538SYMBOL_LIBS += libblkid1 libuuid1
539endif
540	for i in $(SYMBOL_LIBS); \
541	do \
542		echo "Generating symbols for $$i..."; \
543		dpkg-gensymbols -p$$i -Pdebian/$$i > debian/$$i.tmp-patch; \
544		cat debian/$$i.tmp-patch; \
545		patch debian/$$i.symbols < debian/$$i.tmp-patch; \
546		/bin/rm debian/$$i.tmp-patch; \
547	done
548endif
549
550	$(INSTALL) -p -m 0644 debian/e2fsprogs.copyright \
551		${debugdir}/usr/share/doc/e2fsprogs-dbg/copyright
552
553ifneq ($(UTIL_LINUX_NG),yes)
554	$(INSTALL) -p -m 0644 debian/uuid-runtime.copyright \
555		${uuidruntimedbgdir}/usr/share/doc/uuid-runtime-dbg/copyright
556endif
557
558	$(INSTALL) -p -m 0644 debian/e2fslibs.copyright \
559		${libext2dbgdir}/usr/share/doc/e2fslibs-dbg/copyright
560
561	$(INSTALL) -p -m 0644 debian/libcomerr2.copyright \
562		${libcomerrdbgdir}/usr/share/doc/libcomerr2-dbg/copyright
563
564	$(INSTALL) -p -m 0644 debian/libss2.copyright \
565		${libssdbgdir}/usr/share/doc/libss2-dbg/copyright
566
567ifneq ($(UTIL_LINUX_NG),yes)
568	$(INSTALL) -p -m 0644 debian/libblkid.copyright \
569		${libblkiddbgdir}/usr/share/doc/libblkid1-dbg/copyright
570
571	$(INSTALL) -p -m 0644 debian/libuuid1.copyright \
572		${libuuiddbgdir}/usr/share/doc/libuuid1-dbg/copyright
573endif
574
575	dh_compress
576
577	dh_makeshlibs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
578	dh_makeshlibs -plibcomerr${COMERR_SOVERSION} \
579		-V 'libcomerr2 (>= 1.33-3)'
580ifneq ($(UTIL_LINUX_NG),yes)
581	dh_makeshlibs -plibblkid${BLKID_SOVERSION} -V 'libblkid1 (>= 1.39-1)'
582	echo "udeb: libblkid 1 libblkid1-udeb" >> \
583		debian/libblkid1/DEBIAN/shlibs
584	echo "udeb: libuuid 1 libuuid1-udeb" >> debian/libuuid1/DEBIAN/shlibs
585endif
586
587	dh_installdeb
588	dh_shlibdeps -l${stdbuilddir}/lib
589	dh_shlibdeps -pe2fsprogs -l${stdbuilddir}/lib \
590		-u"-Ldebian/e2fsprogs.shlibs.local"
591	dh_shlibdeps -pe2fsprogs-udeb -l${stdbuilddir}/lib \
592		-u"-Ldebian/e2fsprogs-udeb.shlibs.local"
593
594	dh_gencontrol -Ncomerr-dev -Nss-dev -Nuuid-dev \
595		-Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
596	DH_OPTIONS= dh_gencontrol -pcomerr-dev \
597	  -u '-v${COMERR_VERSION}-${MAIN_VERSION} -VmainBinary=${MAIN_VERSION}'
598	DH_OPTIONS= dh_gencontrol -pss-dev \
599	  -u '-v${SS_VERSION}-${MAIN_VERSION} -VmainBinary=${MAIN_VERSION}'
600ifneq ($(UTIL_LINUX_NG),yes)
601	DH_OPTIONS= dh_gencontrol -puuid-dev \
602	  -u '-v${UUID_VERSION}-${MAIN_VERSION} -VmainBinary=${MAIN_VERSION}'
603endif
604	dh_gencontrol	-pe2fsprogs-udeb -- -fdebian/files~
605ifneq ($(UTIL_LINUX_NG),yes)
606	dh_gencontrol	-plibblkid1-udeb -- -fdebian/files~
607	dh_gencontrol	-plibuuid1-udeb -- -fdebian/files~
608endif
609
610	dpkg-distaddfile $(UDEB_NAME) debian-installer $(UDEB_PRIORITY)
611ifneq ($(UTIL_LINUX_NG),yes)
612	dpkg-distaddfile $(BLKID_UDEB_NAME) debian-installer $(BLKID_UDEB_PRIORITY)
613	dpkg-distaddfile $(UUID_UDEB_NAME) debian-installer $(UUID_UDEB_PRIORITY)
614endif
615	dh_md5sums -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
616	dh_builddeb -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
617	dh_builddeb -pe2fsprogs-udeb --filename=$(UDEB_NAME)
618ifneq ($(UTIL_LINUX_NG),yes)
619	dh_builddeb -plibblkid1-udeb --filename=$(BLKID_UDEB_NAME)
620	dh_builddeb -plibuuid1-udeb --filename=$(UUID_UDEB_NAME)
621endif
622
623binary: binary-indep binary-arch
624
625.PHONY: binary binary-arch binary-indep clean checkroot mrproper debian-files
626