summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 24afbabf3371eeaf4ffa8808170d157b9b332b0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#! /usr/bin/make -f

# export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS ?= hardening=+all

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# be paranoid
export LC_ALL ?= C

ifeq ($(DEB_HOST_ARCH_OS), hurd)
SKIP_FUSE2FS=yes
endif

ifeq ($(DEB_HOST_ARCH_OS), linux)
export deb_systemdsystemunitdir = $(shell pkg-config --variable=systemdsystemunitdir systemd | sed s,^/,,)
export deb_udevudevdir = $(shell pkg-config pkg-config --variable=udevdir udev | sed s,^/,,)
endif

ifneq ($(filter pkg.e2fsprogs.no-fuse2fs,$(DEB_BUILD_PROFILES)),)
SKIP_FUSE2FS=yes
endif

COMERR_VERSION ?= $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
SS_VERSION ?= $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)

topdir		?= $(shell pwd)
tmpdir		?= ${topdir}/debian/tmp
udebdir		?= ${topdir}/debian/e2fsprogs-udeb
stdbuilddir	?= ${topdir}/debian/BUILD-STD

INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL) -p -m 0755

ifneq (,$(findstring update-symbols,$(DEB_BUILD_OPTIONS)))
SYMBOL_LIBS := libext2fs libcomerr2 libss2
endif

CFLAGS_SHLIB = $(CFLAGS)
CFLAGS_STLIB = $(CFLAGS)
LDFLAGS_SHLIB = $(LDFLAGS)
LDFLAGS_STATIC = $(filter-out -fPIE -fpie -pie,$(LDFLAGS))

BACKTRACE_CONF_FLAGS ?= $(shell if debian/scripts/test-backtrace ; then echo --disable-backtrace ; fi)

COMMON_CONF_FLAGS = --enable-elf-shlibs --disable-ubsan \
	--disable-addrsan --disable-threadsan --disable-e2initrd-helper \
	--disable-fsck --disable-libblkid --disable-libuuid --disable-uuidd \
	--infodir=/usr/share/info  --enable-symlink-install \
	--with-multiarch=$(DEB_HOST_MULTIARCH) \
	$(BACKTRACE_CONF_FLAGS) ${EXTRA_CONF_FLAGS}

ifneq ($(SKIP_FUSE2FS),)
COMMON_CONF_FLAGS +=  --disable-fuse2fs
endif

ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CC ?= $(DEB_HOST_GNU_TYPE)-gcc
COMMON_CONF_FLAGS += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
endif

%:
	dh $@ -B${stdbuilddir}

override_dh_autoreconf:

override_dh_auto_configure:
	mkdir -p ${stdbuilddir}
	cd ${stdbuilddir} && AWK=/usr/bin/awk \
		../../configure ${COMMON_CONF_FLAGS}

override_dh_auto_build:
	$(MAKE) -C ${stdbuilddir} V=1 all
ifeq (,$(filter pkg.e2fsprogs.no-static,$(DEB_BUILD_PROFILES)))
	$(MAKE) -C ${stdbuilddir}/e2fsck V=1 e2fsck.static
