Whamcloud - gitweb
debian: fix build reproducibility problems in the rules file
[tools/e2fsprogs.git] / debian / rules
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
12 export DEB_BUILD_MAINT_OPTIONS ?= hardening=+all
13
14 # be paranoid
15 export 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)
19 DEB_HOST_ARCH           ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
20 DEB_BUILD_ARCH          ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
21 DEB_HOST_OS             ?= $(shell dpkg-architecture -qDEB_HOST_OS)
22 DEB_HOST_GNU_TYPE       ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
23 DEB_BUILD_GNU_TYPE      ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
24 DEB_HOST_MULTIARCH      ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)
25
26 # Allow distro-specific behaviour
27 DISTRO :=$(shell sed -ne '/DISTRIB_ID/s/.*=//p' /etc/lsb-release 2>/dev/null || echo Debian)
28 UTIL_LINUX_NG ?= yes
29
30 ifeq ($(DEB_BUILD_GNU_SYSTEM), gnu)
31 SKIP_FUSE2FS=yes
32 endif
33
34 DH_VERSION := $(shell dpkg-query -W -f '$${Version}' debhelper)
35
36 # USE_DBGSYM :=
37 USE_DBGSYM ?= $(shell if dpkg --compare-versions $(DH_VERSION) ">=" 9.20160114 ; then echo yes ; fi)
38
39 ifeq ($(USE_DBGSYM),yes)
40 dh_strip_args = -p$(1) --dbgsym-migration='$(1)-dbg (<= 1.43-1)'
41 dh_strip_args2 = -p$(1) --dbgsym-migration='$(2)-dbg (<= 1.43-1)'
42 else
43 dh_strip_args = -p$(1) --dbg-package=$(1)-dbg
44 dh_strip_args2 = -p$(1) --dbg-package=$(2)-dbg
45 endif
46 # find the version for the main package, from changelog file
47 MAIN_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
50 COMERR_VERSION ?= $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
51 COMERR_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/et/Makefile.in | cut '-d ' -f3)
52 SS_VERSION ?= $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
53 SS_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
54
55 ifneq ($(UTIL_LINUX_NG),yes)
56 UUID_VERSION ?= $(shell grep ELF_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
57 UUID_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
58
59 BLKID_VERSION ?= $(shell grep ELF_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
60 BLKID_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
61 endif
62
63 EXT2FS_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/ext2fs/Makefile.in | cut '-d ' -f3)
64 E2P_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/e2p/Makefile.in | cut '-d ' -f3)
65
66 package         ?= e2fsprogs
67
68 topdir          ?= $(shell pwd)
69 debdir          ?= ${topdir}/debian
70 tmpdir          ?= ${debdir}/tmp
71 udebdir         ?= ${debdir}/e2fsprogs-udeb
72 ifneq ($(UTIL_LINUX_NG),yes)
73 blkidudebdir    ?= ${debdir}/libblkid1-udeb
74 uuidudebdir     ?= ${debdir}/libuuid1-udeb
75 endif
76 libcomerrdir    ?= ${debdir}/libcomerr${COMERR_SOVERSION}
77 comerrdevdir    ?= ${debdir}/comerr-dev
78 libcomerrdbgdir ?= ${debdir}/libcomerr2-dbg
79 libssdir        ?= ${debdir}/libss${SS_SOVERSION}
80 ssdevdir        ?= ${debdir}/ss-dev
81 libssdbgdir     ?= ${debdir}/libss2-dbg
82 ifneq ($(UTIL_LINUX_NG),yes)
83 libblkiddir     ?= ${debdir}/libblkid${BLKID_SOVERSION}
84 libblkiddevdir  ?= ${debdir}/libblkid-dev
85 libblkiddbgdir  ?= ${debdir}/libblkid1-dbg
86 libuuiddir      ?= ${debdir}/libuuid${UUID_SOVERSION}
87 uuiddevdir      ?= ${debdir}/uuid-dev
88 libuuiddbgdir   ?= ${debdir}/libuuid1-dbg
89 uuidruntimedir  ?= ${debdir}/uuid-runtime
90 uuidruntimedbgdir ?= ${debdir}/uuid-runtime-dbg
91 endif
92 libext2dir      ?= ${debdir}/e2fslibs
93 libext2devdir   ?= ${debdir}/e2fslibs-dev
94 libext2dbgdir   ?= ${debdir}/e2fslibs-dbg
95 maindir         ?= ${debdir}/e2fsprogs
96 e2fsckstaticdir ?= ${debdir}/e2fsck-static
97 debugdir        ?= ${debdir}/e2fsprogs-dbg
98 stdbuilddir     ?= ${debdir}/BUILD-STD
99 mipsbuilddir    ?= ${debdir}/BUILD-MIPS
100 mipsbuilddir64  ?= ${debdir}/BUILD-MIPS-64
101 # docdir        ?= ${maindir}/usr/share/doc/${package}
102 MANDIR          ?= /usr/share/man
103 mandir          ?= ${tmpdir}${MANDIR}
104
105 UDEB_NAME       ?= $(package)-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
106 UDEB_PRIORITY   ?= $(shell grep '^Package: e2fsprogs-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
107
108 ifneq ($(UTIL_LINUX_NG),yes)
109 BLKID_UDEB_NAME ?= libblkid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
110 BLKID_UDEB_PRIORITY ?= $(shell grep '^Package: libblkid1-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
111
112 UUID_UDEB_NAME ?= libuuid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
113 UUID_UDEB_PRIORITY ?= $(shell grep '^Package: libuuid1-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
114 endif
115
116 STAMPSDIR       ?= debian/stampdir
117 CFGSTDSTAMP     ?= ${STAMPSDIR}/configure-std-stamp
118 CFGBFSTAMP      ?= ${STAMPSDIR}/configure-bf-stamp
119 BUILDSTDSTAMP   ?= ${STAMPSDIR}/build-std-stamp
120 BUILDBFSTAMP    ?= ${STAMPSDIR}/build-bf-stamp
121
122 INSTALL ?= install
123 INSTALL_PROGRAM ?= $(INSTALL) -p -o root -g root -m 0755
124
125 #ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
126 #INSTALL_PROGRAM += -s
127 #endif
128
129 ifneq (,$(findstring update-symbols,$(DEB_BUILD_OPTIONS)))
130 SYMBOL_LIBS := e2fslibs libcomerr2 libss2
131 ifneq ($(UTIL_LINUX_NG),yes)
132 SYMBOL_LIBS += libblkid1 libuuid1
133 endif
134 endif
135
136 DEFAULT_CFLAGS ?= -g -O2
137 DEFAULT_LDFLAGS ?= -Wl,-Bsymbolic-functions
138
139 CFLAGS ?= $(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)
142 LDFLAGS ?= $(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)
145 CPPFLAGS ?= $(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
149 ifeq (${DEB_HOST_ARCH},alpha)
150 CFLAGS += -DHAVE_NETINET_IN_H
151 else
152 CFLAGS += -D__NO_STRING_INLINES
153 endif
154
155 E2FSCK_STATIC = ${stdbuilddir}/e2fsck/e2fsck.static
156
157 CFLAGS_SHLIB = $(CFLAGS)
158 CFLAGS_STLIB = $(CFLAGS)
159 LDFLAGS_SHLIB = $(LDFLAGS)
160 LDFLAGS_STATIC = $(filter-out -fPIE -fpie -pie,$(LDFLAGS))
161
162 ifneq ($(SKIP_UDEB),)
163 SKIP_BF ?= yes
164 endif
165
166 ifeq ($(SKIP_BF),yes)
167 BUILD_BF =
168 bfbuilddir      ?= ${stdbuilddir}
169 else
170 BUILD_BF = build-bf
171 bfbuilddir      ?= ${debdir}/BUILD-BF
172 endif
173
174 BF_CFLAGS = -Os -fomit-frame-pointer
175
176 ifeq ($(UTIL_LINUX_NG),yes)
177 UTIL_CONF_FLAGS ?= --disable-fsck --disable-libblkid \
178                         --disable-libuuid --disable-uuidd
179 else
180 UTIL_CONF_FLAGS ?= --enable-fsck --enable-libblkid \
181                         --enable-libuuid --enable-uuidd
182 endif
183
184 ifneq ($(SKIP_FUSE2FS),)
185 UTIL_CONF_FLAGS +=  --disable-fuse2fs
186 endif
187
188 ifneq ($(strip $(DEB_HOST_MULTIARCH)),)
189 MULTIARCH_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)
193 USRLIB ?= /usr/lib
194 else
195 USRLIB ?= /usr/lib
196 endif
197
198 BACKTRACE_CONF_FLAGS ?= $(shell if ${debdir}/scripts/test-backtrace ; then echo --disable-backtrace ; fi)
199
200 COMMON_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
204 STD_CONF_FLAGS ?= --enable-elf-shlibs
205
206 BF_CONF_FLAGS ?= --enable-elf-shlibs --disable-nls --disable-imager \
207         --disable-testio-debug --disable-uuidd --disable-tls \
208         --disable-tdb --disable-debugfs
209
210 MIPS_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
215 MIPS_CFLAGS ?= -G 0 -fno-pic -mno-abicalls
216 MIPS_CFLAGS_64 ?= -mabi=64 -G 0 -fno-pic -mno-abicalls
217
218 ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
219 ifneq (,$(findstring $(DEB_BUILD_ARCH),mips mipsel))
220 ismips=ismips
221 endif
222 endif
223
224 M4_ARGS=
225 DBG_PACKAGES=
226
227 ifeq ($(USE_DBGSYM),yes)
228 M4_ARGS+=-DUSE_DBGSYM
229 else
230 DBG_PACKAGES += -pe2fsprogs-dbg -pe2fslibs-dbg -plibcomerr2-dbg -plibss2-dbg
231 M4_ARGS+=-UUSE_DBGSYM
232 endif
233
234 ifeq ($(UTIL_LINUX_NG),yes)
235 M4_ARGS+=-DUTIL_LINUX_NG
236 else
237 DBG_PACKAGES += -puuid-runtime-dbg -plibuuid1-dbg -plibblkid1-dbg
238 M4_ARGS+=-UUTIL_LINUX_NG
239 endif
240
241 ifneq ($(strip $(DEB_HOST_MULTIARCH)),)
242 M4_ARGS+=-DDO_MULTIARCH
243 else
244 M4_ARGS+=-UDO_MULTIARCH
245 endif
246
247 ifneq ($(BUILD_E2FSCK_STATIC),no)
248 M4_ARGS+=-DE2FSCK_STATIC
249 else
250 M4_ARGS+=-UE2FSCK_STATIC
251 endif
252
253 ifeq ($(SKIP_UDEB),)
254 INSTALL_UDEB = install-udeb
255 M4_ARGS+=-DUDEB_PKGS
256 else
257 M4_ARGS+=-UUDEB_PKGS
258 endif
259
260 ifeq ($(SKIP_FUSE2FS),)
261 M4_ARGS+=-DFUSE2FS
262 else
263 M4_ARGS+=-UFUSE2FS
264 endif
265
266 FILES_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
270 debian-files: debian/control debian/e2fsprogs.shlibs.local
271 ifeq ($(strip $(DEB_HOST_MULTIARCH)),)
272         for i in $(FILES_FIXUP); do \
273                 sed -e 's;lib/\*/;lib/;' debian/$$i.in > debian/$$i; \
274         done
275 else
276         for i in $(FILES_FIXUP); do cp debian/$$i.in debian/$$i; done
277 endif
278
279 mrproper: clean
280         rm debian/control debian/e2fsprogs.shlibs.local
281
282 debian/control: debian/control.in debian/rules
283         m4 $(M4_ARGS) < debian/control.in | grep -v ^REMOVE_ME$$ > $@
284
285 debian/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}
295 ifeq ($(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)"
303 else
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)"
313 endif
314
315   # specially-built MIPS libs
316 ifneq ($(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)"
334 endif
335
336         mkdir -p ${STAMPSDIR}
337         touch ${CFGSTDSTAMP}
338
339 ${CFGBFSTAMP}:
340         dh_testdir
341         rm -f config.cache
342
343         mkdir -p ${bfbuilddir}
344 ifeq ($(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)"
353 else
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)"
363 endif
364         mkdir -p ${STAMPSDIR}
365         touch ${CFGBFSTAMP}
366
367 build-arch: build
368 build-indep: build
369 build: build-std $(BUILD_BF)
370
371 build-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
378 ifneq ($(BUILD_E2FSCK_STATIC),no)
379         $(MAKE) -C ${stdbuilddir}/e2fsck e2fsck.static
380 endif
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
392 ifneq ($(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
401 endif
402
403         touch ${BUILDSTDSTAMP}
404
405 build-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
414 clean:
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
429 install: 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
434 cleanup:
435         dh_testdir
436         dh_testroot
437         dh_prep
438
439 install-std: DH_OPTIONS=
440 install-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
451 ifneq ($(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
455 endif
456
457 ifeq ($(DEB_BUILD_GNU_SYSTEM), gnu) 
458         ${INSTALL} -m 0644 misc/mke2fs-hurd.conf ${tmpdir}/etc/mke2fs.conf
459 endif
460
461         dh_movefiles
462         test -z "`find ${tmpdir} -type f`"
463
464   # specially-built MIPS libs
465 ifneq ($(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
470 endif
471
472 install-udeb: DH_OPTIONS=
473 install-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
496 ifneq ($(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
502 endif
503
504 binary-indep: 
505   # no arch-independant debs.
506
507 binary-arch: DH_OPTIONS= -a
508 binary-arch: install $(INSTALL_UDEB)
509         dh_testdir
510         dh_testroot
511
512         dh_lintian
513
514   # symlinks to prepare dh_installdocs run
515
516 ifneq ($(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
520 endif
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
530 ifneq ($(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
534 endif
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
540 ifneq ($(UTIL_LINUX_NG),yes)
541         $(INSTALL) -p -m 0644 debian/libblkid.copyright \
542                 ${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION}/copyright
543 endif
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)
576 ifneq ($(BUILD_E2FSCK_STATIC),no)
577         dh_strip $(call dh_strip_args2,e2fsck-static,e2fsprogs)
578 endif
579 ifneq ($(ismips),)
580         dh_strip $(call dh_strip_args,e2fslibs) -Xlib64ext2fs-nopic.a
581 else
582         dh_strip $(call dh_strip_args,e2fslibs)
583 endif
584         dh_strip $(call dh_strip_args,libss${SS_SOVERSION})
585         dh_strip $(call dh_strip_args,libcomerr${COMERR_SOVERSION})
586 ifneq ($(UTIL_LINUX_NG),yes)
587         dh_strip $(call dh_strip_args,libblkid${BLKID_SOVERSION})
588         dh_strip $(call dh_strip_args,libuuid${UUID_SOVERSION})
589 endif
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
605 ifeq ($(SKIP_UDEB),)
606 ifneq ($(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
610 endif
611 endif
612
613         dh_installdeb
614         dh_shlibdeps -l${stdbuilddir}/lib
615         dh_shlibdeps -pe2fsprogs -l${stdbuilddir}/lib \
616                 -u"-Ldebian/e2fsprogs.shlibs.local"
617 ifeq ($(SKIP_UDEB),)
618         dh_shlibdeps -pe2fsprogs-udeb -l${stdbuilddir}/lib \
619                 -u"-Ldebian/e2fsprogs-udeb.shlibs.local"
620 endif
621 ifeq ($(SKIP_FUSE2FS),)
622         dh_shlibdeps -pfuse2fs -l${stdbuilddir}/lib \
623                 -u"-Ldebian/e2fsprogs.shlibs.local"
624 endif
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}'
632 ifneq ($(UTIL_LINUX_NG),yes)
633         DH_OPTIONS= dh_gencontrol -puuid-dev \
634           -u '-v${UUID_VERSION}-${MAIN_VERSION} -VmainBinary=${MAIN_VERSION}'
635 endif
636 ifeq ($(SKIP_UDEB),)
637         dh_gencontrol   -pe2fsprogs-udeb -- -fdebian/files~
638 ifneq ($(UTIL_LINUX_NG),yes)
639         dh_gencontrol   -plibblkid1-udeb -- -fdebian/files~
640         dh_gencontrol   -plibuuid1-udeb -- -fdebian/files~
641 endif
642 endif
643
644 ifeq ($(SKIP_UDEB),)
645         dpkg-distaddfile $(UDEB_NAME) debian-installer $(UDEB_PRIORITY)
646 ifneq ($(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)
649 endif
650 endif
651         dh_md5sums
652         dh_builddeb
653
654 binary: binary-indep binary-arch
655
656 .PHONY: binary binary-arch binary-indep clean checkroot mrproper \
657         debug_flags debian-files
658
659 debug_flags:
660         @echo CFLAGS is $(CFLAGS)
661         @echo LDFLAGS is $(LDFLAGS)
662         @echo CPPFLAGS is $(CPPFLAGS)