[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#354895: Works fine now - nevertheless here's my rules file



Hi,

first, I would like to confirm that the wizard is working fine now.

Nevertheless, I still get lots of email asking for instructions how to build 
OOo with Sun's JDK, or the rules file.

So here it is, the rules file I had used for building 2.0.4-5 packages with 
Sun's JDK.

And here's my advice how to build them:

1. Don't do it! The bug is fixed at least in the packages from unstable. Use 
them!
2. If you are an Ubuntu user and can't use those packages due to a package 
version conflict, well, then you should definitely switch to Debian  ;-)


Kind regards,

Felix
#!/usr/bin/make -f
###################################################################################
# OpenOffice.org source package rules flie
#
# Please see debian/README for detailed documentation about the build system, and
# how to build OpenOffice.org.
###################################################################################
# Authors:
# Chris Halls <halls@debian.org>
# Rene Engelhard <rene@debian.org>
# Copyright 2002-2006 Software in the Public Interest, Inc.
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
###################################################################################

default: environment
#VER:=2
SHELL:=/bin/bash
PKGDIR:=debian/openoffice.org$(VER)
OODIR:=usr/lib/openoffice$(VER)

PKGSOURCE := $(shell dpkg-parsechangelog | awk '/^Source:/ {print $$2;exit 0}')
SOURCE_VERSION:=$(shell head -1 debian/changelog | cut -d\( -f2 | cut -d\) -f1)
UPSTREAM_VERSION:=$(shell echo "$(SOURCE_VERSION)"| cut -d- -f1)
BASE_VERSION:=$(UPSTREAM_VERSION)
#HELP_L10N_VIRTUAL_VERSION:=$(UPSTREAM_VERSION)
HELP_L10N_VIRTUAL_VERSION:=2.0.4

BINARY_VERSION=$(SOURCE_VERSION)
#BINARY_VERSION=2.0.3-$(shell dpkg-parsechangelog  | grep urgency \
	| awk '{print $$2}' | sed -e s/"("// -e s/")"// | cut -d"-" -f2)
PACKAGES := $(shell dh_listpackages)

ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
DIST := $(shell lsb_release -is)
DISTREL := $(shell lsb_release -cs)
# Figure out who's building this package.
BUILDER:=$(shell echo $$LOGNAME)
OOO_VENDOR:=Debian
ifeq "$(DIST)" "Ubuntu"
OOO_VENDOR+= and Ubuntu
endif
export OOO_VENDOR

# debhelper
export DH_OPTIONS
export DH_ALWAYS_EXCLUDE=CVS
#export DH_VERBOSE=1

# work around tcsh bugs.debian.org/339034: tcsh: Unknown colorls variable `su'
unexport LS_COLORS

#TAG=src680-$(MILESTONE)
#MILESTONE:=$(shell echo "$(UPSTREAM_VERSION)"| cut -d~ -f2)
TAG=OOO_2_0_4
OOO_BUILD_BRANCH=-rooo-build-2-0-4
SOURCE_TREE=ooo-build/build/$(TAG)
STAMP_DIR=debian/stampdir

# Read in architecture-specific variables of importance.
#include debian/scripts/vars.$(ARCH)

ifeq "$(DISTREL)" "sarge"
  SARGE_BACKPORT=y
endif

#########
# Default package configuration
#
OS:= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
BUILD_AMD64=y
PATCHSET=$(DIST)
BUILD_DEPS=
BUILD_PYUNO=y
PACKAGE_QA_TOOLS=y
PACKAGE_TTF_OPENSYMBOL=y
PACKAGE_NPSOPLUGIN=n
BUILD_JARS_NATIVE=n
BUILD_BINFILTERS=y
BUILD_ONLY_EN_US=n
ENABLE_JAVA=y
ENABLE_MONO=n
USE_SYSTEM_HUNSPELL=y
SYSTEM_ALTLINUXHYPH=y
LIBALTLINUXHYPH_MINVER= (>= 0.1.1-7)
USE_AGG=n
SYSTEM_AGG=n
USE_STLPORT=y
USE_STLPORT5=n
USE_SYSTEM_STLPORT=y
ifeq "$(USE_STLPORT5)" "y"
  LIBSTLPORT_MINVER= (>= 5.0.2-8)
else
  LIBSTLPORT_MINVER= (>= 4.6.2-3)
endif
#ifeq "$(USE_STLPORT5)" "y"
  USE_SYSTEM_BOOST=y
#else
#  USE_SYSTEM_BOOST=n
#endif
USE_SYSTEM_PORTAUDIO=y
USE_EXTERNAL_CXXLIBS=y
LIBWPD8_MINVER= (>= 0.8.3-3)
USE_SYSTEM_SABLOT=n
USE_LIBXSLT=y
USE_EXTERNAL_MYTHES=n
USE_SYSTEM_ICU=y
USE_SYSTEM_XMLSEC=n
BUILD_CAIROCANVAS=y
USE_SYSTEM_CAIRO=y
BUILD_MDBTOOLS=y
USE_SYSTEM_MDBTOOLS=y
BUILD_KDE=y
BUILD_DBG_PACKAGE=y
USE_SYSTEM_BSH=y
USE_SYSTEM_HSQLDB=y
LIBDB_JAVA_MINVER= (>= 4.2.52-21)
USE_FIREFOX=n
USE_XULRUNNER=n
KDELIBS_MINVER= (>= 4:3.4.3-2)
USE_SYSTEM_LPSOLVE=y
USE_DBUS=y
USE_GSTREAMER=y
USE_SYSTEM_NEON=y
USE_PYCENTRAL=y
PACKAGE_QUICKSTART=y
USE_OOO_BUILD_DESKTOPS=n

# when we have a package we want to have to be installed on older things with some older
# C++ ABI (like it was the case with openoffice.org2), we need to set this. Don't touch
# otherwise
INTERNAL_STDLIBS=n

# Default flags to pass to configure of ooo-build
CONFIGURE_FLAGS= --disable-post-install-scripts \
                 --with-tag=$(TAG) \
                --with-system-gcc \
                --with-distro=$(PATCHSET) \
		--with-vendor='$(OOO_VENDOR)' \
                --enable-package-directories \
                --with-installed-ooo-dirname=openoffice$(VER) \
                --mandir=/usr/share/man \
                --with-docdir=/usr/share/doc/openoffice.org \
		--with-lang="$(ISOS)" \
                --with-build-version="openoffice.org$(VER)-core $(BINARY_VERSION), `LANG=C date`" \
                --disable-strip \
                --enable-atkbridge \
                --enable-lockdown

ifneq "$(PACKAGE_QUICKSTART)" "y"
  CONFIGURE_FLAGS+= --disable-quickstart
endif

#############
# Distro-specific overrides

# Debian
ifeq "$(DIST)" "Debian"
  # we don't need to build all languages and the thesaurus on the buildds;
  # they do binary-only builds anyway
  ifeq (buildd,$(shell whoami))
       BUILD_ONLY_EN_US=y
  endif
  SYSTEM_AGG=y
  USE_SYSTEM_HUNSPELL=y
  USE_XULRUNNER=y
endif

ifeq "$(DIST)" "Ubuntu"
  USE_FIREFOX=y
endif

# Debian Sarge backport
ifeq "$(SARGE_BACKPORT)" "y"
  OS:= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
  PATCHSET=$(DIST)Sarge
  BUILD_CAIROCANVAS=n
  BUILD_JARS_NATIVE=n
  KDELIBS_MINVER=
  LIBALTLINUXHYPH_MINVER=
  LIBDB_JAVA_MINVER=
  LIBSTLPORT_MINVER=
  LIBWPD8_MINVER=
  SYSTEM_AGG=n
  SYSTEM_ALTLINUXHYPH=n
  USE_STLPORT5=n
  USE_SYSTEM_BSH=n
  USE_SYSTEM_HSQLDB=n
  USE_SYSTEM_HUNSPELL=n
  USE_SYSTEM_ICU=n
  USE_SYSTEM_MDBTOOLS=n
  USE_SYSTEM_PORTAUDIO=n
  USE_SYSTEM_XMLSEC=n
  USE_XULRUNNER=n
  USE_SYSTEM_LPSOLVE=n
  USE_DBUS=n
  USE_GSTREAMER=n
  USE_PYCENTRAL=n
endif

# X, curl, db and neon builddeps...
ifeq "$(SARGE_BACKPORT)" "y"
	BUILD_DEPS += , libcurl3-dev [$(OOO_ARCHS)]
	BUILD_DEPS += , xlibs-static-dev [$(OOO_ARCHS)], render-dev [$(OOO_ARCHS)]
	BUILD_DEPS += , unixodbc-dev [$(OOO_ARCHS)]
	BUILD_DEPS += , libdb4.2-dev [$(OOO_ARCHS)]
else
	BUILD_DEPS += , libcurl3-openssl-dev [$(OOO_ARCHS)]
	BUILD_DEPS += , libxkbfile-dev [$(OOO_ARCHS)], libxinerama-dev [$(OOO_ARCHS)], x11proto-render-dev [$(OOO_ARCHS)]
	BUILD_DEPS += , unixodbc-dev (>= 2.2.11) [$(OOO_ARCHS)]
	BUILD_DEPS += , libdb4.4-dev [$(OOO_ARCHS)]
	DBG_DBG_SUGGESTS += libcurl3-dbg, libxinerama1-dbg
endif

#############
# Architecture-specific changes

OOO_ARCHS= i386 powerpc sparc
ifeq "$(BUILD_AMD64)" "y"
  OOO_ARCHS += amd64
endif
# Java...
OOO_JAVA_ARCHS = i386 powerpc sparc
ifeq "$(BUILD_AMD64)" "y"
  OOO_JAVA_ARCHS+= amd64
endif
ifeq (,$(findstring $(ARCH),$(OOO_JAVA_ARCHS)))
       ENABLE_JAVA=n
endif

# Changes for 64 bit build
ifeq "$(ARCH)" "amd64"
  PATCHSET:=$(PATCHSET)64
  USE_SYSTEM_BOOST=y
endif

# For sarge, there's no suitable Java
ifeq "$(ARCH)" "sparc"
  ifeq "$(SARGE_BACKPORT)" "y"
    ENABLE_JAVA=n
  endif
endif
ifeq "$(ARCH)-linux-gnu" "sparc-linux-gnu"
	# use 32-bit compiler
	CC_PREFIX=sparc-linux-gnu-
endif

# We only build the main openoffice.org packages on those architectures where it works
# # all other architectures build libmythes-dev
ifneq "$(USE_EXTERNAL_MYTHES)" "y"
  ifneq ($(ARCH),$(findstring $(ARCH),$(OOO_ARCHS)))
       BUILD_ONLY_LIBMYTHES=y
  else
    ifeq "$(ARCH)" "amd64"
      ifneq "$(BUILD_AMD64)" "y"
               BUILD_ONLY_LIBMYTHES=y
      endif
    endif
  endif
endif

ifneq "$(BUILD_DBG_PACKAGE)" "y"
	DH_COMPAT=4
	SMALL_SYMBOLS = y
else
	DH_COMPAT=5
	# -g gives a far too big deb (>400M, ca. 1GB I-S)
	SMALL_SYMBOLS = y
	DBG_DBG_SUGGESTS+= , libatk1.0-dbg, libglib2.0-0-dbg, libgnomevfs2-0-dbg, libstdc++6-dbg, libx11-6-dbg, libxext6-dbg, libxaw7-dbg, libxml2-dbg, libgtk2.0-0-dbg, libxau6-dbg, libice6-dbg, libsm6-dbg
endif
export DH_COMPAT

ifeq "$(BUILD_PYUNO)" "y"
    ifeq "$(USE_PYCENTRAL)" "y"
	BUILD_DEPS += , python-central (>= 0.5) [$(OOO_ARCHS)], debhelper (>= 5.0.37.2), python-dev (>= 2.4) [$(OOO_ARCHS)]
    else
	BUILD_DEPS += , debhelper (>= 4.2.21), python-dev [$(OOO_ARCHS)]
    endif
    WRITER_PYUNO_DEP = python-uno (>= $(UPSTREAM_VERSION))
    DBG_DBG_SUGGESTS+= , python-dbg
else 
  ifeq "$(BUILD_DBG_PACKAGE)" "y"
	BUILD_DEPS += , debhelper (>= 4.2.21)
  else
    ifneq "$(SARGE_BACKPORT)" "y"
	BUILD_DEPS += , debhelper (>= 5)
    endif
  endif
  BUILD_DEPS += python [$(OOO_ARCHS)]
endif

ifeq "$(BUILD_JARS_NATIVE)" "y"
	BUILD_DEPS += , dpkg-dev (>= 1.13.19)
	STAMP_NATIVE_JARS = $(STAMP_DIR)/native-jars
	JAVA_GCJ_DEPENDS = libgcj-common (>= 1:4.1.1-14)
endif

ifneq "$(PACKAGE_QA_TOOLS)" "y"
	DEBHELPER_OPTIONS+= -Nopenoffice.org$(VER)-qa-tools -Nopenoffice.org$(VER)-qa-api-tests
	CONFIGURE_FLAGS += --disable-qadevooo
endif
ifneq "$(PACKAGE_TTF_OPENSYMBOL)" "y"
	DEBHELPER_OPTIONS+= -Nttf-opensymbol
endif

ifneq "$(BUILD_ONLY_EN_US)" "y"
  ifeq (lang=,$(findstring lang=,$(DEB_BUILD_OPTIONS)))
    ISOS=$(shell echo "$(DEB_BUILD_OPTIONS)," | sed -n 's/^.*lang=\([^,]*\),.*/\1/p')
    HELPISOS=$(shell echo "$(DEB_BUILD_OPTIONS)," | sed -n 's/^.*lang=\([^,]*\),.*/\1/p')
    LANGPACKISOS=$(shell echo "$(DEB_BUILD_OPTIONS)," | sed -n 's/^.*lang=\([^,]*\),.*/\1/p')
  else
    # Note that the first one here *has to be* en-US. the first one gets
    # gid_Module_Root as filelist later and the rest gid_Module_Root.$iso
    # but we can't/shouldn't do dynamic switching, so let en-US be the first
    # one to that gid_Module_Root always is english and the other langpacks
    # have gid_Module_Root.$iso
    #ISOS=$(shell ooo-build/bin/openoffice-xlate-lang -i all')
    ISOS:=en-US de 
    #HELPISOS:=$(shell ooo-build/bin/openoffice-xlate-lang -i all') 
    HELPISOS:=en-US de 
    #LANGPACKISOS:=$(shell ooo-build/bin/openoffice-xlate-lang -i all')
    LANGPACKISOS:=en-US de 

    ifneq "$(SARGE_BACKPORT)" "y"
      ISOS := en-US $(sort $(filter-out en-US, $(ISOS)) )
      LANGPACKISOS := en-US $(sort $(filter-out en-US, $(LANGPACKISOS)) )
    endif
  endif
else
  ISOS=en-US
  HELPISOS=en-US
  LANGPACKISOS=en-US
endif

ifeq "$(VER)" ""
	CONFIGURE_FLAGS += --with-binsuffix=no
else
	CONFIGURE_FLAGS += --with-binsuffix=$(VER)
endif

ifeq "$(ENABLE_JAVA)" "y"
ifneq "$(SARGE_BACKPORT)" "y"
	JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
	JAVA_HOME_GCJ=/usr/lib/jvm/java-gcj
	BUILD_DEPS += , sun-java5-jdk [i386], ibm-j2sdk1.4 [powerpc], ant [$(OOO_JAVA_ARCHS)]
	#CONFIGURE_FLAGS += --with-java=gij --enable-gcjaot
    ifeq "$(BUILD_JARS_NATIVE)" "y"
	BUILD_DEPS += , java-gcj-compat-dev (>= 1.0.65-4) [$(OOO_JAVA_ARCHS)]
    else
	BUILD_DEPS += , java-gcj-compat-dev (>= 1.0.56) [$(OOO_JAVA_ARCHS)]
    endif
	BUILD_DEPS += , ant (>= 1.6.5) [$(OOO_JAVA_ARCHS)]
	GCJ_VERSION = $(shell $(JAVA_HOME_GCJ)/bin/gcj --version | head -n 1 | awk '{ print $$3; }' | cut -d"." -f1,2)
	GCJ_DBTOOL = gcj-dbtool-$(GCJ_VERSION)
	SYSTEM_XT=y
	SYSTEM_XALAN=y
	SYSTEM_XERCES=y
	SYSTEM_XML_APIS=y
