File debian.rules of Package Mono

#!/usr/bin/make -f

#export DH_VERBOSE=1
export MONO_SHARED_DIR=$(CURDIR)

# Assume Debian behaviour by default.
DISTRO = $(shell lsb_release -si)

MAKEFILE = $(firstword $(MAKEFILE_LIST))
DEBIAN_DIR = $(dir $(MAKEFILE))
SOURCE_DIR = $(DEBIAN_DIR)/..

VERSION = $(shell dpkg-parsechangelog -l$(DEBIAN_DIR)/changelog | grep ^Vers | cut -d\  -f2)
UPVERSION = $(shell echo $(VERSION) | sed 's,-.*,,' | sed 's,+dfsg.*,,')
NEXT_UPVERSION = $(shell perl -e '$$_=pop; s/(\d+)$$/$$1+1/e; print' $(UPVERSION))
DEB_SOURCE_NAME = $(shell dpkg-parsechangelog -l$(DEBIAN_DIR)/changelog | grep ^Source | cut -d" " -f2)

RUN_MONO = LD_LIBRARY_PATH=debian/tmp/usr/lib MONO_PATH=debian/tmp/usr/lib/mono/2.0 debian/tmp/usr/bin/mono
DH_INTERNAL_MONO_PARAM = --internal-mono
ifeq ($(shell dpkg --compare-versions $$(dpkg-query -f '$${Version}' -W debhelper) lt 7.1; echo $$?), 0)
	DH_INTERNAL_MONO_PARAM = internal-mono
endif

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)

ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
	CONF_FLAGS += --build $(DEB_HOST_GNU_TYPE)
else
	CONF_FLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif

ifeq ($(DEB_BUILD_ARCH_OS), kfreebsd)
        CONF_FLAGS += --enable-minimal=aot
endif

ifeq ($(DEB_BUILD_ARCH), armel)
	CONF_FLAGS += --with-fpu=NONE
	# the build-system picks __thread for armel which is not working,
	# thus we have to explicitly pick pthread
	CONF_FLAGS += --with-tls=pthread
endif

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0 -g
else
	CFLAGS += -O2 -g
endif

ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	MINI_TEST = true
	MONO_TEST = true
else
	MINI_TEST = cd mono/mini && make check
	MONO_TEST = cd mono/tests && make test
endif

CONFIGURE =	CFLAGS="$(CFLAGS)" \
		./configure $(CONF_FLAGS) --prefix=/usr \
		  --mandir=\$${prefix}/share/man \
		  --infodir=\$${prefix}/share/info --sysconfdir=/etc \
		  --with-jit=yes --with-ikvm-native=no --with-preview=yes \
		  --with-libgdiplus=installed --with-x=yes \
		  --with-moonlight=no \
		  --enable-quiet-build=no

# Mono's build system doesn't like -j > 1
MAKE_FLAGS += -j1
export MAKEFLAGS=$(MAKE_FLAGS)

#ifeq ($(DEB_BUILD_ARCH), i386)
#	MAKE_FLAGS += RUNTIME=$(CURDIR)/debian/mono-aot-wrapper
#endif

# Include dpatch stuff.
include /usr/share/dpatch/dpatch.make

autoreconf: patch autoreconf-stamp
autoreconf-stamp:
	autoreconf -f -i
	touch $@

configure-arch: configure-arch-stamp
configure-arch-stamp: autoreconf
	dh_testdir
	$(CONFIGURE) --disable-mcs-build
	touch $@

configure-indep: patch configure-indep-stamp
configure-indep-stamp: autoreconf
	dh_testdir
	$(CONFIGURE)
	touch $@

build: build-arch
build-all: build-arch build-indep

build-arch: configure-arch build-arch-stamp
build-arch-stamp:
	dh_testdir
	LC_ALL=C $(MAKE) $(MAKE_FLAGS) EXTERNAL_MCS=false EXTERNAL_MONO=false
	cd mcs/jay && \
	  $(MAKE)
	cd debian/detector && \
	  $(MAKE)
	#debian/mono-aot-bootstrap
	touch $@

