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