ifeq "$(GCJ_VERSION)" "4.2"
	LIBGCJ_SONR=8
else
	LIBGCJ_SONR=7
endif
	DBG_DBG_SUGGESTS+= , libgcj$(LIBGCJ_SONR)-dbg
	JAWT_DEPENDS= , libgcj$(LIBGCJ_SONR)-awt

else
ifeq "$(ARCH)" "i386"
	JAVA_HOME=/usr/lib/j2se/1.4
else
	JAVA_HOME=/usr/lib/j2sdk1.4-ibm
endif
	BUILD_DEPS += , j2sdk1.4 [i386], ibm-j2sdk1.4 [powerpc], ant [$(OOO_JAVA_ARCHS)]
	CONFIGURE_FLAGS += --with-system-xml-apis
	SYSTEM_XT=n
	SYSTEM_XALAN=y
	SYSTEM_XERCES=y
	SYSTEM_XML_APIS=y
endif
export JAVA_HOME
	CONFIGURE_FLAGS += --with-jdk-home=$(JAVA_HOME)
	JAVA_COMMON_DEPENDS= , openoffice.org$(VER)-java-common
  ifeq "$(SYSTEM_XT)" "y"
	CONFIGURE_FLAGS += --with-system-xt	
	JAVA_COMMON_JAVA_DEPENDS+= , libxt-java (>= 0.20050823)
	BUILD_DEPS += , libxt-java (>= 0.20050823) [$(OOO_JAVA_ARCHS)]
  endif
  ifeq "$(SYSTEM_XERCES)" "y"
	CONFIGURE_FLAGS += --with-system-xerces
	BUILD_DEPS += , libxerces2-java [$(OOO_JAVA_ARCHS)]
	JAVA_COMMON_JAVA_DEPENDS+= , libxerces2-java
  endif
  ifeq "$(SYSTEM_XALAN)" "y"
	CONFIGURE_FLAGS += --with-system-xalan
	BUILD_DEPS += , libxalan2-java (>= 2.6.0-1) [$(OOO_JAVA_ARCHS)]
	JAVA_COMMON_JAVA_DEPENDS+= , libxalan2-java (>= 2.6.0-1)
  endif
  ifeq "$(SYSTEM_XML_APIS)" "y"
	CONFIGURE_FLAGS += --with-system-xml-apis
	BUILD_DEPS += , libjaxp1.2-java [$(OOO_JAVA_ARCHS)]
	JAVA_COMMON_JAVA_DEPENDS+= , libjaxp1.2-java
  endif
  ifneq "$(SARGE_BACKPORT)" "y"
	BUILD_DEPS += , libdb4.4-java [$(OOO_JAVA_ARCHS)]
  else
	BUILD_DEPS += , libdb4.2-java [$(OOO_JAVA_ARCHS)]
  endif
  ifeq "$(DIST)" "Debian"
	BUILD_DEPS += , mingw32 [$(OOO_JAVA_ARCHS)]
	CONFIGURE_FLAGS += --with-mingwin=i586-mingw32msvc-g++
  endif
else
	CONFIGURE_FLAGS += --without-java
	DEBHELPER_OPTIONS += -Nopenoffice.org$(VER)-officebean -Nopenoffice.org$(VER)-java-common -Nopenoffice.org$(VER)-filter-mobiledev
	HELPISOS=
endif

ifeq "$(USE_FIREFOX)" "y"
	CONFIGURE_FLAGS+= --with-firefox
	BUILD_DEPS+= , firefox-dev [$(OOO_ARCHS)], libnspr-dev [$(OOO_ARCHS)]
else
 ifeq "$(USE_XULRUNNER)" "y"
	CONFIGURE_FLAGS+= --with-xulrunner
	BUILD_DEPS+= , libxul-dev [$(OOO_ARCHS)], libnss3-dev [$(OOO_ARCHS)]
	DBG_DBG_SUGGESTS+= , libnss3-0d-dbg, libnspr4-0d-dbg
 else
	BUILD_DEPS+= , mozilla-dev [$(OOO_ARCHS)], libnss-dev (>= 1.7.5) [$(OOO_ARCHS)]
	MOZILLA_NSS_DEPENDS = libnss3 (>= 1.7.5), libnspr4
 endif
endif

ifeq "$(ENABLE_MONO)" "y"
       BUILD_DEPS += , mono-mcs (>= 1.1.8) [$(OOO_ARCHS)], libmono-dev (>= 1.1.8) [$(OOO_ARCHS)], cli-common-dev (>= 0.4.0) [$(OOO_ARCHS)]
	# http://pkg-mono.alioth.debian.org/cli-policy/ch-mono.html#s7.3
	export MONO_SHARED_DIR=$(CURDIR)
else
       CONFIGURE_FLAGS+= --disable-mono
endif

ifeq "$(USE_SYSTEM_HUNSPELL)" "y"
		BUILD_DEPS += , libhunspell-dev (>= 1.0.8-3) [$(OOO_ARCHS)]
		CONFIGURE_FLAGS+= --with-system-hunspell
endif

ifeq "$(SYSTEM_ALTLINUXHYPH)" "y"
	BUILD_DEPS += , libaltlinuxhyph-dev $(LIBALTLINUXHYPH_MINVER) [$(OOO_ARCHS)]
	CONFIGURE_FLAGS += --with-system-altlinuxhyph
endif

ifeq "$(USE_AGG)" "y"
  CONFIGURE_FLAGS+= --with-agg
  ifeq "$(SYSTEM_AGG)" "y"
       BUILD_DEPS += , libagg-dev (>= 2.3-2) [$(OOO_ARCHS)]
       CONFIGURE_FLAGS += --with-system-agg
  endif
endif

ifneq "$(USE_STLPORT)" "y"
	CONFIGURE_FLAGS += --without-stlport
else
  ifeq "$(USE_SYSTEM_STLPORT)" "y"
    ifeq "$(USE_STLPORT5)" "y"
      BUILD_DEPS += , libstlport5.0-dev $(LIBSTLPORT_MINVER) [$(OOO_ARCHS)]
      DEV_STL_DEPENDS=, libstlport5.0-dev $(LIBSTLPORT_MINVER)
      DBG_DBG_SUGGESTS+= , libstlport5.0-dbg
    else
      BUILD_DEPS += , libstlport4.6-dev $(LIBSTLPORT_MINVER) [$(OOO_ARCHS)]
      DEV_STL_DEPENDS=, libstlport4.6-dev $(LIBSTLPORT_MINVER)
    endif
    CONFIGURE_FLAGS+= --with-stlport=$(CURDIR)/stlport
  endif
endif

ifeq "$(USE_SYSTEM_BOOST)" "y"
	BUILD_DEPS += , libboost-dev [$(OOO_ARCHS)]
	CONFIGURE_FLAGS += --with-system-boost
else
  ifeq "$(BUILD_AMD64)" "y"
	BUILD_DEPS += , libboost-dev [amd64]
  endif
endif

ifeq "$(USE_SYSTEM_PORTAUDIO)" "y"
	BUILD_DEPS += , libportaudio-dev [$(OOO_ARCHS)]
	CONFIGURE_FLAGS += --with-system-portaudio
endif

ifeq "$(USE_EXTERNAL_CXXLIBS)" "y"
       BUILD_DEPS += , libwpd8-dev $(LIBWPD8_MINVER) [$(OOO_ARCHS)]
       CONFIGURE_FLAGS+=  --with-system-libwpd
ifeq "$(USE_SYSTEM_SABLOT)" "y"
	BUILD_DEPS += , libsablot0-dev (>= 1.0.2-4) [$(OOO_ARCHS)]
	CONFIGURE_FLAGS += --with-system-sablot
endif
ifeq "$(USE_EXTERNAL_MYTHES)" "y"
	BUILD_DEPS += , libmythes-dev (>= 1.0-2) [$(OOO_ARCHS)]
	CONFIGURE_FLAGS += --with-system-mythes
	DEBHELPER_OPTIONS+= -Nlibmythes-dev
endif
endif

ifeq "$(USE_SYSTEM_ICU)" "y"
	BUILD_DEPS += , libicu36-dev [$(OOO_ARCHS)]
	CONFIGURE_FLAGS += --with-system-icu
	# ICU utils are in /usr/sbin (!)
	PATH+=:/usr/sbin
endif

ifeq "$(USE_LIBXSLT)" "y"
	CONFIGURE_FLAGS += --with-system-libxslt
	BUILD_DEPS += , libxslt1-dev [$(OOO_ARCHS)]
	DBG_DBG_SUGGESTS+= , libxslt1-dbg
endif

ifeq "$(USE_SYSTEM_XMLSEC)" "y"
  ifeq "$(USE_XULRUNNER)" "y"
	BUILD_DEPS += , libxmlsec1-dev (>= 1.2.9-1.1) [$(OOO_ARCHS)], libxmlsec1-nss (>= 1.2.9-1.1) [$(OOO_ARCHS)], libxmlsec1-openssl (>= 1.2.9-1.1) [$(OOO_ARCHS)]
  else
	BUILD_DEPS += , libxmlsec1-dev (>= 1.2.9) [$(OOO_ARCHS)], libxmlsec1-nss (>= 1.2.9) [$(OOO_ARCHS)], libxmlsec1-openssl (>= 1.2.9) [$(OOO_ARCHS)]
  endif
	CONFIGURE_FLAGS += --with-system-xmlsec
endif

ifeq "$(BUILD_CAIROCANVAS)" "y"
  ifeq "$(USE_SYSTEM_CAIRO)" "y"
    BUILD_DEPS+= , libcairo2-dev [$(OOO_ARCHS)], libglitz-glx1-dev [$(OOO_ARCHS)]
    CONFIGURE_FLAGS+= --with-system-cairo
  endif
else
  CONFIGURE_FLAGS+= --disable-cairo
endif

ifneq "$(BUILD_MDBTOOLS)" "y"
  CONFIGURE_FLAGS+= --disable-access
else
  ifeq "$(USE_SYSTEM_MDBTOOLS)" "y"
    BUILD_DEPS += , mdbtools-dev (>= 0.5.99.0.6pre1.0.20050409-1) [$(OOO_ARCHS)]
    CONFIGURE_FLAGS += --with-system-mdbtools
  endif
endif

ifeq "$(BUILD_KDE)" "n"
	CONFIGURE_FLAGS+= --disable-kde
	DEBHELPER_OPTIONS+= -Nopenoffice.org$(VER)-kde
	CONFIGURE_FLAGS+= --with-images="industrial crystal hicontrast"
else
       BUILD_DEPS += , kdelibs4-dev $(KDELIBS_MINVER) [$(OOO_ARCHS)]
       DBG_DBG_SUGGESTS+= , kdelibs-dbg, qt-x11-free-dbg
endif

ifeq "$(BUILD_BINFILTERS)" "y"
		CONFIGURE_FLAGS+= --enable-binfilter
		OOO_FILTER52_DEP = openoffice.org$(VER)-filter-so52
else
		DEBHELPER_OPTIONS+= -Nopenoffice.org$(VER)-filter-so52
endif
ifneq "$(BUILD_PYUNO)" "y"
		DEBHELPER_OPTIONS+= -Npython-uno
endif

ifeq "$(ENABLE_JAVA)" "y"
  ifeq "$(USE_SYSTEM_HSQLDB)" "y"
	BUILD_DEPS += , libhsqldb-java (>= 1.8.0.0-2) [$(OOO_JAVA_ARCHS)]
	BASE_HSQLDB_DEPENDS = libhsqldb-java (>= 1.8.0.0-2)
	CONFIGURE_FLAGS+= --with-system-hsqldb
  endif

  ifeq "$(USE_SYSTEM_BSH)" "y"
	BUILD_DEPS += , bsh (>= 2.0b4-1) [$(OOO_JAVA_ARCHS)]
	COMMON_BSH_DEPENDS = bsh (>= 2.0b4-1)
	CONFIGURE_FLAGS+= --with-system-beanshell
  endif
endif

ifeq "$(USE_SYSTEM_LPSOLVE)" "y"
	CONFIGURE_FLAGS += --with-system-lpsolve
	BUILD_DEPS += , liblpsolve55-dev [$(OOO_ARCHS)], libufsparse-dev [$(OOO_ARCHS)]
	DBG_DBG_SUGGESTS+= , libufsparse-dbg
endif

ifeq "$(USE_DBUS)" "y"
	BUILD_DEPS += , libdbus-glib-1-dev (>= 0.60) [$(OOO_ARCHS)]
else
	CONFIGURE_FLAGS += --disable-dbus
endif

ifeq "$(USE_GSTREAMER)" "y"
	BUILD_DEPS += , libgstreamer-plugins-base0.10-dev [$(OOO_ARCHS)]
	GSTREAMER_PLUGINS_SUGGESTS += , gstreamer0.10-plugins-base, gstreamer0.10-plugins-good, gstreamer0.10-plugins-ugly, gstreamer0.10-plugins-bad, gstreamer0.10-ffmpeg
	DBG_DBG_SUGGESTS+= , libgstreamer0.10-0-dbg 
else
	CONFIGURE_FLAGS += --disable-gstreamer
endif

ifeq "$(USE_SYSTEM_NEON)" "y"
  ifeq "$(SARGE_BACKPORT)" "y"
	BUILD_DEPS += , libneon24-dev [$(OOO_ARCHS)]
  else
	BUILD_DEPS += , libneon26-dev [$(OOO_ARCHS)]
	DBG_DBG_SUGGESTS+= , libneon26-dbg
  endif
	CONFIGURE_FLAGS += --with-system-neon
endif

# Use compiler cache?  Include ccache in DEB_BUILD_OPTIONS for much faster rebuild times
# A complete build uses about 200Mb of compiler cache.
ifeq (ccache,$(findstring ccache,$(DEB_BUILD_OPTIONS)))
  CONFIGURE_FLAGS += --with-gcc-speedup=ccache
endif

# Small symbols?
ifeq "$(SMALL_SYMBOLS)" "y"
  CONFIGURE_FLAGS += --enable-symbols=SMALL
endif

# Restart build from a particular project?
# DEB_BUILD_OPTIONS=from=<projectname>
BUILD_FROM=$(shell echo "$(DEB_BUILD_OPTIONS)," | sed -n 's/^\(.*,\)\?from=\([a-zA-Z0-9]\+\).*$$/\2/p')
export BUILD_FROM

# Build n projects in paralell / override automatic detection?
# DEB_BUILD_OPTIONS=num-cpus=<n>
NUM_CPUS=$(shell echo "$(DEB_BUILD_OPTIONS)," | sed -n 's/^\(.*,\)\?num-cpus=\([0-9]\+\).*$$/\2/p')
ifneq "$(NUM_CPUS)" ""
  CONFIGURE_FLAGS += --with-num-cpus=$(NUM_CPUS)
else
  NUM_CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
  ifeq "$(NUM_CPUS)" "1"
    # do at least a build with --with-num-cpus=2 to do something while
    # helpcontent2 is doing things slowly..
    NUM_CPUS := 2
  endif
  # using make -jX is not wanted on the Debian buildds, so don't do it...
  ifeq "$(DIST)" "Debian"
    ifeq (buildd,$(shell whoami))
      NUM_CPUS := 1
    endif
  endif
  CONFIGURE_FLAGS += --with-num-cpus=$(NUM_CPUS)
endif

# Build python depends from current python version
PYMAJOR:=$(shell python -c "import sys; print sys.version_info[0]")
PYMINOR:=$(shell python -c "import sys; print sys.version_info[1]")
PYMINORPLUS1:=$(shell python -c "import sys; print sys.version_info[1]+1")
PYTHON_SITE:=debian/python-uno/usr/lib/python$(PYMAJOR).$(PYMINOR)/site-packages

CURDIR ?= $(shell pwd)

ifeq ($(GCC_VERSION),)
	BUILD_PATH = /usr/lib/jvm/java-gcj/bin:$$PATH
else
ifeq ($(GCC_VERSION),snapshot)
	BUILD_PATH = /usr/lib/jvm/java-gcj/bin:/usr/lib/gcc-snapshot/bin:$$PATH
	BUILD_LD_LIBRARY_PATH = /usr/lib/gcc-snapshot/lib:$$LD_LIBRARY_PATH
else
	BUILD_PATH = /usr/lib/jvm/java-gcj/bin:$(CURDIR)/debian/usr/bin:$$PATH
