rules revision e5b164373c2b7feb867f701f6493e3d87765272c
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} -G 0 -fno-pic -mno-abicalls" \ 97 --disable-swapfs --disable-imager \ 98 --disable-resizer --disable-debugfs 99 100ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 101ifneq (,$(findstring $(DEB_BUILD_ARCH),mips mipsel)) 102ismips=ismips 103endif 104endif 105 106${CFGSTDSTAMP}: 107 dh_testdir 108 109 mkdir -p ${stdbuilddir} 110ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 111 cd ${stdbuilddir} && \ 112 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} 113else 114 cd ${stdbuilddir} && CC="${DEB_HOST_GNU_TYPE}-gcc" \ 115 ${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \ 116 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE) 117endif 118 119 # specially-built MIPS lib 120 if [ ismips = "${ismips}" ]; then \ 121 mkdir -p ${mipsbuilddir} ; \ 122 cd ${mipsbuilddir} && \ 123 ${topdir}/configure ${MIPS_NOPIC_CONF_FLAGS} ; \ 124 fi 125 126 mkdir -p ${STAMPSDIR} 127 touch ${CFGSTDSTAMP} 128 129${CFGBFSTAMP}: 130 dh_testdir 131 rm -f config.cache 132 133 mkdir -p ${bfbuilddir} 134ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) 135 cd ${bfbuilddir} && \ 136 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} 137else 138 cd ${bfbuilddir} && CC="${DEB_HOST_GNU_TYPE}-gcc" \ 139 ${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \ 140 --build=$(DEB_BUILD_GNU_TYPE) $(DEB_HOST_GNU_TYPE) 141endif 142 mkdir -p ${STAMPSDIR} 143 touch ${CFGBFSTAMP} 144 145build: build-std build-bf 146 147build-std: ${BUILDSTDSTAMP} 148${BUILDSTDSTAMP}: ${CFGSTDSTAMP} 149 dh_testdir 150 make -C ${stdbuilddir} all 151 152 ( cd ${stdbuilddir}/doc && \ 153 texi2html -split_chapter ${topdir}/doc/libext2fs.texinfo ) 154 ( cd ${stdbuilddir}/lib/et && make com_err.info && \ 155 texi2html -split_chapter -expandinfo ${topdir}/lib/et/com_err.texinfo ) 156 157 # specially-built MIPS lib 158 if [ ismips = "${ismips}" ]; then \ 159 make -C ${mipsbuilddir}/util ; \ 160 make -C ${mipsbuilddir} libs LIB_SUBDIRS="lib/et lib/ext2fs" ; \ 161 fi 162 163 touch ${BUILDSTDSTAMP} 164 165build-bf: ${BUILDBFSTAMP} 166${BUILDBFSTAMP}: ${CFGBFSTAMP} 167 dh_testdir 168 make -C ${bfbuilddir} all 169 touch ${BUILDBFSTAMP} 170 171clean: 172 dh_testdir 173 rm -rf ${STAMPSDIR} 174 -make -C ${stdbuilddir} -i distclean 175 -make -C ${bfbuilddir} -i distclean 176 rm -rf ${stdbuilddir} ${bfbuilddir} 177 rm -f doc/libext2fs_*.html lib/et/com_err_*.html debian/*.substvars 178 dh_clean 179 180install: cleanup install-std install-bf 181 182# This rule allows to factorize the dh_clean between the 2 install rules 183# This must be launched before install-* (if launching them by hand, for 184# exemple) or results are unpredictable 185cleanup: 186 dh_testdir 187 dh_testroot 188 dh_clean -k 189 190install-std: DH_OPTIONS= 191install-std: build 192 dh_testdir 193 dh_testroot 194 dh_installdirs 195 196 mkdir -p ${tmpdir}/sbin 197 make -C ${stdbuilddir} install DESTDIR=${tmpdir} \ 198 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 199 # static libs and .h files 200 make -C ${stdbuilddir} install-libs DESTDIR=${tmpdir} LDCONFIG=true 201 202 # statically-linked fsck 203 ${INSTALL_PROGRAM} ${stdbuilddir}/e2fsck/e2fsck.static ${tmpdir}/sbin 204 ln -s e2fsck.8.gz ${mandir}/man8/e2fsck.static.8.gz 205 206 # specially-built MIPS lib 207 if [ ismips = "${ismips}" ]; then \ 208 cp ${mipsbuilddir}/lib/libext2fs.a \ 209 ${debdir}/e2fslibs-dev/usr/lib/libext2fs-nopic.a ; \ 210 fi 211 212 dh_movefiles 213 test -z `find ${tmpdir} -type f` 214 215install-bf: DH_OPTIONS= 216install-bf: build 217 dh_testdir 218 dh_testroot 219 dh_installdirs 220 221 mkdir -p ${bfdir}/sbin 222 make -C ${bfbuilddir} install DESTDIR=${bfdir} \ 223 INSTALL_PROGRAM="${INSTALL_PROGRAM}" LDCONFIG=true 224 rm -rf ${bfdir}/usr/share ${bfdir}/usr/lib 225 cd ${bfdir}/sbin && rm -f e2label 226 cd ${bfdir}/usr/bin && rm -f uuidgen 227 228 229binary-indep: 230 # no arch-independant debs. 231 232binary-arch: DH_OPTIONS= -a 233binary-arch: install 234 dh_testdir 235 dh_testroot 236 237 # remove obsolete maint-scripts provided by 1.26 upstream 238 cd debian && rm -f comerr-dev.postinst e2fslibs-dev.postinst \ 239 e2fsprogs.postinst e2fsprogs.shlibs e2fsprogs.shlibs.in 240 241 # lintian overrides 242 for i in $$(cd debian && echo *.lintian-overrides); do \ 243 pkg=$${i%.lintian-overrides} ;\ 244 install -m644 -D -p debian/$$i ${debdir}/$${pkg}/usr/share/lintian/overrides/$${pkg} ;\ 245 done 246 247 # mkinitrd script 248 dh_install -p e2fsprogs debian/e2fsprogs.mkinitrd \ 249 /etc/mkinitrd/scripts 250 251 # symlinks to prepare dh_installdocs run 252 mkdir -p ${debdir}/e2fsck-static/usr/share/doc/ 253 ln -sf e2fsprogs ${debdir}/e2fsck-static/usr/share/doc/e2fsck-static 254 255 mkdir -p ${debdir}/e2fslibs-dev/usr/share/doc/e2fsprogs 256 ln -sf e2fsprogs ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev 257 258 mkdir -p ${debdir}/uuid-dev/usr/share/doc/e2fsprogs 259 ln -sf e2fsprogs ${debdir}/uuid-dev/usr/share/doc/uuid-dev 260 261 # comerr and ss have their own copyright notices 262 mkdir -p ${maindir}/usr/share/doc/libcomerr${COMERR_SOVERSION} 263 mkdir -p ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION} 264 ln -sf libcomerr${COMERR_SOVERSION} ${debdir}/comerr-dev/usr/share/doc/comerr-dev 265 266 mkdir -p ${maindir}/usr/share/doc/libss${SS_SOVERSION} 267 mkdir -p ${debdir}/ss-dev/usr/share/doc/libss${SS_SOVERSION} 268 ln -sf libss${SS_SOVERSION} ${debdir}/ss-dev/usr/share/doc/ss-dev 269 270 for i in libcomerr${COMERR_SOVERSION} libss${SS_SOVERSION}; do \ 271 install -m 644 debian/$$i.copyright \ 272 ${maindir}/usr/share/doc/$$i/copyright ; \ 273 done 274 275 dh_installdocs 276 277 install -m 644 debian/e2fsprogs.copyright \ 278 ${bfdir}/usr/share/doc/e2fsprogs-bf/copyright 279 280 # HTML docs 281 install -d ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/html-info/ 282 install -p ${stdbuilddir}/doc/libext2fs_*.html \ 283 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/html-info/ 284 install -d ${debdir}/comerr-dev/usr/share/doc/comerr-dev/html-info/ 285 install -p ${stdbuilddir}/lib/et/com_err_*.html \ 286 ${debdir}/comerr-dev/usr/share/doc/comerr-dev/html-info/ 287 288 # texinfo docs 289 install -p ${topdir}/doc/libext2fs.texinfo \ 290 ${debdir}/e2fslibs-dev/usr/share/doc/e2fslibs-dev/libext2fs.texi 291 install -p ${topdir}/lib/et/com_err.texinfo \ 292 ${debdir}/comerr-dev/usr/share/doc/libcomerr${COMERR_SOVERSION}/com_err.texi 293 294 dh_installexamples 295 296 dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info 297 dh_installinfo -pe2fslibs-dev ${stdbuilddir}/doc/libext2fs.info 298 299 dh_undocumented 300 301 DH_OPTIONS= dh_installchangelogs -pe2fsprogs -pe2fsprogs-bf ChangeLog 302 303 for i in libcomerr${COMERR_SOVERSION} libss${SS_SOVERSION} ; do \ 304 mkdir -p ${maindir}/usr/share/doc/$$i ; \ 305 ln -s ../e2fsprogs/changelog.Debian.gz ${maindir}/usr/share/doc/$$i/ ; \ 306 ln -s ../e2fsprogs/changelog.gz ${maindir}/usr/share/doc/$$i/ ; \ 307 done 308 309 dh_strip 310 311 dh_compress 312 dh_fixperms 313 314 echo "libcdev:Depends=${LIBC-DEV}" > debian/comerr-dev.substvars 315 echo "libcdev:Depends=${LIBC-DEV}" > debian/ss-dev.substvars 316 echo "libcdev:Depends=${LIBC-DEV}" > debian/uuid-dev.substvars 317 echo "libcdev:Depends=${LIBC-DEV}" > debian/e2fslibs-dev.substvars 318 319# Call this mostly to get the maintainer-script snippets 320 dh_makeshlibs -pe2fsprogs 321# We overwrite the shlibs by hand because of virtual packages used 322 : > debian/e2fsprogs/DEBIAN/shlibs 323 echo "libext2fs ${EXT2FS_SOVERSION} libext2fs${EXT2FS_SOVERSION}" \ 324 >> debian/e2fsprogs/DEBIAN/shlibs 325 echo "libe2p ${E2P_SOVERSION} libe2p${E2P_SOVERSION}" \ 326 >> debian/e2fsprogs/DEBIAN/shlibs 327 echo "libuuid ${UUID_SOVERSION} libuuid${UUID_SOVERSION}" \ 328 >> debian/e2fsprogs/DEBIAN/shlibs 329 echo "libcom_err ${COMERR_SOVERSION} libcomerr${COMERR_SOVERSION}" \ 330 >> debian/e2fsprogs/DEBIAN/shlibs 331 echo "libss ${SS_SOVERSION} libss${SS_SOVERSION}" \ 332 >> debian/e2fsprogs/DEBIAN/shlibs 333 334 dh_installdeb 335 dh_shlibdeps -l${stdbuilddir}/lib 336 337 dh_gencontrol -Ncomerr-dev -Nss-dev -Nuuid-dev 338 DH_OPTIONS= dh_gencontrol -pcomerr-dev \ 339 -u '-v${COMERR_VERSION}-${MAIN_VERSION}' 340 DH_OPTIONS= dh_gencontrol -pss-dev \ 341 -u '-v${SS_VERSION}-${MAIN_VERSION}' 342 DH_OPTIONS= dh_gencontrol -puuid-dev \ 343 -u '-v${UUID_VERSION}-${MAIN_VERSION}' 344 345 dh_md5sums 346 dh_builddeb 347 348binary: binary-indep binary-arch 349 350.PHONY: binary binary-arch binary-indep clean checkroot 351