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