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