endif
endif
BUILD_PATH := $(CURDIR)/debian/usr/bin:$(BUILD_PATH)

ifeq "$(BUILD_ONLY_LIBMYTHES)" "y"
clean:
	dh_testdir
	dh_testroot

	rm -rf ooo-build/build
	rm -rf debian/libmythes-dev
	
	dh_clean

build:
	mkdir -p ooo-build/build
	cd ooo-build/build && \
		tar xfvj ../src/$(TAG)-core.tar.bz2 $(TAG)/lingucomponent/source/thesaurus/mythes && \
		tar xfvj ../src/$(TAG)-system.tar.bz2 $(TAG)/dictionaries/util
	cd $(SOURCE_TREE)/lingucomponent/source/thesaurus/mythes && \
		$(CXX) -O2 -Wall -ansi -pedantic -I. -c mythes.cxx && \
		ar rc libmythes.a mythes.o && ranlib libmythes.a && \
		mv libmythes.a $(CURDIR)/ooo-build/build
	cd $(SOURCE_TREE)/lingucomponent/source/thesaurus/mythes && \
		$(CXX) -fPIC -O2 -Wall -ansi -pedantic -I. -c mythes.cxx && \
		ar rc libmythes_pic.a mythes.o && ranlib libmythes_pic.a && \
		mv libmythes_pic.a $(CURDIR)/ooo-build/build

install: $(CURDIR)/ooo-build/build/libmythes.a $(CURDIR)/ooo-build/build/libmythes_pic.a
	mkdir -p debian/libmythes-dev/usr/lib
	mkdir -p debian/libmythes-dev/usr/include
	mkdir -p debian/libmythes-dev/usr/share/mythes
	install -m644 \
		$(CURDIR)/ooo-build/build/libmythes.a \
		debian/libmythes-dev/usr/lib/libmythes.a
	install -m644 \
		$(CURDIR)/ooo-build/build/libmythes_pic.a \
		debian/libmythes-dev/usr/lib/libmythes_pic.a
	install -m644 $(SOURCE_TREE)/lingucomponent/source/thesaurus/mythes/mythes.hxx \
		debian/libmythes-dev/usr/include
	install -m755 $(SOURCE_TREE)/dictionaries/util/th_gen_idx.pl \
		debian/libmythes-dev/usr/share/mythes/th_gen_idx.pl

binary: binary-arch

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installdocs -plibmythes-dev
	dh_installchangelogs -plibmythes-dev
	rm -f debian/libmythes-dev/usr/share/doc/libmythes-dev/NEWS.Debian*
	chmod 755 debian/scripts/installoverrides
	debian/scripts/installoverrides
	dh_link -plibmythes-dev
	dh_fixperms -plibmythes-dev
	dh_compress -plibmythes-dev
	dh_installdeb -plibmythes-dev
	dh_gencontrol -plibmythes-dev -- -v$(BINARY_VERSION)
	dh_md5sums -plibmythes-dev
	dh_builddeb -plibmythes-dev
else
# Because of the stampdir magic, when you actually want to run a rule
# over, you would have to remove the stamp manually.  Now, just do
# 'debian/rules <target> <target> ... FORCE=1', and the stamp files
# that match the given targets will be removed automagically.
stampdir_targets=files.backup icons.scale patch.apply build.prepare.artwork 
stampdir_targets+=build.prepare configure
stampdir_targets+=setupins setup install install-arch install-indep
stampdir_targets+=langpacks helppacks binary-common binary-arch binary-indep
ifdef FORCE
 DUMMY:=$(shell rm -f $(patsubst %,$(STAMP_DIR)/%,$(filter $(stampdir_targets),$(MAKECMDGOALS))))
endif

# If this is defined, then none of the 'long' commands will be run.  Useful
# for testing.
# test_rules=1

# Since the final stages use up a large amount of diskspace, provide targets to
# remove them without needing a full rebuild

# Clean up the package directories (about 830M) 
clean-debdir:
	dh_testdir
	rm -f debian/*.postinst debian/*.postrm debian/*.preinst debian/*.prerm
	rm -f $(STAMP_DIR)/setup
	dh_clean

# Clean up the installation sets and package directories (about 2.5 Gb!)
clean-instsetoo: clean-debdir
	dh_testdir
	rm -f $(STAMP_DIR)/instsetoo
	# Remove all installation sets
	rm -rf $(SOURCE_TREE)/instsetoo/$(ARCHBUILDDIR)

# Clean compilation results, but leave solver (about 600Mb in addition to instsetoo)
clean-objectdirs: clean-instsetoo
	dh_testdir
	find $(SOURCE_TREE) -maxdepth 2 -name $(ARCHBUILDDIR) -type d -exec rm -rf {} \;

clean:
	dh_testroot
	dh_testdir

	if [ -r ooo-build/Makefile ]; then \
	  $(MAKE) -C ooo-build distclean || true ;\
	fi

	# we do not need them and they make problem with dpkg-source....
	rm -f ooo-build/www/*.png \
		ooo-build/www/images/*.png \
		ooo-build/www/l10n/*.gif \
		ooo-build/src/open*.png ooo-build/src/file-bug*.png \
		ooo-build/src/*.bmp ooo-build/src/*.xcf \
		ooo-build/src/*.ico \
		ooo-build/src/Draft.jpg \
		ooo-build/src/easter/*.png
	rm -rf ooo-build/scratch/buildbot ooo-build/buildbot

	if [ -d ooo-build/test ]; then \
		find ooo-build/test ooo-build/doc -type f \
		     \( -name '*.xls' -o -name '*.sx?' -o -name '*.doc' \
			-o -name '*.123' -o -name '*.lwp' -o -name '*.ppt' \
			-o -name '*.wb2' -o -name '*.png' -o -name '*.WB2' \
			-o -name '*.odp' -o -name '*.odt' -o -name "*.ods" \) \
			-exec rm {} \; ;\
	fi
	rm -rf ooo-build/patches/test/*.tar
	find ooo-build/scratch ooo-build/src -type f \
			\( -name '*.ott' -o -name '*.ods' -o -name '*.odg' \) \
			-exec rm {} \;
	rm -f ooo-build/fonts/symbols.xls
	rm -rf ooo-build/desktop/*.desktop
	rm -rf ooo-build/build
	rm -f ooo-build/src/GSI*.sdf
	rm -f ooo-build/po/.intltool-merge-cache
	rm -rf ooo-build/autom4ate.cache

	# remove generated symlinks / java wrappers
	rm -rf debian/usr

	# stlport home
	rm -rf $(CURDIR)/stlport
	# convenience link
	rm -f build

	# uuencode binary files
	set -e; \
	cd ooo-build ;\
	  for f in fonts/opens___.ttf src/ooo_*_images*.bz2 src/extras*bz2 \
	    src/evolocal.odb src/*.gz src/GSI*bz2 src/xt*zip src/go-oo-team.png \
	    templates/*.o?? src/biblio*bz2; do \
	  if [ -s $$f ]; then \
	    uuencode $$f $$f > $$f.uu.tmp && \
	    ../debian/scripts/move-if-change $$f.uu.tmp $$f.uu; \
            touch -r $$f $$f.uu ;\
	  fi ;\
	  rm -f $$f ;\
	done

        # uuencode Ximian desktop icons
	set -e; \
	for i in base calc draw impress math template web writer; do \
	  f=ooo-build/desktop/ooo-$$i.png; \
	  if [ -s $$f ]; then \
	    uuencode $$f $$f > $$f.uu.tmp && \
	    debian/scripts/move-if-change $$f.uu.tmp $$f.uu; \
            touch -r $$f $$f.uu ;\
	fi; \
	done
	rm -f ooo-build/desktop/*.png
	rm -f ooo-build/src/GSI*err
	rm -f ooo-build/config.*

	# uuencode broffice.org bitmaps
	for f in debian/ooonologointro-broffice.org.bmp debian/openabout-broffice.org.bmp; do \
	  if [ -s $$f ]; then \
	    uuencode $$f $$f > $$f.uu.tmp && \
	    debian/scripts/move-if-change $$f.uu.tmp $$f.uu; \
            touch -r $$f $$f.uu ;\
	  fi ;\
	  rm -f $$f ;\
	done
	dh_clean

	# Files created in debian directory
	rm -f debian/*.postinst debian/*.postrm debian/*.preinst debian/*.prerm
	if [ -d "$(STAMP_DIR)" ]; then rm -rf "$(STAMP_DIR)"; fi
	rm -f debian/shlibs.override.stdlibs

ifeq "$(ENABLE_MONO)" "y"
	rm -rf $(MONO_SHARED_DIR)/.wapi
endif

ifeq "$(HELPISOS)" ""
	rm -rf images*
endif

	rm -f l10n.fdupes
	rm -f debian/shlibs.local

	$(MAKE) -f debian/rules control


# Generate control file, because we have so many different languages
# Based on script by Martin Quinson <Martin.Quinson@tuxfamily.org>
control: debian/control
debian/control: debian/control.in debian/control.lang.in debian/control.help.in ooo-build/bin/openoffice-xlate-lang debian/rules
	chmod 755 ooo-build/bin/openoffice-xlate-lang
	sed -e "s#openoffice.orgVER#openoffice.org$(VER)#g" \
	    -e "s#broffice.orgVER#broffice.org$(VER)#g" \
	    -e "s#%$(DIST)=\([^%]*\)%#, \1#g#" \
	    -e "s#%[A-Za-z]*=[^%]*%##g#" \
	    -e "s#%BUILD_DEPS%#$(strip $(BUILD_DEPS))#g" \
	    < debian/control.in > debian/control

	for LNUM in $(filter-out en-US,$(LANGPACKISOS)) ; do \
	    LNAME=`ooo-build/bin/openoffice-xlate-lang -l $$LNUM | perl -e 'print ucfirst(<STDIN>);'`; \
	    LCODE=`ooo-build/bin/openoffice-xlate-lang -i $$LNUM | tr A-Z a-z`; \
	    CCODE=`echo $$LCODE | sed 's/-.*//'`; \
	    case "$$LCODE" in \
		bn|gu-in|pa-in|ml-in|or-in|te-in|ta-in) \
			FONT_SUGGESTS=", ttf-`echo $$LNAME | tr A-Z a-z`-fonts"; \
			;; \
		hi-in|ne|mr-in) \
			FONT_SUGGESTS=", ttf-devanagari-fonts"; \
			;; \
		he) \
			FONT_SUGGESTS=", culmus"; \
			;; \
		km) \
			FONT_SUGGESTS=", ttf-khmeros"; \
			;; \
		lo) \
			FONT_SUGGESTS=", ttf-lao"; \
			;; \
		ar) \
			FONT_SUGGESTS=", ttf-arabeyes"; \
			;; \
		fa) \
			FONT_SUGGESTS=", ttf-farsiweb"; \
			;; \
		*) \
			FONT_SUGGESTS= ;; \
	    esac; \
	    case "$$LCODE" in \
		rw) \
			LOCALES_DEPENDS="locales (>= 2.3.6) | belocs-locales-data | locales-all (>= 2.3.6)" \
			;; \
		ss|ts|km|sr-cs|ns|tn) \
			LOCALES_DEPENDS="locales (>= 2.3.5-12) | belocs-locales-data | locales-all" \
			;; \
		as-in|or-in|nr) \
			LOCALES_DEPENDS="locales (>= 2.3.6.ds1-1) | locales-all (>= 2.3.6.ds1-1)" \
			;; \
		*) \
			LOCALES_DEPENDS="locales | belocs-locales-data | locales-all" \
			;; \
	    esac; \
	    sed -e "s|@LNAME@|$$LNAME|g" -e "s|@LCODE@|$$LCODE|g" \
		-e "s|@CCODE@|$$CCODE|g" \
	        -e "s|@FONT_SUGGESTS@|$$FONT_SUGGESTS|g" \
	        -e "s:@LOCALES_DEPENDS@:$$LOCALES_DEPENDS:g" \
			-e "s|openoffice.orgVER|openoffice.org$(VER)|g" \
	        >> debian/control < debian/control.lang.in; \
	done

ifneq "$(HELPISOS)" ""
	for LNUM in $(HELPISOS) ; do \
	    LNAME=`ooo-build/bin/openoffice-xlate-lang -l $$LNUM | perl -e 'print ucfirst(<STDIN>);'`; \
	    LCODE=`ooo-build/bin/openoffice-xlate-lang -i $$LNUM | tr A-Z a-z`; \
	    CCODE=`echo $$LCODE | sed 's/-.*//'`; \
	    sed -e "s|@LNAME@|$$LNAME|g" -e "s|@LCODE@|$$LCODE|g" \
		-e "s|@CCODE@|$$CCODE|g" \
			-e "s|openoffice.orgVER|openoffice.org$(VER)|g" \
	        >> debian/control < debian/control.help.in; \
	done
	# en_US is in -common
	perl -pi -e 's|(Depends: openoffice.org$(VER)-writer), openoffice.org$(VER)-l10n-en-us|\1|' \
		debian/control
	perl -pi -e 's|(Depends: openoffice.org$(VER)-writer, openoffice.org$(VER)-l10n-en-us)|\1, ttf-devanagari-fonts|' \
		debian/control
endif
ifeq "$(BUILD_JARS_NATIVE)" "y"
	sed -e "s|openoffice.orgVER|openoffice.org$(VER)|g" \
		>> debian/control < debian/control.gcj.in
endif
ifeq "$(ENABLE_MONO)" "y"
	sed -e "s|openoffice.orgVER|openoffice.org$(VER)|g" \
		>> debian/control < debian/control.mono.in
endif
ifeq "$(PACKAGE_QA_TOOLS)" "y"
	sed -e "s|openoffice.orgVER|openoffice.org$(VER)|g" \
		>> debian/control < debian/control.qa.in
endif
ifeq "$(PACKAGE_NPSOPLUGIN)" "y"
	sed -e "s|openoffice.orgVER|openoffice.org$(VER)|g" \
		>> debian/control < debian/control.mozilla.in
endif
ifeq "$(BUILD_DBG_PACKAGE)" "y"
	sed -e "s|openoffice.orgVER|openoffice.org$(VER)|g" \
		>> debian/control < debian/control.debug.in
endif
# Debian sarge->etch transitional packages
ifeq "$(DIST)" "Debian"
	sed -e "s|openoffice.orgVER|openoffice.org$(VER)|g" \
		>> debian/control < debian/control.sarge_etch_transitional.in
	perl -pi -e 's/Description: English_american help for OpenOffice.org/Replaces: openoffice.org$(VER)-help-en\nDescription: English_american help for OpenOffice.org/' debian/control
endif


ifeq "$(SARGE_BACKPORT)" "y"
	perl -pi -e "s,%CONTRIB%,contrib/,g" debian/control
else
	perl -pi -e "s,%CONTRIB%,,g" debian/control
endif

	perl -pi -e "s,%OOO_ARCHS%,$(OOO_ARCHS),g" debian/control

ifeq "$(PACKAGE_QUICKSTART)" "y"
	perl -pi -e 's#\(Widgets, Dialogs\)#\(Widgets, Dialogs, Quickstarter\)#' debian/control
	perl -pi -e 's/GNOME\./GNOME. It also\n contains a QuickStarter for the \"notification area\"./' debian/control
	perl -pi -e 's/Package: openoffice.org$(VER)-gtk$$/Package: openoffice.org-gtk\nConflicts: ooqstart-gnome, oooqs-kde/' debian/control
	perl -pi -e 's/Conflicts: openoffice.org-thesaurus/Conflicts: openoffice.org-thesaurus, oooqstart-gnome, oooqs-kde/' debian/control
else
	perl -pi -e 's/Conflicts: openoffice.org-thesaurus/Conflicts: openoffice.org-thesaurus, oooqstart-gnome <= 0.8.3-8), oooqs-kde (<< 2.0.3-7)/' debian/control
endif

	python debian/scripts/joinctrl.py < debian/control > debian/control.tmp
	mv debian/control.tmp debian/control

	# make -l10n-fi suggest openoffice.org-spellcheck-fi to
	# match myspell-fi and openoffice.org-soikko/-voikko
	perl -pi -e 's/myspell-dictionary-fi/myspell-dictionary-fi | openoffice.org-spellcheck-fi/' debian/control

