Whamcloud - gitweb
LU-8465 e2fsck: do not change global variables
[tools/e2fsprogs.git] / debian / rules
1 #! /usr/bin/make -f
2
3 # export DH_VERBOSE=1
4
5 export DEB_BUILD_MAINT_OPTIONS ?= hardening=+all
6
7 DPKG_EXPORT_BUILDFLAGS = 1
8 include /usr/share/dpkg/default.mk
9
10 # be paranoid
11 export LC_ALL ?= C
12
13 ifeq ($(DEB_HOST_ARCH_OS), hurd)
14 SKIP_FUSE2FS=yes
15 endif
16
17 ifneq ($(filter pkg.e2fsprogs.no-fuse2fs,$(DEB_BUILD_PROFILES)),)
18 SKIP_FUSE2FS=yes
19 endif
20
21 COMERR_VERSION ?= $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
22 SS_VERSION ?= $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
23
24 topdir          ?= $(shell pwd)
25 tmpdir          ?= ${topdir}/debian/tmp
26 udebdir         ?= ${topdir}/debian/e2fsprogs-udeb
27 stdbuilddir     ?= ${topdir}/debian/BUILD-STD
28
29 INSTALL ?= install
30 INSTALL_PROGRAM ?= $(INSTALL) -p -o root -g root -m 0755
31
32 ifneq (,$(findstring update-symbols,$(DEB_BUILD_OPTIONS)))
33 SYMBOL_LIBS := libext2fs libcomerr2 libss2
34 endif
35
36 CFLAGS_SHLIB = $(CFLAGS)
37 CFLAGS_STLIB = $(CFLAGS)
38 LDFLAGS_SHLIB = $(LDFLAGS)
39 LDFLAGS_STATIC = $(filter-out -fPIE -fpie -pie,$(LDFLAGS))
40
41 BACKTRACE_CONF_FLAGS ?= $(shell if debian/scripts/test-backtrace ; then echo --disable-backtrace ; fi)
42
43 COMMON_CONF_FLAGS = --enable-elf-shlibs --disable-ubsan \
44         --disable-addrsan --disable-threadsan --disable-e2initrd-helper \
45         --disable-fsck --disable-libblkid --disable-libuuid --disable-uuidd \
46         --infodir=/usr/share/info  --enable-symlink-install \
47         --with-multiarch=$(DEB_HOST_MULTIARCH) \
48         $(BACKTRACE_CONF_FLAGS) ${EXTRA_CONF_FLAGS}
49
50 ifneq ($(SKIP_FUSE2FS),)
51 COMMON_CONF_FLAGS +=  --disable-fuse2fs
52 endif
53
54 ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
55 CC ?= $(DEB_HOST_GNU_TYPE)-gcc
56 COMMON_CONF_FLAGS += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
57 endif
58
59 %:
60         dh $@ -B${stdbuilddir}
61
62 override_dh_autoreconf:
63
64 override_dh_auto_configure:
65         mkdir -p ${stdbuilddir}
66         cd ${stdbuilddir} && AWK=/usr/bin/awk \
67                 ../../configure ${COMMON_CONF_FLAGS}
68
69 override_dh_auto_build:
70         $(MAKE) -C ${stdbuilddir} V=1 all
71         $(MAKE) -C ${stdbuilddir}/e2fsck V=1 e2fsck.static
72         if ! test -d debian/orig-gmo ; then \
73                 mkdir debian/orig-gmo ; \
74                 mv po/*.gmo po/*.po debian/orig-gmo ; \
75                 cp debian/orig-gmo/*.po po ; \
76         fi
77         $(MAKE) -C ${stdbuilddir}/po V=1 update-gmo
78
79         $(MAKE) -C ${stdbuilddir}/doc V=1 libext2fs.html
80         $(MAKE) -C ${stdbuilddir}/lib/et V=1 com_err.info com_err.html
81         cat $(shell /bin/ls -1 ./doc/RelNotes/*.txt | tac) | \
82                 gzip -9n > ${stdbuilddir}/NEWS.gz
83
84 override_dh_auto_clean:
85         if test -d debian/orig-gmo ; then \
86                 rm -f po/*.gmo po/*.po ; \
87                 mv debian/orig-gmo/* po ; \
88                 rmdir debian/orig-gmo ; \
89         fi
90         rm -rf ${stdbuilddir}
91
92 override_dh_auto_install:
93         mkdir -p ${tmpdir}/sbin
94         $(MAKE) -C ${stdbuilddir} V=1 install DESTDIR=${tmpdir} \
95                 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
96   # static libs and .h files
97         $(MAKE) -C ${stdbuilddir} V=1 install-libs DESTDIR=${tmpdir} LDCONFIG=true
98
99   # statically-linked fsck
100         ${INSTALL_PROGRAM} ${stdbuilddir}/e2fsck/e2fsck.static ${tmpdir}/sbin
101         (cd debian/tmp/usr/share/man/man8 ; cp e2fsck.8 e2fsck.static.8)
102
103 ifeq ($(DEB_HOST_ARCH_OS), hurd)
104         ${INSTALL} -m 0644 misc/mke2fs-hurd.conf ${tmpdir}/etc/mke2fs.conf
105 endif
106
107 override_dh_install:
108         dh_install -p e2fsprogs --sourcedir=${stdbuilddir} NEWS.gz \
109                 usr/share/doc/e2fsprogs
110         dh_install
111         dh_missing --fail-missing
112
113 override_dh_lintian:
114         dh_lintian
115         $(INSTALL) -D -p -m644 debian/e2fsprogs-udeb.lintian-overrides \
116             debian/e2fsprogs-udeb/usr/share/lintian/overrides/e2fsprogs-udeb
117
118 override_dh_installinfo:
119   # HTML docs
120         $(INSTALL) -d debian/libext2fs-dev/usr/share/doc/libext2fs2/html-info/
121         $(INSTALL) -p -m 0644 ${stdbuilddir}/doc/*.html \
122            debian/libext2fs-dev/usr/share/doc/libext2fs2/html-info/
123         $(INSTALL) -d debian/comerr-dev/usr/share/doc/comerr-dev/html-info/
124         $(INSTALL) -p -m 0644 ${stdbuilddir}/lib/et/*.html \
125            debian/comerr-dev/usr/share/doc/comerr-dev/html-info/
126
127   # texinfo docs
128         mkdir -p debian/comerr-dev/usr/share/doc/comerr-dev
129         $(INSTALL) -p -m 0644 ${topdir}/doc/libext2fs.texinfo \
130            debian/libext2fs-dev/usr/share/doc/libext2fs2/libext2fs.texi
131         $(INSTALL) -p -m 0644 ${topdir}/lib/et/com_err.texinfo \
132            debian/comerr-dev/usr/share/doc/comerr-dev/com_err.texi
133
134         $(INSTALL) -d debian/comerr-dev/usr/share/doc/comerr-dev/examples
135         $(INSTALL) -p -m 0644 lib/ss/ss_err.et \
136                 ${stdbuilddir}/lib/ext2fs/ext2_err.et \
137                 debian/comerr-dev/usr/share/doc/comerr-dev/examples
138         $(INSTALL) -d debian/ss-dev/usr/share/doc/ss-dev/examples
139         $(INSTALL) -p -m 0644 debugfs/debug_cmds.ct \
140                 debian/ss-dev/usr/share/doc/ss-dev/examples
141
142         dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info
143         dh_installinfo -plibext2fs-dev ${stdbuilddir}/doc/libext2fs.info
144
145 override_dh_makeshlibs:
146         for i in $(SYMBOL_LIBS); \
147         do \
148                 echo "Generating symbols for $$i..."; \
149                 dpkg-gensymbols -p$$i -Pdebian/$$i > debian/$$i.tmp-patch; \
150                 cat debian/$$i.tmp-patch; \
151                 patch debian/$$i.symbols < debian/$$i.tmp-patch; \
152                 /bin/rm debian/$$i.tmp-patch; \
153         done
154         dh_makeshlibs --add-udeb=e2fsprogs-udeb
155
156 override_dh_shlibdeps:
157         dh_shlibdeps -pe2fsprogs -l${stdbuilddir}/lib \
158                 -- -Ldebian/e2fsprogs.shlibs.local
159         dh_shlibdeps -pe2fsprogs-udeb -l${stdbuilddir}/lib \
160                 -- -Ldebian/e2fsprogs-udeb.shlibs.local
161 ifeq ($(SKIP_FUSE2FS),)
162         dh_shlibdeps -pfuse2fs -l${stdbuilddir}/lib \
163                 -- -Ldebian/e2fsprogs.shlibs.local
164 endif
165         dh_shlibdeps --remaining-packages -l${stdbuilddir}/lib
166
167 override_dh_gencontrol:
168         dh_gencontrol -pcomerr-dev -- -v${COMERR_VERSION}-${DEB_VERSION} -VmainBinary=${DEB_VERSION}
169         dh_gencontrol -pss-dev -- -v${SS_VERSION}-${DEB_VERSION} -VmainBinary=${DEB_VERSION}
170         dh_gencontrol --remaining-packages
171
172 override_dh_auto_test:
173 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
174         $(MAKE) -C ${stdbuilddir} V=1 check
175 endif
176
177 test_printenv:
178         printenv | sort