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