ifeq "$(USE_PYCENTRAL)" "y"
	# new python policy
	perl -pi -e 's/Package: python-uno/Package: python-uno\n\Provides: \$${python:Provides}\n\XB-Python-Version: \$${python:Versions}/' debian/control
endif

.DELETE_ON_ERROR: debian/control

build: build-arch build-indep
build-arch: $(STAMP_DIR)/build
build-indep: $(STAMP_DIR)/build

# All 'important' targets have 2 lines.  The one that is run by
# dpkg-buildpackage or the user, and the one that does the actual work.  This
# indirection is needed so that the 'stamp' files that signify when a rule is
# done can be located in a separate 'stampdir'.  Recall that make has no way to
# know when a goal has been met for a phony target (like "build" or "install").
#
# At the end of each stampdir target, be sure to run the command 'touch $@'
# so that the target will not be run again.  Removing the file will make
# make run the target over.

configure: ooo-build/config.status
ooo-build/config.status: ooo-build/configure
	dh_testdir
	$(MAKE) -f debian/rules environment

	# Make sure needed scripts are executable
	set -e;\
	for FILE in debian/scripts/installoverrides \
		    debian/scripts/move-if-change \
		    debian/scripts/cleandupes \
		    ooo-build/configure \
		    ooo-build/bin/[a-z]* \
		    ooo-build/patches/apply.pl ;\
	do \
	  chmod 755 $$FILE ;\
	done
	  
	mkdir -p $(STAMP_DIR)

	# uudecode source files
	cd ooo-build; for uu in fonts/opens___.ttf.uu src/*.uu templates/*.uu; do \
	  orig="`echo "$$uu" |sed -e 's#.uu$$##'`" ;\
          if [ ! -s $$orig ]; then \
            uudecode -o $$orig $$uu ;\
            touch -r $$uu $$orig ;\
          fi ;\
	done

        # uudecode Ximian desktop icons
	for i in base calc draw impress math template web writer; do \
	  if [ ! -s ooo-build/desktop/ooo-$$i.png ]; then \
	    uudecode -o ooo-build/desktop/ooo-$$i.png \
		ooo-build/desktop/ooo-$$i.png.uu ;\
	    touch -r ooo-build/desktop/ooo-$$i.png.uu \
		ooo-build/desktop/ooo-$$i.png ;\
	  fi; \
	done

	# uudecode broffice.org bitmaps
	for i in debian/ooonologointro-broffice.org.bmp debian/openabout-broffice.org.bmp; do \
	  if [ ! -s $$i ]; then \
	    uudecode -o $$i $$i.uu ;\
	    touch -r $$i.uu $$i; \
	  fi; \
	done

ifneq ($(GCC_VERSION),)
ifneq ($(GCC_VERSION),snapshot)
	# create links for gcc and g++ (and gij and gcj), ooo-build does not
	# honour overriding CC and CXX and we need to use gcc/g++ 4.0 or /
	# ant.mk wants gcj at the moment...
	mkdir -p $(CURDIR)/debian/usr/bin
	ln -sf /usr/bin/$(CC_PREFIX)gcc-$(GCC_VERSION) $(CURDIR)/debian/usr/bin/gcc
	ln -sf /usr/bin/$(CC_PREFIX)g++-$(GCC_VERSION) $(CURDIR)/debian/usr/bin/g++
	#ln -sf /usr/bin/$(CC_PREFIX)gcj-$(GCC_VERSION) $(CURDIR)/debian/usr/bin/gcj
	#ln -sf /usr/bin/gij-$(GCC_VERSION) $(CURDIR)/debian/usr/bin/gij
else
ifneq "$(CC_PREFIX)" ""
	mkdir -p $(CURDIR)/debian/usr/bin
	ln -s /usr/lib/gcc-snapshot/bin/$(CC_PREFIX)gcc $(CURDIR)/debian/usr/bin/gcc
	ln -s /usr/lib/gcc-snapshot/bin/$(CC_PREFIX)g++ $(CURDIR)/debian/usr/bin/g++
	ln -s /usr/lib/gcc-snapshot/bin/$(CC_PREFIX)gcj $(CURDIR)/debian/usr/bin/gcj
	ln -s /usr/lib/gcc-snapshot/bin/$(CC_PREFIX)gij $(CURDIR)/debian/usr/bin/gij
endif
endif
endif

ifeq "$(USE_SYSTEM_STLPORT)" "y"
	# stlport home
	if [ ! -d stlport ]; then \
		mkdir -p stlport; \
		ln -sf /usr/include/stlport stlport/stlport; \
		ln -sf /usr/lib stlport/lib; \
	fi
endif

ifneq "$(BUILD_ONLY_EN_US)" "y"
ifneq "$(LANGPACKISOS)" "en-US"
	# extract extra GSIs
	find ooo-build/src -name "*.sdf.bz2" -exec bunzip2 -k \{\} \;
	for i in `find ooo-build/src/*.sdf.gz`; do gunzip -dc "$$i" > \
		ooo-build/src/`basename $$i .gz`; done
	# work around broken stuff in the GSI breaking the build in svx
	for iso in as-IN he lo lv ml-IN mr-IN nb or-IN sh-YU sr-CS ur-IN; do \
	  case " $(LANGPACKISOS) " in *\ $$iso\ *) ;; *) continue; esac; \
	  [ -f ooo-build/src/GSI_$$iso.sdf ] || continue; \
	  TMP=`mktemp -q`; \
	  grep -v OOO_LICENSE ooo-build/src/GSI_$$iso.sdf \
	    > $$TMP && mv $$TMP ooo-build/src/GSI_$$iso.sdf; \
	done
endif
endif

	# Make convenience link
ifeq (ccache,$(findstring ccache,$(DEB_BUILD_OPTIONS)))
	if [ ! -L build ]; then ln -s ooo-build/build/current build ; fi
else
	if [ ! -L build ]; then ln -s $(SOURCE_TREE) build ; fi
endif

	# Make sure we have /proc mounted - otherwise idlc will fail later.
	test -r /proc/version

	cd ooo-build ; \
		PATH=$(BUILD_PATH) LD_LIBRARY_PATH=$(BUILD_LD_LIBRARY_PATH) ../ooo-build/configure $(CONFIGURE_FLAGS)

	touch $@

build: $(STAMP_DIR)/build
$(STAMP_DIR)/build: ooo-build/config.status
	dh_testdir

ifeq "$(BUILD_KDE)" "n"
	# hack to tell we want crystal icons nevertheless and they should be
	# extracted...
	if ! grep -q crystal ooo-build/bin/setup; then \
		cp ooo-build/bin/setup ooo-build/bin/setup.bak && \
		cat ooo-build/bin/setup.bak \
			| sed -e s/\'industrial/\'industrial\ crystal/ \
			> ooo-build/bin/setup && rm ooo-build/bin/setup.bak; \
	fi
endif

	cd ooo-build ; PATH=$(BUILD_PATH) LD_LIBRARY_PATH=$(BUILD_LD_LIBRARY_PATH) DEFAULT_TO_ENGLISH_FOR_PACKING=1 $(MAKE)

	if [ -d ooo-build/build/current -a ! -d $(SOURCE_TREE) ]; then \
		ln -sf current $(SOURCE_TREE); \
	fi

	# DPKG is only set on with-EPM build what we don't do and the menu stuff
	# is only built wenn DPKG is set.. Same with PKGFORMAT.
	cd $(SOURCE_TREE)/sysui; \
		. $(CURDIR)/$(SOURCE_TREE)/*.sh; \
		PATH=$(BUILD_PATH) DPKG="dpkg" PKGFORMAT="deb" NO_PKG_MANGLE=go-away \
		../solenv/bin/build.pl && ../solenv/bin/deliver.pl

ifneq "$(USE_EXTERNAL_MYTHES)" "y"
	# build non-PIC version of libmythes
	cd $(SOURCE_TREE)/lingucomponent/source/thesaurus/mythes && \
		$(CXX) -O2 -Wall -ansi -pedantic -I. -c mythes.cxx && \
		ar rc libmythes_nopic.a mythes.o && ranlib libmythes_nopic.a && \
		mv libmythes_nopic.a $(CURDIR)/$(SOURCE_TREE)
endif

	touch $@

install: $(STAMP_DIR)/install
$(STAMP_DIR)/install: $(STAMP_DIR)/build
	dh_testdir
	dh_testroot

	rm -rf $(CURDIR)/debian/tmp
	cd ooo-build ; PATH=$(BUILD_PATH) LD_LIBRARY_PATH=$(BUILD_LD_LIBRARY_PATH) DESTDIR=$(CURDIR)/debian/tmp $(MAKE) install

	# no special ooqstart wrappers
	install -m 755 build/ooo-wrapper$(VER) \
	  debian/tmp/pkg/openoffice.org-common/usr/bin/
	for i in debian/tmp/pkg/*/usr/bin/oo*; do \
	  case $$i in *wrapper*) continue; esac; \
	  ln -sf ooo-wrapper$(VER) $$i; \
	done

ifeq "$(HELPISOS)" ""
	for i in common calc math draw writer impress base; do \
		rm -rf debian/tmp/pkg/openoffice.org-$$i/$(OODIR)/help; \
	done
