Whamcloud - gitweb
debian: add pointer for e2fsprogs-udeb to libcomerr2.shlibs
[tools/e2fsprogs.git] / debian / rules
index 484d411..1f6e7b4 100755 (executable)
@@ -7,8 +7,10 @@
 # The `binary' target must be run as root, as it needs to install files with
 # specific ownerships.
 
+-include debian/rules.custom
+
 # be paranoid
-export LC_ALL=C
+export LC_ALL ?= C
 
 # Allow distro-specific behaviour
 DISTRO :=$(shell sed -ne '/DISTRIB_ID/s/.*=//p' /etc/lsb-release 2>/dev/null || echo Debian)
@@ -19,106 +21,108 @@ endif
 
 # These are used for cross-compiling and for saving the configure script
 # from having to guess our platform (since we know it already)
-DEB_HOST_ARCH   ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
-DEB_BUILD_ARCH   ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
-DEB_HOST_OS   ?= $(shell dpkg-architecture -qDEB_HOST_OS)
-DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-DEB_HOST_MULTIARCH  ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)
+DEB_HOST_ARCH          ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_BUILD_ARCH         ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
+DEB_HOST_OS            ?= $(shell dpkg-architecture -qDEB_HOST_OS)
+DEB_HOST_GNU_TYPE      ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE     ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_HOST_MULTIARCH     ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)
 
 # find the version for the main package, from changelog file
 MAIN_VERSION = $(shell head -n 1 debian/changelog | cut '-d ' -f 2 | sed 's/[()]//g')
 # find versions for libraries going into their own packages, from their Makefile.in's,
 # and sonames for all libs
-COMERR_VERSION = $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
-COMERR_SOVERSION = $(shell grep ELF_SO_VERSION lib/et/Makefile.in | cut '-d ' -f3)
-SS_VERSION = $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
-SS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
+COMERR_VERSION ?= $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
+COMERR_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/et/Makefile.in | cut '-d ' -f3)
+SS_VERSION ?= $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
+SS_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
 
 ifneq ($(UTIL_LINUX_NG),yes)
