# Template file for 'chromium'
pkgname=chromium
#See http://www.chromium.org/developers/calendar for the latest version
version=28.0.1500.52
revision=1
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"
_url_base="http://commondatastorage.googleapis.com"
distfiles="${_url_base}/${pkgname}-browser-official/${pkgname}-${version}.tar.xz"
checksum="7b3cbfbb9e5b9d21ffab23d39173611ddb0ba49488795b6db46a62be354518b4"

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."

hostmakedepends="which yasm python pkg-config perl gperf bison"
makedepends="libpng-devel>=1.6 gtk+-devel nss-devel GConf-devel pciutils-devel
 libXi-devel libgcrypt-devel libgnome-keyring-devel cups-devel elfutils-devel
 libXcomposite-devel speech-dispatcher-devel libXrandr-devel mit-krb5-devel
 libXScrnSaver-devel alsa-lib-devel icu-devel protobuf-devel snappy-devel
 libxml2-devel libxslt-devel opus-devel hunspell-devel pulseaudio-devel
 libvpx-devel libflac-devel speex-devel libusb-devel libmtp-devel
 libjpeg-turbo-devel libevent-devel json-c-devel re2-devel harfbuzz-devel
 libwebp-devel minizip-devel libsrtp-devel jsoncpp-devel"

do_configure() {
	unset LD LDFLAGS

	# TODO
	# See https://crbug.com/28287
	# use_system_v8=1 (http://crbug.com/29050 fixed for chromium-27)
	# use_system_ffmpeg=1 (most likely libvpx-related, check on chromium-27)
	# disable_pnacl=0 (http://crbug.com/224169)
	# use_system_sqlite=1 (http://crbug.com/22208)
	# use_system_ssl=1 (http://crbug.com/58087)
	# use_system_tcmalloc=1 (https://crbug.com/174634 WontFix?)
	# use_system_hyphen=1 (http://crbug.com/176285)

	build/gyp_chromium -f make build/all.gyp --depth=. -Dwerror= \
	 -Dlinux_use_gold_binary=0 -Dlinux_use_gold_flags=0 \
	 -Dlinux_sandbox_path=/usr/lib/chromium/chromium-sandbox \
	 -Ddisable_sse2=1 -Drelease_extra_cflags="$CFLAGS" \
	 -Dffmpeg_branding=Chrome -Dproprietary_codecs=1 \
	 -Dlinux_link_libpci=1 -Dlinux_link_pulseaudio=1 \
	 -Dlinux_link_libspeechd=1 -Dlibspeechd_h_prefix=speech-dispatcher/ \
	 -Duse_gconf=0 -Dlinux_use_tcmalloc=0 -Dlinux_link_gsettings=1 \
	 -Ddisable_nacl=1 -Duse_system_bzip2=1 -Duse_system_expat=1 \
	 -Duse_system_flac=1 -Duse_system_harfbuzz=1 -Duse_system_icu=1 \
	 -Duse_system_jsoncpp=1 -Duse_system_libevent=1 -Duse_system_libexif=1 \
	 -Duse_system_libjpeg=1 -Duse_system_libmtp=1 -Duse_system_libpng=1 \
	 -Duse_system_libsrtp=1 -Duse_system_libusb=1 -Duse_system_libwebp=1 \
	 -Duse_system_libxml=1 -Duse_system_minizip=1 \
	 -Duse_system_nspr=1 -Duse_system_opus=1 -Duse_system_protobuf=1 \
	 -Duse_system_re2=1 -Duse_system_speex=1 -Duse_system_stlport=1 \
	 -Duse_system_yasm=1 -Duse_system_zlib=1 -Duse_system_xdg=1 \
	 -Duse_system_libvpx=1 -Duse_system_hunspell=1 -Duse_system_snappy=1
}

do_build() {
	make BUILDTYPE=Release ${makejobs} chrome chrome_sandbox
}

do_install() {
	vinstall out/Release/chrome 755 usr/lib/${pkgname} ${pkgname}
	vinstall out/Release/chrome_sandbox 4755 usr/lib/${pkgname} ${pkgname}-sandbox

	cp out/Release/{*.pak,libffmpegsumo.so} ${DESTDIR}/usr/lib/chromium

	cp -a out/Release/locales ${DESTDIR}/usr/lib/chromium

	vinstall out/Release/chrome.1 644 usr/share/man/man1 chromium.1
	vinstall ${FILESDIR}/chromium.desktop 644 usr/share/applications

	for size in 22 24 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
	for size in 16 32; do
		install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_${size}.png" \
		${DESTDIR}/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png
	done

	vinstall ${FILESDIR}/chromium.sh 755 usr/bin chromium
	vinstall LICENSE 644 usr/share/licenses/${pkgname}
}

chromium_package() {
	depends="desktop-file-utils hicolor-icon-theme"
	pkg_install() {
		vmove all
	}
}