else
	# install *english* help; we can't do that later since this is in
	# arch-dep and arch-indep stuff..
	cd debian/tmp/pkg; \
		mkdir -p openoffice.org-help-en-us/$(OODIR)/help/en; \
		for i in common calc math draw writer impress base; do \
			cp -r ./openoffice.org-$$i/$(OODIR)/help/en/* \
			 ./openoffice.org-help-en-us/$(OODIR)/help/en && \
			if [ "$$i" = "common" ]; then \
				rm -rf ./openoffice.org-$$i/$(OODIR)/help/en; \
			else \
				rm -rf ./openoffice.org-$$i/$(OODIR)/help; \
			fi; \
		done
	# save space by removing non-packaged localized help; we don't need
	# them anyway
	cd debian/tmp/pkg && \
		for iso in $(filter-out en-US,$(LANGPACKISOS)); do \
			if ! `echo $(HELPISOS) | grep -q $$iso`; then \
				rm -rf openoffice.org-help-$$iso; \
			fi; \
		done
endif

	# move resources which have been installed outside of common there
	cd debian/tmp/pkg; \
		for i in `find . -name "*en-US.res" | grep -v common`; do \
			mv $$i openoffice.org-common/$(OODIR)/program/resource/`basename $$i`; \
		done

ifeq "$(ENABLE_JAVA)" "y"
	# move officebean.jar into -officebean (They will be moved out of -core
	# in the install-arch target). Do the /usr/share/java move here already
	cd debian/tmp/pkg; \
		mkdir -p openoffice.org-core/usr/share/java/openoffice$(VER); \
		mv openoffice.org-common/$(OODIR)/program/classes/officebean.jar \
			openoffice.org-core/usr/share/java/openoffice$(VER)

	# move hsqldb.jar and sdbc_hsqldb.jar into -base (do the move
	# to /usr/share/java here directly, we do it for the "rest"
	# later
	cd debian/tmp/pkg; \
		mkdir -p openoffice.org-base/usr/share/java/openoffice$(VER); \
		for i in *hsqldb.jar; do \
			mv openoffice.org-common/$(OODIR)/program/classes/$$i \
				openoffice.org-base/usr/share/java/openoffice$(VER); \
		done
endif

	# move .so to -dev
	cd debian/tmp/pkg; \
		mkdir -p -m755 openoffice.org-dev/$(OODIR)/program; \
		mv openoffice.org-common/$(OODIR)/program/*.so \
			openoffice.org-dev/$(OODIR)/program

	# somehow, these go into -common. Move them to -core here to be able
	# to install them later in install-arch
ifeq "$(ENABLE_MONO)" "y"
	cd debian/tmp/pkg; \
	mv openoffice.org-common/$(OODIR)/program/cli_*.dll  \
		openoffice.org-core/$(OODIR)/program
	if [ -d openoffice.org-common/$(OODIR)/program/assembly ]; then \
		rm -rf openoffice.org-common/$(OODIR)/program/assembly; \
	fi
endif
ifeq "$(PACKAGE_QA_TOOLS)" "y"
	cd debian/tmp/pkg; \
	mv openoffice.org-common/$(OODIR)/program/testtoolrc \
		openoffice.org-core/$(OODIR)/program
	# remove eventually sneaked in .testtoolrc
	cd debian/tmp/pkg; \
	rm -f openoffice.org-common/$(OODIR)/program/.testtoolrc
	
endif

ifeq "$(PACKAGE_QUICKSTART)" "y"
	# ooqstart should go into -core; we have just a glib dependency
	mkdir -p debian/tmp/pkg/openoffice.org-core/$(OODIR)/program
	mv debian/tmp/pkg/openoffice.org-common/$(OODIR)/program/ooqstart \
		debian/tmp/pkg/openoffice.org-core/$(OODIR)/program
	mkdir -p -m755 debian/tmp/pkg/openoffice.org-gnome/$(OODIR)/share/xdg
	mv debian/tmp/pkg/openoffice.org-common/$(OODIR)/share/xdg/qstart.desktop \
		debian/tmp/pkg/openoffice.org-gnome/$(OODIR)/share/xdg
endif

	# move gengal stuff into -dev
	mkdir -p debian/tmp/pkg/openoffice.org-dev/$(OODIR)/program
	mv debian/tmp/pkg/openoffice.org-core/$(OODIR)/program/gengal* \
		debian/tmp/pkg/openoffice.org-dev/$(OODIR)/program
	mv debian/tmp/pkg/openoffice.org-common/$(OODIR)/program/gengal  \
		debian/tmp/pkg/openoffice.org-dev/$(OODIR)/program

	# move SDK documentation into own package
	rm -rf debian/tmp/pkg/openoffice.org-dev-doc
	mkdir -p debian/tmp/pkg/openoffice.org-dev-doc/usr/share/doc/openoffice.org-dev-doc
	mv debian/tmp/pkg/openoffice.org-dev/usr/share/doc/openoffice.org \
		debian/tmp/pkg/openoffice.org-dev-doc/usr/share/doc/openoffice.org-dev && \
	mv debian/tmp/pkg/openoffice.org-dev-doc/usr/share/doc/openoffice.org-dev/sdk/docs \
		debian/tmp/pkg/openoffice.org-dev-doc/usr/share/doc/openoffice.org-dev
	rm -rf debian/tmp/pkg/openoffice.org-dev/usr/share/doc/openoffice.org \
		debian/tmp/pkg/openoffice.org-dev-doc/usr/share/doc/openoffice.org-dev/sdk
	mkdir -p debian/tmp/pkg/openoffice.org-dev-doc/$(OODIR)/sdk
	mv debian/tmp/pkg/openoffice.org-dev/$(OODIR)/sdk/examples \
		debian/tmp/pkg/openoffice.org-dev-doc/$(OODIR)/sdk

	find debian/tmp ! -perm -200 | xargs -r chmod u+w

	touch $@

#
# Generate maintainer scripts
maintscripts: $(STAMP_DIR)/maintscripts
$(STAMP_DIR)/maintscripts: debian/shell-lib.sh debian/control
	dh_testdir

	rm -f debian/*.{pre,post}{inst,rm}

	# generate maintainer scripts from *.in
	for PKG in $(PACKAGES); do \
	  for FILE in postinst postrm preinst prerm; do \
	    MAINTSCRIPT=debian/$$PKG.$$FILE ; \
	    if [ -e $$MAINTSCRIPT.in ]; then \
	      sed -n '1,/^#INCLUDE_SHELL_LIB#$$/p' < $$MAINTSCRIPT.in | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' > $$MAINTSCRIPT; \
	      grep LIBSUFFIX debian/scripts/vars.$(ARCH) >> $$MAINTSCRIPT; \
	      cat debian/shell-lib.sh >> $$MAINTSCRIPT; \
	      sed -n '/^#INCLUDE_SHELL_LIB#$$/,$$p' < $$MAINTSCRIPT.in | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >> $$MAINTSCRIPT; \
	      perl -pi -e "s/\@LANGPACKISOS\@/$(LANGPACKISOS)/" $$MAINTSCRIPT; \
	    fi; \
	  done; \
	done

	touch $@

# Install files generated by setup into package directories
helppacks: $(STAMP_DIR)/helppacks
$(STAMP_DIR)/helppacks: $(STAMP_DIR)/install ooo-build/bin/openoffice-xlate-lang

ifneq "$(HELPISOS)" ""
	# we assume here that when we want to build/package help here we want
	# to do that with en-US anyway...
	rm -rf $(PKGDIR)-help-en-us $(PKGDIR)-help-en-us.*.debhelper; \
	cp -r --preserve=mode debian/tmp/pkg/openoffice.org-help-en-us $(PKGDIR)-help-en-us || exit 1
ifneq "$(HELPISOS)" "en-US"
	set -e; \
	for iso in $(filter-out en-US,$(HELPISOS)); do \
	  pkgiso=`echo $$iso | tr \[:upper:\] \[:lower:\]`; \
	  diriso=`echo $$pkgiso | cut -d"-" -f1`; \
	  if [ "$$pkgiso" = "pt-br" ]; then diriso=pt-BR; fi; \
	  if [ "$$pkgiso" = "th-cn" ]; then diriso=zh-CN; fi; \
	  if [ "$$pkgiso" = "zh-tw" ]; then diriso=zh-TW; fi; \
	  rm -rf $(PKGDIR)-help-$$pkgiso $(PKGDIR)-help-$$pkgiso.*.debhelper; \
	  cp -r --preserve=mode debian/tmp/pkg/openoffice.org-help-$$iso \
		$(PKGDIR)-help-$$pkgiso; \
	done
ifeq (hi-IN,$(findstring hi-IN,$(HELPISOS)))
	for i in $(PKGDIR)-help-hi-in/$(OODIR)/help/hi-IN/*.css; do \
	  perl -pi -e 's|(font-family: )(.*)|\1 \"Lohit Hindi\", \2|' $$i; \
	done
endif
endif

	# quick hack to reduce the size of the help packages
	for iso in $(HELPISOS); do \
	  pkgiso=`echo $$iso | tr \[:upper:\] \[:lower:\]`; \
	  diriso=`echo $$pkgiso | cut -d"-" -f1`; \
	  case "$$iso" in en-US) iso=en; esac; \
	  for f in CONTEXTS DOCS DOCS.TAB LINKNAMES OFFSETS POSITIONS SCHEMA; do \
	    if cmp -s $(PKGDIR)-help-$$pkgiso/$(OODIR)/help/$$iso/simpress.idx/$$f \
	           $(PKGDIR)-help-$$pkgiso/$(OODIR)/help/$$iso/sdraw.idx/$$f; \
	    then \
	      echo "symlinking duplicate files: help/$$iso/sdraw.idx/$$f"; \
	      ln -sf ../sdraw.idx/$$f $(PKGDIR)-help-$$pkgiso/$(OODIR)/help/$$iso/simpress.idx/$$f; \
	    fi; \
	  done; \
	done	
endif

	touch $@

# Install files generated by setup into package directories
langpacks: $(STAMP_DIR)/langpacks
$(STAMP_DIR)/langpacks: $(STAMP_DIR)/install $(STAMP_DIR)/install-indep ooo-build/bin/openoffice-xlate-lang

	for ext in `echo $(LANGPACKISOS) |tr A-Z a-z` ; do \
	  rm -rf $(PKGDIR)-l10n-$$ext;\
	  rm -rf $(PKGDIR)-l10n-$$ext.*.debhelper;\
	done

	# ... and install the rest of the langpacks
	for iso in $(LANGPACKISOS); do \
	  if [ "$$iso" = "en-US" ]; then continue; fi ; \
	  pkgiso=`echo $$iso | tr \[:upper:\] \[:lower:\]`; \
	  rm -rf $(PKGDIR)-l10n-$$pkgiso $(PKGDIR)-l10n-$$pkgiso.*.debhelper; \
	  cp -r --preserve=mode debian/tmp/pkg/openoffice.org-l10n-$$iso \
		$(PKGDIR)-l10n-$$pkgiso || exit 1; \
	done
	
	# remove empty uno_packages dirs somehow in the langpacks(?)
	for iso in `echo $(LANGPACKISOS) | tr A-Z a-z`; do \
		rm -rf $(PKGDIR)-l10n-$$iso/$(OODIR)/share/uno_packages; \
	done
	
	# remove ooo dirs somehow in the langpacks(?)
	for iso in `echo $(LANGPACKISOS) | tr A-Z a-z`; do \
		rm -rf $(PKGDIR)-l10n-$$iso/$(OODIR)/share/dict/ooo; \
	done

	# remove extra license files
	for iso in `echo $(LANGPACKISOS) | tr A-Z a-z`; do \
		rm -rf $(PKGDIR)-l10n-$$iso/$(OODIR)/licenses; \
		rm -rf $(PKGDIR)-l10n-$$iso/$(OODIR)/share/readme/LICENSE*; \
	done
	
	# remove extra readme files
	for iso in `echo $(LANGPACKISOS) | tr A-Z a-z`; do \
		rm -rf $(PKGDIR)-l10n-$$iso/$(OODIR)/readmes; \
		rm -rf $(PKGDIR)-l10n-$$iso/$(OODIR)/share/readme/README*; \
	done

	# remove empty help directories
	for iso in `echo $(LANGPACKISOS) | tr A-Z a-z`; do \
		rm -rf $(PKGDIR)-l10n-$$iso/$(OODIR)/help; \
	done

	# replace duplicate files in the langpacks with symlinks
	fdupes --quiet --recurse --sameline --size \
		debian/openoffice.org$(VER)-common/$(OODIR) \
		$(foreach d,$(shell echo $(filter-out en-US,$(LANGPACKISOS)) | tr A-Z a-z),debian/openoffice.org$(VER)-l10n-$(d)/$(OODIR)) \
		> l10n.fdupes
	debian/scripts/cleandupes --base=openoffice.org$(VER) --prefix=debian < l10n.fdupes

	touch $@

native-jars: $(STAMP_DIR)/native-jars
$(STAMP_DIR)/native-jars: $(STAMP_DIR)/install
	rm -rf debian/tmp/native-jars
	mkdir -p debian/tmp/native-jars/gcj
	cp -a \
	    debian/tmp/pkg/openoffice.org-common/$(OODIR)/program/classes/*.jar \
		debian/tmp/native-jars/
	cp -a \
	    debian/tmp/pkg/openoffice.org-core/usr/share/java/openoffice$(VER)/*.jar \
	        debian/tmp/native-jars/
	cp -a \
	    debian/tmp/pkg/openoffice.org-base/usr/share/java/openoffice$(VER)/*.jar \
	        debian/tmp/native-jars/
	cp -a \
	    debian/tmp/pkg/openoffice.org-writer/$(OODIR)/program/classes/*.jar \
	        debian/tmp/native-jars
	: # remove problematic ones
	rm -f debian/tmp/native-jars/ridl.jar
	: # compile the others
	aot-compile -L /usr/lib/gcj/openoffice \
	    debian/tmp/native-jars debian/tmp/native-jars/gcj
	$(GCJ_DBTOOL) -n debian/tmp/native-jars/tmp.db 64
	find debian/tmp/native-jars/gcj -name '*.db' -print0 \
	    | xargs -r -0 \
		$(GCJ_DBTOOL) -m debian/tmp/native-jars/tmp.db debian/tmp/native-jars/tmp.db || exit 1
	rm -f debian/tmp/native-jars/gcj/*.db
	touch $@

# Install files generated by setup into arch-dependent package directories
install-arch: $(STAMP_DIR)/install-arch
$(STAMP_DIR)/install-arch: $(STAMP_DIR)/install $(STAMP_NATIVE_JARS)
	dh_testdir
	dh_testroot
	umask 022

	# Copy files placed by ooo-build/bin/package-ooo	
	for i in base calc core draw impress math writer gnome dev; do \
	  rm -rf $(PKGDIR)-$$i $(PKGDIR)-$$i.*.debhelper ;\
	  cp -r --preserve=mode debian/tmp/pkg/openoffice.org-$$i $(PKGDIR)-$$i || exit 1;\
	done

	rm -rf debian/mozilla-openoffice.org debian/mozilla-openoffice.org.*.debhelper
	rm -rf $(PKGDIR) $(PKGDIR).*.debhelper
	rm -rf $(PKGDIR)-evolution $(PKGDIR)-evolution.*.debhelper
ifeq "$(BUILD_KDE)" "y"
	rm -rf $(PKGDIR)-kde $(PKGDIR)-kde.*.debhelper
endif

	dh_installdirs -a

ifeq "$(BUILD_KDE)" "y"
	mkdir -p -m755 $(PKGDIR)-kde/$(OODIR)/program
	for f in kdefilepicker libfps_kde.so libvclplug_kde[0-9]*.so libkab*so kdebe*so; do \
	  mv $(PKGDIR)-core/$(OODIR)/program/$$f $(PKGDIR)-kde/$(OODIR)/program || exit 1 ;\
	done
endif

	# move the GNOME stuff which are *not* in gid_Module_Optional_Gnome
	# (which is moved into -gnome in package-ooo) into -gnome
	mkdir -p -m755 $(PKGDIR)-gnome/$(OODIR)/program
	for f in gnome-open-url.bin fps_gnome.uno.so libvclplug_gtk[0-9]*.so; do \
	  mv $(PKGDIR)-core/$(OODIR)/program/$$f $(PKGDIR)-gnome/$(OODIR)/program || exit 1;\
	done
ifeq "$(PACKAGE_QUICKSTART)" "y"
	for f in libeggtray* libqstart_gtk*; do \
	  mv $(PKGDIR)-core/$(OODIR)/program/$$f $(PKGDIR)-gnome/$(OODIR)/program || exit 1;\
	done
else
	for f in libeggtray* libqstart_gtk*; do \
	  rm -f $(PKGDIR)-core/$(OODIR)/program/$$f; \
	done
endif

	# split out gtk stuff
	rm -rf $(PKGDIR)-gtk
	mkdir -p -m755 $(PKGDIR)-gtk/$(OODIR)/program
	mv $(PKGDIR)-gnome/$(OODIR)/program/* $(PKGDIR)-gtk/$(OODIR)/program/
ifeq "$(PACKAGE_QUICKSTART)" "y"
	mkdir -p -m755 $(PKGDIR)-gtk/$(OODIR)/share
	mv $(PKGDIR)-gnome/$(OODIR)/share/xdg $(PKGDIR)-gtk/$(OODIR)/share
else
	rm -rf $(PKGDIR)-gnome/$(OODIR)/share
endif
	mv $(PKGDIR)-gtk/$(OODIR)/program/ucpgvfs1.uno.so \
		$(PKGDIR)-gnome/$(OODIR)/program/
	mv $(PKGDIR)-gtk/$(OODIR)/program/gnome-set-default-application \
		$(PKGDIR)-gnome/$(OODIR)/program/
	mv $(PKGDIR)-gtk/$(OODIR)/program/gconfbe* \
		$(PKGDIR)-gnome/$(OODIR)/program

	mkdir -p -m755 $(PKGDIR)-evolution/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/libevoab2.so $(PKGDIR)-evolution/$(OODIR)/program

ifeq "$(PACKAGE_NPSOPLUGIN)" "y"
	mkdir -p -m755 debian/mozilla-openoffice.org/$(OODIR)/program
	for f in libnpsoplugin.so nsplugin; do \
		mv $(PKGDIR)-core/$(OODIR)/program/$$f debian/mozilla-openoffice.org/$(OODIR)/program; \
	done
	cd debian/mozilla-openoffice.org && \
		for b in mozilla mozilla-firefox firefox; do \
			mkdir -p usr/lib/$$b/plugins && \
				ln -sf /$(OODIR)/program/libnpsoplugin.so \
				   usr/lib/$$b/plugins/libnpsoplugin.so; \
		done
else
	rm -f $(PKGDIR)-core/$(OODIR)/program/libnpsoplugin.so
	rm -f $(PKGDIR)-core/$(OODIR)/program/nsplugin
endif

ifeq "$(BUILD_BINFILTERS)" "y"
	rm -rf $(PKGDIR)-filter-so52/$(OODIR)/program
	mkdir -p -m755 $(PKGDIR)-filter-so52/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/libbf_* \
		$(PKGDIR)-filter-so52/$(OODIR)/program
	mv $(PKGDIR)-calc/$(OODIR)/program/libbf_sc* \
		$(PKGDIR)-filter-so52/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/liblegacy_binfilters* \
		$(PKGDIR)-filter-so52/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/libbindet* \
		$(PKGDIR)-filter-so52/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/legacy_binfilters.rdb \
		$(PKGDIR)-filter-so52/$(OODIR)/program
endif

	# OOo's package split sucks...
	mv $(PKGDIR)-core/$(OODIR)/program/libsw* \
		$(PKGDIR)-writer/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/libsd6* \
	   $(PKGDIR)-core/$(OODIR)/program/libsdd* \
	   $(PKGDIR)-core/$(OODIR)/program/libsdui* \
		$(PKGDIR)-draw/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/slideshow.uno.so \
		$(PKGDIR)-impress/$(OODIR)/program
	mkdir -p -m755 $(PKGDIR)-base/$(OODIR)/program
	for i in dba; do \
		mv $(PKGDIR)-core/$(OODIR)/program/lib$$i* \
		   $(PKGDIR)-base/$(OODIR)/program; \
	done
	for i in odbcbase2 dbpool2 jdbc2 odbc2 sdbc2 mysql2 adabas2; do \
		mv $(PKGDIR)-core/$(OODIR)/program/lib$$i* \
		   $(PKGDIR)-base/$(OODIR)/program; \
	done
ifeq "$(ENABLE_JAVA)" "y"
	for i in jdbc2 hsqldb2; do \
		mv $(PKGDIR)-core/$(OODIR)/program/lib$$i* \
		   $(PKGDIR)-base/$(OODIR)/program; \
	done
	# hack, #340468
	ln -s libhsqldb2.so \
		$(PKGDIR)-base/$(OODIR)/program/libhsqldb2
endif
	mv $(PKGDIR)-core/$(OODIR)/program/libflat*so \
		$(PKGDIR)-base/$(OODIR)/program; \

ifeq "$(BUILD_MDBTOOLS)" "y"
	mv $(PKGDIR)-core/$(OODIR)/program/libmdb*so \
		$(PKGDIR)-base/$(OODIR)/program
endif

	# move vba stuff into -calc, they are calc-only and linked to
	# libsc*
	for i in libvbaobj vbaevents; do \
		mv $(PKGDIR)-core/$(OODIR)/program/$$i*uno.so \
			$(PKGDIR)-calc/$(OODIR)/program; \
	done

	mv $(PKGDIR)-core/$(OODIR)/program/scsolver.uno.so \
		$(PKGDIR)-calc/$(OODIR)/program
ifneq "$(USE_SYSTEM_LPSOLVE)" "y"
	mv $(PKGDIR)-core/$(OODIR)/program/liblpsolve55.so \
		$(PKGDIR)-calc/$(OODIR)/program
endif

ifeq "$(ENABLE_JAVA)" "y"
  ifeq "$(USE_SYSTEM_HSQLDB)" "y"
	# link to system hsqldb
	ln -sf /usr/share/java/hsqldb.jar \
	        $(PKGDIR)-base/usr/share/java/openoffice$(VER)/hsqldb.jar
  endif
endif

ifeq "$(ENABLE_JAVA)" "y"
	rm -rf $(PKGDIR)-officebean
	mkdir -p -m755 $(PKGDIR)-officebean/$(OODIR)/program
	mkdir -p -m755 $(PKGDIR)-officebean/usr/share/java
	mv $(PKGDIR)-core/usr/share/java/openoffice$(VER) \
		$(PKGDIR)-officebean/usr/share/java
	rm -rf $(PKGDIR)-core/usr/share/java
	mv $(PKGDIR)-core/$(OODIR)/program/libofficebean.so \
		$(PKGDIR)-officebean/$(OODIR)/program
endif

	mkdir -p -m755 $(PKGDIR)-base/usr/share/applications \
	               $(PKGDIR)-core/usr/share/applications

ifeq "$(PACKAGE_QA_TOOLS)" "y"
	mkdir -p -m755 $(PKGDIR)-qa-tools/usr/bin
	install -m755 $(SOURCE_TREE)/ootestapi $(PKGDIR)-qa-tools/usr/bin
	install -m755 $(SOURCE_TREE)/ootesttool $(PKGDIR)-qa-tools/usr/bin
	install -m755 $(SOURCE_TREE)/oosmoketest $(PKGDIR)-qa-tools/usr/bin

	mkdir -p -m755 $(PKGDIR)-qa-tools/$(OODIR)/program
	for f in testtool.bin libcommuni* libsimplecm*; do \
		mv $(PKGDIR)-core/$(OODIR)/program/$$f $(PKGDIR)-qa-tools/$(OODIR)/program; \
	done

ifeq "$(ENABLE_JAVA)" "y"
	mkdir -p -m755 $(PKGDIR)-qa-tools/usr/share/java/openoffice$(VER)
	cp $(SOURCE_TREE)/qadevOOo/unx*.pro/class/OOoRunnerLight.jar \
		$(PKGDIR)-qa-tools/usr/share/java/openoffice$(VER)
endif

	mkdir -p -m755 $(PKGDIR)-qa-tools/$(OODIR)/smoketest
	install -m755 $(SOURCE_TREE)/smoketestoo_native/smoketest.pl \
		$(SOURCE_TREE)/smoketestoo_native/testlog.pl \
		$(PKGDIR)-qa-tools/$(OODIR)/smoketest

	mkdir -p -m755 $(PKGDIR)-qa-tools/$(OODIR)/presets/basic/Standard
	install -m644 $(SOURCE_TREE)/smoketestoo_native/data/scripts/*.x* \
		$(PKGDIR)-qa-tools/$(OODIR)/presets/basic/Standard

	mv $(PKGDIR)-core/$(OODIR)/program/testtoolrc \
		$(PKGDIR)-qa-tools/$(OODIR)/program && \
	chmod 644 $(PKGDIR)-qa-tools/$(OODIR)/program/testtoolrc
else
	rm -f $(PKGDIR)-core/$(OODIR)/program/testtool.bin
	rm -f $(PKGDIR)-core/$(OODIR)/program/libcommuni*
	rm -f $(PKGDIR)-core/$(OODIR)/program/libsimplecm*
	rm -f $(PKGDIR)-core/$(OODIR)/program/testtoolrc
endif

ifeq "$(USE_OOO_BUILD_DESKTOPS)" "n"
	# menu files from sysui
	dirname="`cd $(SOURCE_TREE)/sysui/$(shell . $(SOURCE_TREE)/*.sh; echo $$OUTPATH$$PROEXT)/misc/desktopshare >/dev/null; pwd`" ;\
	for p in writer calc impress draw math base; do \
		mkdir -p -m755 $(PKGDIR)-$$p/usr/share/applications ;\
		sed -e 's,Exec=openoffice.org-2.0 \(.*\) %U,Exec=ooffice$(VER) \1 %U,' \
		    -e "s,Icon=openofficeorg-20-$$p,Icon=ooo-$$p," \
			-e 's,Name=OpenOffice.org 2.0,Name=OpenOffice.org $(VER),' \
			-e 's/  / /' \
		   < $$dirname/$$p.desktop \
		   > $(PKGDIR)-$$p/usr/share/applications/ooo$(VER)-$$p.desktop || exit 1 ;\
	done
	for f in `find debian -name '*.desktop'`; do \
		sed -i -e '/^Comment\[de\]/s/- *\([a-zA-Z0-9]*\) *macht.*glich.*$$/mit \1/' $$f; \
		echo 'X-KDE-Protocols=file,http,smb,ftp,webdav' >> $$f; \
	done
	sed -i -e '/^MimeType/s,text/rtf,text/rtf;application/rtf,' \
		$(PKGDIR)-writer/usr/share/applications/ooo$(VER)-writer.desktop
	sed -i -e 's/Office;/Office;Graphics;/' $(PKGDIR)-draw/usr/share/applications/ooo$(VER)-draw.desktop
	#mv $(PKGDIR)-base/usr/share/applications/ooo$(VER)-base.desktop $(PKGDIR)-core/usr/share/applications
	#rm -r $(PKGDIR)-base
else
	# menu files from ooo-build/desktop
	for p in writer calc impress draw math base; do \
		mkdir -p -m755 $(PKGDIR)-$$p/usr/share/applications ;\
			sed -e '/^TryExec=.*/d' \
			    -e "s,^Exec=.*,Exec=ooffice$(VER) -$$p %U," \
			    -e "s,^Icon=.*,Icon=ooo-$$p," \
			    -e '/^Name=/s,  , ,' \
			    -e 's/@STARTUPNOTIFY@/true/' \
			    -e '/^Categories/s/Office/Application;Office/' \
				ooo-build/desktop/$$p.desktop \
				> $(PKGDIR)-$$p/usr/share/applications/ooo$(VER)-$$p.desktop || exit 1 ;\
	done