build-indep: configure-indep build-indep-stamp
build-indep-stamp:
	dh_testdir
	LC_ALL=C $(MAKE) $(MAKE_FLAGS) EXTERNAL_MCS=false EXTERNAL_MONO=false
	chmod +x debian/dh_makeclilibs \
	         debian/dh_clideps \
	         debian/dh_clistrip \
	         debian/dh_clifixperms \
	         debian/dh_monoaot
	touch $@

test: test-arch
test-arch: test-arch-stamp
test-arch-stamp: configure-indep
	# we have to depend on configure-indep here because configure-arch
	# passes --disable-mcs-build to ./configure which skips generating
	# mcs/build/config.make which is required when we wan't to build
	# assemblies here as thats where RUNTIME etc is defined.

	# runtime tests need gmcs, ilasm and mkbundle, so let's build them

	# bootstrap 1.1 needs basic
	cd mcs && LC_ALL=C $(MAKE) EXTERNAL_MCS=false EXTERNAL_MONO=false PROFILE=basic

	# mcs needs bootstrap 1.1
	cd mcs && LC_ALL=C $(MAKE) EXTERNAL_MCS=false EXTERNAL_MONO=false NO_DIR_CHECK=1 PROFILE=net_1_1_bootstrap

	# mcs needs mscorlib, System, System.Xml and Mono.CompilerServices.SymbolWriter
	cd mcs/class/corlib && LC_ALL=C $(MAKE) PROFILE=net_1_1
	cd mcs/class/System && LC_ALL=C $(MAKE) PROFILE=net_1_1
	cd mcs/class/System.XML && LC_ALL=C $(MAKE) PROFILE=net_1_1
	cd mcs/class/Mono.CompilerServices.SymbolWriter && LC_ALL=C $(MAKE) PROFILE=net_1_1
	# build mcs
	cd mcs/mcs && LC_ALL=C $(MAKE) PROFILE=net_1_1

	# gmcs needs bootstrap 2.0, 
	cd mcs && LC_ALL=C $(MAKE) EXTERNAL_MCS=false EXTERNAL_MONO=false NO_DIR_CHECK=1 PROFILE=net_2_0_bootstrap
	# build gmcs
	cd mcs/mcs && LC_ALL=C $(MAKE) PROFILE=net_2_0

	# PEAPI need mscorlib, System, System.Xml and Mono.CompilerServices.SymbolWriter
	cd mcs/class/corlib && LC_ALL=C $(MAKE) PROFILE=net_2_0
	cd mcs/class/System && LC_ALL=C $(MAKE) PROFILE=net_2_0
	cd mcs/class/System.XML && LC_ALL=C $(MAKE) PROFILE=net_2_0
	cd mcs/class/Mono.CompilerServices.SymbolWriter && LC_ALL=C $(MAKE) PROFILE=net_2_0

	# ilasm needs PEAPI and Mono.Security
	cd mcs/class/PEAPI && LC_ALL=C $(MAKE) PROFILE=net_2_0
	cd mcs/class/Mono.Security && LC_ALL=C $(MAKE) PROFILE=net_2_0
	# build ilasm
	cd mcs/ilasm && LC_ALL=C $(MAKE) PROFILE=net_2_0

	# mkbundle needs Mono.Posix and ICSharpCode.SharpZipLib
	cd mcs/class/Mono.Posix && LC_ALL=C $(MAKE) PROFILE=net_2_0
	cd mcs/class/ICSharpCode.SharpZipLib && LC_ALL=C $(MAKE) PROFILE=net_2_0
	# build mkbundle
	cd mcs/tools/mkbundle && LC_ALL=C $(MAKE) PROFILE=net_2_0

	# some tests need System.Core
	cd mcs/class/System.Core && LC_ALL=C $(MAKE) PROFILE=net_2_0

	# mono/mini tests need Mono.Simd
	cd mcs/class/Mono.Simd && LC_ALL=C $(MAKE) PROFILE=net_2_0

	# show time baby: run all tests
	-$(MINI_TEST)
	-$(MONO_TEST)

	# clean up
	cd mono/mini && $(MAKE) clean
	cd mono/tests && $(MAKE) clean
	# funny bug-459094.cs creates too long directory names which
	# pbuilder is unable to remove, eh
	rm -rf mono/tests/abcde12345abcde12345abcde12345abcde12345/
	# delete the assemblies we built here, to make sure they get cleanly
	# rebuild in the build-indep target
	rm -rf \
		mcs/class/lib/basic \
		mcs/class/lib/net_1_1 \
		mcs/class/lib/net_1_1_bootstrap \
		mcs/class/lib/net_2_0 \
		mcs/class/lib/net_2_0_bootstrap

	touch $@

