# Tanım: Google Chrome'un arkasındaki açık kaynaklı proje, daha güvenli, daha hızlı ve daha kararlı bir tarayıcı
# URL: http://www.chromium.org/Home
# Paketçi: milisarge
# Gerekler: atk nss ninja pciutils gperf yasm xorg-mesa libgnome-keyring elfutils subversion gtk2 dbus-glib alsa-lib xdg-utils bzip2 libevent libgcrypt dejavu-ttf opus snappy dbus desktop-file-utils hicolor-icon-theme flac libxml2 pulseaudio xorg-libxscrnsaver xorg-libxtst libexif
# Grup: ağ

isim=chromium
surum=53.0.2785.143
devir=1
kaynak=(http://commondatastorage.googleapis.com/chromium-browser-official/$isim-$surum.tar.xz
        chromium.desktop
        chromium.default
        chromium.sh
        chromium-52.0.2743.116-unset-madv_free.patch
        gzip_string.py)

GOOGLE_API_KEY=AIzaSyBhWJ-j5RXyt5911BMuVen-WuS10mvOnrY
GOOGLE_DEFAULT_CLIENT_ID=952820686433-mbp5sv9scfj78siq96jlvrem47qgvbi3.apps.googleusercontent.com
GOOGLE_DEFAULT_CLIENT_SECRET=XU4b-j0Ssy-XkTvSVmiFMvNY
derle() {
	cd $isim-$surum
	SLKCFLAGS="-O2 -fPIC"
	LIBDIRSUFFIX=""
	TARGETARCH="x64"
	patch -p1 -i $SRC/chromium-52.0.2743.116-unset-madv_free.patch
	if [ "$USE_CLANG" = "YES" ]; then
		CLANG_OPT="-Dclang=1 -Dclang_use_chrome_plugins=0"
		sed -e '/-Wno-absolute-value/d' -i build/common.gypi
		export CC="clang"
		export CXX="clang++"
		SLKCFLAGS="${SLKCFLAGS} -Wno-unknown-warning-option"
	else
		CLANG_OPT="-Dclang=0"
		SLKCFLAGS="${SLKCFLAGS} -Wno-unused-local-typedefs"
	fi
	export -n CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS"
_conf=(
  $CLANG_OPT
  -Ddisable_glibc=1
  -Dffmpeg_branding=Chrome
  -Dffmpeg_component=shared_library
  -Dgoogle_api_key=$GOOGLE_API_KEY
  -Dgoogle_default_client_id=$GOOGLE_DEFAULT_CLIENT_ID
  -Dgoogle_default_client_secret=$GOOGLE_DEFAULT_CLIENT_SECRET
  -Dicu_use_data_file_flag=1
  -Dlinux_sandbox_path=/usr/lib/chromium/chrome_sandbox
  -Dlinux_strip_binary=1
  -Dlinux_use_bundled_binutils=0
  -Dlinux_use_bundled_gold=0
  -Dlinux_use_gold_binary=0
  -Dlinux_use_gold_flags=0
  -Dlogging_like_official_build=1
  -Dproprietary_codecs=1
  -Dremove_webcore_debug_symbols=1
  -Duse_allocator=none
  -Duse_gconf=0
  -Duse_kerberos=0
  -Duse_sysroot=0
  -Duse_pulseaudio=1
  -Duse_system_bzip2=0
  -Duse_system_ffmpeg=0
  -Duse_system_harfbuzz=0
  -Duse_system_icu=0
  -Duse_system_libjpeg=0
  -Duse_system_libpng=0
  -Duse_system_libxml=0
  -Duse_system_libxslt=0
  -Duse_system_opus=0
  -Duse_system_snappy=0
  -Duse_system_zlib=0
  -Duse_system_flac=1
  -Duse_system_libevent=1
  -Duse_system_nspr=1
  -Duse_system_openssl=1
  -Duse_system_xdg_utils=1
  -Duse_system_yasm=1
  -Dwerror=
  -Drelease_extra_cflags="$CFLAGS"
  -Dtarget_arch=$TARGETARCH
  -Ddisable_nacl=1
  -Ddisable_sse2=1
)
	cp $SRC/gzip_string.py  $SRC/$isim-$surum/tools/grit/grit/format/
	third_party/libaddressinput/chromium/tools/update-strings.py
	touch chrome/test/data/webui/i18n_process_css_test.html
	build/linux/unbundle/replace_gyp_files.py "${_conf[@]}"
	build/gyp_chromium --depth=. "${_conf[@]}"
	ninja -C out/Release chrome chrome_sandbox chromedriver
	install -D out/Release/chrome $PKG/usr/lib/chromium/chromium
	install -D -m4755 -o root -g root out/Release/chrome_sandbox $PKG/usr/lib/chromium/chrome-sandbox
	install -D out/Release/chromedriver $PKG/usr/lib/chromium/chromedriver
	cp out/Release/*.pak $PKG/usr/lib/chromium
	cp -a out/Release/locales $PKG/usr/lib/chromium
	cp -a out/Release/pseudo_locales $PKG/usr/lib/chromium
	ln -s locales $PKG/usr/lib/chromium/remoting_locales
	cp -a out/Release/resources $PKG/usr/lib/chromium
	mkdir -p $PKG/usr/lib/chromium/lib
	cp out/Release/lib/libffmpeg.so $PKG/usr/lib/chromium/lib
	cp out/Release/natives_blob.bin $PKG/usr/lib/chromium
	cp out/Release/snapshot_blob.bin $PKG/usr/lib/chromium
	cp -a out/Release/icudtl.dat $PKG/usr/lib/chromium
	mkdir -p $PKG/usr/man/man1
	install -m 0644 -D out/Release/chrome.1 $PKG/usr/man/man1/chromium.1
	mkdir -p $PKG/usr/bin
	cat $SRC/chromium.sh | sed s/@LIBDIRSUFFIX@/$LIBDIRSUFFIX/ > $PKG/usr/bin/chromium
	chmod 0755 $PKG/usr/bin/chromium
	ln -s ../lib/chromium/chromedriver $PKG/usr/bin/chromedriver
	for size in 16 32; do
	  install -D -m0644 \
		chrome/app/theme/default_100_percent/chromium/product_logo_$size.png \
		$PKG/usr/share/icons/hicolor/${size}x${size}/apps/${isim}.png
	done
	for size in 22 24 48 64 128 256; do
	  install -D -m0644 \
		chrome/app/theme/chromium/product_logo_$size.png \
		$PKG/usr/share/icons/hicolor/${size}x${size}/apps/${isim}.png
	done
	install -D -m 0644 $SRC/chromium.desktop $PKG/usr/share/applications/chromium.desktop
	mkdir -p $PKG/etc/chromium
	cat $SRC/chromium.default > $PKG/etc/chromium/00-default.conf.new
}