-UUID_VERSION = $(shell grep ELF_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
-UUID_SOVERSION = $(shell grep ELF_SO_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
+UUID_VERSION ?= $(shell grep ELF_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
+UUID_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/uuid/Makefile.in | cut '-d ' -f3)
 
-BLKID_VERSION = $(shell grep ELF_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
-BLKID_SOVERSION = $(shell grep ELF_SO_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
+BLKID_VERSION ?= $(shell grep ELF_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
+BLKID_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/blkid/Makefile.in | cut '-d ' -f3)
 endif
 
-EXT2FS_SOVERSION = $(shell grep ELF_SO_VERSION lib/ext2fs/Makefile.in | cut '-d ' -f3)
-E2P_SOVERSION = $(shell grep ELF_SO_VERSION lib/e2p/Makefile.in | cut '-d ' -f3)
+EXT2FS_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/ext2fs/Makefile.in | cut '-d ' -f3)
+E2P_SOVERSION ?= $(shell grep ELF_SO_VERSION lib/e2p/Makefile.in | cut '-d ' -f3)
 
-package=e2fsprogs
+package                ?= e2fsprogs
 
-topdir=$(shell pwd)
-debdir=${topdir}/debian
-tmpdir=${debdir}/tmp
-udebdir=${debdir}/e2fsprogs-udeb
+topdir         ?= $(shell pwd)
+debdir         ?= ${topdir}/debian
+tmpdir         ?= ${debdir}/tmp
+udebdir                ?= ${debdir}/e2fsprogs-udeb
 ifneq ($(UTIL_LINUX_NG),yes)
-blkidudebdir=${debdir}/libblkid1-udeb
-uuidudebdir=${debdir}/libuuid1-udeb
-endif
-libcomerrdir=${debdir}/libcomerr${COMERR_SOVERSION}
-comerrdevdir=${debdir}/comerr-dev
-libcomerrdbgdir=${debdir}/libcomerr2-dbg
-libssdir=${debdir}/libss${SS_SOVERSION}
-ssdevdir=${debdir}/ss-dev
-libssdbgdir=${debdir}/libss2-dbg
+blkidudebdir   ?= ${debdir}/libblkid1-udeb
+uuidudebdir    ?= ${debdir}/libuuid1-udeb
+endif
+libcomerrdir   ?= ${debdir}/libcomerr${COMERR_SOVERSION}
+comerrdevdir   ?= ${debdir}/comerr-dev
+libcomerrdbgdir        ?= ${debdir}/libcomerr2-dbg
+libssdir       ?= ${debdir}/libss${SS_SOVERSION}
+ssdevdir       ?= ${debdir}/ss-dev
+libssdbgdir    ?= ${debdir}/libss2-dbg
 ifneq ($(UTIL_LINUX_NG),yes)
-libblkiddir=${debdir}/libblkid${BLKID_SOVERSION}
-libblkiddevdir=${debdir}/libblkid-dev
-libblkiddbgdir=${debdir}/libblkid1-dbg
-libuuiddir=${debdir}/libuuid${UUID_SOVERSION}
-uuiddevdir=${debdir}/uuid-dev
-libuuiddbgdir=${debdir}/libuuid1-dbg
-uuidruntimedir=${debdir}/uuid-runtime
-uuidruntimedbgdir=${debdir}/uuid-runtime-dbg
-endif
-libext2dir=${debdir}/e2fslibs
-libext2devdir=${debdir}/e2fslibs-dev
-libext2dbgdir=${debdir}/e2fslibs-dbg
-maindir=${debdir}/e2fsprogs
-e2fsckstaticdir=${debdir}/e2fsck-static
-debugdir=${debdir}/e2fsprogs-dbg
-stdbuilddir=${debdir}/BUILD-STD
-bfbuilddir=${debdir}/BUILD-BF
-staticbuilddir=${debdir}/BUILD-STATIC
-mipsbuilddir=${debdir}/BUILD-MIPS
-mipsbuilddir64=${debdir}/BUILD-MIPS-64
-# docdir=${maindir}/usr/share/doc/${package}
-MANDIR=/usr/share/man
-mandir=${tmpdir}${MANDIR}
-
-UDEB_NAME = $(package)-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
-UDEB_PRIORITY = $(shell grep '^Package: e2fsprogs-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
+libblkiddir    ?= ${debdir}/libblkid${BLKID_SOVERSION}
+libblkiddevdir ?= ${debdir}/libblkid-dev
+libblkiddbgdir ?= ${debdir}/libblkid1-dbg
+libuuiddir     ?= ${debdir}/libuuid${UUID_SOVERSION}
+uuiddevdir     ?= ${debdir}/uuid-dev
+libuuiddbgdir  ?= ${debdir}/libuuid1-dbg
+uuidruntimedir ?= ${debdir}/uuid-runtime
+uuidruntimedbgdir ?= ${debdir}/uuid-runtime-dbg
+endif
+libext2dir     ?= ${debdir}/e2fslibs
+libext2devdir  ?= ${debdir}/e2fslibs-dev
+libext2dbgdir  ?= ${debdir}/e2fslibs-dbg
+maindir                ?= ${debdir}/e2fsprogs
+e2fsckstaticdir        ?= ${debdir}/e2fsck-static
+debugdir       ?= ${debdir}/e2fsprogs-dbg
+stdbuilddir    ?= ${debdir}/BUILD-STD
+staticbuilddir ?= ${debdir}/BUILD-STATIC
+mipsbuilddir   ?= ${debdir}/BUILD-MIPS
+mipsbuilddir64 ?= ${debdir}/BUILD-MIPS-64
+# docdir       ?= ${maindir}/usr/share/doc/${package}
+MANDIR         ?= /usr/share/man
+mandir         ?= ${tmpdir}${MANDIR}
+
+UDEB_NAME      ?= $(package)-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
+UDEB_PRIORITY  ?= $(shell grep '^Package: e2fsprogs-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
 
 ifneq ($(UTIL_LINUX_NG),yes)
-BLKID_UDEB_NAME = libblkid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
-BLKID_UDEB_PRIORITY = $(shell grep '^Package: libblkid1-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
+BLKID_UDEB_NAME ?= libblkid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
+BLKID_UDEB_PRIORITY ?= $(shell grep '^Package: libblkid1-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
 
-UUID_UDEB_NAME = libuuid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
-UUID_UDEB_PRIORITY = $(shell grep '^Package: libuuid1-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
+UUID_UDEB_NAME ?= libuuid1-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
+UUID_UDEB_PRIORITY ?= $(shell grep '^Package: libuuid1-udeb' debian/control.in -A 10 | grep ^Priority: | cut -d ' ' -f 2)
 endif
 
-STAMPSDIR=debian/stampdir
-CFGSTDSTAMP=${STAMPSDIR}/configure-std-stamp
-CFGBFSTAMP=${STAMPSDIR}/configure-bf-stamp
-CFGSTATICSTAMP=${STAMPSDIR}/configure-static-stamp
-BUILDSTDSTAMP=${STAMPSDIR}/build-std-stamp
-BUILDBFSTAMP=${STAMPSDIR}/build-bf-stamp
-BUILDSTATICSTAMP=${STAMPSDIR}/build-static-stamp
+STAMPSDIR      ?= debian/stampdir
+CFGSTDSTAMP    ?= ${STAMPSDIR}/configure-std-stamp
+CFGBFSTAMP     ?= ${STAMPSDIR}/configure-bf-stamp
+CFGSTATICSTAMP ?= ${STAMPSDIR}/configure-static-stamp
+BUILDSTDSTAMP  ?= ${STAMPSDIR}/build-std-stamp
+BUILDBFSTAMP   ?= ${STAMPSDIR}/build-bf-stamp
+BUILDSTATICSTAMP ?=${STAMPSDIR}/build-static-stamp
 
-INSTALL = install
-INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 0755
+INSTALL ?= install
+INSTALL_PROGRAM ?= $(INSTALL) -p -o root -g root -m 0755
 
 #ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
 #INSTALL_PROGRAM += -s
 #endif
 
-DEFAULT_CFLAGS = -g -O2
-DEFAULT_LDFLAGS = -Wl,-Bsymbolic-functions
+DEFAULT_CFLAGS ?= -g -O2
+DEFAULT_LDFLAGS ?= -Wl,-Bsymbolic-functions
 
-CFLAGS += $(shell dpkg-buildflags --get CFLAGS)
-LDFLAGS += $(shell dpkg-buildflags --get LDFLAGS)
-CPPFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
+CFLAGS ?= $(shell if dpkg-buildflags > /dev/null 2>&1 ; then \
+       dpkg-buildflags --get CFLAGS; else echo $(DEFAULT_CFLAGS) ; fi)
+LDFLAGS ?= $(shell if dpkg-buildflags > /dev/null 2>&1 ; then \
+       dpkg-buildflags --get LDFLAGS; else echo $(DEFAULT_LDFLAGS) ; fi)
+CPPFLAGS ?= $(shell if dpkg-buildflags > /dev/null 2>&1 ; then \
+       dpkg-buildflags --get CPPFLAGS; fi)
 
 ifeq (${DEB_HOST_ARCH},alpha)
 CFLAGS += -DHAVE_NETINET_IN_H
@@ -126,11 +130,24 @@ else
 CFLAGS += -D__NO_STRING_INLINES
 endif
 
-ifeq (${DEB_HOST_ARCH_OS},linux)
+ifneq (${DEB_HOST_ARCH_OS},linux)
+SKIP_STATIC = yes
+endif
+
+ifeq ($(SKIP_STATIC),yes)
+BUILD_STATIC =
+E2FSCK_STATIC = ${stdbuilddir}/e2fsck/e2fsck.static
+else
 BUILD_STATIC = build-static
 E2FSCK_STATIC = ${staticbuilddir}/e2fsck/e2fsck.static
+endif
+
+ifeq ($(SKIP_BF),yes)
+BUILD_BF =
+bfbuilddir     ?= ${stdbuilddir}
 else
-E2FSCK_STATIC = ${stdbuilddir}/e2fsck/e2fsck.static
+BUILD_BF = build-bf
+bfbuilddir     ?= ${debdir}/BUILD-BF
 endif
 
 BF_CFLAGS = -Os -fomit-frame-pointer
@@ -145,30 +162,30 @@ COMMON_CONF_FLAGS += --enable-fsck
 endif
 
 ifneq ($(strip $(DEB_HOST_MULTIARCH)),)
-MULTIARCH_CONF = --with-multiarch=$(DEB_HOST_MULTIARCH)
+MULTIARCH_CONF ?= --with-multiarch=$(DEB_HOST_MULTIARCH)
 # This doesn't work yet because gdb and lintian don't expect and/or
 # don't work with /usr/lib/<triplet>/debug
 #USRLIB = /usr/lib/$(DEB_HOST_MULTIARCH)
-USRLIB = /usr/lib
+USRLIB ?= /usr/lib
 else
-USRLIB = /usr/lib
+USRLIB ?= /usr/lib
 endif
 
-STD_CONF_FLAGS = --enable-symlink-install $(MULTIARCH_CONF)
+STD_CONF_FLAGS ?= --enable-symlink-install $(MULTIARCH_CONF)
 
-BF_CONF_FLAGS = --disable-nls --disable-imager --disable-testio-debug \
+BF_CONF_FLAGS ?= --disable-nls --disable-imager --disable-testio-debug \
        --disable-uuidd --disable-tls --disable-debugfs
 
-STATIC_CONF_FLAGS = --disable-nls --disable-imager \
+STATIC_CONF_FLAGS ?= --disable-nls --disable-imager \
        --disable-uuidd --disable-tls
 
-MIPS_NOPIC_CONF_FLAGS = --disable-nls --disable-imager \
+MIPS_NOPIC_CONF_FLAGS ?= --disable-nls --disable-imager \
        --disable-uuidd --disable-tls \
         --disable-resizer # --disable-debugfs
 
 # we can't use those flags at configure time
-MIPS_CFLAGS= -G 0 -fno-pic -mno-abicalls
-MIPS_CFLAGS_64= -mabi=64 -G 0 -fno-pic -mno-abicalls
+MIPS_CFLAGS ?= -G 0 -fno-pic -mno-abicalls
+MIPS_CFLAGS_64 ?= -mabi=64 -G 0 -fno-pic -mno-abicalls
 
 ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
 ifneq (,$(findstring $(DEB_BUILD_ARCH),mips mipsel))
@@ -189,6 +206,14 @@ else
 M4_ARGS+=-UDO_MULTIARCH
 endif
 
+ifneq ($(SKIP_DIETLIBC),)
+M4_ARGS+=-UDIETLIBC
+WITH_DIET_LIBC = 
+else
+M4_ARGS+=-DDIETLIBC
+WITH_DIET_LIBC = --with-diet-libc 
+endif
+
 FILES_FIXUP= libcomerr2.files comerr-dev.files libss2.files ss-dev.files \
        libuuid1.files uuid-dev.files libblkid1.files libblkid-dev.files \
        e2fslibs.files e2fslibs-dev.files
@@ -268,7 +293,7 @@ ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
        if type diet > /dev/null  2>&1 ; then \
                cd ${staticbuilddir} && AWK=/usr/bin/awk \
                ${topdir}/configure ${STATIC_CONF_FLAGS} \
-               --with-diet-libc CFLAGS="${CFLAGS}"; \
+               ${WITH_DIET_LIBC} CFLAGS="${CFLAGS}"; \
        else \
                cd ${staticbuilddir} && AWK=/usr/bin/awk \
                        ${topdir}/configure ${STATIC_CONF_FLAGS} \
@@ -285,7 +310,7 @@ endif
 
 build-arch: build
 build-indep: build
-build: build-std build-bf $(BUILD_STATIC)
+build: build-std $(BUILD_BF) $(BUILD_STATIC)
 
 build-std: ${BUILDSTDSTAMP}
 ${BUILDSTDSTAMP}: ${CFGSTDSTAMP}
@@ -399,10 +424,10 @@ install-udeb: build
                -a ! -name mke2fs -a ! -name tune2fs \
                -a ! -name resize2fs -a ! -name badblocks -print | xargs rm
 
-       (cd ${udebdir}/sbin; ln -s e2fsck fsck.ext2 ; \
-               ln -s e2fsck fsck.ext3 ; ln -s e2fsck fsck.ext4 ; \
-               ln -s mke2fs mkfs.ext2 ; ln -s mke2fs mkfs.ext3 ; \
-               ln -s mke2fs mkfs.ext4)
+       (cd ${udebdir}/sbin; ln -sf e2fsck fsck.ext2 ; \
+               ln -sf e2fsck fsck.ext3 ; ln -sf e2fsck fsck.ext4 ; \
+               ln -sf mke2fs mkfs.ext2 ; ln -sf mke2fs mkfs.ext3 ; \
+               ln -sf mke2fs mkfs.ext4)
 
 ifneq ($(UTIL_LINUX_NG),yes)
        mkdir -p ${blkidudebdir}/lib
@@ -593,7 +618,7 @@ endif
        dh_compress
 
        dh_makeshlibs -Ne2fsprogs-udeb -Nlibblkid1-udeb -Nlibuuid1-udeb
-       dh_makeshlibs -plibcomerr${COMERR_SOVERSION} \
+       dh_makeshlibs --add-udeb=e2fsprogs-udeb -plibcomerr${COMERR_SOVERSION} \
                -V 'libcomerr2 (>= 1.33-3)'
 ifneq ($(UTIL_LINUX_NG),yes)
        dh_makeshlibs -plibblkid${BLKID_SOVERSION} -V 'libblkid1 (>= 1.39-1)'