rules revision 8c5829fb8e7a59d4bf1ef82f65301658da7b2a3b
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 47# docdir=${maindir}/usr/share/doc/${package} 48MANDIR=/usr/share/man 49mandir=${tmpdir}${MANDIR} 50 51UDEB_NAME = $(package)-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb 52UDEB_PRIORITY = $(shell grep '^Package: e2fsprogs-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2) 53 54BLKID_UDEB_NAME = libblkid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb 55BLKID_UDEB_PRIORITY = $(shell grep '^Package: libblkid1-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2) 56 57UUID_UDEB_NAME = libuuid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb 58UUID_UDEB_PRIORITY = $(shell grep '^Package: libuuid1-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2) 59 60STAMPSDIR=debian/stampdir 61CFGSTDSTAMP=${STAMPSDIR}/configure-std-stamp 62CFGBFSTAMP=${STAMPSDIR}/configure-bf-stamp 63BUILDSTDSTAMP=${STAMPSDIR}/build-std-stamp 64BUILDBFSTAMP=${STAMPSDIR}/build-bf-stamp 65 66CCOPTS = -g -fsigned-char 67 68INSTALL = install 69INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755 70 71ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) 72CCOPTS += -O2 73endif 74ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) 75INSTALL_PROGRAM += -s 76endif 77 78ifeq (${DEB_HOST_ARCH},alpha) 79CCOPTS += -DHAVE_NETINET_IN_H 80else 81CCOPTS += -D__NO_STRING_INLINES 82endif 83 84BF_CCOPTS = -Os -fomit-frame-pointer 85 86COMMON_CONF_FLAGS = \ 87 --enable-elf-shlibs --enable-dynamic-e2fsck \ 88 --infodir=/usr/share/info --enable-fsck 89 90STD_CONF_FLAGS = --with-ccopts="${CCOPTS}" --enable-compression 91 92BF_CONF_FLAGS = --with-ccopts="${CCOPTS} ${BF_CCOPTS}" \ 93 --disable-nls --disable-swapfs --disable-imager \ 94 --disable-resizer --disable-debugfs --disable-e2initrd-helper 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 # Make sure we don't try to rebuild the configure scripts 113 find . -name configure | xargs touch 114 115 mkdir -p ${stdbuilddir} 116ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 117 cd ${stdbuilddir} && AWK=/usr/bin/awk \ 118 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} 119else 120 cd ${stdbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \ 121 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \ 122 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE) 123endif 124 125 # specially-built MIPS lib 126 if [ ismips = "${ismips}" ]; then \ 127 mkdir -p ${mipsbuilddir} ; \ 128 cd ${mipsbuilddir} && AWK=/usr/bin/awk \ 129 ${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS} ; \ 130 fi 131 132 mkdir -p ${STAMPSDIR} 133 touch ${CFGSTDSTAMP} 134 135${CFGBFSTAMP}: 136 dh_testdir 137 rm -f config.cache 138 139 mkdir -p ${bfbuilddir} 140ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 141 cd ${bfbuilddir} && AWK=/usr/bin/awk \ 142 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} 143else 144 cd ${bfbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \ 145 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \ 146 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE) 147endif 148 mkdir -p ${STAMPSDIR} 149 touch ${CFGBFSTAMP} 150 151build: build-std build-bf 152 153build-std: ${BUILDSTDSTAMP} 154${BUILDSTDSTAMP}: ${CFGSTDSTAMP} 155 dh_testdir 156 make -C ${stdbuilddir} all 157 158 ( cd ${stdbuilddir}/doc && \ 159 texi2html -split_chapter ${topdir}/doc/libext2fs.texinfo ) 160 ( cd ${stdbuilddir}/lib/et && make com_err.info && \ 161 texi2html -split_chapter -expandinfo ${topdir}/lib/et/com_err.texinfo ) 162 163 # specially-built MIPS lib 164 if [ ismips = "${ismips}" ]; then \ 165 make -C ${mipsbuilddir}/util ; \ 166 make -C ${mipsbuilddir} libs \ 167 CFLAGS="${CCOPTS} ${MIPS_CFLAGS}" \ 168 LIB_SUBDIRS="lib/et lib/ext2fs" ; \ 169 fi 170 171 touch ${BUILDSTDSTAMP} 172 173build-bf: ${BUILDBFSTAMP} 174${BUILDBFSTAMP}: ${CFGBFSTAMP} 175 dh_testdir 176 make -C ${bfbuilddir} libs 177 make -C ${bfbuilddir}/e2fsck all 178 make -C ${bfbuilddir}/misc all 179 touch ${BUILDBFSTAMP} 180 181clean: 182 dh_testdir 183 rm -rf ${STAMPSDIR} 184 -make -C ${stdbuilddir} -i distclean 185 -make -C ${bfbuilddir} -i distclean 186 rm -rf ${stdbuilddir} ${bfbuilddir} ${mipsbuilddir} 187 rm -f doc/libext2fs/*.html lib/et/com_err/*.html debian/*.substvars 188 dh_clean 189 190install: cleanup install-std 191 192# This rule allows to factorize the dh_clean between the 2 install rules 193# This must be launched before install-* (if launching them by hand, for 194# exemple) or results are unpredictable 195cleanup: 196 dh_testdir 197 dh_testroot 198 dh_clean -k 199 200install-std: DH_OPTIONS= 201install-std: build 202 dh_testdir 203 dh_testroot 204 dh_installdirs 205 206 mkdir -p ${tmpdir}/sbin 207 make -C ${stdbuilddir} install DESTDIR=${tmpdir} \ 208 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 209 # static libs and .h files 210 make -C ${stdbuilddir} install-libs DESTDIR=${tmpdir} LDCONFIG=true 211 212 # statically-linked fsck 213 ${INSTALL_PROGRAM} ${stdbuilddir}/e2fsck/e2fsck.static ${tmpdir}/sbin 214 ln -s e2fsck.8.gz ${mandir}/man8/e2fsck.static.8.gz 215 216 ln -s et/com_err.h ${tmpdir}/usr/include 217 218 dh_movefiles 219 test -z `find ${tmpdir} -type f` 220 221 # specially-built MIPS lib 222 if [ ismips = "${ismips}" ]; then \ 223 cp ${mipsbuilddir}/lib/libext2fs.a \ 224 ${debdir}/e2fslibs-dev/usr/lib/libext2fs-nopic.a ; \ 225 fi 226 227install-udeb: DH_OPTIONS= 228install-udeb: build 229 dh_testdir 230 dh_testroot 231 232 make -C ${bfbuilddir} install-shlibs-libs-recursive DESTDIR=${udebdir} \ 233 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 234 make -C ${bfbuilddir}/e2fsck install DESTDIR=${udebdir} \ 235 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 236 make -C ${bfbuilddir}/misc install DESTDIR=${udebdir} \ 237 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 238 239 rm -rf ${udebdir}/usr 240 find ${udebdir}/sbin -type f -a ! -name e2fsck \ 241 -a ! -name mke2fs -a ! -name tune2fs -print | xargs rm 242 243 (cd ${udebdir}/sbin; ln -s e2fsck fsck.ext2 ; \ 244 ln -s e2fsck fsck.ext3 ; ln -s mke2fs mkfs.ext2 ; \ 245 ln -s mke2fs mkfs.ext3) 246 247 mkdir -p ${blkidudebdir}/lib 248 mv ${udebdir}/lib/libblkid.* ${blkidudebdir}/lib 249 250 mkdir -p ${uuidudebdir}/lib 251 mv ${udebdir}/lib/libuuid.* ${uuidudebdir}/lib 252 253binary-indep: 254 # no arch-independant debs. 255 256binary-arch: DH_OPTIONS= -a 257binary-arch: install install-udeb 258 dh_testdir 259 dh_testroot 260 261 # lintian overrides 262 for i in $$(cd debian && echo *.lintian-overrides); do \ 263 pkg=$${i%.lintian-overrides} ;\ 264 install -m644 -D -p debian/$$i ${debdir}/$${pkg}/usr/share/lintian/overrides/$${pkg} ;\ 265 done 266 267 # mkinitrd script 268 mkdir -p debian/e2fsprogs/usr/share/initrd-tools/scripts 269 install -m755 debian/initrd-tools.e2fsprogs \ 270 debian/e2fsprogs/usr/share/initrd-tools/scripts/e2fsprogs 271 272 # initrd script 273 mkdir -p debian/e2fsprogs/usr/share/e2fsprogs 274 install -m755 debian/initrd.ext3-add-journal \ 275 debian/e2fsprogs/usr/share/e2fsprogs/initrd.ext3-add-journal 276 277 278 # symlinks to prepare dh_installdocs run 279 mkdir -p ${debdir}/e2fsck-static/usr/share/doc/ 280 ln -sf e2fsprogs ${debdir}/e2fsck-static/usr/share/doc/e2fsck-static 281 282 mkdir -p ${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION} 283 mkdir -p ${debdir}/libblkid-dev/usr/share/doc 284 ln -sf libblkid${BLKID_SOVERSION} ${debdir}/libblkid-dev/usr/share/doc/libblkid-dev 285 286 mkdir -p ${debdir}/libss${SS_SOVERSION}/usr/share/doc/libss${SS_SOVERSION} 287 mkdir -p ${debdir}/ss-dev/usr/share/doc 288 ln -sf libss${SS_SOVERSION} ${debdir}/ss-dev/usr/share/doc/ss-dev 289 290 mkdir -p ${debdir}/libcomerr${COMERR_SOVERSION}/usr/share/doc/libcomerr${COMERR_SOVERSION} 291 mkdir -p ${debdir}/comerr-dev/usr/share/doc 292 ln -sf libcomerr${COMERR_SOVERSION} ${debdir}/comerr-dev/usr/share/doc/comerr-dev 293 294 mkdir -p ${debdir}/libuuid${UUID_SOVERSION}/usr/share/doc/libuuid${UUID_SOVERSION} 295 mkdir -p ${debdir}/uuid-dev/usr/share/doc 296 ln -sf libuuid${UUID_SOVERSION} ${debdir}/uuid-dev/usr/share/doc/uuid-dev 297 298 mkdir -p ${debdir}/e2fslibs/usr/share/doc/e2fslibs 299 mkdir -p ${debdir}/e2fslibs-dev/usr/share/doc 300 ln -sf e2fslibs ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev 301 302 install -m 644 debian/libblkid.copyright \ 303 ${debdir}/libblkid${BLKID_SOVERSION}/usr/share/doc/libblkid${BLKID_SOVERSION}/copyright 304 305 dh_installdocs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 306 307 # HTML docs 308 install -d ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/html-info/ 309 install -p ${stdbuilddir}/doc/libext2fs/*.html \ 310 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/html-info/ 311 install -d ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/html-info/ 312 install -p ${stdbuilddir}/lib/et/com_err/*.html \ 313 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/html-info/ 314 315 # texinfo docs 316 mkdir -p ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION} 317 install -p ${topdir}/doc/libext2fs.texinfo \ 318 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs/libext2fs.texi 319 install -p ${topdir}/lib/et/com_err.texinfo \ 320 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/com_err.texi 321 322 install -d ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/examples 323 install -p -m 0644 lib/ss/ss_err.et \ 324 ${stdbuilddir}/lib/ext2fs/ext2_err.et \ 325 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/examples 326 install -d ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION}/examples 327 install -p -m 0644 debugfs/debug_cmds.ct \ 328 ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION}/examples 329 330 install -d ${debdir}/uuid-dev/usr/share/doc/libuuid${UUID_SOVERSION} 331 install -p -m 0644 doc/draft-leach-uuids-guids-01.txt \ 332 ${debdir}/uuid-dev/usr/share/doc/libuuid${UUID_SOVERSION} 333 334 dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info 335 dh_installinfo -pe2fslibs-dev ${stdbuilddir}/doc/libext2fs.info 336 337 DH_OPTIONS= dh_installchangelogs -pe2fsprogs -plibblkid${BLKID_SOVERSION} 338 DH_OPTIONS= dh_installchangelogs -pe2fsprogs -plibcomerr${COMERR_SOVERSION} 339 DH_OPTIONS= dh_installchangelogs -pe2fsprogs -plibss${SS_SOVERSION} 340 DH_OPTIONS= dh_installchangelogs -pe2fsprogs -plibuuid${UUID_SOVERSION} 341 DH_OPTIONS= dh_installchangelogs -pe2fsprogs -pe2fslibs 342 343 dh_strip 344 345 dh_compress 346 dh_fixperms 347 348 dh_makeshlibs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 349 dh_makeshlibs -plibcomerr${COMERR_SOVERSION} \ 350 -V 'libcomerr2 (>= 1.33-3)' 351 352 dh_installdeb 353 dh_shlibdeps -l${stdbuilddir}/lib 354 dh_shlibdeps -pe2fsprogs -l${stdbuilddir}/lib \ 355 -u"-Ldebian/e2fsprogs.shlibs.local" 356 dh_shlibdeps -pe2fsprogs-udeb -l${stdbuilddir}/lib \ 357 -u"-Ldebian/e2fsprogs-udeb.shlibs.local" 358 359 dh_gencontrol -Ncomerr-dev -Nss-dev -Nuuid-dev \ 360 -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 361 DH_OPTIONS= dh_gencontrol -pcomerr-dev \ 362 -u '-v${COMERR_VERSION}-${MAIN_VERSION}' 363 DH_OPTIONS= dh_gencontrol -pss-dev \ 364 -u '-v${SS_VERSION}-${MAIN_VERSION}' 365 DH_OPTIONS= dh_gencontrol -puuid-dev \ 366 -u '-v${UUID_VERSION}-${MAIN_VERSION}' 367 368 dh_md5sums -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 369 dh_builddeb -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb 370 371 # udeb stuff 372 dh_gencontrol -pe2fsprogs-udeb -- -fdebian/files~ 373 dpkg-distaddfile $(UDEB_NAME) debian-installer $(UDEB_PRIORITY) 374 dh_builddeb -pe2fsprogs-udeb --filename=$(UDEB_NAME) 375 376 dh_gencontrol -plibblkid1-udeb -- -fdebian/files~ 377 dpkg-distaddfile $(BLKID_UDEB_NAME) debian-installer $(BLKID_UDEB_PRIORITY) 378 dh_builddeb -plibblkid1-udeb --filename=$(BLKID_UDEB_NAME) 379 380 dh_gencontrol -plibuuid1-udeb -- -fdebian/files~ 381 dpkg-distaddfile $(UUID_UDEB_NAME) debian-installer $(UUID_UDEB_PRIORITY) 382 dh_builddeb -plibuuid1-udeb --filename=$(UUID_UDEB_NAME) 383 384binary: binary-indep binary-arch 385 386.PHONY: binary binary-arch binary-indep clean checkroot 387