clean: clean-patched unpatch
clean-patched:
	echo "distro is $(DISTRO)"
	dh_testdir
	dh_testroot
	[ ! -f Makefile ] || $(MAKE) distclean
	# distclean misses stuff
	find -name "*.mdb" -delete
	# AOT stuff we created using mono-aot-wrapper/mono-aot-bootstrap
	find mcs/class/lib -name "*.so" -delete
	-cd debian/detector && $(MAKE) clean
	rm -f debian/MonoGetAssemblyName.exe \
	      debian/mono-api-diff.exe
	rm -rf $(MONO_SHARED_DIR)/.wapi

	rm -f mcs/class/lib/default/mono-api-info.exe               \
	      mcs/class/lib/net_2_0/mono-api-info.exe               \
	      mcs/class/Managed.Windows.Forms/resources/*.resources \
	      mcs/class/Mono.Data.Sqlite/resources/SR.resources     \
	      mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ResultCodeMessages.resources \
	      mcs/class/System.Web/resources/TranslationResources.resources

	# clean stuff handled by autoreconf
	rm -rf configure config.sub config.guess ltmain.sh aclocal.m4 autom4te.cache/
	find . -name "Makefile.in" -delete

	rm -f autoreconf-stamp
	rm -f configure-*-stamp
	rm -f build-*-stamp
	rm -f install-*-stamp

	dh_clean
	#libtool isn't ok on OBS machines :
	#autoreconf -f -i -s
	
install: install-all
install-all: install-arch install-indep

install-arch: install-arch-stamp
install-arch-stamp:
	dh_testdir
	dh_testroot
	#dh_clean -k -s
	dh_installdirs -s
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
	cd mcs/jay && \
	  $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp prefix=/usr INSTALL=../../install-sh
	touch install-arch-stamp

install-indep: install-indep-stamp
install-indep-stamp:
	dh_testdir
	dh_testroot
	#dh_clean -k -i
	dh_installdirs -i
	cd mcs && \
	  $(MAKE) install NO_DIR_CHECK=1 DESTDIR=$(CURDIR)/debian/tmp PROFILE=net_1_1 && \
	  $(MAKE) install NO_DIR_CHECK=1 DESTDIR=$(CURDIR)/debian/tmp PROFILE=net_2_0 && \
	  $(MAKE) install NO_DIR_CHECK=1 DESTDIR=$(CURDIR)/debian/tmp PROFILE=net_3_5

	# upstream forgot to remove this one
	rm -f debian/tmp/usr/bin/mbas
	# don't want docs of bundled libgc
	rm -rf debian/tmp/usr/share/libgc-mono
	# Mono.WebBrowser.dll is linked with CLI 2.0, thus the symlink in 1.0/ doesn't make sense
	rm -f debian/tmp/usr/lib/mono/1.0/Mono.WebBrowser.dll
	# Mono.Security.Win32.dll is only useful on windows, as it wrap the win api
	rm -rf $(CURDIR)/debian/tmp/usr/lib/mono/gac/Mono.Security.Win32/1.0.5000.0__*/ \
	       $(CURDIR)/debian/tmp/usr/lib/mono/gac/Mono.Security.Win32/2.0.0.0__*/
	rm -f $(CURDIR)/debian/tmp/usr/lib/mono/1.0/Mono.Security.Win32.dll \
	      $(CURDIR)/debian/tmp/usr/lib/mono/2.0/Mono.Security.Win32.dll
	# bug in Mono 2.4: <kangaroo> if you meant on 2.4 that was a bug
	rm -rf $(CURDIR)/debian/tmp/usr/lib/mono/gac/Mono.CompilerServices.SymbolWriter/2.0.5.0__*/
	# CLI 1.0 is only kept for compat, don't ship new 1.0 libs
	rm -rf $(CURDIR)/debian/tmp/usr/lib/mono/gac/Mono.Messaging/1.0.5000.0__*/

	# copy missing 2.0 manpages
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/al.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/al2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/gacutil.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/gacutil2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/mcs.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/gmcs.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/mcs.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/smcs.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/mono-service.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/mono-service2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/mkbundle.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/mkbundle2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/wsdl.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/wsdl2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/monop.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/monop2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/ilasm.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/ilasm2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/resgen.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/resgen2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/genxs.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/genxs2.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/xsd.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/xsd2.1
	# copy missing 1.0 manpages
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/al.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/al1.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/gacutil.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/gacutil1.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/genxs.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/genxs1.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/ilasm.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/ilasm1.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/mkbundle.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/mkbundle1.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/monop.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/monop1.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/resgen.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/resgen1.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/wsdl.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/wsdl1.1
	cp $(CURDIR)/debian/tmp/usr/share/man/man1/xsd.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/xsd1.1
	# copy missing default scripts
	cp $(CURDIR)/debian/tmp/usr/bin/xsd \
	   $(CURDIR)/debian/tmp/usr/bin/xsd1
	# gacutil should be 2.0 by default (like all other development tools)
	mv $(CURDIR)/debian/tmp/usr/bin/gacutil \
	   $(CURDIR)/debian/tmp/usr/bin/gacutil1
	cp $(CURDIR)/debian/tmp/usr/bin/gacutil2 \
	   $(CURDIR)/debian/tmp/usr/bin/gacutil

	touch install-indep-stamp

