blob: 864fb31cd8f6bca707775f72063ae6995c30bc85 [file] [log] [blame]
Theodore Ts'o4d8f08f2001-05-09 04:51:07 +00001#! /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
13DEB_BUILD_ARCH := $(shell dpkg --print-architecture)
14DEB_BUILD_GNU_TYPE := $(shell ./config.guess)
15ifndef DEB_HOST_ARCH
16 DEB_HOST_ARCH := ${DEB_BUILD_ARCH}
17endif
18DEB_HOST_GNU_CPU := $(patsubst hurd-%,%,$(DEB_HOST_ARCH))
19ifeq ($(filter-out hurd-%,${DEB_HOST_ARCH}),)
20 DEB_HOST_GNU_SYSTEM := gnu
21else
22# FIXME: we won't always have only Hurd and Linux
23 DEB_HOST_GNU_SYSTEM := linux
24endif
25DEB_HOST_GNU_TYPE := ${DEB_HOST_GNU_CPU}-${DEB_HOST_GNU_SYSTEM}
26
27
28# find the version for the main package, from changelog file
29MAIN_VERSION = $(shell head -1 debian/changelog | cut '-d ' -f 2 | sed 's/[()]//g')
30# find versions for libraries going into their own packages, from their Makefile.in's
31COMERR_VERSION = $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
32COMERR_MAJOR = $(word 1,$(subst ., ,${COMERR_VERSION}))
33SS_VERSION = $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
34SS_MAJOR = $(word 1,$(subst ., ,${SS_VERSION}))
35UUID_VERSION = $(shell grep ELF_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
36UUID_MAJOR = $(word 1,$(subst ., ,${UUID_VERSION}))
37
38package=e2fsprogs
39
40topdir=$(shell pwd)
41debdir=${topdir}/debian
42maindir=${debdir}/tmp
43builddir=${debdir}/BUILD
44docdir=${maindir}/usr/share/doc/${package}
45MANDIR=/usr/share/man
46mandir=${maindir}${MANDIR}
47
48SUBPACKAGES_DIRS = tmp e2fslibs-dev comerr-dev ss-dev
49
50installdoc = install -m 644
51installbin = install -m 755
52
53CCOPTS = -g -O2 -fsigned-char
54LIBC-DEV = libc6-dev
55
56ifeq (${DEB_HOST_ARCH},alpha)
57CCOPTS += -DHAVE_NETINET_IN_H
58LIBC-DEV = libc6.1-dev
59else
60CCOPTS += -D__NO_STRING_INLINES
61endif
62
63build: build-stamp
64build-stamp: configure-stamp
65 dh_testdir
66 make -C ${builddir}
67 ( cd ${builddir}/doc && \
68 texi2html -split_chapter ${topdir}/doc/libext2fs.texinfo )
69 ( cd ${builddir}/lib/et && make com_err.info && \
70 texi2html -split_chapter -expandinfo ${topdir}/lib/et/com_err.texinfo )
71 touch build-stamp
72
73configure-stamp:
74 dh_testdir
75 mkdir -p ${builddir}
76ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
77 cd ${builddir} && CFLAGS="${CFLAGS}" \
78 ${topdir}/configure --with-ccopts="${CCOPTS}" \
79 --enable-elf-shlibs --enable-dynamic-e2fsck \
80 --enable-nls --enable-compression \
81 --mandir=${MANDIR} --infodir=/usr/share/info
82else
83 cd ${builddir} && CFLAGS="${CFLAGS}" CC="${DEB_HOST_GNU_TYPE}-gcc" \
84 ${topdir}/configure --with-ccopts="${CCOPTS}" \
85 --enable-elf-shlibs --enable-dynamic-e2fsck \
86 --enable-nls --enable-compression \
87 --mandir=${MANDIR} --infodir=/usr/share/info \
88 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE)
89endif
90 touch configure-stamp
91
92clean:
93 dh_testdir
94 rm -f build-stamp configure-stamp install
95 -make -C ${builddir} -i distclean
96 rm -rf ${builddir}
97 rm -f doc/libext2fs_*.html lib/et/com_err_*.html
98 dh_clean
99
100binary-indep: build
101 # no arch-independant debs.
102
103binary-arch: build
104 dh_testversion 0.56 # == 0.53 + fixes
105 dh_testdir -a
106 dh_testroot -a
107 dh_clean -a
108 dh_installdirs -a
109
110 mkdir -p ${maindir}/sbin
111 make -C ${builddir} install DESTDIR=${maindir}
112 # static libs and .h files
113 make -C ${builddir} install-libs DESTDIR=${maindir}
114
115# correct locations
116 (cd ${maindir}/sbin && mv debugfs ../usr/sbin/)
117 (cd ${maindir}/sbin && mv e2label ../usr/sbin/)
118
119# docs
120 # fully handled by debhelper
121 rm -rf ${maindir}/usr/share/info
122
123 mkdir -p ${debdir}/e2fslibs-dev/usr/share/doc/e2fsprogs
124 ln -sf e2fsprogs ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev
125
126 mkdir -p ${maindir}/usr/share/doc/libcomerr${COMERR_MAJOR}
127 mkdir -p ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_MAJOR}
128 ln -sf libcomerr${COMERR_MAJOR} ${debdir}/comerr-dev/usr/share/doc/comerr-dev
129
130 mkdir -p ${maindir}/usr/share/doc/libss${SS_MAJOR}
131 mkdir -p ${debdir}/ss-dev/usr/share/doc/libss${SS_MAJOR}
132 ln -sf libss${SS_MAJOR} ${debdir}/ss-dev/usr/share/doc/ss-dev
133
134 mkdir -p ${debdir}/uuid-dev/usr/share/doc/e2fsprogs
135 ln -sf e2fsprogs ${debdir}/uuid-dev/usr/share/doc/uuid-dev
136
137 dh_installdocs -a
138
139 for i in libcomerr${COMERR_MAJOR} libss${SS_MAJOR}; do \
140 install -m 644 debian/$$i.copyright ${maindir}/usr/share/doc/$$i/copyright ;\
141 done
142
143 # HTML docs
144 install -d ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/html-info/
145 install -p ${builddir}/doc/libext2fs_*.html \
146 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/html-info/
147 install -d ${debdir}/comerr-dev/usr/share/doc/comerr-dev/html-info/
148 install -p ${builddir}/lib/et/com_err_*.html \
149 ${debdir}/comerr-dev/usr/share/doc/comerr-dev/html-info/
150
151 # texinfo docs
152 install -p ${topdir}/doc/libext2fs.texinfo \
153 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/libext2fs.texi
154 install -p ${topdir}/lib/et/com_err.texinfo \
155 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_MAJOR}/com_err.texi
156
157 # info docs
158# dh_installinfo -pcomerr-dev ${builddir}/lib/et/com_err.info
159 dh_installinfo -pe2fslibs-dev ${builddir}/doc/libext2fs.info
160
161 # examples
162 dh_installexamples -a
163
164 # dh_installmanpages still makes a mess as of 0.54 (see below dh_movefiles)
165 ln -s e2fsck.8 ${mandir}/man8/fsck.ext2.8
166 ln -s mke2fs.8 ${mandir}/man8/mkfs.ext2.8
167
168 dh_movefiles -a
169 # cleanup empty dirs
170 cd ${maindir}/usr/include/ && rmdir * && cd .. && rmdir include/
171 cd ${maindir}/usr/share/ && rmdir et ss && cd man && rmdir man3
172 cd ${maindir}/usr && rmdir lib
173
174 # broken + useless in 0.52
175 # dh_installmanpages -a
176
177 dh_undocumented -a
178
179 dh_installchangelogs -pe2fsprogs ChangeLog
180 for i in libcomerr${COMERR_MAJOR} libss${SS_MAJOR}; do \
181 ln -s ../e2fsprogs/changelog.Debian.gz ${maindir}/usr/share/doc/$$i/ ;\
182 ln -s ../e2fsprogs/changelog.gz ${maindir}/usr/share/doc/$$i/ ;\
183 done
184
185 dh_strip -a
186 dh_compress -a
187 dh_fixperms -a
188
189 echo "libcdev:Depends=${LIBC-DEV}" >> debian/comerr-dev.substvars
190 echo "libcdev:Depends=${LIBC-DEV}" >> debian/ss-dev.substvars
191 echo "libcdev:Depends=${LIBC-DEV}" >> debian/uuid-dev.substvars
192 echo "libcdev:Depends=${LIBC-DEV}" >> debian/e2fslibs-dev.substvars
193
194 dh_installdeb -a
195 LD_LIBRARY_PATH=${builddir}/lib:/lib:/usr/lib \
196 dh_shlibdeps -a
197 dh_gencontrol -pe2fsprogs -pe2fslibs-dev
198 dh_gencontrol -pcomerr-dev \
199 -u '-v${COMERR_VERSION}-${MAIN_VERSION}'
200 dh_gencontrol -pss-dev \
201 -u '-v${SS_VERSION}-${MAIN_VERSION}'
202 dh_gencontrol -puuid-dev \
203 -u '-v${UUID_VERSION}-${MAIN_VERSION}'
204# We do this one by hand
205# dh_makeshlibs -a
206 dh_md5sums -a
207 dh_builddeb -a
208
209binary: binary-indep binary-arch
210
211.PHONY: binary binary-arch binary-indep clean checkroot