oops…
[alioth/cvs.git] / debian / rules
index ff0feae..e705404 100755 (executable)
@@ -1,6 +1,20 @@
 #!/usr/bin/make -f
 
-CC?=                   gcc
+DEB_BUILD_ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
+DEB_HOST_ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+
+# is ${CC} defined anywhere (other than implicit rules?)
+ifneq (,$(findstring $(origin CC),default undefined))
+# no - then default to gcc (or cross-gcc)
+ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
+CC=                    ${DEB_HOST_GNU_TYPE}-gcc
+else
+CC=                    gcc
+endif
+endif
+
 CONFIGURE_ENV:=                CC='${CC}'
 EXTRA_CFLAGS=          -Wall -fno-strict-aliasing -Wformat
 # addresses part of #698908
@@ -26,17 +40,14 @@ CONFIGURE_ENV+=             CPPFLAGS='${CPPFLAGS}'
 CONFIGURE_ENV+=                LDFLAGS='${LDFLAGS}'
 endif
 
-ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
-NUMJOBS=               $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
-MAKEFLAGS+=            -j${NUMJOBS}
-endif
-
 LIBS+=                 -lbsd
 
 CONFIGURE_ENV+=                LIBS='${LIBS}'
 CONFIGURE_ENV+=                CSH=/bin/csh
 
-CONFIGURE_ARGS:=       --prefix=/usr \
+CONFIGURE_ARGS:=       --build=${DEB_BUILD_GNU_TYPE} \
+                       --host=${DEB_HOST_GNU_TYPE} \
+                       --prefix=/usr \
                        --infodir=/usr/share/info \
                        --mandir=/usr/share/man \
                        --sysconfdir=/etc \
@@ -82,6 +93,12 @@ debian/.configure_stamp:
        mkdir debian/builddir debian/stagedir
        cd debian/builddir && \
            env ${CONFIGURE_ENV} sh ../../configure ${CONFIGURE_ARGS}
+       # generate PDF 1.4 by default
+       ln -s ../../../build-aux/texinfo.tex debian/builddir/doc/texinfo-r.tex
+       printf '%s\n' \
+           '\pdfminorversion4\relax\pdfobjcompresslevel0\relax%' \
+           '\input texinfo-r.tex' \
+           >debian/builddir/doc/texinfo.tex
        @:>$@
 
 build-indep:
@@ -90,10 +107,13 @@ build build-arch: debian/.build_stamp
 debian/.build_stamp: debian/.configure_stamp
        dh_testdir
        cd debian/builddir && ${MAKE} ${MAKE_ARGS}
+ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
        cd debian/builddir && ${MAKE} -C doc ${MAKE_ARGS} doc html info pdf txt
+endif
 ifneq (,$(filter sanity,$(DEB_BUILD_OPTIONS)))
        # run the testsuite after build (DEB_BUILD_OPTIONS=sanity)
        # warning: this takes a *lot* of time!
+       # idea: run this under Valgrind to take even more time ;)
        cd debian/builddir && ${MAKE} ${MAKE_ARGS} check
 endif
        @:>$@
@@ -139,6 +159,9 @@ binary-arch: debian/.build_stamp
        # we ship cvs-switchroot(1) instead
        rm -f debian/stagedir/usr/share/cvs/contrib/newcvsroot
        dh_installchangelogs debian/stagedir/clogs/ChangeLog
+ifneq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
+       # this will cause lintian warnings as it installs the doc-base files
+endif
        dh_installdocs
        dh_install
        dh_installinfo