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