binary: binary-arch binary-indep

binary-indep: build-arch install-arch build-indep install-indep
	dh_testdir
	dh_testroot

	# Build the late-GAC tool,
	# using the built Mono runtime from debian/tmp
	# (thus the install-arch target dependency!)
	$(RUN_MONO) mcs/class/lib/net_2_0/gmcs.exe \
	  -target:exe \
	  -out:debian/MonoGetAssemblyName.exe \
	  debian/MonoGetAssemblyName.cs

	# Build mono-api-diff
	$(RUN_MONO) mcs/class/lib/net_2_0/gmcs.exe \
	  -target:exe \
	  -out:debian/mono-api-diff.exe \
	  debian/mono-api-diff.cs

	# that exclude list are programs for arch-dep packages
	dh_install -i -Xbin/monodis -Xbin/monograph -Xbin/mono-find-provides -Xbin/mono-find-requires -Xbin/pedump -Xbin/jay

	# Late GAC
	install -D -m 755 debian/mono.runtime-script debian/mono-gac/usr/share/cli-common/runtimes.d/mono

	install -m 644 debian/System.Data.dll.config debian/libmono-system-data1.0-cil/usr/lib/mono/gac/System.Data/1.0.*/
	install -m 644 debian/System.Data.dll.config debian/libmono-system-data2.0-cil/usr/lib/mono/gac/System.Data/2.0.*/
	install -m 644 debian/System.Drawing.dll.config debian/libmono-system1.0-cil/usr/lib/mono/gac/System.Drawing/1.0.*/
	install -m 644 debian/System.Drawing.dll.config debian/libmono-system2.0-cil/usr/lib/mono/gac/System.Drawing/2.0.*/
	install -m 644 debian/System.Windows.Forms.dll.config debian/libmono-winforms1.0-cil/usr/lib/mono/gac/System.Windows.Forms/1.0.*/
	install -m 644 debian/System.Windows.Forms.dll.config debian/libmono-winforms2.0-cil/usr/lib/mono/gac/System.Windows.Forms/2.0.*/
	install -m 644 debian/Mono.Cairo.dll.config debian/libmono-cairo1.0-cil/usr/lib/mono/gac/Mono.Cairo/1.0.*/
	install -m 644 debian/Mono.Cairo.dll.config debian/libmono-cairo2.0-cil/usr/lib/mono/gac/Mono.Cairo/2.0.*/
	install -m 644 debian/Mono.Data.SqliteClient.dll.config debian/libmono-sqlite1.0-cil/usr/lib/mono/gac/Mono.Data.SqliteClient/1.0.*/
	install -m 644 debian/Mono.Data.SqliteClient.dll.config debian/libmono-sqlite2.0-cil/usr/lib/mono/gac/Mono.Data.SqliteClient/2.0.*/
	install -m 644 debian/Mono.Data.Sqlite.dll.config debian/libmono-sqlite1.0-cil/usr/lib/mono/gac/Mono.Data.Sqlite/1.0.*/
	install -m 644 debian/Mono.Data.Sqlite.dll.config debian/libmono-sqlite2.0-cil/usr/lib/mono/gac/Mono.Data.Sqlite/2.0.*/
	install -m 644 debian/FirebirdSql.Data.Firebird.dll.config debian/libmono-firebirdsql1.7-cil/usr/lib/mono/gac/FirebirdSql.Data.Firebird/1.7.*/
	
	dh_link -i
	dh_installchangelogs -i -X ChangeLog
	dh_installdocs -i
	dh_installman -i
	debian/dh_clistrip -i --dbg-package=mono-dbg
	dh_compress -i
	
	# Hack workaround to allow Ubuntu to run its own preinst (e.g. to kill symlinked docdirs)
	if [ "$(DISTRO)" = "Ubuntu" ]; then \
	  for p in $$(dh_listpackages -i); do \
	    sed "s/#PACKAGENAME#/$$p/g" $(CURDIR)/debian/preinst.ubuntu >> debian/$$p.preinst.debhelper; \
	  done; \
	fi

	dh_fixperms -i
	debian/dh_clifixperms -i
	dh_installdeb -i
	#DH_VERBOSE=1 DH_AUTOSCRIPTDIR=$(CURDIR)/debian debian/dh_monoaot -i
	debian/dh_makeclilibs -i -m 1.0 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono1.0-cil -m 2.0 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono2.0-cil -m 2.0 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-cairo1.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-cairo2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-corlib1.0-cil -m 1.2.2.1 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-corlib2.0-cil -m 1.2.2.1 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-data1.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-data2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-data-tds1.0-cil -m 2.4.2 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-data-tds2.0-cil -m 2.4.2 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-ldap1.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-ldap2.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-microsoft-build2.0-cil -m 2.4.2 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-oracle2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-peapi1.0-cil -m 2.4.2 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-peapi2.0-cil -m 2.4.2 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-posix1.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-posix2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-relaxng1.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-relaxng2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-system1.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-system2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-system-data1.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-system-data2.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-system-ldap2.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-system-runtime2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-system-web2.0-cil -m 1.9.1 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-security1.0-cil -m 2.0 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-security2.0-cil -m 2.0 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-sqlite1.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-sqlite2.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-web1.0-cil -m 1.9 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-web2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-webbrowser0.5-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-winforms1.0-cil -m 1.2.6 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_makeclilibs -p libmono-winforms2.0-cil -m 2.4 $(DH_INTERNAL_MONO_PARAM)
	# preview APIs get tighter clilibs
	debian/dh_makeclilibs -p libmono-system2.1-cil -m 2.0 $(DH_INTERNAL_MONO_PARAM)
	debian/dh_clideps -i -l debian/tmp $(DH_INTERNAL_MONO_PARAM)
	#DH_VERBOSE=1 debian/dh_clideps -i -l debian/tmp $(DH_INTERNAL_MONO_PARAM)
	# mono-1.0/2.0-gac needs special runtime dep, to prevent circular dep (mono-runtime <-> mono-1.0/2.0-gac)
	debian/dh_clideps -p mono-1.0-gac -r $(DH_INTERNAL_MONO_PARAM)
	debian/dh_clideps -p mono-2.0-gac -r $(DH_INTERNAL_MONO_PARAM)
	dh_gencontrol -i -- -Vmono:upversion=$(UPVERSION) -Vmono:next-upversion=$(NEXT_UPVERSION)
	dh_md5sums -i
	dh_builddeb -i

