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