endif
	if ! test -d debian/orig-gmo ; then \
		mkdir debian/orig-gmo ; \
		mv po/*.gmo po/*.po debian/orig-gmo ; \
		cp debian/orig-gmo/*.po po ; \
	fi
	$(MAKE) -C ${stdbuilddir}/po V=1 update-gmo

	$(MAKE) -C ${stdbuilddir}/doc V=1 libext2fs.html
	$(MAKE) -C ${stdbuilddir}/lib/et V=1 com_err.info com_err.html
	cat $(shell /bin/ls -1 ./doc/RelNotes/*.txt | tac) | \
		gzip -9n > ${stdbuilddir}/NEWS.gz

override_dh_auto_clean:
	if test -d debian/orig-gmo ; then \
		rm -f po/*.gmo po/*.po ; \
		mv debian/orig-gmo/* po ; \
		rmdir debian/orig-gmo ; \
	fi
	rm -rf ${stdbuilddir}

override_dh_auto_install:
	mkdir -p ${tmpdir}/sbin
	$(MAKE) -C ${stdbuilddir} V=1 install DESTDIR=${tmpdir} \
		INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true
  # static libs and .h files
	$(MAKE) -C ${stdbuilddir} V=1 install-libs DESTDIR=${tmpdir} LDCONFIG=true

ifeq (,$(filter pkg.e2fsprogs.no-static,$(DEB_BUILD_PROFILES)))
  # statically-linked fsck
	${INSTALL_PROGRAM} ${stdbuilddir}/e2fsck/e2fsck.static ${tmpdir}/sbin
	(cd debian/tmp/usr/share/man/man8 ; cp e2fsck.8 e2fsck.static.8)
endif

ifeq ($(DEB_HOST_ARCH_OS), hurd)
	${INSTALL} -m 0644 misc/mke2fs-hurd.conf ${tmpdir}/etc/mke2fs.conf
endif

override_dh_install:
	dh_install -p e2fsprogs --sourcedir=${stdbuilddir} NEWS.gz \
		usr/share/doc/e2fsprogs
	dh_install
	dh_missing --fail-missing

ifeq (,$(filter noudeb,$(DEB_BUILD_PROFILES)))
override_dh_lintian:
	dh_lintian
	$(INSTALL) -D -p -m644 debian/e2fsprogs-udeb.lintian-overrides \
	    debian/e2fsprogs-udeb/usr/share/lintian/overrides/e2fsprogs-udeb
endif

override_dh_installinfo:
  # HTML docs
	$(INSTALL) -d debian/libext2fs-dev/usr/share/doc/libext2fs2/html-info/
	$(INSTALL) -p -m 0644 ${stdbuilddir}/doc/*.html \
	   debian/libext2fs-dev/usr/share/doc/libext2fs2/html-info/
	$(INSTALL) -d debian/comerr-dev/usr/share/doc/comerr-dev/html-info/
	$(INSTALL) -p -m 0644 ${stdbuilddir}/lib/et/*.html \
	   debian/comerr-dev/usr/share/doc/comerr-dev/html-info/

  # texinfo docs
	mkdir -p debian/comerr-dev/usr/share/doc/comerr-dev
	$(INSTALL) -p -m 0644 ${topdir}/doc/libext2fs.texinfo \
	   debian/libext2fs-dev/usr/share/doc/libext2fs2/libext2fs.texi
	$(INSTALL) -p -m 0644 ${topdir}/lib/et/com_err.texinfo \
	   debian/comerr-dev/usr/share/doc/comerr-dev/com_err.texi

	$(INSTALL) -d debian/comerr-dev/usr/share/doc/comerr-dev/examples
	$(INSTALL) -p -m 0644 lib/ss/ss_err.et \
		${stdbuilddir}/lib/ext2fs/ext2_err.et \
		debian/comerr-dev/usr/share/doc/comerr-dev/examples
	$(INSTALL) -d debian/ss-dev/usr/share/doc/ss-dev/examples
	$(INSTALL) -p -m 0644 debugfs/debug_cmds.ct \
		debian/ss-dev/usr/share/doc/ss-dev/examples

	dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info
	dh_installinfo -plibext2fs-dev ${stdbuilddir}/doc/libext2fs.info

override_dh_makeshlibs:
	for i in $(SYMBOL_LIBS); \
	do \
		echo "Generating symbols for $$i..."; \
		dpkg-gensymbols -p$$i -Pdebian/$$i > debian/$$i.tmp-patch; \
		cat debian/$$i.tmp-patch; \
		patch debian/$$i.symbols < debian/$$i.tmp-patch; \
		/bin/rm debian/$$i.tmp-patch; \
	done
	dh_makeshlibs $(if $(filter noudeb,$(DEB_BUILD_PROFILES)),,--add-udeb=e2fsprogs-udeb)

override_dh_shlibdeps:
	dh_shlibdeps -pe2fsprogs -l${stdbuilddir}/lib \
		-- -Ldebian/e2fsprogs.shlibs.local
ifeq (,$(filter noudeb,$(DEB_BUILD_PROFILES)))
	dh_shlibdeps -pe2fsprogs-udeb -l${stdbuilddir}/lib \
		-- -Ldebian/e2fsprogs-udeb.shlibs.local
endif
ifeq ($(SKIP_FUSE2FS),)
	dh_shlibdeps -pfuse2fs -l${stdbuilddir}/lib \
		-- -Ldebian/e2fsprogs.shlibs.local
endif
	dh_shlibdeps --remaining-packages -l${stdbuilddir}/lib

override_dh_gencontrol:
	dh_gencontrol -pcomerr-dev -- -v${COMERR_VERSION}-${DEB_VERSION} -VmainBinary=${DEB_VERSION}
	dh_gencontrol -pss-dev -- -v${SS_VERSION}-${DEB_VERSION} -VmainBinary=${DEB_VERSION}
	dh_gencontrol --remaining-packages

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	PRINT_FAILED=yes $(MAKE) -C ${stdbuilddir} V=1 check
endif

test_printenv:
	printenv | sort