binary-arch: build-arch install-arch test-arch-stamp
	dh_testdir
	dh_testroot
	
	cd debian/detector && \
	  install -D -m 755 binfmt-detector-cli $(CURDIR)/debian/mono-runtime/usr/lib/cli/binfmt-detector-cli
	install -D -m 644 -o root -g root debian/cli.binfmt \
	  debian/mono-runtime/usr/share/binfmts/cli

	dh_install -s
	dh_link -s
	dh_installchangelogs -s -X ChangeLog
	dh_installchangelogs -pmono-runtime
	dh_installchangelogs -pmono-jay $(CURDIR)/mcs/jay/ChangeLog
	dh_installdocs -s
	dh_installman -s
	dh_installexamples -s
	dh_installexamples -pmono-jay $(CURDIR)/mcs/jay/skeleton.cs
	dh_strip -pmono-runtime --dbg-package=mono-runtime-dbg
	dh_strip -plibmono0 --dbg-package=libmono0-dbg
	dh_strip -s
	dh_compress -s -Xskeleton.cs

	# Hack workaround to allow Ubuntu to run its own preinst (e.g. to kill symlinked docdirs)
	if [ "$(DISTRO)" = "Ubuntu" ]; then \
	  for p in $$(dh_listpackages -a); do \
	    sed "s/#PACKAGENAME#/$$p/g" $(CURDIR)/debian/preinst.ubuntu >> debian/$$p.preinst.debhelper; \
	  done; \
	fi

	dh_fixperms -s
	dh_makeshlibs -plibmono0 -V 'libmono0 (>= $(UPVERSION))'
	dh_installdeb -s
	dh_shlibdeps -s -Xlibmono-profiler-cov -ldebian/libmono0/usr/lib
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s

