]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - debian/rules
Merge branch 'maint' into next
[thirdparty/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 # be paranoid
11 export LC_ALL=C
12
13 # These are used for cross-compiling and for saving the configure script
14 # from having to guess our platform (since we know it already)
15 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
16 DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
17 DEB_HOST_OS ?= $(shell dpkg-architecture -qDEB_HOST_OS)
18 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
19 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
20
21 # find the version for the main package, from changelog file
22 MAIN_VERSION = $(shell head -n 1 debian/changelog | cut '-d ' -f 2 | sed 's/[()]//g')
23 # find versions for libraries going into their own packages, from their Makefile.in's,
24 # and sonames for all libs
25 COMERR_VERSION = $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
26 COMERR_SOVERSION = $(shell grep ELF_SO_VERSION lib/et/Makefile.in | cut '-d ' -f3)
27 SS_VERSION = $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
28 SS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
29 UUID_VERSION = $(shell grep ELF_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
30 UUID_SOVERSION = $(shell grep ELF_SO_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
31 BLKID_VERSION = $(shell grep ELF_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
32 BLKID_SOVERSION = $(shell grep ELF_SO_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
33 EXT2FS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ext2fs/Makefile.in | cut '-d ' -f3)
34 E2P_SOVERSION = $(shell grep ELF_SO_VERSION lib/e2p/Makefile.in | cut '-d ' -f3)
35
36 package=e2fsprogs
37
38 topdir=$(shell pwd)
39 debdir=${topdir}/debian
40 tmpdir=${debdir}/tmp
41 udebdir=${debdir}/e2fsprogs-udeb
42 blkidudebdir=${debdir}/libblkid1-udeb
43 uuidudebdir=${debdir}/libuuid1-udeb
44 maindir=${debdir}/e2fsprogs
45 stdbuilddir=${debdir}/BUILD-STD
46 bfbuilddir=${debdir}/BUILD-BF
47 mipsbuilddir=${debdir}/BUILD-MIPS
48 mipsbuilddir64=${debdir}/BUILD-MIPS-64
49 # docdir=${maindir}/usr/share/doc/${package}
50 MANDIR=/usr/share/man
51 mandir=${tmpdir}${MANDIR}
52
53 UDEB_NAME = $(package)-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
54 UDEB_PRIORITY = $(shell grep '^Package: e2fsprogs-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2)
55
56 BLKID_UDEB_NAME = libblkid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
57 BLKID_UDEB_PRIORITY = $(shell grep '^Package: libblkid1-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2)
58
59 UUID_UDEB_NAME = libuuid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
60 UUID_UDEB_PRIORITY = $(shell grep '^Package: libuuid1-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2)
61
62 STAMPSDIR=debian/stampdir
63 CFGSTDSTAMP=${STAMPSDIR}/configure-std-stamp
64 CFGBFSTAMP=${STAMPSDIR}/configure-bf-stamp
65 BUILDSTDSTAMP=${STAMPSDIR}/build-std-stamp
66 BUILDBFSTAMP=${STAMPSDIR}/build-bf-stamp
67
68 CCOPTS = -g
69
70 INSTALL = install
71 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 0755
72
73 ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
74 CCOPTS += -O2
75 endif
76 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
77 INSTALL_PROGRAM += -s
78 endif
79
80 ifeq (${DEB_HOST_ARCH},alpha)
81 CCOPTS += -DHAVE_NETINET_IN_H
82 else
83 CCOPTS += -D__NO_STRING_INLINES
84 endif
85
86 ifeq (${DEB_HOST_ARCH_OS},linux)
87 DEVMAPPER = --enable-blkid-devmapper
88 endif
89
90 BF_CCOPTS = -Os -fomit-frame-pointer
91
92 COMMON_CONF_FLAGS = \
93 --enable-elf-shlibs --enable-dynamic-e2fsck \
94 --infodir=/usr/share/info --enable-fsck
95
96 STD_CONF_FLAGS = --with-ccopts="${CCOPTS}" --enable-compression \
97 ${DEVMAPPER}
98
99 BF_CONF_FLAGS = --with-ccopts="${CCOPTS} ${BF_CCOPTS}" \
100 --disable-nls --disable-imager \
101 --disable-debugfs --disable-e2initrd-helper
102
103 MIPS_NOPIC_CONF_FLAGS = --with-ccopts="${CCOPTS}" \
104 --disable-nls --disable-imager --disable-resizer # --disable-debugfs
105
106 # we can't use those flags at configure time
107 MIPS_CFLAGS= -G 0 -fno-pic -mno-abicalls
108 MIPS_CFLAGS_64= -mabi=64 -G 0 -fno-pic -mno-abicalls
109
110 ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
111 ifneq (,$(findstring $(DEB_BUILD_ARCH),mips mipsel))
112 ismips=ismips
113 endif
114 endif
115
116 ${CFGSTDSTAMP}:
117 dh_testdir
118
119 # Make sure we don't try to rebuild the configure scripts
120 find . -name configure | xargs touch
121
122 mkdir -p ${stdbuilddir}
123 ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
124 cd ${stdbuilddir} && AWK=/usr/bin/awk \
125 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS}
126 else
127 cd ${stdbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \
128 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \
129 --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
130 endif
131
132 # specially-built MIPS libs
133 ifneq ($(ismips),)
134 mkdir -p ${mipsbuilddir} ${mipsbuilddir64}
135 cd ${mipsbuilddir} && AWK=/usr/bin/awk \
136 ${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS}
137 cd ${mipsbuilddir64} && AWK=/usr/bin/awk \
138 ${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS}
139 endif
140
141 mkdir -p ${STAMPSDIR}
142 touch ${CFGSTDSTAMP}
143
144 ${CFGBFSTAMP}:
145 dh_testdir
146 rm -f config.cache
147
148 mkdir -p ${bfbuilddir}
149 ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
150 cd ${bfbuilddir} && AWK=/usr/bin/awk \
151 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS}
152 else
153 cd ${bfbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \
154 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \
155 --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
156 endif
157 mkdir -p ${STAMPSDIR}
158 touch ${CFGBFSTAMP}
159
160 build: build-std build-bf
161
162 build-std: ${BUILDSTDSTAMP}
163 ${BUILDSTDSTAMP}: ${CFGSTDSTAMP}
164 dh_testdir
165 make -C ${stdbuilddir} all
166
167 ( cd ${stdbuilddir}/doc && \
168 texi2html -split_chapter ${topdir}/doc/libext2fs.texinfo )
169 ( cd ${stdbuilddir}/lib/et && make com_err.info && \
170 texi2html -split_chapter -expandinfo ${topdir}/lib/et/com_err.texinfo )
171
172 # specially-built MIPS libs
173 ifneq ($(ismips),)
174 make -C ${mipsbuilddir}/util
175 make -C ${mipsbuilddir} \
176 CFLAGS="${CCOPTS} ${MIPS_CFLAGS}" \
177 LIB_SUBDIRS="lib/et lib/ext2fs" libs
178 make -C ${mipsbuilddir64}/util
179 make -C ${mipsbuilddir64} \
180 CFLAGS="${CCOPTS} ${MIPS_CFLAGS_64}" \
181 LIB_SUBDIRS="lib/et lib/ext2fs" libs
182 endif
183
184 touch ${BUILDSTDSTAMP}
185
186 build-bf: ${BUILDBFSTAMP}
187 ${BUILDBFSTAMP}: ${CFGBFSTAMP}
188 dh_testdir
189 make -C ${bfbuilddir} libs
190 make -C ${bfbuilddir}/e2fsck all
191 make -C ${bfbuilddir}/misc all
192 touch ${BUILDBFSTAMP}
193
194 clean:
195 dh_testdir
196 rm -rf ${STAMPSDIR}
197 [ ! -f ${stdbuilddir}/Makefile ] || make -C ${stdbuilddir} distclean
198 [ ! -f ${bfbuilddir}/Makefile ] || make -C ${bfbuilddir} distclean
199 rm -rf ${stdbuilddir} ${bfbuilddir} ${mipsbuilddir} ${mipsbuilddir64}
200 rm -f doc/libext2fs/*.html lib/et/com_err/*.html debian/*.substvars
201 dh_clean
202
203 install: cleanup install-std
204
205 # This rule allows to factorize the dh_clean between the 2 install rules
206 # This must be launched before install-* (if launching them by hand, for
207 # exemple) or results are unpredictable
208 cleanup:
209 dh_testdir
210 dh_testroot
211 dh_clean -k
212
213 install-std: DH_OPTIONS=
214 install-std: build
215 dh_testdir
216 dh_testroot
217 dh_installdirs
218
219 mkdir -p ${tmpdir}/sbin
220 make -C ${stdbuilddir} install DESTDIR=${tmpdir} \
221 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
222 # static libs and .h files
223 make -C ${stdbuilddir} install-libs DESTDIR=${tmpdir} LDCONFIG=true
224
225 # statically-linked fsck
226 ${INSTALL_PROGRAM} ${stdbuilddir}/e2fsck/e2fsck.static ${tmpdir}/sbin
227 cp ${mandir}/man8/e2fsck.8 ${mandir}/man8/e2fsck.static.8
228
229 ln -s et/com_err.h ${tmpdir}/usr/include
230
231 dh_movefiles
232 test -z `find ${tmpdir} -type f`
233
234 # specially-built MIPS libs
235 ifneq ($(ismips),)
236 $(INSTALL) -p -m 0644 ${mipsbuilddir}/lib/libext2fs.a \
237 ${debdir}/e2fslibs-dev/usr/lib/libext2fs-nopic.a
238 $(INSTALL) -p -m 0644 ${mipsbuilddir64}/lib/libext2fs.a \
239 ${debdir}/e2fslibs-dev/usr/lib/lib64ext2fs-nopic.a
240 endif
241
242 install-udeb: DH_OPTIONS=
243 install-udeb: build
244 dh_testdir
245 dh_testroot
246
247 make -C ${bfbuilddir} install-shlibs-libs-recursive DESTDIR=${udebdir} \
248 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
249 make -C ${bfbuilddir}/e2fsck install DESTDIR=${udebdir} \
250 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
251 make -C ${bfbuilddir}/misc install DESTDIR=${udebdir} \
252 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
253 make -C ${bfbuilddir}/resize install DESTDIR=${udebdir} \
254 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
255
256 rm -rf ${udebdir}/usr
257 find ${udebdir}/sbin -type f -a ! -name e2fsck \
258 -a ! -name mke2fs -a ! -name tune2fs \
259 -a ! -name resize2fs -a ! -name badblocks -print | xargs rm
260
261 (cd ${udebdir}/sbin; ln -s e2fsck fsck.ext2 ; \
262 ln -s e2fsck fsck.ext3 ; ln -s mke2fs mkfs.ext2 ; \
263 ln -s mke2fs mkfs.ext3)
264
265 mkdir -p ${blkidudebdir}/lib
266 mv ${udebdir}/lib/libblkid.* ${blkidudebdir}/lib
267
268 mkdir -p ${uuidudebdir}/lib
269 mv ${udebdir}/lib/libuuid.* ${uuidudebdir}/lib
270
271 binary-indep:
272 # no arch-independant debs.
273
274 binary-arch: DH_OPTIONS= -a
275 binary-arch: install install-udeb
276 dh_testdir
277 dh_testroot
278
279 # lintian overrides
280 for i in $$(cd debian && echo *.lintian-overrides); do \
281 pkg=$${i%.lintian-overrides} ;\
282 $(INSTALL) -m 0644 -D -p debian/$$i ${debdir}/$${pkg}/usr/share/lintian/overrides/$${pkg} ;\
283 done
284
285 # mkinitrd script
286 mkdir -p debian/e2fsprogs/usr/share/initrd-tools/scripts
287 $(INSTALL) -p -o root -g root -m 0755 debian/initrd-tools.e2fsprogs \
288 debian/e2fsprogs/usr/share/initrd-tools/scripts/e2fsprogs
289
290 # initrd script
291 mkdir -p debian/e2fsprogs/usr/share/e2fsprogs
292 $(INSTALL) -p -o root -g root -m 0755 debian/initrd.ext3-add-journal \
293 debian/e2fsprogs/usr/share/e2fsprogs/initrd.ext3-add-journal
294
295
296 # symlinks to prepare dh_installdocs run
297
298 mkdir -p ${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION}
299 mkdir -p ${debdir}/libblkid-dev/usr/share/doc
300 ln -sf libblkid${BLKID_SOVERSION} ${debdir}/libblkid-dev/usr/share/doc/libblkid-dev
301
302 mkdir -p ${debdir}/libss${SS_SOVERSION}/usr/share/doc/libss${SS_SOVERSION}
303 mkdir -p ${debdir}/ss-dev/usr/share/doc
304 ln -sf libss${SS_SOVERSION} ${debdir}/ss-dev/usr/share/doc/ss-dev
305
306 mkdir -p ${debdir}/libcomerr${COMERR_SOVERSION}/usr/share/doc/libcomerr${COMERR_SOVERSION}
307 mkdir -p ${debdir}/comerr-dev/usr/share/doc
308 ln -sf libcomerr${COMERR_SOVERSION} ${debdir}/comerr-dev/usr/share/doc/comerr-dev
309
310 mkdir -p ${debdir}/libuuid${UUID_SOVERSION}/usr/share/doc/libuuid${UUID_SOVERSION}
311 mkdir -p ${debdir}/uuid-dev/usr/share/doc
312 # ln -sf libuuid${UUID_SOVERSION} ${debdir}/uuid-dev/usr/share/doc/uuid-dev
313
314 mkdir -p ${debdir}/e2fslibs/usr/share/doc/e2fslibs
315 mkdir -p ${debdir}/e2fslibs-dev/usr/share/doc
316 ln -sf e2fslibs ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev
317
318 $(INSTALL) -p -m 0644 debian/libblkid.copyright \
319 ${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION}/copyright
320
321 dh_installdocs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
322
323 # HTML docs
324 $(INSTALL) -d ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/html-info/
325 $(INSTALL) -p -m 0644 ${stdbuilddir}/doc/libext2fs/*.html \
326 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/html-info/
327 $(INSTALL) -d ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/html-info/
328 $(INSTALL) -p -m 0644 ${stdbuilddir}/lib/et/com_err/*.html \
329 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/html-info/
330
331 # texinfo docs
332 mkdir -p ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}
333 $(INSTALL) -p -m 0644 ${topdir}/doc/libext2fs.texinfo \
334 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/libext2fs.texi
335 $(INSTALL) -p -m 0644 ${topdir}/lib/et/com_err.texinfo \
336 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/com_err.texi
337
338 $(INSTALL) -d ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/examples
339 $(INSTALL) -p -m 0644 lib/ss/ss_err.et \
340 ${stdbuilddir}/lib/ext2fs/ext2_err.et \
341 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/examples
342 $(INSTALL) -d ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION}/examples
343 $(INSTALL) -p -m 0644 debugfs/debug_cmds.ct \
344 ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION}/examples
345
346 $(INSTALL) -d ${debdir}/uuid-dev/usr/share/doc/libuuid${UUID_SOVERSION}
347
348 if test -f /etc/lsb-release && \
349 grep -q DISTRIB_ID=Ubuntu /etc/lsb-release; then \
350 $(INSTALL) -p -m 0644 e2fsck/e2fsck.conf.ubuntu \
351 ${debdir}/e2fsprogs/etc/e2fsck.conf; \
352 fi
353
354 dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info
355 dh_installinfo -pe2fslibs-dev ${stdbuilddir}/doc/libext2fs.info
356
357 DH_OPTIONS= dh_installchangelogs -pe2fsprogs \
358 -plibblkid${BLKID_SOVERSION} -plibcomerr${COMERR_SOVERSION} \
359 -plibss${SS_SOVERSION} -plibuuid${UUID_SOVERSION} \
360 -pe2fslibs -puuid-dev -puuid-runtime -pe2fsck-static
361
362 dh_fixperms
363 ifneq ($(ismips),)
364 dh_strip -Xlib64ext2fs-nopic.a
365 else
366 dh_strip
367 endif
368
369 dh_compress
370
371 dh_makeshlibs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
372 dh_makeshlibs -plibcomerr${COMERR_SOVERSION} \
373 -V 'libcomerr2 (>= 1.33-3)'
374 dh_makeshlibs -plibblkid${BLKID_SOVERSION} -V 'libblkid1 (>= 1.39-1)'
375 echo "udeb: libblkid 1 libblkid1-udeb" >> \
376 debian/libblkid1/DEBIAN/shlibs
377 echo "udeb: libuuid 1 libuuid1-udeb" >> debian/libuuid1/DEBIAN/shlibs
378
379 dh_installdeb
380 rm debian/e2fsprogs-udeb/DEBIAN/conffiles
381 dh_shlibdeps -l${stdbuilddir}/lib
382 dh_shlibdeps -pe2fsprogs -l${stdbuilddir}/lib \
383 -u"-Ldebian/e2fsprogs.shlibs.local"
384 dh_shlibdeps -pe2fsprogs-udeb -l${stdbuilddir}/lib \
385 -u"-Ldebian/e2fsprogs-udeb.shlibs.local"
386
387 dh_gencontrol -Ncomerr-dev -Nss-dev -Nuuid-dev \
388 -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
389 DH_OPTIONS= dh_gencontrol -pcomerr-dev \
390 -u '-v${COMERR_VERSION}-${MAIN_VERSION}'
391 DH_OPTIONS= dh_gencontrol -pss-dev \
392 -u '-v${SS_VERSION}-${MAIN_VERSION}'
393 DH_OPTIONS= dh_gencontrol -puuid-dev \
394 -u '-v${UUID_VERSION}-${MAIN_VERSION}'
395
396 dh_md5sums -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
397 dh_builddeb -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
398
399 # udeb stuff
400 dh_gencontrol -pe2fsprogs-udeb -- -fdebian/files~
401 dpkg-distaddfile $(UDEB_NAME) debian-installer $(UDEB_PRIORITY)
402 dh_builddeb -pe2fsprogs-udeb --filename=$(UDEB_NAME)
403
404 dh_gencontrol -plibblkid1-udeb -- -fdebian/files~
405 dpkg-distaddfile $(BLKID_UDEB_NAME) debian-installer $(BLKID_UDEB_PRIORITY)
406 dh_builddeb -plibblkid1-udeb --filename=$(BLKID_UDEB_NAME)
407
408 dh_gencontrol -plibuuid1-udeb -- -fdebian/files~
409 dpkg-distaddfile $(UUID_UDEB_NAME) debian-installer $(UUID_UDEB_PRIORITY)
410 dh_builddeb -plibuuid1-udeb --filename=$(UUID_UDEB_NAME)
411
412 binary: binary-indep binary-arch
413
414 .PHONY: binary binary-arch binary-indep clean checkroot