# Template file for 'chromium'
pkgname=chromium
version=12.0.742.100
distfiles="http://build.chromium.org/official/$pkgname-$version.tar.bz2"
build_style=custom-install
short_desc="Google's attempt at creating a safer, faster, and more stable browser"
maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://www.chromium.org/"
license="BSD"
checksum=58f51ace0ad420357491953ad9a4b3421e830cf9dcdebfe8da3ed672eea2a6ed
long_desc="
 Chromium is an open-source browser project that aims to build a safer,
 faster, and more stable way for all Internet users to experience the web.

 Chromium serves as a base for Google Chrome, which is Chromium rebranded
 (name and logo) with very few additions such as usage tracking and an
 auto-updater system.

 This package contains the Chromium browser."

gtk_iconcache_dirs="/usr/share/icons/hicolor"
nostrip=yes

Add_dependency run libX11
Add_dependency run glibc
Add_dependency run libXrender
Add_dependency run libXScrnSaver
Add_dependency run libXext
Add_dependency run gtk+
Add_dependency run pango
Add_dependency run gdk-pixbuf
Add_dependency run libpng
Add_dependency run cairo
Add_dependency run freetype
Add_dependency run fontconfig
Add_dependency run glib
Add_dependency run libevent
Add_dependency run icu-libs
Add_dependency run zlib
Add_dependency run jpeg
Add_dependency run nss
Add_dependency run nspr
Add_dependency run libxml2
Add_dependency run libxslt
Add_dependency run bzip2
Add_dependency run alsa-lib
Add_dependency run expat
Add_dependency run libflac
Add_dependency run dbus-glib
Add_dependency run dbus-libs
Add_dependency run libXdamage
Add_dependency run libXtst
Add_dependency run pam
Add_dependency run libstdc++
Add_dependency run libgcc

Add_dependency build pkg-config
Add_dependency build coreutils
Add_dependency build yasm
Add_dependency build flex
Add_dependency build gperf
Add_dependency build perl	">=0"
Add_dependency build python
Add_dependency build libX11-devel
Add_dependency build glibc-devel
Add_dependency build libXrender-devel
Add_dependency build libXScrnSaver-devel
Add_dependency build libXext-devel
Add_dependency build gtk+-devel
Add_dependency build pango-devel
Add_dependency build gdk-pixbuf-devel
Add_dependency build libpng-devel
Add_dependency build cairo-devel
Add_dependency build freetype-devel
Add_dependency build fontconfig-devel
Add_dependency build glib-devel
Add_dependency build libevent-devel
Add_dependency build icu-devel
Add_dependency build zlib-devel
Add_dependency build jpeg-devel
Add_dependency build nss-devel
Add_dependency build nspr-devel
Add_dependency build libxml2-devel
Add_dependency build libxslt-devel
Add_dependency build bzip2-devel
Add_dependency build alsa-lib-devel
Add_dependency build expat-devel
Add_dependency build libflac-devel
Add_dependency build dbus-glib-devel
Add_dependency build dbus-devel
Add_dependency build libXdamage-devel
Add_dependency build libXtst-devel
Add_dependency build pam-devel
Add_dependency build libgnome-keyring-devel

Add_dependency full desktop-file-utils
Add_dependency full hicolor-icon-theme

do_build()
{
	# We need to disable system_ssl until "next protocol negotiation" support is
	# available in our nss package.
	# (See https://bugzilla.mozilla.org/show_bug.cgi?id=547312)
	#
	# XXX: Disable CUPS until a package exists.
	build/gyp_chromium -f make build/all.gyp --depth=. \
		-Dgcc_version=45 \
		-Dno_strict_aliasing=1 \
		-Dwerror= \
		-Dlinux_sandbox_path=/usr/lib/chromium/chromium-sandbox \
		-Dlinux_strip_binary=1 \
		-Drelease_extra_cflags="$CFLAGS" \
		-Dffmpeg_branding=Chrome \
		-Dproprietary_codecs=1 \
		-Duse_system_libjpeg=1 \
		-Duse_system_libxslt=1 \
		-Duse_system_libxml=1 \
		-Duse_system_bzip2=1 \
		-Duse_system_zlib=1 \
		-Duse_system_libpng=1 \
		-Duse_system_ffmpeg=0 \
		-Duse_system_yasm=1 \
		-Duse_system_libevent=1 \
		-Duse_system_ssl=0 \
		-Duse_system_flac=1 \
		-Duse_system_icu=1 \
		-Duse_system_xdg_utils=1 \
		-Duse_gconf=0 \
		-Duse_cups=0

	make ${makejobs} chrome chrome_sandbox BUILDTYPE=Release
}

do_install()
{
	install -D out/Release/chrome ${DESTDIR}/usr/lib/chromium/chromium
	install -Dm4755 out/Release/chrome_sandbox \
		${DESTDIR}/usr/lib/chromium/chromium-sandbox
	install -Dm644 out/Release/chrome.pak ${DESTDIR}/usr/lib/chromium/chrome.pak
	install -Dm644 out/Release/resources.pak \
		${DESTDIR}/usr/lib/chromium/resources.pak
	install -D out/Release/libffmpegsumo.so \
		${DESTDIR}/usr/lib/chromium/libffmpegsumo.so
	cp -a out/Release/locales out/Release/resources ${DESTDIR}/usr/lib/chromium/
	find ${DESTDIR}/usr/lib/chromium/ -name '*.d' -type f -delete
	install -Dm644 out/Release/chrome.1 ${DESTDIR}/usr/share/man/man1/chromium.1
	install -Dm644 ${FILESDIR}/chromium.desktop \
		${DESTDIR}/usr/share/applications/chromium.desktop
	for size in 16 22 24 32 48 64 128 256; do
		install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
		${DESTDIR}/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png
	done
	install -D ${FILESDIR}/chromium.sh ${DESTDIR}/usr/bin/chromium
	install -Dm644 LICENSE ${DESTDIR}/usr/share/licenses/chromium/LICENSE
}
