rules revision 2a4c77bc1d64585d7c00251c2b3ba2f7cb25094e
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 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 have always just 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, 31# and sonames for all libs 32COMERR_VERSION = $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3) 33COMERR_SOVERSION = $(shell grep ELF_SO_VERSION lib/et/Makefile.in | cut '-d ' -f3) 34SS_VERSION = $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3) 35SS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ss/Makefile.in | cut '-d ' -f3) 36UUID_VERSION = $(shell grep ELF_VERSION lib/uuid/Makefile.in | cut '-d ' -f3) 37UUID_SOVERSION = $(shell grep ELF_SO_VERSION lib/uuid/Makefile.in | cut '-d ' -f3) 38EXT2FS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ext2fs/Makefile.in | cut '-d ' -f3) 39E2P_SOVERSION = $(shell grep ELF_SO_VERSION lib/e2p/Makefile.in | cut '-d ' -f3) 40 41package=e2fsprogs 42 43topdir=$(shell pwd) 44debdir=${topdir}/debian 45tmpdir=${debdir}/tmp 46bfdir=${debdir}/e2fsprogs-bf 47maindir=${debdir}/e2fsprogs 48stdbuilddir=${debdir}/BUILD-STD 49bfbuilddir=${debdir}/BUILD-BF 50mipsbuilddir=${debdir}/BUILD-MIPS 51# docdir=${maindir}/usr/share/doc/${package} 52MANDIR=/usr/share/man 53mandir=${tmpdir}${MANDIR} 54 55SUBPACKAGES_DIRS = tmp e2fslibs-dev comerr-dev ss-dev 56 57STAMPSDIR=debian/stampdir 58CFGSTDSTAMP=${STAMPSDIR}/configure-std-stamp 59CFGBFSTAMP=${STAMPSDIR}/configure-bf-stamp 60BUILDSTDSTAMP=${STAMPSDIR}/build-std-stamp 61BUILDBFSTAMP=${STAMPSDIR}/build-bf-stamp 62 63CCOPTS = -O2 -fsigned-char 64LIBC-DEV = libc6-dev 65 66INSTALL = install 67INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755 68 69ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) 70CCOPTS += -g -O1 71endif 72ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) 73INSTALL_PROGRAM += -s 74endif 75 76ifeq (${DEB_HOST_ARCH},alpha) 77CCOPTS += -DHAVE_NETINET_IN_H 78LIBC-DEV = libc6.1-dev 79else 80CCOPTS += -D__NO_STRING_INLINES 81endif 82 83BF_CCOPTS = -Os -fomit-frame-pointer 84 85COMMON_CONF_FLAGS = \ 86 --enable-elf-shlibs --enable-dynamic-e2fsck \ 87 --enable-nls \ 88 --infodir=/usr/share/info 89 90STD_CONF_FLAGS = --with-ccopts="${CCOPTS}" --enable-compression 91 92BF_CONF_FLAGS = --with-ccopts="${CCOPTS} ${BF_CCOPTS}" \ 93 --disable-swapfs --disable-imager \ 94 --disable-resizer --disable-debugfs 95 96MIPS_NOPIC_CONF_FLAGS = --with-ccopts="${CCOPTS}" \ 97 --disable-nls \ 98 --disable-swapfs --disable-imager \ 99 --disable-resizer --disable-debugfs 100# we can't use those flags at configure time 101MIPS_CFLAGS= -G 0 -fno-pic -mno-abicalls 102 103ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 104ifneq (,$(findstring $(DEB_BUILD_ARCH),mips mipsel)) 105ismips=ismips 106endif 107endif 108 109${CFGSTDSTAMP}: 110 dh_testdir 111 112 mkdir -p ${stdbuilddir} 113ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 114 cd ${stdbuilddir} && \ 115 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} 116else 117 cd ${stdbuilddir} && CC="${DEB_HOST_GNU_TYPE}-gcc" \ 118 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \ 119 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE) 120endif 121 122 # specially-built MIPS lib 123 if [ ismips = "${ismips}" ]; then \ 124 mkdir -p ${mipsbuilddir} ; \ 125 cd ${mipsbuilddir} && \ 126 ${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS} ; \ 127 fi 128 129 mkdir -p ${STAMPSDIR} 130 touch ${CFGSTDSTAMP} 131 132${CFGBFSTAMP}: 133 dh_testdir 134 rm -f config.cache 135 136 mkdir -p ${bfbuilddir} 137ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 138 cd ${bfbuilddir} && \ 139 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} 140else 141 cd ${bfbuilddir} && CC="${DEB_HOST_GNU_TYPE}-gcc" \ 142 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \ 143 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE) 144endif 145 mkdir -p ${STAMPSDIR} 146 touch ${CFGBFSTAMP} 147 148build: build-std build-bf 149 150build-std: ${BUILDSTDSTAMP} 151${BUILDSTDSTAMP}: ${CFGSTDSTAMP} 152 dh_testdir 153 make -C ${stdbuilddir} all 154 155 ( cd ${stdbuilddir}/doc && \ 156 texi2html -split_chapter ${topdir}/doc/libext2fs.texinfo ) 157 ( cd ${stdbuilddir}/lib/et && make com_err.info && \ 158 texi2html -split_chapter -expandinfo ${topdir}/lib/et/com_err.texinfo ) 159 160 # specially-built MIPS lib 161 if [ ismips = "${ismips}" ]; then \ 162 make -C ${mipsbuilddir}/util ; \ 163 make -C ${mipsbuilddir} libs \ 164 CFLAGS="${CCOPTS} ${MIPS_CFLAGS}" \ 165 LIB_SUBDIRS="lib/et lib/ext2fs" ; \ 166 fi 167 168 touch ${BUILDSTDSTAMP} 169 170build-bf: ${BUILDBFSTAMP} 171${BUILDBFSTAMP}: ${CFGBFSTAMP} 172 dh_testdir 173 make -C ${bfbuilddir} all 174 touch ${BUILDBFSTAMP} 175 176clean: 177 dh_testdir 178 rm -rf ${STAMPSDIR} 179 -make -C ${stdbuilddir} -i distclean 180 -make -C ${bfbuilddir} -i distclean 181 rm -rf ${stdbuilddir} ${bfbuilddir} ${mipsbuilddir} 182 rm -f doc/libext2fs_*.html lib/et/com_err_*.html debian/*.substvars 183 dh_clean 184 185install: cleanup install-std install-bf 186 187# This rule allows to factorize the dh_clean between the 2 install rules 188# This must be launched before install-* (if launching them by hand, for 189# exemple) or results are unpredictable 190cleanup: 191 dh_testdir 192 dh_testroot 193 dh_clean -k 194 195install-std: DH_OPTIONS= 196install-std: build 197 dh_testdir 198 dh_testroot 199 dh_installdirs 200 201 mkdir -p ${tmpdir}/sbin 202 make -C ${stdbuilddir} install DESTDIR=${tmpdir} \ 203 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 204 # static libs and .h files 205 make -C ${stdbuilddir} install-libs DESTDIR=${tmpdir} LDCONFIG=true 206 207 # remove FSIM for now. 208 rm ${tmpdir}/lib/evms/libe2fsim.1.1.1.so 209 210 # statically-linked fsck 211 ${INSTALL_PROGRAM} ${stdbuilddir}/e2fsck/e2fsck.static ${tmpdir}/sbin 212 ln -s e2fsck.8.gz ${mandir}/man8/e2fsck.static.8.gz 213 214 dh_movefiles 215 test -z `find ${tmpdir} -type f` 216 217 # specially-built MIPS lib 218 if [ ismips = "${ismips}" ]; then \ 219 cp ${mipsbuilddir}/lib/libext2fs.a \ 220 ${debdir}/e2fslibs-dev/usr/lib/libext2fs-nopic.a ; \ 221 fi 222 223install-bf: DH_OPTIONS= 224install-bf: build 225 dh_testdir 226 dh_testroot 227 dh_installdirs 228 229 mkdir -p ${bfdir}/sbin 230 make -C ${bfbuilddir} install DESTDIR=${bfdir} \ 231 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 232 rm -rf ${bfdir}/usr/share ${bfdir}/usr/lib 233 cd ${bfdir}/sbin && rm -f e2label 234 cd ${bfdir}/usr/bin && rm -f uuidgen 235 236 # remove FSIM for now. 237 rm ${bfdir}/lib/evms/libe2fsim.1.1.1.so 238 239 240binary-indep: 241 # no arch-independant debs. 242 243binary-arch: DH_OPTIONS= -a 244binary-arch: install 245 dh_testdir 246 dh_testroot 247 248 # remove obsolete maint-scripts provided by 1.26 upstream 249 cd debian && rm -f comerr-dev.postinst e2fslibs-dev.postinst \ 250 e2fsprogs.postinst e2fsprogs.shlibs e2fsprogs.shlibs.in 251 252 # lintian overrides 253 for i in $$(cd debian && echo *.lintian-overrides); do \ 254 pkg=$${i%.lintian-overrides} ;\ 255 install -m644 -D -p debian/$$i ${debdir}/$${pkg}/usr/share/lintian/overrides/$${pkg} ;\ 256 done 257 258 # mkinitrd script 259 dh_install -p e2fsprogs debian/e2fsprogs.mkinitrd \ 260 /etc/mkinitrd/scripts/e2fsprogs 261 chmod +x ${debdir}/e2fsprogs/etc/mkinitrd/scripts/* 262 263 # symlinks to prepare dh_installdocs run 264 mkdir -p ${debdir}/e2fsck-static/usr/share/doc/ 265 ln -sf e2fsprogs ${debdir}/e2fsck-static/usr/share/doc/e2fsck-static 266 267 mkdir -p ${debdir}/e2fslibs-dev/usr/share/doc/e2fsprogs 268 ln -sf e2fsprogs ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev 269 270 mkdir -p ${debdir}/uuid-dev/usr/share/doc/e2fsprogs 271 ln -sf e2fsprogs ${debdir}/uuid-dev/usr/share/doc/uuid-dev 272 273 # comerr and ss have their own copyright notices 274 mkdir -p ${maindir}/usr/share/doc/libcomerr${COMERR_SOVERSION} 275 mkdir -p ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION} 276 ln -sf libcomerr${COMERR_SOVERSION} ${debdir}/comerr-dev/usr/share/doc/comerr-dev 277 278 mkdir -p ${maindir}/usr/share/doc/libss${SS_SOVERSION} 279 mkdir -p ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION} 280 ln -sf libss${SS_SOVERSION} ${debdir}/ss-dev/usr/share/doc/ss-dev 281 282 for i in libcomerr${COMERR_SOVERSION} libss${SS_SOVERSION}; do \ 283 install -m 644 debian/$$i.copyright \ 284 ${maindir}/usr/share/doc/$$i/copyright ; \ 285 done 286 287 dh_installdocs 288 289 install -m 644 debian/e2fsprogs.copyright \ 290 ${bfdir}/usr/share/doc/e2fsprogs-bf/copyright 291 292 # HTML docs 293 install -d ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/html-info/ 294 install -p ${stdbuilddir}/doc/libext2fs_*.html \ 295 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/html-info/ 296 install -d ${debdir}/comerr-dev/usr/share/doc/comerr-dev/html-info/ 297 install -p ${stdbuilddir}/lib/et/com_err_*.html \ 298 ${debdir}/comerr-dev/usr/share/doc/comerr-dev/html-info/ 299 300 # texinfo docs 301 install -p ${topdir}/doc/libext2fs.texinfo \ 302 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/libext2fs.texi 303 install -p ${topdir}/lib/et/com_err.texinfo \ 304 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/com_err.texi 305 306 dh_installexamples 307 308 dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info 309 dh_installinfo -pe2fslibs-dev ${stdbuilddir}/doc/libext2fs.info 310 311 dh_undocumented 312 313 DH_OPTIONS= dh_installchangelogs -pe2fsprogs -pe2fsprogs-bf ChangeLog 314 315 for i in libcomerr${COMERR_SOVERSION} libss${SS_SOVERSION} ; do \ 316 mkdir -p ${maindir}/usr/share/doc/$$i ; \ 317 ln -s ../e2fsprogs/changelog.Debian.gz ${maindir}/usr/share/doc/$$i/ ; \ 318 ln -s ../e2fsprogs/changelog.gz ${maindir}/usr/share/doc/$$i/ ; \ 319 done 320 321 dh_strip 322 323 dh_compress 324 dh_fixperms 325 326 echo "libcdev:Depends=${LIBC-DEV}" > debian/comerr-dev.substvars 327 echo "libcdev:Depends=${LIBC-DEV}" > debian/ss-dev.substvars 328 echo "libcdev:Depends=${LIBC-DEV}" > debian/uuid-dev.substvars 329 echo "libcdev:Depends=${LIBC-DEV}" > debian/e2fslibs-dev.substvars 330 331# Call this mostly to get the maintainer-script snippets 332 dh_makeshlibs -pe2fsprogs 333# We overwrite the shlibs by hand because of virtual packages used 334 : > debian/e2fsprogs/DEBIAN/shlibs 335 echo "libext2fs ${EXT2FS_SOVERSION} libext2fs${EXT2FS_SOVERSION}" \ 336 >> debian/e2fsprogs/DEBIAN/shlibs 337 echo "libe2p ${E2P_SOVERSION} libe2p${E2P_SOVERSION}" \ 338 >> debian/e2fsprogs/DEBIAN/shlibs 339 echo "libuuid ${UUID_SOVERSION} libuuid${UUID_SOVERSION}" \ 340 >> debian/e2fsprogs/DEBIAN/shlibs 341 echo "libcom_err ${COMERR_SOVERSION} libcomerr${COMERR_SOVERSION}" \ 342 >> debian/e2fsprogs/DEBIAN/shlibs 343 echo "libss ${SS_SOVERSION} libss${SS_SOVERSION}" \ 344 >> debian/e2fsprogs/DEBIAN/shlibs 345 346 dh_installdeb 347 dh_shlibdeps -l${stdbuilddir}/lib 348 349 dh_gencontrol -Ncomerr-dev -Nss-dev -Nuuid-dev 350 DH_OPTIONS= dh_gencontrol -pcomerr-dev \ 351 -u '-v${COMERR_VERSION}-${MAIN_VERSION}' 352 DH_OPTIONS= dh_gencontrol -pss-dev \ 353 -u '-v${SS_VERSION}-${MAIN_VERSION}' 354 DH_OPTIONS= dh_gencontrol -puuid-dev \ 355 -u '-v${UUID_VERSION}-${MAIN_VERSION}' 356 357 dh_md5sums 358 dh_builddeb 359 360binary: binary-indep binary-arch 361 362.PHONY: binary binary-arch binary-indep clean checkroot 363