* Minor optimization: swap instead of assign.
[ginac.git] / debian / rules
index e6493b5b2f3c869350829d17e51f0116222c7576..4834145346ccc94c982291d6bbc5425fc99cd39b 100755 (executable)
@@ -1,67 +1,86 @@
 #!/usr/bin/make -f
-# Made with the aid of debmake, by Christoph Lameter,
-# based on the sample debian/rules file for GNU hello by Ian Jackson.
 
-package=ginac
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
 
-version=$(shell expr `pwd` : '.*-\([0-9.]*\)')
-version_major=$(shell expr `pwd` : '.*-\([0-9]*\).[0-9.]*')
+# This is the debhelper compatability version to use.
+export DH_COMPAT=4
+# This has to be exported to make some magic below work.
+export DH_OPTIONS
 
-build:
+# 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_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       export CXXFLAGS = -O0
+else
+       export CXXFLAGS = -O2 -finline-limit=1200
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+       INSTALL_PROGRAM += -s
+endif
+
+config.status: configure
        dh_testdir
-       ./configure --prefix=/usr
+       # Add here commands to configure the package.
+       # The Makefile is removed on error in order to prevent the build at this early stage.
+       ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info || rm -f Makefile
+
+build: build-arch
 
-       -mkdir shared static
-       #
-       # First build the shared library
-       #
-       cd shared ; \
-           $(MAKE) -f ../Makefile VPATH=".." srcdir=".." \
-               CFLAGS="-O2 -fPIC -pipe" ; \
-           gcc -shared -Wl,-soname,$(package).so.$(version_major) -o $(package).so.$(version) `ls *.o`
-       #
-       # Build the static library (it does not need Position Independent Code,
-       # which reserves one register; thus, without -fPIC we get more efficient
-       # code).
-       #
-       cd static ; \
-            $(MAKE) -f ../Makefile VPATH=".." srcdir=".." \
-                 CFLAGS="-O2 -pipe" LDFLAGS="-s" progs
-       touch build
+build-arch: build-arch-stamp
+build-arch-stamp:  config.status
+       # Add here commands to compile the arch part of the package.
+       $(MAKE)
 
 clean:
        dh_testdir
-       dh_clean
-       -rm -f build
+       dh_testroot
+       rm -f build-arch-stamp config-stamp
        -$(MAKE) distclean
-       -rm -f `find . -name "*~"`
-       -rm -rf debian/tmp `find debian/* -type d ! -name CVS` debian/files* core
-       -rm -f debian/*substvars
+       dh_clean
 
-binary-indep: build
+install: install-arch
+install-arch:
        dh_testdir
-# There are no architecture-independent files to be uploaded
-# generated by this package.  If there were any they would be
-# made here.
+       dh_testroot
+       dh_clean -k -a
+       dh_installdirs -a
+       # Add here commands to install the arch part of the package into 
+       # debian/tmp.
+       $(MAKE) install prefix=$(CURDIR)/debian/tmp/usr
+       mkdir -p $(CURDIR)/debian/tmp/usr/share/pixmaps
+       cp $(CURDIR)/debian/ginac.xpm $(CURDIR)/debian/tmp/usr/share/pixmaps/
 
-binary-arch: build
+# Must not depend on anything. This is to be called by
+# binary-arch/binary-multi
+# in another 'make' thread.
+binary-common:
        dh_testdir
-       -rm -rf debian/tmp `find debian/* -type d`
-       install -d debian/tmp
-       cd debian/tmp && install -d `cat ../dirs`
-       install -m644 static/$(package).a debian/tmp/usr/lib/
-       install -m644 static/gdbm.h dbm.h ndbm.h debian/tmp/usr/include/
-       install -m644 gdbm.3 debian/tmp/usr/share/man/man3/gdbm.3gdbm
-
-       install -m644 shared/$(package).so.$(version) debian/tmp/usr/lib
-
-       $(MAKE) install prefix=`pwd`/debian/tmp/usr
-       debstd -m ChangeLog NEWS README 
-       dpkg-gencontrol -pginac1-dev
-       chown -R root.root debian/tmp
-       chmod -R go=rX debian/tmp
-       dpkg --build debian/tmp ..
+       dh_testroot
+       dh_installdocs
+       dh_installmenu
+       dh_installman
+       dh_installinfo
+       dh_installchangelogs ChangeLog
+       dh_movefiles
+       dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+       dh_makeshlibs
+       dh_shlibdeps --libpackage=libginac1.3 -l debian/libginac1.3/usr/lib
+       dh_gencontrol
+       dh_installdeb
+       dh_md5sums
+       dh_builddeb
 
-binary: binary-indep binary-arch
+# Build architecture dependant packages using the common target.
+binary-arch: build-arch install-arch
+       $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
 
-.PHONY: binary binary-arch binary-indep clean
+binary: binary-arch
+.PHONY: build clean binary-arch binary install install-arch