get-orig-source: TARBALL_DIR = $(DEB_SOURCE_NAME)-$(UPVERSION)
get-orig-source:
	uscan \
		--package $(DEB_SOURCE_NAME) \
		--watchfile $(DEBIAN_DIR)/watch \
		--upstream-version $(UPVERSION) \
		--download-version $(UPVERSION) \
		--destdir . \
		--force-download \
		--rename \
		--repack
	if [ -d $(TARBALL_DIR) ]; then \
		echo "$(TARBALL_DIR) is in the way, bailing out!"; \
		exit 1; \
	fi
	if [ -d $(TARBALL_DIR)+dfsg ]; then \
		echo "$(TARBALL_DIR)+dfsg is in the way, bailing out!"; \
		exit 1; \
	fi
	tar -xzf $(DEB_SOURCE_NAME)_$(UPVERSION).orig.tar.gz
	rm $(DEB_SOURCE_NAME)_$(UPVERSION).orig.tar.gz
	find $(TARBALL_DIR) -name "*.dll" -not -path "$(TARBALL_DIR)/mcs/class/lib/monolite/*" -print -delete
	find $(TARBALL_DIR) -name "*.exe" -not -path "$(TARBALL_DIR)/mcs/class/lib/monolite/*" -print -delete
	mv $(TARBALL_DIR) $(TARBALL_DIR)+dfsg
	tar -czf $(DEB_SOURCE_NAME)_$(UPVERSION)+dfsg.orig.tar.gz $(TARBALL_DIR)+dfsg
	rm -r $(TARBALL_DIR)+dfsg

.PHONY: autoreconf \
        configure-arch configure-indep \
        clean clean-patched \
        build build-all build-arch build-indep \
        test test-arch \
        install install-all install-arch install-indep \
        binary binary-arch binary-indep \
        patch unpatch \
        get-orig-source

.NOTPARALLEL:

  
openSUSE Build Service is sponsored by