rules revision 8d54e8f2c5df737d06da20f289d46d0a34c42f48
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 13# These are used for cross-compiling and for saving the configure script 14# from having to guess our platform (since we know it already) 15DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) 16DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) 17DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 18DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) 19 20# find the version for the main package, from changelog file 21MAIN_VERSION = $(shell head -n 1 debian/changelog | cut '-d ' -f 2 | sed 's/[()]//g') 22# find versions for libraries going into their own packages, from their Makefile.in's, 23# and sonames for all libs 24COMERR_VERSION = $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3) 25COMERR_SOVERSION = $(shell grep ELF_SO_VERSION lib/et/Makefile.in | cut '-d ' -f3) 26SS_VERSION = $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3) 27SS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ss/Makefile.in | cut '-d ' -f3) 28UUID_VERSION = $(shell grep ELF_VERSION lib/uuid/Makefile.in | cut '-d ' -f3) 29UUID_SOVERSION = $(shell grep ELF_SO_VERSION lib/uuid/Makefile.in | cut '-d ' -f3) 30BLKID_VERSION = $(shell grep ELF_VERSION lib/blkid/Makefile.in | cut '-d ' -f3) 31BLKID_SOVERSION = $(shell grep ELF_SO_VERSION lib/blkid/Makefile.in | cut '-d ' -f3) 32EXT2FS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ext2fs/Makefile.in | cut '-d ' -f3) 33E2P_SOVERSION = $(shell grep ELF_SO_VERSION lib/e2p/Makefile.in | cut '-d ' -f3) 34 35package=e2fsprogs 36 37topdir=$(shell pwd) 38debdir=${topdir}/debian 39tmpdir=${debdir}/tmp 40udebdir=${debdir}/e2fsprogs-udeb 41blkidudebdir=${debdir}/libblkid1-udeb 42uuidudebdir=${debdir}/libuuid1-udeb 43maindir=${debdir}/e2fsprogs 44stdbuilddir=${debdir}/BUILD-STD 45bfbuilddir=${debdir}/BUILD-BF 46mipsbuilddir=${debdir}/BUILD-MIPS 47mipsbuilddir64=${debdir}/BUILD-MIPS-64 48# docdir=${maindir}/usr/share/doc/${package} 49MANDIR=/usr/share/man 50mandir=${tmpdir}${MANDIR} 51 52UDEB_NAME = $(package)-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb 53UDEB_PRIORITY = $(shell grep '^Package: e2fsprogs-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2) 54 55BLKID_UDEB_NAME = libblkid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb 56BLKID_UDEB_PRIORITY = $(shell grep '^Package: libblkid1-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2) 57 58UUID_UDEB_NAME = libuuid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb 59UUID_UDEB_PRIORITY = $(shell grep '^Package: libuuid1-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2) 60 61STAMPSDIR=debian/stampdir 62CFGSTDSTAMP=${STAMPSDIR}/configure-std-stamp 63CFGBFSTAMP=${STAMPSDIR}/configure-bf-stamp 64BUILDSTDSTAMP=${STAMPSDIR}/build-std-stamp 65BUILDBFSTAMP=${STAMPSDIR}/build-bf-stamp 66 67CCOPTS = -g 68 69INSTALL = install 70INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 0755 71 72ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) 73CCOPTS += -O2 74endif 75ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) 76INSTALL_PROGRAM += -s 77endif 78 79ifeq (${DEB_HOST_ARCH},alpha) 80CCOPTS += -DHAVE_NETINET_IN_H 81else 82CCOPTS += -D__NO_STRING_INLINES 83endif 84 85BF_CCOPTS = -Os -fomit-frame-pointer 86 87COMMON_CONF_FLAGS = \ 88 --enable-elf-shlibs --enable-dynamic-e2fsck \ 89 --infodir=/usr/share/info --enable-fsck 90 91STD_CONF_FLAGS = --with-ccopts="${CCOPTS}" --enable-compression \ 92 --enable-blkid-devmapper 93 94BF_CONF_FLAGS = --with-ccopts="${CCOPTS} ${BF_CCOPTS}" \ 95 --disable-nls --disable-swapfs --disable-imager \ 96 --disable-debugfs --disable-e2initrd-helper 97 98MIPS_NOPIC_CONF_FLAGS = --with-ccopts="${CCOPTS}" \ 99 --disable-nls \ 100 --disable-swapfs --disable-imager \ 101 --disable-resizer # --disable-debugfs 102 103# we can't use those flags at configure time 104MIPS_CFLAGS= -G 0 -fno-pic -mno-abicalls 105MIPS_CFLAGS_64= -mabi=64 -G 0 -fno-pic -mno-abicalls 106 107ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 108ifneq (,$(findstring $(DEB_BUILD_ARCH),mips mipsel)) 109ismips=ismips 110endif 111endif 112 113${CFGSTDSTAMP}: 114 dh_testdir 115 116 # Make sure we don't try to rebuild the configure scripts 117 find . -name configure | xargs touch 118 119 mkdir -p ${stdbuilddir} 120ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 121 cd ${stdbuilddir} && AWK=/usr/bin/awk \ 122 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} 123else 124 cd ${stdbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \ 125 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \ 126 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE) 127endif 128 129 # specially-built MIPS libs 130ifneq ($(ismips),) 131 mkdir -p ${mipsbuilddir} ${mipsbuilddir64} 132 cd ${mipsbuilddir} && AWK=/usr/bin/awk \ 133 ${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS} 134 cd ${mipsbuilddir64} && AWK=/usr/bin/awk \ 135 ${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS} 136endif 137 138 mkdir -p ${STAMPSDIR} 139 touch ${CFGSTDSTAMP} 140 141${CFGBFSTAMP}: 142 dh_testdir 143 rm -f config.cache 144 145 mkdir -p ${bfbuilddir} 146ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 147 cd ${bfbuilddir} && AWK=/usr/bin/awk \ 148 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} 149else 150 cd ${bfbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \ 151 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \ 152 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE) 153endif 154 mkdir -p ${STAMPSDIR} 155 touch ${CFGBFSTAMP} 156 157build: build-std build-bf 158 159build-std: ${BUILDSTDSTAMP} 160${BUILDSTDSTAMP}: ${CFGSTDSTAMP} 161 dh_testdir 162 make -C ${stdbuilddir} all 163 164 ( cd ${stdbuilddir}/doc && \ 165 texi2html -split_chapter ${topdir}/doc/libext2fs.texinfo ) 166 ( cd ${stdbuilddir}/lib/et && make com_err.info && \ 167 texi2html -split_chapter -expandinfo ${topdir}/lib/et/com_err.texinfo ) 168 169 # specially-built MIPS libs 170ifneq ($(ismips),) 171 make -C ${mipsbuilddir}/util 172 make -C ${mipsbuilddir} \ 173 CFLAGS="${CCOPTS} ${MIPS_CFLAGS}" \ 174 LIB_SUBDIRS="lib/et lib/ext2fs" libs 175 make -C ${mipsbuilddir64}/util 176 make -C ${mipsbuilddir64} \ 177 CFLAGS="${CCOPTS} ${MIPS_CFLAGS_64}" \ 178 LIB_SUBDIRS="lib/et lib/ext2fs" libs 179endif 180 181 touch ${BUILDSTDSTAMP} 182 183build-bf: ${BUILDBFSTAMP} 184${BUILDBFSTAMP}: ${CFGBFSTAMP} 185 dh_testdir 186 make -C ${bfbuilddir} libs 187 make -C ${bfbuilddir}/e2fsck all 188 make -C ${bfbuilddir}/misc all 189 touch ${BUILDBFSTAMP} 190 191clean: 192 dh_testdir 193 rm -rf ${STAMPSDIR} 194 -make -C ${stdbuilddir} -i distclean 195 -make -C ${bfbuilddir} -i distclean 196 rm -rf ${stdbuilddir} ${bfbuilddir} ${mipsbuilddir} ${mipsbuilddir64} 197 rm -f doc/libext2fs/*.html lib/et/com_err/*.html debian/*.substvars 198 dh_clean 199 200install: cleanup install-std 201 202# This rule allows to factorize the dh_clean between the 2 install rules 203# This must be launched before install-* (if launching them by hand, for 204# exemple) or results are unpredictable 205cleanup: 206 dh_testdir 207 dh_testroot 208 dh_clean -k 209 210install-std: DH_OPTIONS= 211install-std: build 212 dh_testdir 213 dh_testroot 214 dh_installdirs 215 216 mkdir -p ${tmpdir}/sbin 217 make -C ${stdbuilddir} install DESTDIR=${tmpdir} \ 218 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 219 # static libs and .h files 220 make -C ${stdbuilddir} install-libs DESTDIR=${tmpdir} LDCONFIG=true 221 222 # statically-linked fsck 223 ${INSTALL_PROGRAM} ${stdbuilddir}/e2fsck/e2fsck.static ${tmpdir}/sbin 224 cp ${mandir}/man8/e2fsck.8 ${mandir}/man8/e2fsck.static.8 225 226 ln -s et/com_err.h ${tmpdir}/usr/include 227 228 dh_movefiles 229 test -z `find ${tmpdir} -type f` 230 231 # specially-built MIPS libs 232ifneq ($(ismips),) 233 $(INSTALL) -p -m 0644 ${mipsbuilddir}/lib/libext2fs.a \ 234 ${debdir}/e2fslibs-dev/usr/lib/libext2fs-nopic.a 235 $(INSTALL) -p -m 0644 ${mipsbuilddir64}/lib/libext2fs.a \ 236 ${debdir}/e2fslibs-dev/usr/lib/lib64ext2fs-nopic.a 237endif 238 239install-udeb: DH_OPTIONS= 240install-udeb: build 241 dh_testdir 242 dh_testroot 243 244 make -C ${bfbuilddir} install-shlibs-libs-recursive DESTDIR=${udebdir} \ 245 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 246 make -C ${bfbuilddir}/e2fsck install DESTDIR=${udebdir} \ 247 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 248 make -C ${bfbuilddir}/misc install DESTDIR=${udebdir} \ 249 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 250 make -C ${bfbuilddir}/resize install DESTDIR=${udebdir} \ 251 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 252 253 rm -rf ${udebdir}/usr 254 find ${udebdir}/sbin -type f -a ! -name e2fsck \ 255 -a ! -name mke2fs -a ! -name tune2fs \ 256 -a ! -name resize2fs -a ! -name badblocks -print | xargs rm 257 258 (cd ${udebdir}/sbin; ln -s e2fsck fsck.ext2 ; \ 259 ln -s e2fsck fsck.ext3 ; ln -s mke2fs mkfs.ext2 ; \ 260 ln -s mke2fs mkfs.ext3) 261 262 mkdir -p ${blkidudebdir}/lib 263 mv ${udebdir}/lib/libblkid.* ${blkidudebdir}/lib 264 265 mkdir -p ${uuidudebdir}/lib 266 mv ${udebdir}/lib/libuuid.* ${uuidudebdir}/lib 267 268binary-indep: 269 # no arch-independant debs. 270 271binary-arch: DH_OPTIONS= -a 272binary-arch: install install-udeb 273 dh_testdir 274 dh_testroot 275 276 # lintian overrides 277 for i in $$(cd debian && echo *.lintian-overrides); do \ 278 pkg=$${i%.lintian-overrides} ;\ 279 $(INSTALL) -m 0644 -D -p debian/$$i ${debdir}/$${pkg}/usr/share/lintian/overrides/$${pkg} ;\ 280 done 281 282 # mkinitrd script 283 mkdir -p debian/e2fsprogs/usr/share/initrd-tools/scripts 284 $(INSTALL) -p -o root -g root -m 0755 debian/initrd-tools.e2fsprogs \ 285 debian/e2fsprogs/usr/share/initrd-tools/scripts/e2fsprogs 286 287 # initrd script 288 mkdir -p debian/e2fsprogs/usr/share/e2fsprogs 289 $(INSTALL) -p -o root -g root -m 0755 debian/initrd.ext3-add-journal \ 290 debian/e2fsprogs/usr/share/e2fsprogs/initrd.ext3-add-journal 291 292 293 # symlinks to prepare dh_installdocs run 294 295 mkdir -p ${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION} 296 mkdir -p ${debdir}/libblkid-dev/usr/share/doc 297 ln -sf libblkid${BLKID_SOVERSION} ${debdir}/libblkid-dev/usr/share/doc/libblkid-dev 298 299 mkdir -p ${debdir}/libss${SS_SOVERSION}/usr/share/doc/libss${SS_SOVERSION} 300 mkdir -p ${debdir}/ss-dev/usr/share/doc 301 ln -sf libss${SS_SOVERSION} ${debdir}/ss-dev/usr/share/doc/ss-dev 302 303 mkdir -p ${debdir}/libcomerr${COMERR_SOVERSION}/usr/share/doc/libcomerr${COMERR_SOVERSION} 304 mkdir -p ${debdir}/comerr-dev/usr/share/doc 305 ln -sf libcomerr${COMERR_SOVERSION} ${debdir}/comerr-dev/usr/share/doc/comerr-dev 306 307 mkdir -p ${debdir}/libuuid${UUID_SOVERSION}/usr/share/doc/libuuid${UUID_SOVERSION} 308 mkdir -p ${debdir}/uuid-dev/usr/share/doc 309# ln -sf libuuid${UUID_SOVERSION} ${debdir}/uuid-dev/usr/share/doc/uuid-dev 310 311 mkdir -p ${debdir}/e2fslibs/usr/share/doc/e2fslibs 312 mkdir -p ${debdir}/e2fslibs-dev/usr/share/doc 313 ln -sf e2fslibs ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev 314 315 $(INSTALL) -p -m 0644 debian/libblkid.copyright \ 316 ${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION}/copyright 317 318 dh_installdocs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 319 320 # HTML docs 321 $(INSTALL) -d ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/html-info/ 322 $(INSTALL) -p -m 0644 ${stdbuilddir}/doc/libext2fs/*.html \ 323 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/html-info/ 324 $(INSTALL) -d ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/html-info/ 325 $(INSTALL) -p -m 0644 ${stdbuilddir}/lib/et/com_err/*.html \ 326 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/html-info/ 327 328 # texinfo docs 329 mkdir -p ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION} 330 $(INSTALL) -p -m 0644 ${topdir}/doc/libext2fs.texinfo \ 331 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/libext2fs.texi 332 $(INSTALL) -p -m 0644 ${topdir}/lib/et/com_err.texinfo \ 333 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/com_err.texi 334 335 $(INSTALL) -d ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/examples 336 $(INSTALL) -p -m 0644 lib/ss/ss_err.et \ 337 ${stdbuilddir}/lib/ext2fs/ext2_err.et \ 338 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/examples 339 $(INSTALL) -d ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION}/examples 340 $(INSTALL) -p -m 0644 debugfs/debug_cmds.ct \ 341 ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION}/examples 342 343 $(INSTALL) -d ${debdir}/uuid-dev/usr/share/doc/libuuid${UUID_SOVERSION} 344 if test -f /etc/lsb-release && \ 345 grep -q DISTRIB_ID=Ubuntu /etc/lsb-release; then \ 346 $(INSTALL) -p -m 0644 doc/rfc4122.txt \ 347 ${debdir}/uuid-dev/usr/share/doc/libuuid${UUID_SOVERSION}; \ 348 fi 349 350 dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info 351 dh_installinfo -pe2fslibs-dev ${stdbuilddir}/doc/libext2fs.info 352 353 DH_OPTIONS= dh_installchangelogs -pe2fsprogs \ 354 -plibblkid${BLKID_SOVERSION} -plibcomerr${COMERR_SOVERSION} \ 355 -plibss${SS_SOVERSION} -plibuuid${UUID_SOVERSION} \ 356 -pe2fslibs -puuid-dev -pe2fsck-static 357 358ifneq ($(ismips),) 359 dh_strip -Xlib64ext2fs-nopic.a 360else 361 dh_strip 362endif 363 364 dh_compress 365 dh_fixperms 366 367 dh_makeshlibs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 368 dh_makeshlibs -plibcomerr${COMERR_SOVERSION} \ 369 -V 'libcomerr2 (>= 1.33-3)' 370 echo "udeb: libblkid 1 libblkid1-udeb" >> \ 371 debian/libblkid1/DEBIAN/shlibs 372 echo "udeb: libuuid 1 libuuid1-udeb" >> debian/libuuid1/DEBIAN/shlibs 373 374 dh_installdeb 375 rm debian/e2fsprogs-udeb/DEBIAN/conffiles 376 dh_shlibdeps -l${stdbuilddir}/lib 377 dh_shlibdeps -pe2fsprogs -l${stdbuilddir}/lib \ 378 -u"-Ldebian/e2fsprogs.shlibs.local" 379 dh_shlibdeps -pe2fsprogs-udeb -l${stdbuilddir}/lib \ 380 -u"-Ldebian/e2fsprogs-udeb.shlibs.local" 381 382 dh_gencontrol -Ncomerr-dev -Nss-dev -Nuuid-dev \ 383 -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 384 DH_OPTIONS= dh_gencontrol -pcomerr-dev \ 385 -u '-v${COMERR_VERSION}-${MAIN_VERSION}' 386 DH_OPTIONS= dh_gencontrol -pss-dev \ 387 -u '-v${SS_VERSION}-${MAIN_VERSION}' 388 DH_OPTIONS= dh_gencontrol -puuid-dev \ 389 -u '-v${UUID_VERSION}-${MAIN_VERSION}' 390 391 dh_md5sums -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 392 dh_builddeb -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 393 394 # udeb stuff 395 dh_gencontrol -pe2fsprogs-udeb -- -fdebian/files~ 396 dpkg-distaddfile $(UDEB_NAME) debian-installer $(UDEB_PRIORITY) 397 dh_builddeb -pe2fsprogs-udeb --filename=$(UDEB_NAME) 398 399 dh_gencontrol -plibblkid1-udeb -- -fdebian/files~ 400 dpkg-distaddfile $(BLKID_UDEB_NAME) debian-installer $(BLKID_UDEB_PRIORITY) 401 dh_builddeb -plibblkid1-udeb --filename=$(BLKID_UDEB_NAME) 402 403 dh_gencontrol -plibuuid1-udeb -- -fdebian/files~ 404 dpkg-distaddfile $(UUID_UDEB_NAME) debian-installer $(UUID_UDEB_PRIORITY) 405 dh_builddeb -plibuuid1-udeb --filename=$(UUID_UDEB_NAME) 406 407binary: binary-indep binary-arch 408 409.PHONY: binary binary-arch binary-indep clean checkroot 410