endif

ifeq "$(BUILD_PYUNO)" "y"
	# PyUNO packging
	rm -rf debian/python-uno debian/python-uno.*.debhelper
	cp -r --preserve=mode debian/tmp/pkg/python-uno debian/python-uno
	
	install -d $(PYTHON_SITE)
	mv debian/python-uno/$(OODIR)/program/uno.py $(PYTHON_SITE)
	mv debian/python-uno/$(OODIR)/program/unohelper.py $(PYTHON_SITE)
	mv debian/python-uno/$(OODIR)/program/pyuno.so $(PYTHON_SITE)
	touch debian/python-uno/$(OODIR)/program/pythonloader.unorc
	chmod u+w debian/python-uno/$(OODIR)/program/pythonloader.unorc
	( echo '[Bootstrap]'; \
	  echo 'PYTHONHOME=file:///usr/lib/python$(PYMAJOR).$(PYMINOR)' ;\
	  echo 'PYTHONPATH=$$PYTHONHOME $$PYTHONHOME/site-packages $$PYTHONHOME/lib-dynload $$PYTHONHOME/lib-tk $$ORIGIN' \
	) > debian/python-uno/$(OODIR)/program/pythonloader.unorc
	chmod u-w debian/python-uno/$(OODIR)/program/pythonloader.unorc
	chmod 755 debian/python-uno/$(OODIR)/program/mailmerge.py
	perl -pi -e 's,/bin,/usr/bin,' \
		 debian/python-uno/$(OODIR)/program/mailmerge.py

	mkdir -p debian/python-uno/usr/share/doc/python-uno
	for i in doc demo; do \
		cp -r $(SOURCE_TREE)/pyuno/$$i \
		  debian/python-uno/usr/share/doc/python-uno; \
	done
	cd debian/python-uno/usr/share/doc/python-uno && \
		find . -type d -name "CVS" | xargs -r rm -rf
endif

ifeq "$(ENABLE_MONO)" "y"
	# Mono bindings
	mkdir -p -m755 debian/libuno-cil/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/libcli* \
		debian/libuno-cil/$(OODIR)/program
	mv $(PKGDIR)-core/$(OODIR)/program/cli_*.dll \
		debian/libuno-cil/$(OODIR)/program
endif

ifeq "$(USE_SYSTEM_STLPORT)" "y"
	# when we use external stlport, we just can and should do a symlink
	# for the SDK includes
	cd $(PKGDIR)-dev/usr/include/openoffice$(VER) && \
		rm -rf stl && ln -s /usr/include/stlport stl
ifeq "$(USE_STLPORT5)" "y"
	perl -pi -e "s/STORELIB=-lstore/STORELIB=-lstore\nSTLPORT_VER=500/" \
		 $(PKGDIR)-dev/$(OODIR)/sdk/settings/settings.mk
endif
endif
ifeq "$(ENABLE_JAVA)" "y"
	# move SDK Java stuff into /usr/share/java/openoffice
	rm -f $(PKGDIR)-dev/$(OODIR)/sdk/classes
	mkdir -p $(PKGDIR)-dev/usr/share/java/openoffice$(VER)/win
	mkdir -p $(PKGDIR)-dev/$(OODIR)/sdk/classes
	mv $(PKGDIR)-dev/usr/share/openoffice/sdk/classes/com \
		$(PKGDIR)-dev/usr/share/java/openoffice$(VER) && \
	mv $(PKGDIR)-dev/usr/share/openoffice/sdk/classes/win/unowinreg.dll \
		$(PKGDIR)-dev/usr/share/java/openoffice$(VER)/win
	chmod 644 $(PKGDIR)-dev/usr/share/java/openoffice$(VER)/win/unowinreg.dll
	cd $(PKGDIR)-dev/$(OODIR)/sdk/classes && \
		ln -s /usr/share/java/openoffice$(VER)/com com
	rm -rf $(PKGDIR)-dev/usr/share/openoffice/sdk
