# $Id$
# Maintainer: Muflone http://www.muflone.com/contacts/english/
# Contributor: peace4all <markspost at rocketmail dot com>
# Contributor: ingamedeo <ingamedeo at gmail dot com>

# thanks to tadzio, and techlive for the investigation
# work and fix included as the NS_IMETHOD_i686.patch

# Sorry for not honouring makepkg.conf (!buildflags)
# but the source doesn't compile with makepkg's default C/CXXFLAGS

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - ARM patches from debian to fix FTBFS

pkgname=kompozer
pkgver=0.8b3
pkgrel=18
pkgdesc="A Dreamweaver style WYSIWYG web editor; Nvu unofficial bug-fix release"
arch=('x86_64' 'i686')
license=('GPL')
url="http://www.kompozer.net"
depends=('gtk2' 'nss' 'libxt' 'libidl2' 'gnome-vfs' 'desktop-file-utils')
makedepends=('zip' 'pkgconfig' 'pangox-compat' 'nss')
options=('!buildflags')
source=("http://downloads.sourceforge.net/kompozer/${pkgname}-${pkgver}-src.tar.bz2" 
        'kompozer.desktop' 
        'mozconfig.patch' 
        'kompozer-libpng15.patch' 
        'kompozer-libpng14.patch' 
        'gcc46_default_ctors.patch' 
        'kompozer_gcc_4.7.patch' 
        'any_kernel_26_plus.patch'
        'NS_IMETHOD_i686.patch'
        'freetype-pango.patch'
        'freetype-xft.patch'
        'external-nss-for-shlibsign.patch'
        "bug_698592_cxx11_user_defined_literals.patch"::"https://bug698592.bmoattachments.org/attachment.cgi?id=573137"
        '11_arm_xpcom_unused_attribute.patch'
        '12_arm_xpcom_optim.patch')
sha256sums=('9dfef34e5941ce1e68e2f952c9783b281a74be226dad3ab1a2b1b8c99df5c5e3'
            '9c051098389cfe8cb0f2fa296022e9160417af7601d0f2543d22823ee3f230d9'
            '188ca29c3e0d15ebafe2c8cdc9b4daf9bec0d1b5477206590ddc7a02230d925d'
            'bbab99625647ca678c3b399551c945647117f817f238905c9c0babe1db941773'
            '7319c26c9c16e3817377815d5cc9b2f490a49c5a51a5d3bee0f496a2931c64c1'
            'cefc169f14a02591d335cf4763e057284a3350edb2e4474fad0e92c5273e25fb'
            '099bd752d08dd3ec8fd7157ba994b547efd625a40d7d11376451f0e673b681f5'
            '2d24c5a2580c967e96b8d4cf41d71bd972b9652f0e41b71b5c4fa179a5954265'
            '9e378e7b176374f35c4c00ec777b9c16461a8692e6164abd05ebc1513c6be942'
            'f46aef175bb6361dfca6bb0ccc9fba6c3a89a1a125e695bb1ae4bf3859d267ff'
            'd8f2f13c749a20cc9a2f2fd471dc747fe264bf9384ea96b94d2f9d9cca37099d'
            'f1b4a0855be4883f4a6a8f309bf8c97a17815f11109141b1880c055bc8c96962'
            'dcea4088ba120baad6df9d7a7b3fefe9d3ff76e9ed12f56e28b9381087029d81'
            '818e770833635a44f6f0ce98e985bde47a728cfa2a613bb8d0afba48497d8dac'
            '6345e13a8fe89e9525de42ed8077f2c52456f00af2f3ef568914cd0758741671')

prepare() {
  cd "${srcdir}/mozilla"
  patch -Np0 -i "${srcdir}/mozconfig.patch"
  patch -Np0 -i "${srcdir}/kompozer-libpng14.patch"
  patch -Np0 -i "${srcdir}/kompozer-libpng15.patch"
  patch -Np0 -i "${srcdir}/gcc46_default_ctors.patch"
  patch -Np0 -i "${srcdir}/kompozer_gcc_4.7.patch"
  patch -Np0 -i "${srcdir}/any_kernel_26_plus.patch"
  patch -Np0 -i "${srcdir}/NS_IMETHOD_i686.patch"
  # Patches for moving from freetype to freetype2 packages
  patch -Np2 -i "${srcdir}/freetype-pango.patch"
  patch -Np2 -i "${srcdir}/freetype-xft.patch"
  # Patch to exclude the integrated nss library to sign
  # the binary libraries (currently broken for i686)
  patch -Np1 -i "${srcdir}/external-nss-for-shlibsign.patch"
  # Patch for C++11
  patch -Np0 security/nss-fips/lib/pk11wrap/secmodt.h \
    "${srcdir}/bug_698592_cxx11_user_defined_literals.patch"
  patch -Np0 security/nss/lib/pk11wrap/secmodt.h \
    "${srcdir}/bug_698592_cxx11_user_defined_literals.patch"
  # ARM fixes
  patch -Np2 -i "${srcdir}/11_arm_xpcom_unused_attribute.patch"
  patch -Np2 -i "${srcdir}/12_arm_xpcom_optim.patch"
}

build() {
  cd "${srcdir}/mozilla"
  ./configure
  make
}

package() {
  cd "${srcdir}/mozilla"

  make DESTDIR="${pkgdir}" install
  # Remove nspr.m4 because it's now provided by nspr package
  rm "${pkgdir}/usr/share/aclocal/nspr.m4"
  rmdir "${pkgdir}/usr/share/aclocal"

  install -m755 -dD "${pkgdir}/usr/share/applications/"
  install -m644  "${srcdir}/kompozer.desktop" "${pkgdir}/usr/share/applications/"

  install -d -m755 "${pkgdir}/usr/share/pixmaps/"
  ln -s "/usr/lib/kompozer/icons/mozicon256.png" "${pkgdir}/usr/share/pixmaps/kompozer.png"
  ln -s "/usr/lib/kompozer/icons/mozicon50.xpm" "${pkgdir}/usr/share/pixmaps/kompozer.xpm"
}