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