endif
	chmod 644 $(PKGDIR)-dev/$(OODIR)/sdk/configure.pl
	for i in csh csh.in; do \
		perl -pi -e 's,/usr/bin/csh,/bin/csh,'\
			$(PKGDIR)-dev/$(OODIR)/sdk/setsdkenv_unix.$$i; \
	done
	# create wrapper scripts
	cd $(PKGDIR)-dev/$(OODIR)/sdk/$(OS)/bin && \
	for i in *; do \
		if [ "$$i" = "regcomp" -o "$$i" = "regcomp.bin" ]; then \
			continue; \
		fi; \
		mv $$i $$i.bin && \
		( \
		  echo "#!/bin/sh"; \
		  echo "# wrapper script for OOos SDK programs"; \
		  echo ""; \
		  echo 'LD_LIBRARY_PATH=/$(OODIR)/program /$(OODIR)/sdk/$(OS)/bin/`basename $$0`.bin $$@'; \
		) > $$i; \
		chmod 755 $$i; \
	done && \
	( \
	  echo "#!/bin/sh"; \
	  echo "# wrapper script for OOos SDK programs"; \
	  echo ""; \
	  echo 'LD_LIBRARY_PATH=/$(OODIR)/program /$(OODIR)/sdk/$(OS)/bin/`basename $$0`.bin $$@'; \
	) > regcomp; \
	chmod 755 regcomp
        # remove symlink, it should be in -dev-doc
	cd $(PKGDIR)-dev/$(OODIR)/sdk && \
		rm docs

	# install gsicheck into -dev
	install -m755 $(SOURCE_TREE)/solver/$(shell . $(SOURCE_TREE)/*.sh; echo $$UPD/$$OUTPATH$$PROEXT)/bin/gsicheck \
		$(PKGDIR)-dev/$(OODIR)/program/gsicheck.bin
	( \
	  echo '#! /bin/sh'; \
	  echo 'LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}/$(OODIR)/program'; \
	  echo 'export LD_LIBRARY_PATH'; \
	  echo 'exec /$(OODIR)/program/gsicheck.bin "$$@"'; \
	) > $(PKGDIR)-dev/$(OODIR)/program/gsicheck
	chmod 755 $(PKGDIR)-dev/$(OODIR)/program/gsicheck

ifeq "$(INTERNAL_STDLIBS)" "y"
	# we have to do this manually; specifying --without-system-stdlibs
	# won't work because the odering of the configure arguments...
	LIBSTDCPP=`readlink `PATH=$(BUILD_PATH) g++ --print-file-name=libstdc++.so``; \
	LIBGCC=`readlink `PATH=$(BUILD_PATH) gcc --print-file-name=libgcc_s.so``; \
	LIBSTDCPP_SOVER=`echo $$LIBSTDCPP | sed -e 's/.*\.//'`; \
	LIBGCC_SOVER=`echo $$LIBGCC | sed -e 's/.*\.//'`; \
	cp $$LIBSTDCPP $(PKGDIR)-core/$(OODIR)/program; \
	cp $$LIBGCC $(PKGDIR)-core/$(OODIR)/program; \
	echo "libstdc++	$$LIBSTDCPP_SOVER" > debian/shlibs.override.stdlibs; \
	echo "libgcc_s	$$LIBGCC_SOVER" >> debian/shlibs.override.stdlibs
endif
ifeq "$(USE_SYSTEM_STLPORT)" "y"
	# remove a eventually sneaked-in stlport...
	rm -f $(PKGDIR)-core/$(OODIR)/program/libstlport*
endif

ifeq "$(ENABLE_JAVA)" "y"
  ifeq "$(BUILD_JARS_NATIVE)" "y"
	rm -rf $(PKGDIR)-gcj/usr/lib/gcj
	mkdir -p $(PKGDIR)-gcj/usr/lib/gcj/openoffice
	cp -p debian/tmp/native-jars/gcj/* $(PKGDIR)-gcj/usr/lib/gcj/openoffice
	mkdir -p $(PKGDIR)-gcj/usr/share/gcj/classmap.d
	cp -p debian/tmp/native-jars/tmp.db \
		$(PKGDIR)-gcj/usr/share/gcj/classmap.d/openoffice.org.db
  endif
endif

	# install some docs.
	mkdir -p $(PKGDIR)-base/usr/share/doc/openoffice.org$(VER)-base
	cp ooo-build/doc/using-mysql-databases.txt \
		$(PKGDIR)-base/usr/share/doc/openoffice.org$(VER)-base
	cp ooo-build/doc/data-from-remote-mysql-server.txt \
		$(PKGDIR)-base/usr/share/doc/openoffice.org$(VER)-base

ifneq "$(USE_EXTERNAL_MYTHES)" "y"
	# install libmythes and th_gen_idx.pl (on archs where we build OOo)
	rm -rf debian/libmythes-dev
	mkdir -p debian/libmythes-dev/usr/lib
	mkdir -p debian/libmythes-dev/usr/include
	mkdir -p debian/libmythes-dev/usr/share/mythes
	install -m644 \
		$(SOURCE_TREE)/lingucomponent/$(shell . $(SOURCE_TREE)/*.sh; echo $$OUTPATH$$PROEXT)/lib/libmythes.a \
		debian/libmythes-dev/usr/lib/libmythes_pic.a
	install -m644 \
		$(SOURCE_TREE)/libmythes_nopic.a \
		debian/libmythes-dev/usr/lib/libmythes.a
	install -m644 $(SOURCE_TREE)/lingucomponent/source/thesaurus/mythes/mythes.hxx \
		debian/libmythes-dev/usr/include
	install -m755 $(SOURCE_TREE)/dictionaries/util/th_gen_idx.pl \
		debian/libmythes-dev/usr/share/mythes/th_gen_idx.pl
endif

ifeq "$(ENABLE_JAVA)" "y"
	# install the UNO Java sources for e.g. eclipse
	mkdir -p $(CURDIR)/$(PKGDIR)-dev/usr/share/java/openoffice$(VER)
	cd $(SOURCE_TREE)/solver/$(shell . $(SOURCE_TREE)/*.sh; echo $$UPD)/$(shell . $(SOURCE_TREE)/*.sh; echo $$OUTPATH$$PROEXT)/bin && \
		for i in juh jurt jut ridl unoloader; do \
			cp $${i}_src.zip \
			  $(CURDIR)/$(PKGDIR)-dev/usr/share/java/openoffice; \
		done
endif

ifeq "$(ENABLE_JAVA)" "y"
	# hrmpf, again something like that, we really need to find the root cause for that
	ln -s libjava_uno.so \
		$(PKGDIR)-base/$(OODIR)/program/libjava_uno
endif

	# move impressgraphics filter stuff into -impress
	mkdir -p $(PKGDIR)-draw/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Types
	mkdir -p $(PKGDIR)-draw/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Filter
	mv $(PKGDIR)-draw/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Types/fcfg_impressgraphics_types.xcu \
	  $(PKGDIR)-impress/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Types
	mv $(PKGDIR)-draw/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Filter/fcfg_impressgraphics_filters.xcu \
	  $(PKGDIR)-impress/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Filter

ifeq "$(ENABLE_JAVA)" "y"
	# move writer2latex.jar into the right dir
	mkdir -p $(PKGDIR)-writer/usr/share/java/openoffice$(VER)
	mv $(PKGDIR)-writer/$(OODIR)/program/classes/writer2latex.jar \
		$(PKGDIR)-writer/usr/share/java/openoffice$(VER) && \
	rmdir $(PKGDIR)-writer/$(OODIR)/program/classes
endif

	# remove empty resource directories
	for i in draw base writer impress calc math; do \
		rm -rf $(PKGDIR)-$$i/$(OODIR)/program/resource; \
	done

	touch $@
	
broffice: $(STAMP_DIR)/broffice
$(STAMP_DIR)/broffice: $(STAMP_DIR)/install $(STAMP_DIR)/install-arch $(STAMP_DIR)/install-indep $(STAMP_DIR)/langpacks
	dh_testdir
	dh_testroot
	
	# BrOffice.org
	rm -rf debian/broffice.org
	mkdir -p debian/broffice.org/usr/bin
	mkdir -p debian/broffice.org/usr/share/applications
	mkdir -p debian/broffice.org/usr/lib/openoffice/program/resource
	mkdir -p debian/broffice.org/usr/lib/openoffice/share/registry/data/org/openoffice
	cat $(PKGDIR)-common/$(OODIR)/program/bootstraprc \
		| sed -e "s/OpenO/BrO/" | sed -e "s/openo/bro/" \
		> debian/broffice.org/$(OODIR)/program/bootstraprc
	cat $(PKGDIR)-common/$(OODIR)/program/versionrc \
		| sed -e "s/en-US/pt-BR/" | sed -e "s/openo/bro/" \
		> debian/broffice.org/$(OODIR)/program/versionrc
	cat $(PKGDIR)-common/$(OODIR)/share/registry/data/org/openoffice/Setup.xcu \
		| sed -e "s/OpenO/BrO/" \
		> debian/broffice.org/$(OODIR)/share/registry/data/org/openoffice/Setup.xcu
	for iso in $(LANGPACKISOS); do \
		if [ "$$iso" = "en-US" ]; then p=common; else p=l10n-`echo $$iso | tr A-Z a-z`; fi; \
		cat $(PKGDIR)-$$p/$(OODIR)/program/resource/ooo680$$iso.res \
		| sed -e "s/OpenO/BrO/" \
		> debian/broffice.org/$(OODIR)/program/resource/ooo680$$iso.res; \
	done
	for i in writer calc draw impress math base; do \
		cat $(PKGDIR)-$$i/usr/share/applications/ooo-$$i.desktop \
			| sed -e "s/ooff/broff/" | sed -e "s/OpenO/BrO/" \
			> debian/broffice.org/usr/share/applications/ooo-$$i.desktop; \
	done
	install -m644 debian/ooonologointro-broffice.org.bmp \
		debian/broffice.org/$(OODIR)/program/intro.bmp
	install -m644 debian/openabout-broffice.org.bmp \
		debian/broffice.org/$(OODIR)/program/about.bmp
	cd debian/broffice.org/usr/bin && ln -s ooffice broffice

	touch $@

# Install files generated by setup into arch-independent package directories
install-indep: $(STAMP_DIR)/install-indep
#$(STAMP_DIR)/install-indep: debian/openoffice.org$(VER).install 
#$(STAMP_DIR)/install-indep: debian/openoffice.org$(VER)-mimelnk.install 
#$(STAMP_DIR)/install-indep: debian/openoffice.org$(VER).dirs
$(STAMP_DIR)/install-indep: $(STAMP_DIR)/install
$(STAMP_DIR)/install-indep: ooo-build/fonts/opens___.ttf
	dh_testdir
	dh_testroot

	# Copy files placed by ooo-build/bin/package-ooo/install
	rm -rf $(PKGDIR)-common $(PKGDIR)-common.*.debhelper; \
	cp -r --preserve=mode debian/tmp/pkg/openoffice.org-common $(PKGDIR)-common || exit 1
	rm -rf $(PKGDIR)-dev-doc $(PKGDIR)-dev-doc.*.debhelper; \
	cp -r --preserve=mode debian/tmp/pkg/openoffice.org-dev-doc $(PKGDIR)-dev-doc || exit 1

	dh_installdirs -i

ifneq "$(USE_GSTREAMER)" "y"
	# sound doesn't work anyway, remove the .wav files to save space
	rm -rf $(PKGDIR)-common/$(OODIR)/share/gallery/sounds
	rm -f $(PKGDIR)-common/$(OODIR)/share/gallery/sg9.*
endif

	rm -f $(PKGDIR)-common/$(OODIR)/program/oo_product.bmp

	# Extract and install icons
	cd $(SOURCE_TREE)/sysui/$(shell . $(SOURCE_TREE)/*.sh; echo $$OUTPATH$$PROEXT)/bin/desktop-integration && dpkg --extract openoffice.org-debian-menus_*_all.deb . && cd usr/share/icons; \
	for d in `find -type d`; do \
	  install -d -m755 $(CURDIR)/$(PKGDIR)-common/usr/share/icons/$$d || exit 1 ;\
	done &&\
	for f in `find -type f`; do \
	  install -m644 $$f $(CURDIR)/$(PKGDIR)-common/usr/share/icons/$$f || exit 1 ;\
	done && cd ../../.. && rm -rf usr etc

	# install .applications, .keys and .mime
	mkdir -p $(PKGDIR)-common/usr/share/application-registry && \
	install -m644 $(SOURCE_TREE)/sysui/desktop/mimetypes/openoffice.applications \
		$(PKGDIR)-common/usr/share/application-registry
	mkdir -p $(PKGDIR)-common/usr/share/mime/packages && \
	mkdir -p $(PKGDIR)-common/usr/share/mime-info && \
	install -m644 $(SOURCE_TREE)/sysui/desktop/mimetypes/openoffice.mime \
		$(PKGDIR)-common/usr/share/mime-info && \
	rm -f $(PKGDIR)-common/usr/share/mime-info/openoffice.keys; \
	for i in $(SOURCE_TREE)/sysui/$(shell . $(SOURCE_TREE)/*.sh; echo $$OUTPATH$$PROEXT)/misc/debian/*.keys; do \
		cat $$i >> $(PKGDIR)-common/usr/share/mime-info/openoffice.keys; \
	done
#	install -m644 $(SOURCE_TREE)/sysui/$(shell . $(SOURCE_TREE)/*.sh; echo $$OUTPATH$$PROEXT)/misc/desktopshare/openoffice.org.xml \
#		$(PKGDIR)-common/usr/share/mime/packages

	# install openoffice-xlate-lang
	install -d -m755 $(PKGDIR)-common/usr/share/openoffice$(VER)/bin
	install -m755 ooo-build/bin/openoffice-xlate-lang \
		$(PKGDIR)-common/usr/share/openoffice$(VER)/bin

ifeq "$(HELPISOS)" ""
	# when we don't build helpcontent2 here we are missing helpxsl.zip so
	# this file doesn't get installed either. Do it manually..
	mkdir -p -m755 $(PKGDIR)-common/$(OODIR)/help && \
	cp $(SOURCE_TREE)/helpcontent2/source/auxiliary/main_transform.xsl \
		$(PKGDIR)-common/$(OODIR)/help
endif

	# fix shebang
	perl -pi -e 's,/bin/awk,/usr/bin/awk,'\
		$(PKGDIR)-common/$(OODIR)/program/uri-encode

	chmod 644 $(PKGDIR)-dev-doc/usr/share/doc/openoffice.org-dev/docs/images/bg_table2.gif
	chmod 644 $(PKGDIR)-dev-doc/usr/share/doc/openoffice.org-dev/docs/images/bg_table3.gif
	chmod 644 $(PKGDIR)-dev-doc/$(OODIR)/sdk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/build.xml
	chmod 644 $(PKGDIR)-dev-doc/$(OODIR)/sdk/examples/DevelopersGuide/ScriptingFramework/SayHello/build.xml
	rm -f $(PKGDIR)-dev-doc/usr/share/doc/openoffice.org-dev-doc/LICENSE

	# replace href's to the non-free DevelopersGuide with links to the
	# online docs
	find $(PKGDIR)-dev-doc/usr/share/doc/openoffice.org-dev/docs -name '*.html' \
	  | xargs sed -ri 's,href="[^"]*DevelopersGuide/([^"]*\.(xhtml|pdf)[^"]*)".*,href="http://api.openoffice.org/docs/DevelopersGuide/\1,g'

ifeq "$(ENABLE_JAVA)" "y"
	rm -rf $(PKGDIR)-java-common
	# move common Java stuff to -java-common
	mkdir -p $(PKGDIR)-java-common/$(OODIR)/program
	mkdir -p $(PKGDIR)-java-common/$(OODIR)/share/Scripts
	mv $(PKGDIR)-common/$(OODIR)/program/JREProperties.class \
		$(PKGDIR)-java-common/$(OODIR)/program
	mv $(PKGDIR)-common/$(OODIR)/share/Scripts/java \
		$(PKGDIR)-java-common/$(OODIR)/share/Scripts
	mkdir -p $(PKGDIR)-java-common/usr/share/java/openoffice$(VER)
	mv $(PKGDIR)-common/$(OODIR)/program/classes/* \
		$(PKGDIR)-java-common/usr/share/java/openoffice$(VER)
	rm -rf $(PKGDIR)-common/$(OODIR)/program/classes
	ln -s /usr/share/java/openoffice$(VER) \
		$(PKGDIR)-java-common/$(OODIR)/program/classes
	cd $(PKGDIR)-common/$(OODIR)/program && \
	  for i in jvmfwk3rc setuprc unorc; do \
	    perl -pi -e \
	      's,\$$ORIGIN/classes,file:///usr/share/java/openoffice$(VER),g' \
		$$i; \
	  done

	# move into extra package
	mkdir -p $(PKGDIR)-filter-mobiledev/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Filter
	mkdir -p $(PKGDIR)-filter-mobiledev/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Types
	mkdir -p $(PKGDIR)-filter-mobiledev/usr/share/java/openoffice$(VER)
	for i in palm pocketexcel pocketword; do \
	  mv $(PKGDIR)-common/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Filter/fcfg_$${i}_filters.xcu \
	    $(PKGDIR)-filter-mobiledev/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Filter; \
	  mv $(PKGDIR)-common/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Types/fcfg_$${i}_types.xcu \
	    $(PKGDIR)-filter-mobiledev/$(OODIR)/share/registry/modules/org/openoffice/TypeDetection/Types; \
	done
	for i in aportisdoc pexcel pocketword; do \
	  mv $(PKGDIR)-java-common/usr/share/java/openoffice$(VER)/$$i.jar \
		$(PKGDIR)-filter-mobiledev/usr/share/java/openoffice$(VER); \
	done
endif

	# fix permissions
	for i in editpic poll savepic show webcast; do \
		chmod 755 $(PKGDIR)-common/$(OODIR)/share/config/webcast/$$i.pl; \
	done

	# fix permission
	chmod 644 $(PKGDIR)-common/$(OODIR)/program/hid.lst

	rm -f $(PKGDIR)-common/$(OODIR)/LICENSE

	# move uno_packages/cache to /var and create symlink for for
	# documentation referencing it...
	rm -rf $(PKGDIR)-common/$(OODIR)/share/uno_packages/cache
	mkdir -p $(PKGDIR)-common/var/spool/openoffice$(VER)/uno_packages/cache
	ln -s /var/spool/openoffice$(VER)/uno_packages/cache \
		$(PKGDIR)-common/$(OODIR)/share/uno_packages/cache
	perl -pi -e \
	      's,\$$UNO_SHARED_PACKAGES/cache,file:///var/spool/openoffice$(VER)/uno_packages/cache,g' \
		$(PKGDIR)-common/$(OODIR)/program/unorc

	# install DicOOo and FontOOo; we need to do this manually; the
	# dictionaries/ module isn't built with --without-myspell-dicts
	# and those two somehow (why?) are in there...
	mkdir -p $(PKGDIR)-common/usr/share/myspell/dicts
	install -m644 $(SOURCE_TREE)/dictionaries/diclst/DicOOo.sxw \
		$(PKGDIR)-common/usr/share/myspell/dicts
	#install -m644 $(SOURCE_TREE)/dictionaries/diclst/FontOOo.sxw \
	#	$(PKGDIR)-common/usr/share/myspell/dicts

ifeq "$(PACKAGE_TTF_OPENSYMBOL)" "y"
	mkdir -p debian/ttf-opensymbol/usr/share/fonts/truetype/openoffice
	rm -f $(PKGDIR)-common/$(OODIR)/share/fonts/truetype/opens___.ttf
	install -m644 ooo-build/fonts/opens___.ttf \
		debian/ttf-opensymbol/usr/share/fonts/truetype/openoffice
else
	rm -f $(PKGDIR)-common/$(OODIR)/share/fonts/truetype/opens___.ttf
endif

	# dictionary symlink
	rm -rf $(PKGDIR)-common/$(OODIR)/share/dict/ooo
	ln -s /usr/share/myspell/dicts \
		$(PKGDIR)-common/$(OODIR)/share/dict/ooo
	mkdir -p $(PKGDIR)-common/usr/share/myspell/dicts
	ln -s /etc/openoffice/dictionary.lst \
		$(PKGDIR)-common/usr/share/myspell/dicts/dictionary.lst

	# convert icons to xpm; we need them for the Debian menu policy...
	cd $(PKGDIR)-common/usr/share/icons/gnome/32x32/apps && \
	  for x in *.png; do convert $$x `basename $$x .png`.xpm; done

ifeq "$(ENABLE_JAVA)" "y"
	# symlink jars we use externally
ifeq "$(SYSTEM_XT)" "y"
	ln -sf /usr/share/java/xt.jar \
		$(PKGDIR)-java-common/usr/share/java/openoffice$(VER)/xt.jar
endif
ifeq "$(SYSTEM_XALAN)" "y"
	ln -sf /usr/share/java/xalan2.jar \
		$(PKGDIR)-java-common/usr/share/java/openoffice$(VER)/xalan.jar
endif
ifeq "$(SYSTEM_XML_APIS)" "y"
	ln -sf /usr/share/java/jaxp-1.2.jar \
		$(PKGDIR)-java-common/usr/share/java/openoffice$(VER)/xml-apis.jar
endif
ifeq "$(SYSTEM_XERCES)" "y"
	ln -sf /usr/share/java/xercesImpl.jar \
		$(PKGDIR)-java-common/usr/share/java/openoffice$(VER)/xercesImpl.jar
endif
ifeq "$(USE_SYSTEM_BSH)" "y"
	ln -sf /usr/share/java/bsh.jar \
	        $(PKGDIR)-java-common/usr/share/java/openoffice$(VER)/bsh.jar
endif
endif
	# remove extra license files
	rm -rf $(PKGDIR)-commmon/$(OODIR)/licenses
	rm -rf $(PKGDIR)-common/$(OODIR)/share/readme/LICENSE*
	rm -f $(PKGDIR)-common/$(OODIR)/THIRDPARTYLICENSEREADME.html
	rm -f $(PKGDIR)-common/$(OODIR)/LICENSE.html

	# remove extra readme files
	rm -rf $(PKGDIR)-common/$(OODIR)/readmes
	rm -rf $(PKGDIR)-common/$(OODIR)/share/readme/README*

	# install Ximian desktop icons
	mkdir -p $(PKGDIR)-common/usr/share/icons/hicolor/48x48/apps
	cp ooo-build/desktop/*.png \
		$(PKGDIR)-common/usr/share/icons/hicolor/48x48/apps

	# add MySQL, MaxDB and PostgreSQL JDBC drivers to OOos CLASSPATH
	TMP=`mktemp -q`; \
	sed -e 's|\(UNO_JAVA_JFW_CLASSPATH_URLS=.*\)|\1 file:///usr/share/java/mysql.jar|' \
	    -e 's|\(UNO_JAVA_JFW_CLASSPATH_URLS=.*\)|\1 file:///usr/share/java/sapdbc.jar|' \
	    -e 's|\(UNO_JAVA_JFW_CLASSPATH_URLS=.*\)|\1 file:///usr/share/java/postgresql.jar|' < $(PKGDIR)-common/$(OODIR)/program/jvmfwk3rc > $$TMP && \
	mv $$TMP $(PKGDIR)-common/$(OODIR)/program/jvmfwk3rc

	# move psprint.conf into /etc
	mkdir -p $(PKGDIR)-common/etc/openoffice$(VER)
	mv $(PKGDIR)-common/$(OODIR)/share/psprint/psprint.conf \
		$(PKGDIR)-common/etc/openoffice$(VER)
	ln -s /etc/openoffice$(VER)/psprint.conf \
		$(PKGDIR)-common/$(OODIR)/share/psprint/psprint.conf

	# prepare a fake sofficerc in the place where OOo expects it
	# which does nothing except reference the "normal" one
	# which we put into /etc
	mv $(PKGDIR)-common/$(OODIR)/program/sofficerc \
		$(PKGDIR)-common/etc/openoffice$(VER)/sofficerc
	( \
	  echo "# *DO NOT* CHANGE THIS FILE. IT ONLY TAKES THE SETTINGS FROM"; \
	  echo "# /etc/openoffice$(VER)/sofficerc. CHANGE THAT FILE IF YOU"; \
	  echo "# REALLY WANT TO CHANGE SOMETHING."; \
	  echo "FHS_CONFIG_FILE=file:///etc/openoffice$(VER)/sofficerc"; \
	  echo "" >> $(PKGDIR)-common/$(OODIR)/program/sofficerc; \
	) > $(PKGDIR)-common/$(OODIR)/program/sofficerc	
	cat $(PKGDIR)-common/etc/openoffice$(VER)/sofficerc \
		| perl -p -e 's/(.*)=(.*)/$$1=\$${\$$FHS_CONFIG_FILE:Bootstrap:$$1}/' \
		>> $(PKGDIR)-common/$(OODIR)/program/sofficerc

ifeq "$(HELPISOS)" ""
	# the helpimgs are not included when we don't build with help here.
	# Add them now because openoffice.org-help-* packaged in contrib or so
	# will need them
	set -e; \
	for z in images.zip images_industrial.zip images_crystal.zip images_hicontrast.zip; do \
		echo "repackaging $$z..."; \
		rm -rf $$z; mkdir $$z; \
		cd $$z; \
		unzip -q $(CURDIR)/$(PKGDIR)-common/$(OODIR)/share/config/$$z && \
		cp -r $(CURDIR)/$(SOURCE_TREE)/default_images/res/helpimg res && \
		chmod +w $(CURDIR)/$(PKGDIR)-common/$(OODIR)/share/config/$$z && \
		zip -q -r $(CURDIR)/$(PKGDIR)-common/$(OODIR)/share/config/$$z *; \
		cd ..; \
		rm -rf $$z; \
	done
endif

	rm -rf $(PKGDIR)-dtd-officedocument1.0
	mkdir -p $(PKGDIR)-dtd-officedocument1.0/$(OODIR)/share/dtd
	mv $(PKGDIR)-common/$(OODIR)/share/dtd/officedocument \
		$(PKGDIR)-dtd-officedocument1.0/$(OODIR)/share/dtd
	cp debian/catalog.xml $(PKGDIR)-dtd-officedocument1.0/$(OODIR)/share/dtd/officedocument/1_0

ifeq "$(PACKAGE_QA_TOOLS)" "y"
ifeq "$(ENABLE_JAVA)" "y"
	mkdir -p -m755 $(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/tests/java
	for d in objdsc testdocs; do \
		cp -r $(SOURCE_TREE)/qadevOOo/$$d $(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/$$d; \
	done
endif

	mkdir -p -m755 $(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/tests
	cp -r $(SOURCE_TREE)/qadevOOo/tests/basic $(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/tests
ifeq "$(ENABLE_JAVA)" "y"
	for d in mod ifc; do \
		cp -r $(SOURCE_TREE)/qadevOOo/unx*.pro/class/$$d $(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/tests/java; \
	done
endif

	find $(PKGDIR)-qa-api-tests -type d -name "CVS" | xargs rm -rf
	find $(PKGDIR)-qa-api-tests -type f | xargs chmod 0644

ifeq "$(ENABLE_JAVA)" "y"
	echo "TestBase=java_fat" > $(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/java.props
endif
	echo "TestBase=java_complex" > $(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/complex.props
	echo "TestBase=basic_fat" > $(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/basic.props

	echo "BASICBRIDGE=/$(OODIR)/qadevOOo/testdocs/BasicBridge.sxw" >> \
		$(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/basic.props
	echo "BASICRESPTH=/$(OODIR)/qadevOOo/tests/basic" >> \
		$(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/basic.props

ifeq "$(ENABLE_JAVA)" "y"
	echo "DescriptionPath=/$(OODIR)/qadevOOo/objdsc" >> \
		$(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/java.props; \
	echo "TestDocumentPath=/$(OODIR)/qadevOOo/testdocs" >> \
		$(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/java.props; \
	echo "AppExecutionCommand=/$(OODIR)/program/soffice" \
		"-norestore -nocrashreport -accept=socket,host=localhost,port=8100;urp;" >> \
		$(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/java.props
endif
	for i in complex basic; do \
		echo "DescriptionPath=/$(OODIR)/qadevOOo/objdsc" >> \
			$(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/$$i.props; \
		echo "TestDocumentPath=/$(OODIR)/qadevOOo/testdocs" >> \
			$(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/$$i.props; \
		echo "AppExecutionCommand=/$(OODIR)/program/soffice" \
			"-norestore -nocrashreport -accept=socket,host=localhost,port=8100;urp;" >> \
			$(PKGDIR)-qa-api-tests/$(OODIR)/qadevOOo/$$i.props; \
	done
endif

	# add "openoffice" symlink
	cd $(PKGDIR)-common/usr/bin && ln -s ooo-wrapper openoffice
	
	# add symlinks for docs and examples
	cd $(PKGDIR)-dev-doc/$(OODIR)/sdk && \
		rm -rf docs && \
		ln -sf /usr/share/doc/openoffice.org-dev/docs docs
	cd $(PKGDIR)-dev-doc/usr/share/doc/openoffice.org-dev-doc && \
		ln -s /usr/share/doc/openoffice.org-dev/docs docs
	cd $(PKGDIR)-dev-doc/usr/share/doc/openoffice.org-dev-doc && \
		ln -s /$(OODIR)/sdk/examples examples
	cd $(PKGDIR)-dev-doc/usr/share/doc/openoffice.org-dev && \
		ln -s /$(OODIR)/sdk/examples examples
	
	rm -f $(PKGDIR)-core/$(OODIR)/program/*updchk*

	touch $@


# This single target is used to build all the packages, all at once, or
# one at a time. So keep in mind: any options passed to commands here will
# affect _all_ packages. Anything you want to only affect one package
# should be put in another target, such as the install target.
binary-common:
	dh_testdir
	dh_testroot

	for pkg in $(PACKAGES) ; do \
	  rm -f debian/$$pkg.*.debhelper;\
	  rm -rf debian/$$pkg/DEBIAN;\
	done

	dh_installdocs -A -Nlibmythes-dev debian/README.Debian \
		debian/tmp/pkg/openoffice.org-common/$(OODIR)/README
	dh_installdocs -plibmythes-dev debian/copyright
	dh_installman
	# fix manpage symlinks
	for i in writer calc draw base math impress common; do \
		for i in `find $(PKGDIR)-$$i -type l -name "o*.1"`; do \
			mv $$i $$i.gz; \
			if [ "`readlink $$i`" != "openoffice.1.gz" ]; then \
				ln -sf openoffice.1.gz $$i.gz; \
			fi; \
		done; \
	done
	dh_installchangelogs -Nlibmythes-dev ooo-build/ChangeLog
ifneq "$(USE_EXTERNAL_MYTHES)" "y"
	dh_installchangelogs -plibmythes-dev
	rm -f debian/libmythes-dev/usr/share/doc/libmythes-dev/NEWS.Debian*
endif
	dh_installdebconf
	dh_installmime
	dh_installmenu
ifeq "$(USE_PYCENTRAL)" "y"
	dh_pycentral
endif
	dh_python
	debian/scripts/installoverrides
	dh_link
	dh_fixperms
ifeq "$(BUILD_DBG_PACKAGE)" "y"
	dh_strip --dbg-package=openoffice.org$(VER)-dbg -Xunowinreg.dll
	# somehow they are stripped...
	rm -rf $(PKGDIR)-dbg/usr/lib/debug/$(OODIR)/sdk
else
	dh_strip -Xunowinreg.dll
endif
	dh_desktop
	dh_installxmlcatalogs
	dh_compress
	dh_makeshlibs -n -V
	dh_installdeb
	cat debian/openoffice.org-core.shlibs.local > debian/shlibs.local
ifneq "$(USE_SYSTEM_XMLSEC)" "y"
	cat debian/shlibs.override.xmlsec >> debian/shlibs.local
endif
ifeq "$(USE_SYSTEM_ICU)" "n"
	cat debian/shlibs.override.icu >> debian/shlibs.local
endif
ifeq "$(INTERNAL_STDLIBS)" "y"
	cat debian/shlibs.override.stdlibs >> debian/shlibs.local
endif
ifeq "$(ARCH)" "i386"
	# this LD_ASSUME_KERNEL is for working around some bug which makes
	# dh_shlibddeps report/find nothing with libc6-i686/TLS systems
	LD_LIBRARY_PATH="$(PKGDIR)-core/$(OODIR)/program" LD_ASSUME_KERNEL="2.4.27" dh_shlibdeps $(SHLIBS_OVERRIDE)
else
	LD_LIBRARY_PATH="$(PKGDIR)-core/$(OODIR)/program" dh_shlibdeps $(SHLIBS_OVERRIDE)
endif
ifeq "$(ENABLE_MONO)" "y"
	dh_clideps
endif
# This switch to dh_shlibdeps reduces the 'libXXX not found' warnings but
# causes ldd crashes sometimes when used with fakeroot:
#          -l $(PKGDIR)-core/$(OPENOFFICEDIR)/program
	dh_gencontrol -- \
		-V'base-version=$(BASE_VERSION)' \
		-V'help-l10n-virtual-version=$(HELP_L10N_VIRTUAL_VERSION)' \
		-V'dev-stl-depends=$(DEV_STL_DEPENDS)' \
		-V'writer-pyuno-dep=$(WRITER_PYUNO_DEP)' \
		-V'base-hsqldb-depends=$(BASE_HSQLDB_DEPENDS)' \
		-V'common-bsh-depends=$(COMMON_BSH_DEPENDS)' \
		-V'java-common-depends=$(JAVA_COMMON_DEPENDS)' \
		-V'jawt-depends=$(JAWT_DEPENDS)' \
		-V'java-common-java-depends=$(JAVA_COMMON_JAVA_DEPENDS)' \
		-V'java-gcj-depends=$(JAVA_GCJ_DEPENDS)' \
		-V'mozilla-nss-depends=$(MOZILLA_NSS_DEPENDS)' \
		-V'Binary-Version=$(BINARY_VERSION)' \
		-V'ooo-filter52-dep=$(OOO_FILTER52_DEP)' \
		-V'gstreamer-plugins-suggests=$(GSTREAMER_PLUGINS_SUGGESTS)' \
		-V'dbg-dbg-suggests=$(DBG_DBG_SUGGESTS)' \
		-v$(BINARY_VERSION)
	dh_md5sums
	dh_builddeb

# Build architecture independant packages using the common target.
binary-indep: $(STAMP_DIR)/binary-indep
$(STAMP_DIR)/binary-indep: $(STAMP_DIR)/install-indep debian/control $(STAMP_DIR)/maintscripts $(STAMP_DIR)/langpacks $(STAMP_DIR)/helppacks $(STAMP_DIR)/broffice
ifneq ($(ARCH),$(findstring $(ARCH),$(OOO_JAVA_ARCHS)))
	echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
	echo "For uploads with binary-all packages, please use arches where Java is enabled!!!!!"
	echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
endif
	$(MAKE) -f debian/rules DH_OPTIONS="$(DEBHELPER_OPTIONS) -i" binary-common

	touch $@

# Build architecture dependant packages using the common target.
binary-arch: $(STAMP_DIR)/binary-arch
$(STAMP_DIR)/binary-arch: $(STAMP_DIR)/install-arch debian/control $(STAMP_DIR)/maintscripts
	$(MAKE) -f debian/rules DH_OPTIONS="$(DEBHELPER_OPTIONS) -s" binary-common
	touch $@

# Any other binary targets build just one binary package at a time.
binary-%: $(STAMP_DIR)/install-indep $(STAMP_DIR)/install-arch $(STAMP_DIR)/langpacks $(STAMP_DIR)/maintscripts
	$(MAKE) -f debian/rules binary-common DH_OPTIONS="$(DEBHELPER_OPTIONS) -p$*"

binary: binary-arch binary-indep

# -------------------------------------------------------
# Miscellaneous targets used to do a few useful operations

# Use 'debian/rules environment' to help debug architecture-related problems
# with the rules file.
environment:

	@echo 'Package build environment (not all variables may be set):'
	@echo '$$(ARCH)' is "$(ARCH)"
	@echo '$$(DEB_HOST_ARCH)' is "$(DEB_HOST_ARCH)"
	@echo '$$(CURDIR)' is "$(CURDIR)"
	@echo '$$(SOURCE_VERSION)' is "$(SOURCE_VERSION)"
	@echo '$$(UPSTREAM_VERSION)' is "$(UPSTREAM_VERSION)"
	@echo '$$(MILESTONE)' is "$(MILESTONE)"
	@echo '$$(JDK_HOME)' is "$(JDK_HOME)"
	@echo '$$(SUNJDK_VER)' is "$(SUNJDK_VER)"
	@echo '$$(_CC)' is "$(_CC)"
	@echo '$$(CXX)' is "$(CXX)"
	@echo '$$(BUILDCMD)' is "$(BUILDCMD)"
	@echo '$$(CONFIGURE_FLAGS)' is "$(CONFIGURE_FLAGS)"
	@echo '$$(BUILDFLAGS)' is "$(BUILDFLAGS)"
	@echo '$$(DMAKEFLAGS)' is "$(DMAKEFLAGS)"
	@echo '$$(SHLIBS_OVERRIDE)' is "$(SHLIBS_OVERRIDE)"
	@echo '$$(BUILD_ALL_LANGPACKS)' is "$(BUILD_ALL_LANGPACKS)"
	@echo '$$(BUILDLANG),$$(BUILDLANG_PREFIX)' is "$(BUILDLANG),$(BUILDLANG_PREFIX)"
	@echo '$$(USE_INTERNAL_FREETYPE)' is "$(USE_INTERNAL_FREETYPE)"
	@echo '$$(DEBHELPER_OPTIONS)' is "$(DEBHELPER_OPTIONS)"
	@echo '$$(PYTHON_DEPENDS)' is "$(PYTHON_DEPENDS)"
	@echo 'See debian/control for build dependencies.'

# Get the ximian packaging directory from gnome anoncvs
get-ooo-build:
	# press enter at the password prompt
	cvs -d:pserver:anonymous@anoncvs3.gnome.org:/cvs/gnome login
	cvs -z3 -d:pserver:anonymous@anoncvs3.gnome.org:/cvs/gnome co $(OOO_BUILD_BRANCH) ooo-build
	cd ooo-build && NOCONFIGURE=1 ./autogen.sh

# Download the latest ooo-build sources
download: ooo-build/config.status
	ooo-build/download	

# Update debian and ooo-build directories from version control
cvsupdate:
	cd debian && baz update
	cd ooo-build && cvs -z3 -q update -dP

# Take a tarfile of all the non-stripped binaries in solver, for generating backtraces
# from coredumps.
makebinariestar:
ifeq "$(ARCH)" "i386"
	cd $(SOURCE_TREE)/solver/$(shell . $(SOURCE_TREE)/*.sh; echo $$UPD)/$(shell . $(SOURCE_TREE)/*.sh; echo $$OUTPATH$$PROEXT) && \
	  find bin lib | xargs file | sed -n '/LSB \(executable\|shared object\),.* not stripped/ s/:.*$$//p' | \
	  tar -T - -jcvf $(CURDIR)/../openoffice.org$(VER)-binaries_$(SOURCE_VERSION)_$(ARCH).tar.bz2
else
  ifeq "$(ARCH)" "arm"
	cd $(SOURCE_TREE)/solver/$(shell . $(SOURCE_TRE)/*.sh; echo $$UPD)/$(shell . $(SOURCE_TREE/*.sh; echo $$OUTPATH$$PROEXT) && \
	  find bin lib | xargs file | sed -n '/LSB \(executable\|shared object\),.* not stripped/ s/:.*$$//p' | \
	  tar -T - -jcvf $(CURDIR)/../openoffice.org$(VER)-binaries_$(SOURCE_VERSION)_$(ARCH).tar.bz2
  else
	cd $(SOURCE_TREE)/solver/$(shell . $(SOURCE_TREE)/*.sh; echo $$UPD)/$(shell . $(SOURCE_TREE)/*.sh; echo $$OUTPATH$$PROEXT) && \
	  find bin lib | xargs file | sed -n '/MSB \(executable\|shared object\),.* not stripped/ s/:.*$$//p' | \
	  tar -T - -jcvf $(CURDIR)/../openoffice.org$(VER)-binaries_$(SOURCE_VERSION)_$(ARCH).tar.bz2
  endif
endif
# -------------------------------------------------------

.PHONY: environment checksource control makebinariestar
.PHONY: clean-debdir clean-instsetoo clean-objectdirs clean default configure
.PHONY: build build-indep build-arch install-arch install-indep
.PHONY: $(stampdir_targets)
endif

# vim:set noet ai sts=8 sw=8 tw=0:

Reply to: